繁体   English   中英

如何列出所有已安装的ActiveX控件?

[英]How to list all installed ActiveX controls?

我需要显示一个ActiveX控件列表供用户选择。 它需要显示控件名称和描述。

如何在已安装的控件上查询Windows?

有没有办法区分控制与COM自动化服务器?

谷歌搜索“枚举activex控件”给出了这个作为第一个结果:

http://www.codeguru.com/cpp/com-tech/activex/controls/article.php/c5527/Listing-All-Registered-ActiveX-Controls.htm

虽然我想补充一点,你不需要在pCatInfo上调用AddRef() ,因为CoCreateInstance()会为你调用它。

我就是这样做的:

#include <cstdio>
#include <windows.h>
#include <comcat.h>

int main()
{
    // Initialize COM
    ::CoInitializeEx(NULL, COINIT_MULTITHREADED);
    // Obtain interface for enumeration
    ICatInformation* catInfo = NULL;
    HRESULT hr = ::CoCreateInstance(CLSID_StdComponentCategoriesMgr,
        NULL, CLSCTX_INPROC_SERVER, IID_ICatInformation, (void**)&catInfo);

    // Obtain an enumerator for classes in the CATID_Control category.
    IEnumGUID* enumGuid = NULL;
    CATID catidImpl = CATID_Control;
    CATID catidReqd = CATID_Control;
    catInfo->EnumClassesOfCategories(1, &catidImpl, 0, &catidReqd, &enumGuid);

    // Enumerate through the CLSIDs until there is no more.
    CLSID clsid;
    while((hr = enumGuid->Next(1, &clsid, NULL)) == S_OK)
    {
        BSTR name;
        // Obtain full name
        ::OleRegGetUserType(clsid, USERCLASSTYPE_FULL, &name);
        // Do something with the string
        printf("%S\n", name);
        // Release string.
        ::SysFreeString(name);
    }

    // Clean up.
    enumGuid->Release();
    catInfo->Release();
    ::CoUninitialize();
    return 0;
}

由于某种原因,另一个例子为我发布了seg故障。 这是我的抨击:

https://gist.github.com/810398

虽然那个C代码似乎并没有为我列举所有这些代码。 了解如何枚举WIN32OLE可用服务器? 我想是为了得到更多的答案。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM