Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. COM
  4. why CoCreateInstance( ... IID_IShellLink, ..) failed

why CoCreateInstance( ... IID_IShellLink, ..) failed

Scheduled Pinned Locked Moved COM
csharpdatabasequestion
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    nofeel
    wrote on last edited by
    #1

    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

    P L 3 Replies Last reply
    0
    • N nofeel

      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

      P Offline
      P Offline
      PengFeidu
      wrote on last edited by
      #2

      Maybe you didnot register on others' computer dupengfei

      1 Reply Last reply
      0
      • N nofeel

        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

        L Offline
        L Offline
        Lim Bio Liong
        wrote on last edited by
        #3

        Hello Ting Xu, What is the return value (HRESULT) from the ::CoCreateInstance() function ? Regards, Bio.

        1 Reply Last reply
        0
        • N nofeel

          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

          L Offline
          L Offline
          Lim Bio Liong
          wrote on last edited by
          #4

          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.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups