Windows Explorer Shell Extension for double click - windows

Is there a way to change the default application that opens all files under specified directory on Windows Explorer double click event?
For other folders I want files to be opened by standard applications.

Implement a IContextMenu shell extension. Register it under HKCR\*\ShellEx and add the MayChangeDefaultMenu key to the CLSID registration.
You must create and register both a 32-bit and a 64-bit extension on 64-bit Windows.
When a file is double-clicked Explorer will load the extension and you can add a new default menu item if the file(s) in the dataobject fulfil your criteria. This will have a small system-wide performance impact.

Related

Shell extension on Windows 8.1

I wrote a little command-line utility in C++ which I compiled and copied into a location in the system path. I then added the following registry entries. When I right-click a TXT file, the pop-up context menu shows the usual "Open" and "Edit" but also "DoSomething" and "SomethingElse". Selecting either sends the path of the file just clicked to the utility, which processes the file.
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\txtfile\shell]
[HKEY_CLASSES_ROOT\txtfile\shell\cmd2]
#="&DoSomething"
[HKEY_CLASSES_ROOT\txtfile\shell\cmd2\command]
#="DoSomething.exe 0 %1"
[HKEY_CLASSES_ROOT\txtfile\shell\cmd3]
#="&SomethingElse"
[HKEY_CLASSES_ROOT\txtfile\shell\cmd3\command]
#="DoSomething.exe 1 %1"
This works great on Windows XP...but try as I might, I cannot get the context menu entry "DoSomething" to appear on Windows 8.1. And advice on how to modify the registry entries or use another method for 8.1?

How WinRar let Windows explorer support drop a file on *.rar/*.zip/... type files?

I only known how to support drag item form my app to explorer; or drag item form explorer to my app.
I want to know hot to make windows explorer support more file type, for example :when dorp a file on "xxx.mypackage" in explorer, my app run and package the file into "xxx.mypackage".
thanks lot~~
You're looking for a Drop Handler shell extension.
The drop handler lives inside a DLL, which has to be able to create a COM object that implements IPersistFile and IDropTarget. The DLL is registered under the filetype's ProgId key in the registry (look at HKEY_CLASSES_ROOT\CompressedFolder\ShellEx\DropHandler for an example of this).

Add java argument to windows right click? [duplicate]

How would one go about adding a submenu item to the windows explorer context menu (like for example 7-Zip does) for a Java application?
I am aware of two ways to do it. The fancy way is to write a windows shell extension, which is how powerarchiver, winzip etc do it I believe (this involves running code to determine what the context menu items will be dependent on the file chosen).
The simple way, for simple functionality, is you can add an entry in the registry :
HKEY_CLASSES_ROOT\<file type>\shell\<display text>\command
Where <file type> is the files that this context menu should apply to i.e. *, .mdb, .doc
and
<display text> what you want to show in the context menu.
Then add the default string as a path to the application you want to launch from the context menu, and you can use %1 to refer to the currently selected file i.e. for MS Access I use :
HKEY_CLASSES_ROOT\*\shell\MS Access 2000\command
"C:\Program Files\Microsoft Office\Office\MSACCESS.EXE" "%1"
This then adds a context menu item for any file I select (hence the *), which allows me to launch it in MS Access 2000.
Of course, always back up your registry before hacking it.
Your program could do this during install, or on first run.
You could also package the java program in an installer like NSIS and you could use NSIS script to generate explorer context menu

Register program on windows registry so that it appears on "Uninstall a program" on Control Panel

Let's say I have a simple program: SomeProgram.exe and Uninstaller.exe those programs are in C:\ProgramFiles\MyProgram along with several dll's and resources.
Anyways I have a simple installer that installs several prerequisites to that path. Now my question is how can I register SomeProgram.exe on window registry so that I can have it appear in add or remove programs in control panel. I will like to execute Uninstaller.exe when the user clicks on remove my program. Also I will like to create a folder on windows startup menu so that the user can start the program from there in case he does not want to have a shortcut on the desktop.
All you need to do is to create the registry entries as documented in the second link from "sergmat". This will make the program to appear in the list from Control Panel.
http://msdn.microsoft.com/en-us/library/windows/desktop/aa372105(v=vs.85).aspx

How does Windows associate icons to files in explorer shell?

I have both InDesign CS2 and CS3 installed. Both use files with .indd extension. How does Windows know which icon to use? It uses correct icons i.e. CS2 files have cs2 icon and CS3 files have CS3 icon.
How does Windows know how to do this?
And how can I extract or use this version-detection system in my programs?
Edit:
Thank you for your shell-extension-icon-handler answers. Something new to me. But is there any way I could connect to IconHandler that InDesign provides and use it to detect version of the InDesign file?
You need to write an Icon Handler shell extension. See the MSDN documentation for IExtractIcon. The basic mechanism is that you create a shell extension and register the icon handler for the file type you want (look in HKEY_CLASSES_ROOT/.indd) and then the shell loads your handler, passes the file information and requests an icon in return. There's also the IExtractImage method if you want to provide a thumbnail bitmap rather than just an icon.
Note that you need to be especially careful writing shell extension handlers as any memory leaks or crashes can nuke the explorer and any other applications that display a file open/save dialog.
For some files it's HKEY_CLASSES_ROOT\<file extension here>\DefaultIcon registry entry, but most files map to a more friendly name, e.g. .pdf\(Default) -> AcroExch.Document (if Adobe Reader is installed).
In that case you have to go along the registry to AcroExch.Document and see that either
DefaultIcon is right there or
AcroExch.Document\CLSID\(Default) is some GUID. Then, follow HKEY_CLASSES_ROOT\CLSID\<insert that guid here> and you'll notice that this key contains DefaultIcon
... and DefaultIcon is where the icon is loaded from.
Hope that was clear enough ;). I don't know about your special case but there should be a distinction in the registry.
It almost certainly installs a shell icon extension handler. Writing your own and knowing how to detect the version in a file format that isn't documented well or at all is quite tricky.

Resources