Skip to content

Instantly share code, notes, and snippets.

@rdp
Created February 3, 2011 22:55
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save rdp/810398 to your computer and use it in GitHub Desktop.
Save rdp/810398 to your computer and use it in GitHub Desktop.
// 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 ();
}
@zippy1981
Copy link

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

@rdp
Copy link
Author

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

@zippy1981
Copy link

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