views:

272

answers:

2

Shell explorer on Windows define global objects such as ::{2559a1f4-21d7-11d4-bdaf-00c04f60b9f0 which is a link to the user "internet browser". I got these value from a shortcut that is drag&dropped over my application, but I can't find how to use it to open it...

I'd like to get information about what this object is too.

  • Does someone know how to ask Windows about what this object is ?
  • Does someone know how to open it ?

I have found that these objects can be found by reading from the registry at :

initString = HLCR\CLSID\\{CLSID\}\PersistentBag\InitString
openCommand = HKLM\Software\Clients\{initString}\shell\open\command

Usually its not a good idea to read directly from the registry. I'd be please to have a cleaner way to read these values.

Thanks.

A: 

Apparently you need to fill in a SHELLEXECUTEINFO structure, with the fMask field set to SEE_MASK_CLASSKEY, the lpVerb field set to "open" and the lpClass set to your GUID.

However, I never got the damn thing to work. Instead I used a file of the correct type to use in a CreateProcess call.

 HINSTANCE h = FindExecutable("blank.htm", NULL, buffer);

 STARTUPINFO si;
 PROCESS_INFORMATION pi;
 ZeroMemory( &si, sizeof(si) );
 si.cb = sizeof(si);
 ZeroMemory( &pi, sizeof(pi) );

 char url[MAX_PATH];
 sprintf(url, "\"%s\" %s", buffer, (LPCTSTR)m_url);
 CreateProcess(NULL, url, NULL, NULL, FALSE, 0 , NULL, NULL, &si, &pi);

Which opens the app that is defined as the default viewer for files of type .htm.

gbjbaanb
I really need to execute any of these links, not just the "internet browser" one. I'll try your first tip though. Thanks.
Emmanuel Caradec
A: 

From "Creating Shell Extensions with Shell Instance Objects" at http://msdn.microsoft.com/en-us/library/ms997573.aspx it is told that

Whereas a traditional shell extension requires a DLL to implement the object, a shell instance object retrieves everything it needs to know from the registry.

It seems to be safe to read the informations from the registry as it is the documented solution to create them.

Emmanuel Caradec