Icon (DefaultIcon) is displayed differently - windows

I'm struggling with the icon of my application's document files.
First, I'm registering the file extension:
HKEY_CLASSES_ROOT\.Ext\(default) = AppName
Then I give it a shell open command and a icon:
HKEY_CLASSES_ROOT\[AppName]\shell\open\command\(default)="path\app.exe"
HKEY_CLASSES_ROOT\[AppName]\DefaultIcon\(default)="path\app.exe",0
The icon is displayed in Explorer, but not the original one, instead it displays it on a white sheet:
The left one is the associated file, the right one is the executable.
How do I set the registry entries to get the original icon displayed?

I don't know if DefaultIcon supports quotes on the path, other than that the registration looks OK.
After writing these entries you should call SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, 0, 0) so other applications can refresh themselves.
The document icon is generated by the shell (GIL_SIMULATEDOC) when it cannot find a valid DefaultIcon entry but it knows which executable it is going to use. This can happen if you use "Open With" to open your file-type when it has no registration.
Try calling SHChangeNotify and then reboot. If that does not fix it then you should search the registry for your file extension and remove it from Explorers HKCU FileExts keys and any "auto" entries for your type in HKCR. Clearing the shell iconcache might also help.

Related

.srt file types doesn't exist under 'Choose default apps by file type' after after formatting windows 10, what to do?

Before I did a clean install of my desktop with windows 10 I had .srt to open by default in Sublime Text after I have formatted my computer I somehow miss the file format .srt under 'Choose default apps by file type'.
The .srt should be be between the .srf and .srw file types, but it isn't (as shown in the image here: https://answers.microsoft.com/en-us/windows/forum/windows_10-desktop-winpc/srt-files-back-to-unknown-application/e33cace8-dd59-4557-9631-e8e82a8307b3?auth=1).
If I try "open with and find Sublime (or any other software for that matter, it will open it, but it will not set it as the default program even though I checked the box) and will still appear as an unknown filetype....
If I go into properties and try to change the "open with" from there, it will just keep showing "choose a program" even still.
tried updating the computer and restart it and frankly I've given up, and it doesn't seem anyone have run into this problem before of missing a filetype under 'Choose default apps by file type'.
I also tried
1) Settings - Indexing Options
2) Advanced button
3) File Types tab
4) Add New Extension to List box, type in extension (without a period) such as "py"
5) Click Add, OK and Close
and while the format does appear in the 'Choose default apps by file type', it still doesn't let me change it at all...
Anyone got an answer to this problem?
I have now tried to go into regedit and use "search" on anything that included "sublime" and ".srt" and deleted them all... restarted the computer, reinstall sublime. The file extension I created myself in the indexing option, has been deleted.
Sublime can still open the file, but if you try to make it default program by simply opening it or or going into the files properties and do it that way, it will just open the file without it making it the default program as it should.
going into the indexing option and create the .srt extension format so it can be found under 'Choose default apps by file type' will allow you to choose notepad or wordpad as default program. When I choose either of them, the will just freeze for 1-2 sec and then nothing has changed and the extension havn't been associated with any of the programs.
I tried following the following links, and nothing has worked. Guess I'll just have to accept there is no solution rather than to live with out until I reform my PC again, cause it works without a problem on my laptop and I formatted them both the same time and installed the exact same things on both and the exact same way s:
I've tried to use the following links for help, but to no avail since non of the things I have tried have fixed it.
https://superuser.com/questions/655600/i-cant-set-a-program-as-the-default-to-open-a-filetype-with-in-windows-7
https://superuser.com/questions/91655/open-with-dialog-ignores-my-selection
https://superuser.com/questions/13653/how-to-set-the-default-program-for-opening-files-without-an-extension-in-windows
Windows 7 file extension association
One way to get an empty .srt entry back in the 'Choose default apps by file type' control panel is to create a new key for .srt in your registry under HKEY_CLASSES_ROOT:
Open Registry Editor, e.g. by typing 'regedit' into the start menu or a command prompt
At the top of the tree, right-click on 'HKEY_CLASSES_ROOT', New -> Key
Rename the new key to '.srt' and press enter to save

Add entry to right-click menu for a specific filetype

What I want
I want to add a custom entry to the menu that appears when right-clicking a .jpg/.jpeg for my program (editing images).
What I tried
I added to HKEY_CLASSES_ROOT\jpegfile\shell a key test, in there a second key command and set the (default) value of that to notepad.exe (just for testing). Because no test entry appeared in the menu, I did the same just unter HKEY_CLASSES_ROOT\Directory where it worked!
The file I click is an JPEG and the default value of HKEY_CLASSES_ROOT.jpg is jpegfile.
(Also tested with txtfile but with no success.)
What did I do wrong to add a custom command to specific filetypes only?
What you did was correct. Possible reasons why it didn't work include:
Windows Update has an annoying tendency in Windows 10 to reset file associations to Windows defaults all the time.
You added this facility to the jpegfile key, but the type .jpg may be associated with a different file-type key.
Go to HKEY_CLASSES_ROOT.jpg and see what the association is (alternatively, type ASSOC .jpg in Command Prompt). If it isn't jpegfile, check what it is, in case you actually want to keep that association.
To give you an example, I have a working right-click menu entry for .png files, which runs the pngout utility on them. I did that by editing the Registry. My current association for .png files is FastStone Image Viewer:
So I changed the shell menu for FastStone's file type key:
And now my right-click menu entry works.

How can i add a Right Click option/options on any specific directory of window

I am creating a directory synch application in java programming application. Now i want to add share option when user right click with in a specific directory, and want to open an dynamic url on clicking that new option. Can anyone help me to find any good solution. Can anyone provide me Registry Script For this task.
An msdn resource on Extending Shortcut Menus will be good for you.
Anyway, I'd like to introduce my own "minimal" example. This opens a gnuplot's wgnuplot terminal at the right-clicked directory after choosing "Open gnuplot here" shortcut.
You can add keys into HKEY_CLASSES_ROOT\Directory\shell. I added HKEY_CLASSES_ROOT\Directory\shell\gnuplot with string (name: (Default)) Open gnuplot here, provided an icon string with the program's icon path, a LegacyEnable empty string and a command key that windows have to execute when clicking. You can reach the right clicked directory name with %V (You can find out more special variables on this Q&A thread at SU). Here's the code that creates the structure:
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Directory\shell\gnuplot]
#="Open gnuplot here"
"Icon"="\"C:\\Windows\\icons\\wgnuplot.ico\""
"LegacyEnable"=""
[HKEY_CLASSES_ROOT\Directory\shell\gnuplot\command]
#="\"C:\\Users\\Cron\\Documents\\egyetem\\gnuplot\\bin\\pgnuplot.exe\" -e \"cd '%V'\" -persist"

How to determine the Windows default browser (at the top of the start menu)

How can I determine the Windows default browser (at the top of the start menu)?
I am using VB6 but can probably adapt other code no problem.
There are similar questions on Stack Overflow, but they seem to provide incorrect answers.
For instance the key HKEY_LOCAL_MACHINE\Software\Clients\StartMenuInternet\ lists both Internet Explorer and Firefox on my PC.
And getting the .html association fails for me as well, as HTML files are associated with IE but Firefox is my default browser.
Note that I don't want to actually open the browser, just get it's name.
When you click on a .html file, the browser that opens it is the one that has registered the .html extension.
When you open a http:// link (e.g. by typing it into the "Start->Run" box), the browser that opens is the one that has registered the HTTP protocol (although it's usually the same browser in both cases).
Whatever is displayed in Start Menu is not related to this.
HKEY_CURRENT_USER\Software\Classes\http\shell\open\command\(Default) is the current user's handler for the HTTP protocol (which means "default browser"; NOTE: this is NOT the same thing as the .html default handler!).
However, it is possible to have a different browser at the top of Start Menu without changing the default. FYI, the browser executable name in Start menu is stored in HKEY_CURRENT_USER\Software\Clients\StartMenuInternet\(Default).
Tested in Windows 7 x64:
This is a two step process. The user's default browser is in key:
HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.html\UserChoice\Progid
Common browser Key Name:
IE: IE.AssocFile.HTM
FireFox: FirefoxHTML
Chrome: ChromeHTML
Opera: Opera.HTML
Replace <KEY NAME> below with one of the values above to find the executable:
HKCR\<KEY NAME>\shell\open\command
Autohotkey script to display the default browser path and executable:
MsgBox % "Default browser: " Browser()
Browser()
{
; Find the Registry key name for the default browser
RegRead, BrowserKeyName, HKEY_CURRENT_USER, Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.html\UserChoice, Progid
; Find the executable command associated with the above Registry key
RegRead, BrowserFullCommand, HKEY_CLASSES_ROOT, %BrowserKeyName%\shell\open\command
; The above RegRead will return the path and executable name of the brower contained within qoutes and optional parameters
; We only want the text contained inside the first set of quotes which is the path and executable
; Find the ending quote position (we know the beginning quote is in position 0 so start searching at position 1)
StringGetPos, pos, BrowserFullCommand, ",,1
; Decrement by one for the StringMid to work correctly
pos := --pos
; Extract and return the path and executable of the browser
StringMid, BrowserPathandEXE, BrowserFullCommand, 2, %pos%
Return BrowserPathandEXE
}
Default browsers are usually set on a per user basis. Have you tried HKEY_CURRENT_USER instead? Shows up on mine under there correctly.
reg QUERY HKEY_CLASSES_ROOT\htmlfile\shell\open\command /ve
you'll get something like
HKEY_CLASSES_ROOT\htmlfile\shell\open\command
(Default) REG_SZ "C:\Program Files\Internet Explorer\iexplore.exe" %1

Is it possible to replace the system open file dialog?

I want to replace the standard system open file dialog with the one I wrote, that means no matter within which programs you are opening a file, my dialog will be shown instead of the standard one, is this possible?
It seems that that there is no such API provided to accomplish this, is it possible to use some hooking technique, but this has to be reliable and not to be treated as spyware by anti-virus tools?
any other options?
If this is not possible, is it possible to add to the spacebar or toolbar in the standard open file dialog a button which invokes my dialog, which allow users select a file and in turn returns the path of the selected file to the "File name" input box of the standard dialog?
Any hits, links and code examples will be appreciated.
Starting in Vista, the FileOpen/FileSave dialogs are now "Common Item Dialogs" of which IFileOpenDialog & IFileSaveDialog are the two published implementations.
Since they're just COM objects with known CLSIDs you might get away with just replacing them by re-registering using their CLSIDs. Never tried something like that, might trip all sorts of alarm bells.
Pre-Vista file dialogs can be hooked in process, but I've never come across anything about global hooks or equivalent.
If you copy a file/folder to a dialog's filename field it usually pastes the full path anyway.
For example, if you have open both a program calling the standard open/save dialog box and also have a window open at the file or path that you want to work with (open from/save to), you can simply copy the file/folder from the explorer window, and then paste into the filename field of the dialog box, and it will insert the full path of the file/folder. No custom script is required!
Alternatively, for those programs that use custom dialog boxes where this step fails, copy the same file/folder in the window into the address bar of the same window (assuming it is visible). This will paste the full path, which you can copy again, and then paste this full path into the custom dialog box. I often use this when creating Office hyperlinks (Ctrl+K), because the Insert Hyperlink dialog does not work for the first method.
You can also use similar methods but paste into address bar fields and it works.

Resources