Torrunt / vimage

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

Added support for file association handling #27

Closed whisperity closed 6 years ago

whisperity commented 9 years ago

I have checked the library linked by JanWerder and modified it a little so it does not require administrator privileges, only when writing to the registry.

With this done, and with meddling around in the swamp of WinAPI (... it's so... uck.), I think file association support should be implemented with this chage.

When started normally, the settings program will show file types that could be handled by vimage along with what they are handled by right now. No administrator rights

Click on that little button, it will restart with Administrator rights. And then, the Associate button becomes available which registers the file type for vimage. File type associated properly

Settings the file icon (and the open command, of course): vimage-associated file in a folder

(So this should fix issue #17 )

Torrunt commented 9 years ago

Nice work! It's late here at the moment so I haven't gotten that good of a look at the changes yet but the File Associations don't work for me at all. It's probably because they changed how it works quite a bit in Windows 8.

The File Associations tab doesn't get the correct names of the programs currently associated (the icons are correct though) and clicking associate just makes it so the next time you open that file type you get a prompt saying there is a new program that can open it. If I then change the association of something elsewhere then come back to vimage settings it still thinks it's associated with vimage and shows a tick (even though it shows the correct icon for the new association).

whisperity commented 9 years ago

Strange... it works completely fine for me. And it does not seem like that much would have changed, at least according to the official documentation. I will get a copy of Windows 8 and install it in virtual box to try it out.

whisperity commented 9 years ago

Oh yeah. Microsoft has added a Hash value into the registry where the user-specific "Open with" values are stored, which is generate when you by yourself decide that the new file association happens.

Compare: File associations Win7 and Win8.1

And if this hash is missing (which, frankly, is) the system just purely ignores what is the default in the registry and prompts the user to select what he/she wishes to open the images with. (All the resources I currently find on the internet is about how you can pack these custom file associations into the installer when you are running a corporate install across tens or hundreds of computers. Which is obvious, that they did not release how you can create this hash programmatically.)

Inb4 automatic file associations are a no-go because Windows 8.

whisperity commented 9 years ago

So according to this post (with the cleanest explanation), this is a no-go under Windows 8. Unless... we try this...(:disappointed_relieved: Bless Google and the people on that forum!)

Well, at least what I could test on it (Windows 8.1 Professional Build 9600 (32-bit, but that should matter the least :D), this should now work. Rather an overkill-y scenario, but if that's the way you can make Windows 8 eat the association, you have to tug it down its throat.

Torrunt commented 9 years ago

From what I've tested so far it still doesn't work for me. Setting the association does the same thing as before: opens the image with it's current associated program and prompts about there being a new program that can open it.

vimage_settings doesn't check the current associations properly on Windows 8 either. vimage settings At the time of that screenshot nothing was associated with vimage (the ones with the vimage icon are associated with the vimage in my work folder). The current association is in the UserChoice Progid for Windows 8 and it's currently not checking there so It get's the wrong results.

whisperity commented 9 years ago

Well, it might be something that the system it not a fresh install maybe? The "UserChoice" thingy is removed. The hack works like it is: you remove every application which could open the certain association and the HKCR sets vimage as the default and then when you effectively try to open one, Windows will believe that vimage is the only image viewer installed on the system and so, put it as default.

I don't know. What I did was to install Windows 8.1 and then copy the vimage binaries on it and use the settings and it worked perfectly. Maybe I restarted it after setting the associations or the virtual host crashed out due to OOM, but according to the documentation, it should be working.

(A strange phenomenon was that when an image was properly opened (as: the file associations did work), there were no image at all just a grey background with the width and height of the image. But that is indifferent as it is an issue with no video drivers installed.)

Somewhen I will try another fresh install to test it out... Unfortunately I don't have a real Windows 8 (or 8.1) install and I am refraining (because of issues like this and because I haven't seen a more annoying and uncomfortable operating system like Win8...) from having it as a main OS. But vboxes are a way to go in this situation. :)