Listing All Registered ActiveX Controls

Environment: Visual C++ 6.0.

Overview

This code is meant to illustrate how to use COM in order to retrieve a list of all the registered ActiveX controls in your system. The demo application (see screen shot above) displays the names of all located ActiveX controls in a listbox.

Source Code

//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);
 CString strControlName(bstrClassName);
 //Add string in our listbox
 m_list1.AddString (strControlName);
}          

//we are done so now release the interface ptr
pCatInfo->Release ();

CoUninitialize ();

The program first intialises the COM libraries. Then it creates an instance of standard component category manager

HRESULT hr=CoCreateInstance(CLSID_StdComponentCategoriesMgr,
                            NULL,
                            CLSCTX_INPROC_SERVER,
                            IID_ICatInformation,
                            (void **)&pCatInfo);

IcatInformation interface provides the information about COM classes and categories. IEnumGUID interface provides enumerator for iterating through the collection of COM classes. Then we enumerate the controls with a call to EnumClassesOfCategories.As we are interested in only controls We fill the array with CATID_Control.Next we enumerate through the collection ,get the class name And put it in the listbox.

Downloads

Download demo - 11 Kb


Comments

  • Great article.I was jst wondering whether the same thing would be possible in c#?

    Posted by shashank_v1 on 09/28/2005 07:28am

    Im doing a project in C# and i would like to know if i could list all the activeX controls on the system using C#.I donno if C# has all the inbuilt functionality that c++ has with regard to ActiveX and COM.

    Reply
  • Retreive the Control properties just by having the name

    Posted by Legacy on 09/15/2003 12:00am

    Originally posted by: Hajer

    Hi All,

    I created two activeX controls. the second references the name of the first control, i want to insert those controls in the same application form (VB for example), and i want that the second activex could search for the control correspoding for the name i references, then retreives all the matching properties.

    Best Regards.
    Thanks.

    Reply
  • list all the properties of a control.

    Posted by Legacy on 04/18/2003 12:00am

    Originally posted by: pathman

    This is very cool. Is it possible to list all the properties of a specific activeX control?

    Reply
  • How can I get other control's Iunknow interface point in the same container?

    Posted by Legacy on 09/17/2002 12:00am

    Originally posted by: peter

    How can I get other control's Iunknow interface point in the same container?

    Reply
  • Controls ok but dll's ?

    Posted by Legacy on 10/30/2001 12:00am

    Originally posted by: arkam

    Your code is great but how can i retrieve ALL the ActiveX registered on my computer (and not only controls) ?

    Thanks

    Reply
Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • Live Event Date: October 29, 2014 @ 11:00 a.m. ET / 8:00 a.m. PT Are you interested in building a cognitive application using the power of IBM Watson? Need a platform that provides speed and ease for rapidly deploying this application? Join Chris Madison, Watson Solution Architect, as he walks through the process of building a Watson powered application on IBM Bluemix. Chris will talk about the new Watson Services just released on IBM bluemix, but more importantly he will do a step by step cognitive …

  • Live Event Date: October 23, 2014 @ 12:00 p.m. ET / 9:00 a.m. PT Despite the current "virtualize everything" mentality, there are advantages to utilizing physical hardware for certain tasks. This is especially true for backups. In many cases, it is clearly in an organization's best interest to make use of physical, purpose-built backup appliances rather than relying on virtual backup software (VBA - Virtual Backup Appliances). Join us for this eSeminar to learn why physical appliances are preferable to …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds