1

I am creating a setup file for my application using Inno Setup. When right clicking a PDF file on Windows operating system i can see "Edit with Adobe Acrobat" menu item:

enter image description here

I want to add a similar menu item for my application to appear as "Edit with MyAppName". Is this possible using Inno Setup?

--------------------------------------------------------- Update:

Here is the registry code that i've tried to use in Inno Setup, but it's not working:

Root: "HKCR"; Subkey: ".pdf"; ValueType: string; ValueData: "PDF_File"; Flags: uninsdeletevalue
Root: "HKCR"; Subkey: "PDF_File\shell\Edit with My PDF Editor"; ValueType: string; ValueData: """{app}\My PDF Editor.exe"" ""%1"""; Flags: uninsdeletevalue
Root: "HKCR"; Subkey: "PDF_File\DefaultIcon"; ValueType: string; ValueData: "{app}\images\my_pdf_editor_icon.ico"; Flags: uninsdeletevalue
Brad
  • 4,457
  • 10
  • 56
  • 93
  • 1
    You just add the proper registry keys (you can follow [this thread](https://stackoverflow.com/q/2123762/960757)). – TLama Nov 11 '19 at 13:52
  • I have tried to follow the mentioned thread steps, and it works fine for new extensions, but not for known ones like PDF files. The 1st problem is how to get the registry key of pdf files through Inno Setup?! – Brad Nov 12 '19 at 16:33
  • 1
    Lookup the `.pdf` key, read its default value (= `PDF_File` in your case). And then lookup a key with that name. Though I'm not sure if modifying an entry created by another application is a good idea. It will likely get overwritten when the application is reinstalled/upgraded. There is probably another way (at least for modern versions of Windows). – Martin Prikryl Nov 13 '19 at 06:59
  • 1
    FWIW, it's poor style to add a top-level verb for that sort of thing. Recommended practice is to add your app to the [Open With menu](https://learn.microsoft.com/en-us/visualstudio/extensibility/specifying-file-handlers-for-file-name-extensions) instead. – Miral Nov 16 '19 at 00:17
  • I've already added my application to the "Open with" menu, but i wanted to do both, as a request from my customers. – Brad Nov 16 '19 at 07:43

1 Answers1

3

I was able to accomplish this, and I am sharing my solution here if anyone would need it:

; Add 'My PDF Editor' menu item to the Shell menu for PDF files:
Root: "HKCR"; Subkey: "SystemFileAssociations\.pdf\shell\Edit with My PDF Editor"; ValueType: none; ValueName: ""; ValueData: ""; Flags: uninsdeletekey
; Specify icon for the menu item:
Root: "HKCR"; Subkey: "SystemFileAssociations\.pdf\shell\Edit with My PDF Editor"; ValueType: string; ValueName: "Icon"; ValueData: "{app}\images\shortcut.ico"; Flags: uninsdeletekey
; Add separator before and after the menu item:
Root: "HKCR"; Subkey: "SystemFileAssociations\.pdf\shell\Edit with My PDF Editor"; ValueType: string; ValueName: "SeparatorBefore"; ValueData: ""; Flags: uninsdeletekey
Root: "HKCR"; Subkey: "SystemFileAssociations\.pdf\shell\Edit with My PDF Editor"; ValueType: string; ValueName: "SeparatorAfter"; ValueData: ""; Flags: uninsdeletekey
; Define command for the menu item:
Root: "HKCR"; Subkey: "SystemFileAssociations\.pdf\shell\Edit with My PDF Editor\command"; ValueType: string; ValueName: ""; ValueData: """{app}\My PDF Editor.exe""  ""%1"""; Flags: uninsdeletekey
TLama
  • 75,147
  • 17
  • 214
  • 392
Brad
  • 4,457
  • 10
  • 56
  • 93
  • 1
    Well done! As for adding separator, [this registry key works in Windows 7](https://stackoverflow.com/a/43011181/960757), but for the whole task you can try to follow registry entries made by Adobe if they do not use Shell extension. – TLama Nov 14 '19 at 05:52
  • Thanks a lot TLama! I just don't get it for how to apply this for my Inno Setup code above! – Brad Nov 14 '19 at 09:14
  • Under the very same subkey create string value of name `SeparatorBefore` (`SeparatorAfter`) with an empty value. Having more entries, you'd then use e.g. `SeparatorBefore` for the first command entry and `SeparatorAfter` for the last. P.S. be careful with the `deletekey` flag that you have by your last entry in your example. – TLama Nov 14 '19 at 10:07
  • 1
    I've included this into your example. Hope you don't mind :) – TLama Nov 14 '19 at 10:17