This is the mail archive of the cygwin@sourceware.cygnus.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: How to create shortcut?


Hi Michael,


Michael Lemke wrote:
> ... I also
> could not find which library exports the IShell stuff.

No documented library, it's a COM object, the binding is dynamic through
the ID IID_IShellLink.

> Is this the only way to make a shortcut?  Looks extremely cumbersome to
> me.

Looks rather straight-forward to me ;-). One could ask, why this
function was not included in some OS DLL. But then at least they give
this code, and it's even in C, instead of the C++, which would be more
common for COM code.

> Anyway, here goes:
> 
> #include <windows.h>
> // CreateLink - uses the shell's IShellLink and IPersistFile interfaces
> //   to create and store a shortcut to the specified object.
> ....
> And that is what I get:
> 
> BASH.EXE-2.01$ gcc shortc.c
> shortc.c: In function `CreateLink':
> shortc.c:16: `IShellLink' undeclared (first use this function)
> ...
> shortc.c:19: `CLSID_ShellLink' undeclared (first use this function)
> ...
> shortc.c:22: `IPersistFile' undeclared (first use this function)

Seem pretty clear to me. The sample code omits the headers for the COM
interfaces that it uses. The VC++ compiler probably has them included in
#include<windows.h>. According to my code you need #include<shlobj.h> to
get the definitions. This header was not included with cygwin32.b18 and
probably is not with b19 either. It certainly is in the PlatformSDK, so
you may want to try that version. You'll probably need some other
headers, too, that are sub-included from <shlobj.h>.

Note that in addition to the code given in the sample code you will need
to call CoInitialize() and CoUninitialize() to register your process
with COM. Look at the docs for these.


so long, benny
======================================
Benjamin Riefenstahl (benny@crocodial.de)
Crocodial Communications EntwicklungsGmbH
Ruhrstraße 61, D-22761 Hamburg, Germany
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]