Torrunt / vimage

A simplistic image viewer for Windows, inspired by vjpeg.
https://torrunt.net/vimage
MIT License
104 stars 13 forks source link

file association #17

Open JanWerder opened 10 years ago

JanWerder commented 10 years ago

I'd be nice to have a installer where the user could set all common file association to vimage

Torrunt commented 10 years ago

I just recently tried making an Installer though I'm having trouble getting the file associations set. When you set a default program for a file type (eg: .jpg) it seems it changes Progid in the "Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts.jpg\UserChoice" but also has a Hash. I can't just change the Progid value since that doesn't do anything. I've seen some people suggest deleting all the values in the OpenWithList for an extension so your program is the only one and therefore defaults to it, but I don't want to do that. I'm just gonna give up for now.

Here's the .iss (Inno Setup Script) file I made:

[Setup]
AppId={{B3A85F74-AFE6-44E6-92BD-3DAB1F18F869}
AppName=vimage
AppVersion=6
;AppVerName=vimage version 6
AppPublisher=Torrunt
AppPublisherURL=http://torrunt.net
AppSupportURL=http://torrunt.net/vimage
AppUpdatesURL=http://torrunt.net
DefaultDirName={pf}\vimage
DisableDirPage=no
DefaultGroupName=vimage
DisableProgramGroupPage=yes
DisableWelcomePage=yes
OutputBaseFilename=vimage_setup
Compression=lzma
SolidCompression=yes
ChangesAssociations=yes

[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"

[Files]
Source: "vimage.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "config.txt"; DestDir: "{app}"; Flags: ignoreversion
Source: "csfml-graphics-2.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "csfml-window-2.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "DevIL.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "readme.txt"; DestDir: "{app}"; Flags: ignoreversion

[Icons]
Name: "{group}\vimage"; Filename: "{app}\vimage.exe"

[Tasks]
Name: Association_jpg; Description: "jpg"; GroupDescription: File Associations:
Name: Association_png; Description: "png"; GroupDescription: File Associations:
Name: Association_gif; Description: "gif"; GroupDescription: File Associations:

[Registry]
Root: HKLM; Subkey: "Software\Classes\vimage.AssocFile.jpg"; ValueType: String; ValueData: "jpg"; Flags: uninsdeletekey
Root: HKLM; Subkey: "Software\Classes\vimage.AssocFile.jpg\DefaultIcon"; ValueType: String; ValueData: "{app}\vimage.exe,0"; Flags: uninsdeletekey
Root: HKLM; Subkey: "Software\Classes\vimage.AssocFile.jpg\Shell\Open\Command"; ValueType: String; ValueData: """{app}\vimage.exe"" ""%1"""; Flags: uninsdeletekey
Root: HKLM; Subkey: "Software\Classes\.jpg"; ValueType: String; ValueData: "vimage.AssocFile.jpg"; Flags: uninsdeletevalue uninsdeletekeyifempty; Tasks: Association_jpg

Root: HKLM; Subkey: "Software\Classes\vimage.AssocFile.png"; ValueType: String; ValueData: "png"; Flags: uninsdeletekey
Root: HKLM; Subkey: "Software\Classes\vimage.AssocFile.png\DefaultIcon"; ValueType: String; ValueData: "{app}\vimage.exe,0"; Flags: uninsdeletekey
Root: HKLM; Subkey: "Software\Classes\vimage.AssocFile.png\Shell\Open\Command"; ValueType: String; ValueData: """{app}\vimage.exe"" ""%1"""; Flags: uninsdeletekey
Root: HKLM; Subkey: "Software\Classes\.png"; ValueType: String; ValueData: "vimage.AssocFile.png"; Flags: uninsdeletevalue uninsdeletekeyifempty; Tasks: Association_png

Root: HKLM; Subkey: "Software\Classes\vimage.AssocFile.gif"; ValueType: String; ValueData: "gif"; Flags: uninsdeletekey
Root: HKLM; Subkey: "Software\Classes\vimage.AssocFile.gif\DefaultIcon"; ValueType: String; ValueData: "{app}\vimage.exe,0"; Flags: uninsdeletekey
Root: HKLM; Subkey: "Software\Classes\vimage.AssocFile.gif\Shell\Open\Command"; ValueType: String; ValueData: """{app}\vimage.exe"" ""%1"""; Flags: uninsdeletekey
Root: HKLM; Subkey: "Software\Classes\.gif"; ValueType: String; ValueData: "vimage.AssocFile.gif"; Flags: uninsdeletevalue uninsdeletekeyifempty; Tasks: Association_gif

(Note: I use ILMerge-GUI to merge the other .dlls with the vimage.exe)

JanWerder commented 10 years ago

Adding it to settings menu, would be an option. Then C# could solve the Problem. This class should do the trick http://www.codeproject.com/Articles/43675/C-FileAssociation-Class

Bondualf commented 2 years ago

SetUserFTA: UserChoice Hash defeated – Set File Type Associations per User or Group on Windows 8/10

https://kolbi.cz/blog/2017/10/25/setuserfta-userchoice-hash-defeated-set-file-type-associations-per-user/