Replace Section with ${MementoSection} and SectionEnd with ${MementoSectionEnd} for sections that whose state should be remembered by Memento.
${MementoSectionEnd}
!include Memento.nsh
!define MEMENTO_REGISTRY_ROOT HKLM
!define MEMENTO_REGISTRY_KEY Software\Microsoft\Windows\CurrentVersion\Uninstall\MyProgram
Function .onInit
${MementoSectionRestore}
FunctionEnd
Function .onInstSuccess
${MementoSectionSave}
FunctionEnd
${MementoSection} "name" "some_id"
; some code...
${MementoSectionEnd}
${MementoUnselectedSection} dinosaur sec_dinosaur
; some code...
${MementoSectionEnd}
${MementoSectionDone}
Written by kichik