如何列出所有已安装的ActiveX控件? [英] How to list all installed ActiveX controls?

查看:262
本文介绍了如何列出所有已安装的ActiveX控件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I need to display a list of ActiveX controls for the user to choose. It needs to show the control name and description.

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

How do I query Windows on the installed controls?

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

Is there a way to differentiate controls from COM automation servers?

推荐答案

p> Googling forenumerate activex controls将此作为第一个结果:

Googling for "enumerate activex controls" give this as the first result:

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

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

Although I would add that you don't need to call AddRef() on pCatInfo since CoCreateInstance() calls that for you.

这是我该怎么做:

#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;
}

这篇关于如何列出所有已安装的ActiveX控件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆