Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
// 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 ,
IID_ICatInformation ,
(void **)&pCatInfo);
//Increase ref count on interface
pCatInfo->AddRef ();
//IEnumGUID interface provides enumerator for enumerating through
//the collection of COM objects
//We are intersted in finding out only controls so put CATID_Control
//in the array
CATID pcatidImpl[1];
CATID pcatidReqd[1];
//Now enumerate the classes i.e. COM objects of this type.
pCatInfo->EnumClassesOfCategories (1,
pcatidReqd ,
//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
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 ();

That is really useful. Now if I can figure out how to do that from powershell.


rdp commented May 11, 2011

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