Created
February 3, 2011 22:55
-
-
Save rdp/810398 to your computer and use it in GitHub Desktop.
enumerate all activex controls http://stackoverflow.com/questions/2755351/how-to-list-all-installed-activex-controls
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// enum.cpp : Defines the entry point for the console application. | |
// | |
#include "stdafx.h" | |
#include <cstdio> | |
#include <cstring> | |
#include <windows.h> | |
#include <comcat.h> | |
int _tmain(int argc, _TCHAR* argv[]) | |
{ | |
//Initialise COM libraries | |
CoInitialize (NULL); | |
//The Component Category Manager implemented by System implements | |
//this interface | |
ICatInformation *pCatInfo=NULL; | |
//Create an instance of standard Component Category Manager | |
HRESULT hr=CoCreateInstance (CLSID_StdComponentCategoriesMgr , | |
NULL, | |
CLSCTX_INPROC_SERVER, | |
IID_ICatInformation , | |
(void **)&pCatInfo); | |
//Increase ref count on interface | |
pCatInfo->AddRef (); | |
//IEnumGUID interface provides enumerator for enumerating through | |
//the collection of COM objects | |
IEnumGUID *pEnumGUID=NULL; | |
//We are intersted in finding out only controls so put CATID_Control | |
//in the array | |
CATID pcatidImpl[1]; | |
CATID pcatidReqd[1]; | |
pcatidImpl[0]=CATID_Control; | |
//Now enumerate the classes i.e. COM objects of this type. | |
pCatInfo->EnumClassesOfCategories (1, | |
pcatidImpl, | |
0, | |
pcatidReqd , | |
&pEnumGUID); | |
//Enumerate as long as you get S_OK | |
CLSID clsid; | |
while( (hr= pEnumGUID->Next( 1, &clsid, NULL ))==S_OK ) | |
{ | |
BSTR bstrClassName; //Get the information of class | |
//This is what MSDN says about the parameters | |
/*----------------------------------------------- | |
USERCLASSTYPE_FULL The full type name of the class. | |
USERCLASSTYPE_SHORT A short name (maximum of 15 characters) that | |
is used for popup menus and the Links dialog | |
box. | |
USERCLASSTYPE_APPNAME The name of the application servicing the class | |
and is used in the Result text in dialog boxes. | |
-----------------------------------------------*/ | |
OleRegGetUserType (clsid,USERCLASSTYPE_FULL,&bstrClassName); | |
printf("%S\n", bstrClassName); | |
//Add string in our listbox | |
} | |
//we are done so now release the interface ptr | |
pCatInfo->Release (); | |
CoUninitialize (); | |
} |
I'm not sure if this actually lists them all, but you should be able to run it as an exe
It lists the one I need when I run it as an EXE. My end goal is to uninstall the activex control via Powershell.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
That is really useful. Now if I can figure out how to do that from powershell.