1 ;; From http://nsis.sourceforge.net/How_can_I_associate_a_file_extension_with_my_application
4 !define registerExtension "!insertmacro registerExtension"
5 !define unregisterExtension "!insertmacro unregisterExtension"
7 !macro registerExtension executable flags extension description
8 Push "${executable}" ; "full path to my.exe"
9 Push "${flags}" ; "options to pass to my.exe"
10 Push "${extension}" ; ".mkv"
11 Push "${description}" ; "MKV File"
12 Call registerExtension
15 ; back up old value of .opt
16 Function registerExtension
17 !define Index "Line${__LINE__}"
24 ReadRegStr $1 HKCR $R1 ""
25 StrCmp $1 "" "${Index}-NoBackup"
26 StrCmp $1 "OptionsFile" "${Index}-NoBackup"
27 WriteRegStr HKCR $R1 "backup_val" $1
29 WriteRegStr HKCR $R1 "" $R0
30 ReadRegStr $0 HKCR $R0 ""
31 StrCmp $0 "" 0 "${Index}-Skip"
32 WriteRegStr HKCR $R0 "" $R0
33 WriteRegStr HKCR "$R0\shell" "" "open"
34 WriteRegStr HKCR "$R0\DefaultIcon" "" "$R2,0"
36 WriteRegStr HKCR "$R0\shell\open\command" "" '$R2 $R3 "%1"'
37 WriteRegStr HKCR "$R0\shell\edit" "" "Edit $R0"
38 WriteRegStr HKCR "$R0\shell\edit\command" "" '$R2 $R3 "%1"'
44 !macro unregisterExtension extension description
45 Push "${extension}" ; ".mkv"
46 Push "${description}" ; "MKV File"
47 Call un.unregisterExtension
50 Function un.unregisterExtension
53 !define Index "Line${__LINE__}"
55 ReadRegStr $1 HKCR $R0 ""
56 StrCmp $1 $R1 0 "${Index}-NoOwn" ; only do this if we own it
57 ReadRegStr $1 HKCR $R0 "backup_val"
58 StrCmp $1 "" 0 "${Index}-Restore" ; if backup="" then delete the whole key
62 WriteRegStr HKCR $R0 "" $1
63 DeleteRegValue HKCR $R0 "backup_val"
64 DeleteRegKey HKCR $R1 ;Delete key with association name settings