From: Luke D. <cod...@ho...> - 2003-07-25 01:53:16
|
----- Original Message ----- From: "Sam Steingold" <sd...@gn...> To: <min...@li...> Sent: Friday, July 25, 2003 12:08 AM Subject: [Mingw-users] shell link resolution: works with gcc but not g++ > the following piece of code works with mingw gcc and with msvc, but not > with g++, where it gives the following errors: > > w32shell.c: In function `BOOL resolve_shell_shortcut(const CHAR*, CHAR*)': > w32shell.c:51: could not convert `&CLSID_ShellLink' to `const CLSID&' > /usr/include/w32api/objbase.h:121: in passing argument 1 of `HRESULT > CoCreateInstance(const CLSID&, IUnknown*, long unsigned int, const IID&, > void**)' > w32shell.c:54: `struct IShellLinkA' has no member named `lpVtbl' COM code is supposed to be different between C and C++, so this is not a surprise. If you rename the source to w32shell.cpp and compile using MSVC you'll probably get the same errors. > hres = psl->lpVtbl->QueryInterface(psl, &IID_IPersistFile,(LPVOID *) &ppf); Try changing the above to: hres = psl->QueryInterface(&IID_IPersistFile,(LPVOID *) &ppf); That is, you remove the "->lpVtbl" and also the first argument to the function (because it is passed implicitly by the compiler). This is described somewhere in the MS COM documentation. However, if you only want to use your function in a C++ program you could just compile it as C and link with C++ code. Compile it using the command "gcc" or "g++ -x c", and link with "g++". Luke |