2 ; File association helper macros
\r
5 ; Features automatic backup system and UPDATEFILEASSOC macro for
\r
6 ; shell change notification.
\r
9 ; To associate a file with an application so you can double-click it in explorer, use
\r
10 ; the APP_ASSOCIATE macro like this:
\r
13 ; !insertmacro APP_ASSOCIATE "txt" "myapp.textfile" "$INSTDIR\myapp.exe,0" \
\r
14 ; "Open with myapp" "$INSTDIR\myapp.exe $\"%1$\""
\r
16 ; Never insert the APP_ASSOCIATE macro multiple times, it is only ment
\r
17 ; to associate an application with a single file and using the
\r
18 ; the "open" verb as default. To add more verbs (actions) to a file
\r
19 ; use the APP_ASSOCIATE_ADDVERB macro.
\r
22 ; !insertmacro APP_ASSOCIATE_ADDVERB "myapp.textfile" "edit" "Edit with myapp" \
\r
23 ; "$INSTDIR\myapp.exe /edit $\"%1$\""
\r
25 ; To have access to more options when registering the file association use the
\r
26 ; APP_ASSOCIATE_EX macro. Here you can specify the verb and what verb is to be the
\r
27 ; standard action (default verb).
\r
29 ; And finally: To remove the association from the registry use the APP_UNASSOCIATE
\r
30 ; macro. Here is another example just to wrap it up:
\r
31 ; !insertmacro APP_UNASSOCIATE "txt" "myapp.textfile"
\r
34 ; When defining your file class string always use the short form of your application title
\r
35 ; then a period (dot) and the type of file. This keeps the file class sort of unique.
\r
39 ; Photoshop.JPEGFile
\r
42 ; The registry key layout for a file association is:
\r
44 ; <applicationID> = <"description">
\r
46 ; <verb> = <"menu-item text">
\r
47 ; command = <"command string">
\r
50 !macro APP_ASSOCIATE EXT FILECLASS DESCRIPTION ICON COMMANDTEXT COMMAND
\r
51 ; Backup the previously associated file class
\r
52 ReadRegStr $R0 HKCR ".${EXT}" ""
\r
53 WriteRegStr HKCR ".${EXT}" "${FILECLASS}_backup" "$R0"
\r
55 WriteRegStr HKCR ".${EXT}" "" "${FILECLASS}"
\r
57 WriteRegStr HKCR "${FILECLASS}" "" `${DESCRIPTION}`
\r
58 WriteRegStr HKCR "${FILECLASS}\DefaultIcon" "" `${ICON}`
\r
59 WriteRegStr HKCR "${FILECLASS}\shell" "" "open"
\r
60 WriteRegStr HKCR "${FILECLASS}\shell\open" "" `${COMMANDTEXT}`
\r
61 WriteRegStr HKCR "${FILECLASS}\shell\open\command" "" `${COMMAND}`
\r
64 !macro APP_ASSOCIATE_EX EXT FILECLASS DESCRIPTION ICON VERB DEFAULTVERB SHELLNEW COMMANDTEXT COMMAND
\r
65 ; Backup the previously associated file class
\r
66 ReadRegStr $R0 HKCR ".${EXT}" ""
\r
67 WriteRegStr HKCR ".${EXT}" "${FILECLASS}_backup" "$R0"
\r
69 WriteRegStr HKCR ".${EXT}" "" "${FILECLASS}"
\r
70 StrCmp "${SHELLNEW}" "0" +2
\r
71 WriteRegStr HKCR ".${EXT}\ShellNew" "NullFile" ""
\r
73 WriteRegStr HKCR "${FILECLASS}" "" `${DESCRIPTION}`
\r
74 WriteRegStr HKCR "${FILECLASS}\DefaultIcon" "" `${ICON}`
\r
75 WriteRegStr HKCR "${FILECLASS}\shell" "" `${DEFAULTVERB}`
\r
76 WriteRegStr HKCR "${FILECLASS}\shell\${VERB}" "" `${COMMANDTEXT}`
\r
77 WriteRegStr HKCR "${FILECLASS}\shell\${VERB}\command" "" `${COMMAND}`
\r
80 !macro APP_ASSOCIATE_ADDVERB FILECLASS VERB COMMANDTEXT COMMAND
\r
81 WriteRegStr HKCR "${FILECLASS}\shell\${VERB}" "" `${COMMANDTEXT}`
\r
82 WriteRegStr HKCR "${FILECLASS}\shell\${VERB}\command" "" `${COMMAND}`
\r
85 !macro APP_ASSOCIATE_REMOVEVERB FILECLASS VERB
\r
86 DeleteRegKey HKCR `${FILECLASS}\shell\${VERB}`
\r
90 !macro APP_UNASSOCIATE EXT FILECLASS
\r
91 ; Backup the previously associated file class
\r
92 ReadRegStr $R0 HKCR ".${EXT}" `${FILECLASS}_backup`
\r
93 WriteRegStr HKCR ".${EXT}" "" "$R0"
\r
95 DeleteRegKey HKCR `${FILECLASS}`
\r
98 !macro APP_ASSOCIATE_GETFILECLASS OUTPUT EXT
\r
99 ReadRegStr ${OUTPUT} HKCR ".${EXT}" ""
\r
103 ; !defines for use with SHChangeNotify
\r
104 !ifdef SHCNE_ASSOCCHANGED
\r
105 !undef SHCNE_ASSOCCHANGED
\r
107 !define SHCNE_ASSOCCHANGED 0x08000000
\r
111 !define SHCNF_FLUSH 0x1000
\r
113 !macro UPDATEFILEASSOC
\r
114 ; Using the system.dll plugin to call the SHChangeNotify Win32 API function so we
\r
115 ; can update the shell.
\r
116 System::Call "shell32::SHChangeNotify(i,i,i,i) (${SHCNE_ASSOCCHANGED}, ${SHCNF_FLUSH}, 0, 0)"
\r