Unable to set DefaultIcon in registry - windows

I am attempting to update the Windows registry to add an icon for my custom file extension, and I have thus far been unsuccessful. My current version is closest to this stackoverflow question. Unfortunately, my file's icon is still one of the generic built-in Windows icons (see screenshot below).
At this point my best guess is perhaps there is something wrong with my .ICO file. I have shared it here on Dropbox
Here is the full registry update I'm making with regedit. As you can see, I am also associating my file extension with a .bat file for execution. That works great. Also the Type displayed in Windows Explorer is PartQuest Archive which is also great (see above screenshot). Alas, no dice with the last entry for the icon.
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\pqunzip]
#="PartQuest Archive"
[HKEY_CLASSES_ROOT\pqunzip\shell]
[HKEY_CLASSES_ROOT\pqunzip\shell\open]
[HKEY_CLASSES_ROOT\pqunzip\shell\open\command]
#="\"C:\\MentorGraphics\\PartQuestTools\\SDD_HOME\\common\\win32\\scripts\\pqunzip.bat\" \"%1\""
[HKEY_CLASSES_ROOT\.pqz]
#="pqunzip"
[HKEY_CLASSES_ROOT\.pqz\DefaultIcon]
#="\"C:\\MentorGraphics\\PartQuestTools\\SDD_HOME\\common\\win32\\config\\decrypted.ico\""
I have also attempted adding a ,1 to the end of the file name since the .ICO file appears it may have two icons embedded in it. This is did not make a difference.
For good measure, I have been rebooting after each change. I'm not certain if this is necessary.
Any tips from the Windows experts around here will certainly be appreciated!

So I did a little reverse-engineering to figure out the issue based on 7Zip's file associations. It turns out that the DefaultIcon key entry should be a child of the application, not the file name. So in my case I need it associated with pqunzip rather than .pqz:
[HKEY_CLASSES_ROOT\pqunzip\DefaultIcon]
#="\"C:\\MentorGraphics\\PartQuestTools\\SDD_HOME\\common\\win32\\config\\decrypted.ico\""
For maximal clarity, this is the entire contents of my .req file that works as expected:
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\pqunzip]
#="PartQuest Archive"
[HKEY_CLASSES_ROOT\pqunzip\shell]
[HKEY_CLASSES_ROOT\pqunzip\shell\open]
[HKEY_CLASSES_ROOT\pqunzip\shell\open\command]
#="\"C:\\MentorGraphics\\PartQuestTools\\SDD_HOME\\common\\win32\\scripts\\pqunzip.bat\" \"%1\""
[HKEY_CLASSES_ROOT\pqunzip\DefaultIcon]
#="\"C:\\MentorGraphics\\PartQuestTools\\SDD_HOME\\common\\win32\\config\\decrypted.ico\""
[HKEY_CLASSES_ROOT\.pqz]
#="pqunzip"

Related

Windows - Add item to the context menu for PNG files for the current user only

I'm trying to create a program for editing the context menu of specific file/folder types. I was trying to use it to edit the .png menu, but the added item isn't showing up.
As far as I'm aware, this should add an item with the label "aaa", but it doesn't appear to do anything
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Classes\pngfile\shell\aaa\command]
#="aaa"
I've tried replacing pngfile with png and .png with no success.
I can find plenty of posts about doing this in HKCR, but not in HKCU, which doesn't require admin privileges to edit. Well, no posts about in HKCU that work for me for whatever reason.
Bonus question: How would I find where I need to put the command for other file types, like .jpg?
EDIT: Found the answer after a bit more searching
What I have to do:
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Classes\*\shell\aaa]
#="aaa"
"AppliesTo"=".jpg"
and for .jpg and .png (Not tested, but this is what it says to do.)
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Classes\*\shell\aaa]
#="aaa"
"AppliesTo"="System.FileName:\"*.jpg\" OR System.FileName:\"*.png\""
[HKEY_CURRENT_USER\Software\Classes\*\shell\aaa\command]
#="aaa"

"Windows can't open this file" for .appref-ms extension

I'm trying to run a ClickOnce installer and I get this useless error message from Windows 7: "Windows can't open this file".
The file extension is .appref-ms
Has anyone seen this or have any advice?
I had this issue on a client's machine. It appears that the operating system does not know the correct association for the file extension, but in reality .appref-ms is not a normal extension and is not directly associated with any program.
I found the following page eventually:
https://social.msdn.microsoft.com/forums/windows/en-us/9ff7867c-7e57-468c-a632-762a76f66f6d/windows-7-64-bit-unable-to-open-apprefms
This contains some information on restoring potentially damaged registry keys, which can cause this issue. However, in my opinion it gives the wrong advice to associate dfshim.dll with .appref-ms. When I did this, it created an association to that dll in the registry, but upon checking the registry of a working machine, no such association exists. This association also causes .appref-ms files to lose their application specific icons, and display instead this icon:
In addition, this association did not actually launch my application successfully, but for some others it may actually work (I don't know).
The correct solution is to restore even more registry keys, which cascade to allow windows to treat .appref-ms files more like applications than files to be opened with programs. The necessary keys are below (I may have overzealously included a couple that are not strictly necessary, but at least some of them are):
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\.appref-ms]
#="Application.Reference"
[HKEY_CLASSES_ROOT\.application]
"Content Type"="application/x-ms-application"
#="Application.Manifest"
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Application.Reference\shell]
#="open"
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Application.Reference\shell\open]
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Application.Reference\shell\open\command]
#="\"C:\\Windows\\System32\\rundll32.exe\" \"C:\\Windows\\System32\\dfshim.dll\",ShOpenVerbShortcut %1|%2"
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Application.Manifest\shell]
#="open"
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Application.Manifest\shell\open]
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Application.Manifest\shell\open\command]
#="\"C:\\Windows\\System32\\rundll32.exe\" \"C:\\Windows\\System32\\dfshim.dll\",ShOpenVerbApplication %1"
This appears to apply to both .application and .appref-ms type files. The first key identifies .appref-ms as class "Application.Reference". The later key under "Classes\Application.Reference" defines how these types are launched. These are not simple "open with" associations that Windows is trying to help you create (and which will be created under HKCU instead of HKLM).

Opening a CHM file produces: "navigation to the webpage was canceled"

I am trying to open a .chm file.
I downloaded the source, extracted it, and double clicked on Waffle.chm and clicked "Open" but no matter what element in the chm file I click, I get the message:
Navigation to the webpage was canceled.
What you can try:
Retype the address.
What's going on here?
Summary
Microsoft Security Updates 896358 & 840315 block display of CHM file contents when opened from a network drive (or a UNC path). This is Windows' attempt to stop attack vectors for viruses/malware from infecting your computer and has blocked out the .chm file that draw data over the "InfoTech" protocol, which this chm file uses.
Microsoft's summary of the problem: http://support.microsoft.com/kb/896054
Solutions
If you are using Windows Server 2008, Windows 7, windows has created a quick fix. Right click the chm file, and you will get the "yourfile.chm Properties" dialog box, at the bottom, a button called "Unblock" appears. Click Unblock and press OK, and try to open the chm file again, it works correctly. This option is not available for earlier versions of Windows before WindowsXP (SP3).
Solve the problem by moving your chm file OFF the network drive. You may be unaware you are using a network drive, double check now: Right click your .chm file, click properties and look at the "location" field. If it starts with two backslashes like this: \\epicserver\blah\, then you are using a networked drive. So to fix it, Copy the chm file, and paste it into a local drive, like C:\ or E:. Then try to reopen the chm file, windows does not freak out.
Last resort, if you can't copy/move the file off the networked drive. If you must open it where it sits, and you are using a lesser version of windows like XP, Vista, ME or other, you will have to manually tell Windows not to freak out over this .chm file. HHReg (HTML Help Registration Utility) Utility Automates this Task. Basically you download the HHReg utility, load your .chm file, press OK, and it will create the necessary registry keys to tell Windows not to block it. For more info: http://www.winhelponline.com/blog/fix-cannot-view-chm-files-network-xp-2003-vista/
Windows 8 or 10? --> Upgrade to Windows XP.
"unblocking" the file fixes the problem. Screenshot:
Win 8 x64:
just move it to another folder or rename your folder (in my case: my folder was "c#").
avoid to use symbol on folder name. name it with letter.
done.
In addition to Eric Leschinski's answer, and because this is stackoverflow, a programmatical solution:
Windows uses hidden file forks to mark content as "downloaded". Truncating these unblocks the file. The name of the stream used for CHM's is "Zone.Identifier". One can access streams by appending :streamname when opening the file. (keep backups the first time, in case your RTL messes that up!)
In Delphi it would look like this:
var f : file;
begin
writeln('unblocking ',s);
assignfile(f,'some.chm:Zone.Identifier');
rewrite(f,1);
truncate(f);
closefile(f);
end;
I'm told that on non forked filesystems (like FAT32) there are hidden files, but I haven't gotten to the bottom of that yet.
P.s. Delphi's DeleteFile() should also recognize forks.
The definitive solution is to allow the InfoTech protocol to work in the intranet zone.
Add the following value to the registry and the problem should be solved:
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\HTMLHelp\1.x\ItssRestrictions]
"MaxAllowedZone"=dword:00000001
More info here: http://support.microsoft.com/kb/896054
Go to Start
Type regsvr32 hhctrl.ocx
You should get a success message like:
" DllRegisterServer in hhctrl.ocx succeeded "
Now try to open your CHM file again.
other way is to use different third party software. This link shows more third party software to view chm files...
I tried with SumatraPDF and it work fine.
I fixed this programmatically in my software, using C++ Builder.
Before I assign the CHM help file, Application->HelpFile = HelpFileName, I check to see if it contains the "Zone.Identifier" stream, and when it does, I simply remove it.
String ZIStream(HelpFileName + ":Zone.Identifier") ;
if (FileExists(ZIStream))
{ DeleteFile(ZIStream) ; }
There are apparently different levels of authentication. Most articles I read tell you to set the MaxAllowedZone to '1' which means that local machine zone and intranet zone are allowed but '4' allows access for 'all' zones.
For more info, read this article:
https://support.microsoft.com/en-us/kb/892675
This is how my registry looks (I wasn't sure it would work with the wild cards but it seems to work for me):
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\HTMLHelp]
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\HTMLHelp\1.x]
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\HTMLHelp\1.x\ItssRestrictions]
"MaxAllowedZone"=dword:00000004
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\HTMLHelp\1.x\ItssRestrictions]
"UrlAllowList"="\\\\<network_path_root>;\\\\<network_path_root>\*;\\ies-inc.local;http://www.*;http://*;https://www.*;https://*;"
As an additional note, weirdly the "UrlAllowList" key was required to make this work on another PC but not my test one. It's probably not required at all but when I added it, it fixed the problem. The user may have not closed the original file or something like that. So just a consideration. I suggest try the least and test it, then add if needed. Once you confirm, you can deploy if needed. Good Luck!
Edit: P.S. Another method that worked was mapping the path to the network locally by using mklink /d (symbolic linking in Windows 7 or newer) but mapping a network drive letter (Z: for testing) did not work. Just food for thought and I did not have to 'Unblock' any files. Also the accepted 'Solution' did not resolve the issue for me.
Moving to local folder is the quickest solution, nothing else worked for me esp because I was not admin on my system (can't edit registery etc), which is a typical case in a work environment.
Create a folder in C:\help drive, lets call it help and copy the files there and open.
Do not copy to mydocuments or anywhere else, those locations are usually on network drive in office setup and will not work.

Find the relation between ".automaticDestinations-ms" and it's file?

Does anyone know (Because on microsoft forums nobody answered me), how can I find what app has which automaticDestinations-ms file in %appdata%\microsoft\windows\recent\automaticdestinations ?
That's the folder where Windows 7 stores its jump lists, and I want to know how to automatically/programmatic find the relation between each file and an application.
At least, even manual I didn't found any pattern, just to look after file extensions in the files, because some programs open files with the same extension (like images), so this method it's not OK for all programs.
Do you have any other idea? Maybe knowing the format of those files?
Thanks.
the GUIDs appear to persist.
I was trying to edit my control panel jumplist - I found where the "Realtek HD audio manager" control-panel-applet-title-string is (using resource hacker on "C:\Windows\System32\RTSnMg64.cpl"), and restored it's original title ("Dell Audio" - 'cause I'm OCD:) but the original pinned Realtek entry is stuck.
A quick filesearch for pinned took me to
C:\Users\Jonny\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\User Pinned
but I really needed to be # C:\Users\Jonny\AppData\Roaming\Microsoft\Windows\Recent\AutomaticDestinations
If you use something like Nirsoft's Jumplist View you can see the entries etc. Sort by "application ID" column to see jumplists by application. You can even change the monitored folder (advanced options).
I'm going to have to delete and recreate my control panel jumplist (7e4dca80246863e3.automaticDestinations-ms).
TIP: If you're not sure which is which, try pinning a new jumplist-entry to an application. This will appear at the top (if sorted by "record time")
The best way to find out is to sort the files by date modified, then interact with your machine, eg open a file with Powerpoint, look and see what file moved to the top. That is probably the file for Powerpoint, which you can confirm by opening it and looking in it.
Then you could build a table of magic guids, and search for those in the registry to see if there is an obvious key connecting the guid to an application id.
Here is a list of 620 applications here with the corresponding App ID byEricZimmerman
https://github.com/EricZimmerman/JumpList/blob/master/JumpList/Resources/AppIDs.txt
eg 0a1d19afe5a80f80|FileZilla 2.2.32
last update 12 days ago

IFileSaveDialog - choosing folders in Windows 7

In Vista, I have been using an IFileSaveDialog to let users pick a "save-as" folder. Users export a folder of images, say, and need to choose a new or existing target folder.
Briefly, the code goes like this:
IFileSaveDialog* dialog; // created
dialog->SetOptions(FOS_PICKFOLDERS);
dialog->Show(NULL);
dialog->GetResult(&shellItem)
In Windows 7, the FOS_PICKFOLDERS option appears to have been disallowed (and is marked as such in the API). The return value on the SetOptions call is E_INVALIDARG. If I use a IFileOpenDialog, I'm allowed to set the folders option, but the user is prompted with an error when choosing a nonexistent folder (despite my setting flags suggesting not to do this).
Is there an alternate way to get the new IFileDialog to act as a "save folder" dialog?
[To head off some comments, the SHBrowseForFolder API still exists, but is still not an acceptable solution for our UI deciders.]
The reason for this can be found in the documentation:
FOS_PICKFOLDERS: Present the Open dialog offering a choice of folders rather than files.
Using FOS_PICKFOLDERS for "save" was never supposed to be supported - but Vista didn't enforce it. Use IFileOpenDialog instead and you're good to go.
You are picking an existing folder (not specifying a folder to create), so open was always the correct choice.
I haven't played around with the Windows 7 dialogs yet, but downloaded the Windows® API Code Pack just this morning as I am implementing the Thumbnail Toolbar and Icon Overlay in the application I am working on. It'll probably point you in the right direction.

Resources