• COM线程模型调试


    场景:com.dll 没有声明其套件类型:

    1. CoInitialize(0);

    CoInitializeEx(0, COINIT_APARTMENTTHREADED);

    只有一个线程:

     

    2. CoInitializeEx(0, COINIT_MULTITHREADED);

    进入套件前,只有主线程。

    CoInitializeEx(0, COINIT_MULTITHREADED); 调用之后线程没有增加。

     

    CoCreateInstance(CLSID_CBClassFactory, NULL, CLSCTX_INPROC_SERVER, IID_IY, (void**)&piy);

    这条语句执行之后,线程数增加。增加了5个。调用失败了。

    ---------------------------------------------------

    客户套件类型            组件套件类型         是否成功        线程数

    COINIT_APARTMENTTHREADED 没有声明            调用成功     1

    COINIT_MULTITHREADED 没有声明            调用失败     6

    COINIT_MULTITHREADED Apartment            调用失败     6

    COINIT_MULTITHREADED Free             调用成功     1

    COINIT_MULTITHREADED Both             调用成功     1

    COINIT_APARTMENTTHREADED Both            调用成功     1

    COINIT_APARTMENTTHREADED Free            调用失败     7

    COINIT_APARTMENTTHREADED Apartment            调用成功     1

    可以看到上面有3中类型的调用失败了,其失败的原因是:

    客户套件和组件线程模型不兼容,所以调用失败

  • 相关阅读:
    poj2386 Lake Counting
    poj 1852 Ants
    Luogu P2419 [USACO08JAN]牛大赛Cow Contest
    Luogu P2336 [SCOI2012]喵星球上的点名
    Luogu P2463 [SDOI2008]Sandy的卡片
    Luogu P2852 [USACO06DEC]牛奶模式Milk Patterns
    Luogu P4248 [AHOI2013]差异
    【NOI2008】志愿者招募
    Luogu P2743 [USACO5.1]乐曲主题Musical Themes
    P3723 [AH2017/HNOI2017]礼物
  • 原文地址:https://www.cnblogs.com/a-ray-of-sunshine/p/4658691.html
Copyright © 2020-2023  润新知