Skip to content

Instantly share code, notes, and snippets.

@RickStrahl
Created June 29, 2017 08:09
Show Gist options
  • Save RickStrahl/5eb8b21d1847739f3293009d831f05af to your computer and use it in GitHub Desktop.
Save RickStrahl/5eb8b21d1847739f3293009d831f05af to your computer and use it in GitHub Desktop.
File Association Registry Settings
[Registry]
; File Association for .md and .markdown
Root: HKCR; Subkey: ".md"; ValueData: "{#MyAppName}"; Flags: uninsdeletevalue; ValueType: string; ValueName: ""
Root: HKCR; Subkey: ".markdown"; ValueData: "{#MyAppName}"; Flags: uninsdeletevalue; ValueType: string; ValueName: ""
Root: HKCR; Subkey: "{#MyAppName}"; ValueData: "Program {#MyAppName}"; Flags: uninsdeletekey; ValueType: string; ValueName: ""
Root: HKCR; Subkey: "{#MyAppName}\DefaultIcon"; ValueData: "{app}\{#MyAppExeName},0"; ValueType: string; ValueName: ""
Root: HKCR; Subkey: "{#MyAppName}\shell\open\command"; ValueData: """{app}\{#MyAppExeName}"" ""%1"""; ValueType: string; ValueName: ""
@RickStrahl
Copy link
Author

#MyAppName - "Markdown Monster"
#MyAppExe - "MarkdownMonster.exe"
app - Install folder

@FransBouma
Copy link

Here's how I do it in NSIS:

	; Setup .llblgenproj file association with llblgenpro.exe
	; back up old value of .opt
	!define Index "Line${__LINE__}"
		ReadRegStr $1 HKCR ".llblgenproj" ""
		StrCmp $1 "" "${Index}-NoBackup"
			StrCmp $1 "LLBLGen Pro ${APPVERSION} Project Files" "${Index}-NoBackup"
			WriteRegStr HKCR ".llblgenproj" "backup_val" $1
	"${Index}-NoBackup:"
		WriteRegStr HKCR ".llblgenproj" "" "LLBLGen Pro ${APPVERSION} Project Files"
		ReadRegStr $0 HKCR "LLBLGen Pro ${APPVERSION} Project Files" ""
		StrCmp $0 "" 0 "${Index}-Skip"
			WriteRegStr HKCR "LLBLGen Pro ${APPVERSION} Project Files" "" "LLBLGen Pro ${APPVERSION} Project Files"
			WriteRegStr HKCR "LLBLGen Pro ${APPVERSION} Project Files\shell" "" "open"
			WriteRegStr HKCR "LLBLGen Pro ${APPVERSION} Project Files\DefaultIcon" "" "$INSTDIR\LLBLGenPro.exe,0"
	"${Index}-Skip:"
		WriteRegStr HKCR "LLBLGen Pro ${APPVERSION} Project Files\shell\open\command" "" '$INSTDIR\LLBLGenPro.exe "%1"'
		; Uncomment next line if the shell should reflect the changes immediately. This could slow down XP Explorer alot.
		; System::Call 'Shell32::SHChangeNotify(i 0x8000000, i 0, i 0, i 0)'
	!undef Index

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment