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. Mixed COM Apartment models

Mixed COM Apartment models

Scheduled Pinned Locked Moved COM
helpcomannouncement
1 Posts 1 Posters 2 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.
  • C Offline
    C Offline
    Christian Skovdal Andersen
    wrote on last edited by
    #1

    Hi, I have the following problem. From within the same thread I wish to call two components with different threading models. Number one component will instantiate another component and receive events through connection points. This component will have to be Free-threaded or the call to ICOnnectionPoint::Advise() will fail. The other component should instantiate the IShellLink interface to create a shortcut. Take a look at this sample:

        // COINIT\_MULTITHREADED is neccesary because one component is free-threaded
    ::CoInitializeEx(NULL, COINIT\_MULTITHREADED);
    
    HRESULT hr = S\_OK;
    IMulti\* p1 = NULL;
    
    IShellLink \*psl=NULL;
    hr = ::CoCreateInstance(CLSID\_ShellLink, NULL, CLSCTX\_INPROC\_SERVER, IID\_IShellLink, (LPVOID\*) &psl);
    ASSERT(SUCCEEDED(hr));		
    
    hr = CoCreateInstance(CLSID\_Multi, NULL, CLSCTX\_INPROC\_SERVER, \_\_uuidof(IMulti), (void\*\*)&p1);
    ASSERT(SUCCEEDED(hr));		
    
    p1->Release();
    psl->Release();
    
    ::CoUninitialize();
    

    The problem is that the call to

    hr = ::CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, (LPVOID*) &psl)

    fails when CoInitializeEx has been called with the COINIT_MULTITHREADED parameter Any help will be greatly appreciated Christian Skovdal Andersen

    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