簡體   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