Click here to Skip to main content
13,048,805 members (87,884 online)
Click here to Skip to main content
Add your own
alternative version


15 bookmarked
Posted 4 Oct 2001

COM Category ComboBox

, 4 Oct 2001
Rate this:
Please Sign up or sign in to vote.
A ComboBox listing all COM objects from specified COM Category

Sample Image


I like the idea of programming by components. After reading on the topic of COM Categories I started to thing about a possible way to make kind of plugins for my applications. The first idea came at home when I was thinking about my job. We do fingerprint identification and use multiple hardware to capture a fingerprint picture. So I generalized fingerprint scanners as hardware pieces that delivers fingerprint pictures. Then I built an interface that is generic to all scanners. This allow us now to choose the scanner we would like to use at run time.
You may get more information in the articles from Len Holgate: Writing extensible applications, Component Category Manager wrapper classes.


The ComboBox is built according to an CATID (UUID) representing the COM Category. It searches the registry all COM objects implementing that Category using ICatInformation. Then it add them in the list box of the ComboBox. It also sets the 32-bit value associated with the specified item in the combo box to be a CString's pointer containing the interface identifier (IID). This will permit to create the COM object according to user choice at runtime. To optimize the speed of displaying, the ComboBox search the registry only if a user click on the dropdown. It also cache in the registry the latest value selected for creation speed.


To use this WTL control, place a ComboBox on your dialog. Add a member variable to your dialog implementation file:

CCOMCategoriesComboBox m_catCombo;

In the OnInitDialog() event handler, add the following line:

LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)

    // Attach controls to members
    m_catCombo.SubclassWindow( GetDlgItem(IDC_COMBO_CAT) );


Add the following reflection macro to your main message map:


Use this to initialize the CCOMCategoriesComboBox in the dialog constructor:

CMainDlg() :
    m_catCombo( "{00021493-0000-0000-C000-000000000046}", // Internet Explorer Browser Band CATID
                CString(_T("SOFTWARE\\Tech Head\\COMCategoryComboBox")),
                CString(_T("IE Browser Band")) )

To get user's selected COM object, you have two solutions:

  1. Read the value written in the registry at HKLM\SOFTWARE\Tech Head\COMCategoryComboBox\IE Browser BandIID
  2. Use CComboBox::GetItemDataPtr to retrieves the application-supplied 32-bit value associated with the specified combo box item that is a pointer to a CString containing the interface identifier (IID).

Faced Problems

None (at the moment ;-).


Version 1.01 October 4, 2001
. Added comments to the source code.
. Updated the article on Tech Head web site.
. Submited the article to Codeproject web site.
Version 1.00 October 3, 2001
. Added the article on Tech Head web site.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Laurent Kempé
France France

Laurent Kempé is the editor, founder, and primary contributor of Tech Head Brothers, a French portal about Microsoft .NET technologies.

He is currently employed by Innoveo Solutions since 10/2007 as a Senior Solution Architect and certified Scrum Master.

Founder, owner and Managing Partner of Jobping, which provides a unique and efficient platform for connecting Microsoft skilled job seekers with employers using Microsoft technologies.

Laurent is awarded by Microsoft since Avril 2002: Most Valuable Professional (MVP).

You may also be interested in...


Comments and Discussions

GeneralI want to Fingerprint source Pin
naraelim29-Feb-08 0:05
membernaraelim29-Feb-08 0:05 
GeneralFingerprint Pin
vutrunghieu9-Jun-05 0:59
membervutrunghieu9-Jun-05 0:59 
GeneralEdit Pin
Jiri Tesar10-Apr-02 4:29
memberJiri Tesar10-Apr-02 4:29 
GeneralRe: Edit Pin
Laurent Kempé10-Apr-02 7:23
memberLaurent Kempé10-Apr-02 7:23 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170713.1 | Last Updated 5 Oct 2001
Article Copyright 2001 by Laurent Kempé
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid