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

时间:2010-05-02 22:58:29

标签: c++ windows winapi

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

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

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

2 个答案:

答案 0 :(得分:3)

谷歌搜索“枚举activex控件”将此作为第一个结果:

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

虽然我想补充一点,因为AddRef()会为您调用pCatInfo,因此您无需在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; }

我就是这样做的:

{{1}}

答案 1 :(得分:1)

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

https://gist.github.com/810398

虽然C代码似乎并没有为我列举所有这些代码。 我想,请参阅how do you enumerate WIN32OLE available servers?了解更多答案。