Click here to Skip to main content
13,457,433 members
Click here to Skip to main content
Add your own
alternative version


46 bookmarked
Posted 2 Apr 2002

How to find the name for interfaces implemented by a COM object

, 2 Apr 2002
Rate this:
Please Sign up or sign in to vote.
The article descibes how can you find the interfaces implemented by a COM object


This is a class that helps you to find the interfaces implemented by a COM object. Here's how you can use that MsgBox method

QI::MsgBox( yourCOMObject ); 

Code Listing

#include <atlbase.h>
#include <string>
#include <sstream>
class QI : protected CRegKey,
#ifdef _UNICODE
    public std::wstringstream
    public std::stringstream
    virtual tstring Query( IUnknown* pUnk )
        if ( pUnk != NULL && ( ERROR_SUCCESS == 
            Open( HKEY_CLASSES_ROOT, _T("Interface") ) ) )
            TCHAR szKeyName[1024] = _T("");
            for ( int i = 0; ERROR_SUCCESS == 
                RegEnumKey( m_hKey, i, szKeyName, 1024 ); i++ )
                CLSID clsID = CLSID_NULL;
                if ( SUCCEEDED( CLSIDFromString( T2OLE(szKeyName), 
                    &clsID ) ) )
                    CComPtr<IUnknown> spObject = NULL;
                    if ( SUCCEEDED( pUnk->QueryInterface( clsID, 
                        (void**)&spObject ) ) )
                        TCHAR szValue[1024] = _T(""); 
                        LONG ncbValue = 1024;
                        if ( ERROR_SUCCESS == RegQueryValue( m_hKey, 
                            szKeyName, szValue, &ncbValue ) )
                            *this << tstring(szValue) + _T("\r\n");
        return str();

    static void MsgBox( IUnknown* pUnk )
        QI objQI;
        MessageBox( NULL, objQI.Query( pUnk ).c_str(),
            _T("The object implements:"), MB_ICONINFORMATION );


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

Web Developer
Romania Romania
No Biography provided

You may also be interested in...


Comments and Discussions

GeneralMy vote of 1 Pin
tha_specializt10-Jan-14 12:55
membertha_specializt10-Jan-14 12:55 
GeneralExcellent Utility - Small and Cute Pin
Sharjith2-Apr-09 18:52
memberSharjith2-Apr-09 18:52 
GeneralCan't query clsid's Pin
René Greiner8-Apr-02 3:42
memberRené Greiner8-Apr-02 3:42 
GeneralRe: Can't query clsid's Pin
Mikelangelo8-Apr-02 8:21
memberMikelangelo8-Apr-02 8:21 
GeneralRe: Can't query clsid's Pin
René Greiner9-Apr-02 23:39
memberRené Greiner9-Apr-02 23:39 
GeneralRe: Can't query clsid's Pin
Mikelangelo9-Apr-02 23:44
memberMikelangelo9-Apr-02 23:44 
GeneralRe: Can't query clsid's Pin
Mikelangelo9-Apr-02 23:51
memberMikelangelo9-Apr-02 23:51 
GeneralRe: Can't query clsid's Pin
René Greiner10-Apr-02 0:01
memberRené Greiner10-Apr-02 0:01 

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.180322.1 | Last Updated 3 Apr 2002
Article Copyright 2002 by Mikelangelo
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid