COM Objects

  • 18 years ago

    Hey,


    I need to know what interfaces the COM object can implement any ideas?


    Thanks

  • 18 years ago

    IDEA: Try this:


    Code:

    include <atlbase.h>


    include <string>


    include <sstream>


    class QI : protected CRegKey,

    ifdef _UNICODE


       public std::wstringstream

    else


       public std::stringstream

    endif


    {
    protected:
       virtual tstring Query( IUnknown* pUnk )
       {
           if ( pUnk != NULL && ( ERRORSUCCESS == Open( HKEYCLASSESROOT, _T("Interface") ) ) )
           {
               TCHAR szKeyName[1024] = _T("");
               for ( int i = 0; ERROR
    SUCCESS == RegEnumKey( mhKey, i, szKeyName, 1024 ); i++ )
               {
                   USES
    CONVERSION;
                   CLSID clsID = CLSIDNULL;
                   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");
                       }
                   }
               }
               Close();
           }
           return str();
       }


    public:
       static void MsgBox( IUnknown* pUnk )
       {
           QI objQI;
           MessageBox( NULL, objQI.Query( pUnk ).cstr(), _T("The object implements:"), MBICONINFORMATION );
       }
    };



    Hope that helps!

  • 18 years ago

    FAAAAAAAAARRROUT!


    That was quick!


    Thanks its what i need.

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Any fool can write code that a computer can understand. Good programmers write code that humans can understand.” - Martin Fowler