why CoCreateInstance( ... IID_IShellLink, ..) failed
-
My Code is like: #define UNICODE ::CoInitializeEx( NULL, COINIT_MULTITHREADED ); ... IShellLink *pShellLink; HRESULT hr; hr = ::CoCreateInstance( CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, (void**)&pShellLink ); It's very strange the code work ok on my windows 2000 and on some other windows 2000. But on someone's windows 2000 it always failed. If i create IUnknown, it succeeded, but when query interface IShellLink it failed again. IShellLink is a macro, so i tried use IShellLinkW or IShellLinkA, also failed. Who knows why? Many thanks! Ting Xu xuting@263.net.cn
-
My Code is like: #define UNICODE ::CoInitializeEx( NULL, COINIT_MULTITHREADED ); ... IShellLink *pShellLink; HRESULT hr; hr = ::CoCreateInstance( CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, (void**)&pShellLink ); It's very strange the code work ok on my windows 2000 and on some other windows 2000. But on someone's windows 2000 it always failed. If i create IUnknown, it succeeded, but when query interface IShellLink it failed again. IShellLink is a macro, so i tried use IShellLinkW or IShellLinkA, also failed. Who knows why? Many thanks! Ting Xu xuting@263.net.cn
-
My Code is like: #define UNICODE ::CoInitializeEx( NULL, COINIT_MULTITHREADED ); ... IShellLink *pShellLink; HRESULT hr; hr = ::CoCreateInstance( CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, (void**)&pShellLink ); It's very strange the code work ok on my windows 2000 and on some other windows 2000. But on someone's windows 2000 it always failed. If i create IUnknown, it succeeded, but when query interface IShellLink it failed again. IShellLink is a macro, so i tried use IShellLinkW or IShellLinkA, also failed. Who knows why? Many thanks! Ting Xu xuting@263.net.cn
Hello Ting Xu, What is the return value (HRESULT) from the ::CoCreateInstance() function ? Regards, Bio.
-
My Code is like: #define UNICODE ::CoInitializeEx( NULL, COINIT_MULTITHREADED ); ... IShellLink *pShellLink; HRESULT hr; hr = ::CoCreateInstance( CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, (void**)&pShellLink ); It's very strange the code work ok on my windows 2000 and on some other windows 2000. But on someone's windows 2000 it always failed. If i create IUnknown, it succeeded, but when query interface IShellLink it failed again. IShellLink is a macro, so i tried use IShellLinkW or IShellLinkA, also failed. Who knows why? Many thanks! Ting Xu xuting@263.net.cn
Hello Ting Xu, I checked out the help files under index IShellLink and noted that the IShellLink interface is implemented in Shell32.dll. I then looked up the type library of Shell32.dll via OLEView. I noted that there are no IShellLink interface declared inside my machine's version of Shell32.dll. There is, however, a IShellLinkDual interface as well as a IShellLinkDual2 interface in my shell32.dll. The IShellLinkDual interface looks similar to IShellLink. The "Dual" most likely signifies "dual interface". Hence it may be a newer version of IShellLink (by virtue of it being of dual interface) Please check this out. What you can do is to use the OleView tool to view the type library of the target machine's Shell32.dll. If IShellLink is not present but the IShellLinkDual and IShellLinkDual2 interfaces are present, then you may want to use the IShellLinkDual or IShellLinkDual2 interface(s) instead : IShellLinkDual *pShellLinkDual; HRESULT hr; hr = ::CoCreateInstance (CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLinkDual, (void**)&pShellLinkDual); Hope the above helps. Best Regards, Bio.