Click here to Skip to main content
15,892,059 members
Home / Discussions / COM
   

COM

 
GeneralRe: Querying WMI from inside WMI Provider Pin
Baltoro6-Jun-09 8:35
Baltoro6-Jun-09 8:35 
GeneralRe: Querying WMI from inside WMI Provider Pin
krishiyengar8-Jun-09 3:04
krishiyengar8-Jun-09 3:04 
GeneralRe: Querying WMI from inside WMI Provider Pin
krishiyengar8-Jun-09 6:02
krishiyengar8-Jun-09 6:02 
QuestionPROBLEM IN MDAC version2.6 Pin
RAJAGOPALMS762-Jun-09 0:08
RAJAGOPALMS762-Jun-09 0:08 
QuestionHow to get Defalut interface of CoClass Pin
vibindia1-Jun-09 23:55
vibindia1-Jun-09 23:55 
AnswerRe: How to get Defalut interface of CoClass Pin
«_Superman_»2-Jun-09 0:21
professional«_Superman_»2-Jun-09 0:21 
AnswerRe: How to get Defalut interface of CoClass Pin
vibindia2-Jun-09 0:37
vibindia2-Jun-09 0:37 
AnswerRe: How to get Defalut interface of CoClass [modified] Pin
Lim Bio Liong6-Jun-09 5:32
Lim Bio Liong6-Jun-09 5:32 
Hello vibindia,

Try out the following code :

int main()
{
   ITypeLib* pITypeLib = NULL;
   HRESULT   hrRet = S_OK;

   hrRet = LoadTypeLibEx
   (
      (LPCOLESTR)(L"C:\\WINDOWS\\system32\\FM20.DLL"),
      (ITypeLib**)&pITypeLib
   );

   if (pITypeLib)
   {
      ITypeInfo *pITypeInfo_Coclass = NULL;
      CLSID      clsid;

      CLSIDFromString
      (
         L"{8BD21D40-EC42-11CE-9E0D-00AA006002F3}",
         &clsid
      );
     
      pITypeLib -> GetTypeInfoOfGuid(clsid, &pITypeInfo_Coclass);

      if (pITypeInfo_Coclass)
      {
         TYPEATTR*     pTYPEATTR = NULL ;

         pITypeInfo_Coclass -> GetTypeAttr (&pTYPEATTR);

         // For each implemented interface in this coclass, get its name and determine if it is the default interface.
         int i ;
         for (i = 0 ; i < (pTYPEATTR->cImplTypes); i ++)
         {
            HREFTYPE hRefType = NULL;
    
            pITypeInfo_Coclass->GetRefTypeOfImplType (i, &hRefType);

            if (hRefType)
            {
        ITypeInfo*     pRefTypeInfo = NULL;
        BSTR          bstrName = NULL;

               pITypeInfo_Coclass->GetRefTypeInfo (hRefType, &pRefTypeInfo);

               if (pRefTypeInfo)
        {
                  pRefTypeInfo->GetDocumentation(MEMBERID_NIL, &bstrName, NULL, NULL, NULL);

           int iImplTypeFlags = 0;

                  pITypeInfo_Coclass->GetImplTypeFlags
           (
              i,
              &iImplTypeFlags
           );

                  if (iImplTypeFlags & IMPLTYPEFLAG_FDEFAULT)
           {
                     if (iImplTypeFlags & IMPLTYPEFLAG_FSOURCE)
              {
          printf ("[default, source] interface is [%s].\r\n", (LPCTSTR)_bstr_t(bstrName));
              }
              else
              {
          printf ("[default] interface is [%s].\r\n", (LPCTSTR)_bstr_t(bstrName));
              }
           }

           pRefTypeInfo->Release();
           pRefTypeInfo = NULL;
               }

               if (bstrName)
        {
           ::SysFreeString(bstrName);
           bstrName = NULL;
        }
            }
         }

         pITypeInfo_Coclass->ReleaseTypeAttr(pTYPEATTR);
         pTYPEATTR = NULL;

         pITypeInfo_Coclass->Release();
         pITypeInfo_Coclass = NULL;
      }

      pITypeLib->Release();
      pITypeLib = NULL;
   }

   return 0;
}


Note that there could be two default interfaces : one being the default incoming interface (i.e. [default]) and the other a default source interface (i.e. [default, source].

The important method to use is ITypeInfo::GetImplTypeFlags(). Call it on the ITypeInfo interface of the coclass that you are interested in e.g. :

pITypeInfo_Coclass->GetImplTypeFlags
(
   i,
   &iImplTypeFlags
);

This method will return a IMPLTYPEFLAGS. The code to obtain the default interface should be self-explanatory.

The calls to GetRefTypeOfImplType() and GetRefTypeInfo() are so that we can get the ITypeInfo interface on each of the interfaces of the coclass.



Best Regards,
Bio.

modified on Monday, June 8, 2009 12:08 AM

QuestionHow to customise the window xp print dialog. Pin
manjari kar30-May-09 1:23
manjari kar30-May-09 1:23 
QuestionDebugging WMI Providers Pin
krishiyengar28-May-09 7:26
krishiyengar28-May-09 7:26 
AnswerRe: Debugging WMI Providers Pin
Stuart Dootson28-May-09 8:08
professionalStuart Dootson28-May-09 8:08 
GeneralRe: Debugging WMI Providers Pin
krishiyengar29-May-09 2:10
krishiyengar29-May-09 2:10 
GeneralRe: Debugging WMI Providers Pin
Stuart Dootson29-May-09 2:12
professionalStuart Dootson29-May-09 2:12 
GeneralRe: Debugging WMI Providers Pin
krishiyengar29-May-09 2:49
krishiyengar29-May-09 2:49 
GeneralRe: Debugging WMI Providers Pin
Stuart Dootson29-May-09 2:53
professionalStuart Dootson29-May-09 2:53 
GeneralRe: Debugging WMI Providers Pin
krishiyengar29-May-09 3:03
krishiyengar29-May-09 3:03 
GeneralRe: Debugging WMI Providers Pin
Stuart Dootson29-May-09 3:18
professionalStuart Dootson29-May-09 3:18 
GeneralRe: Debugging WMI Providers Pin
krishiyengar29-May-09 3:31
krishiyengar29-May-09 3:31 
GeneralRe: Debugging WMI Providers Pin
Stuart Dootson29-May-09 3:43
professionalStuart Dootson29-May-09 3:43 
GeneralRe: Debugging WMI Providers Pin
krishiyengar29-May-09 3:54
krishiyengar29-May-09 3:54 
GeneralRe: Debugging WMI Providers Pin
krishiyengar29-May-09 4:46
krishiyengar29-May-09 4:46 
GeneralRe: Debugging WMI Providers Pin
krishiyengar29-May-09 5:34
krishiyengar29-May-09 5:34 
GeneralRe: Debugging WMI Providers Pin
Stuart Dootson29-May-09 6:10
professionalStuart Dootson29-May-09 6:10 
GeneralRe: Debugging WMI Providers Pin
krishiyengar29-May-09 6:31
krishiyengar29-May-09 6:31 
GeneralRe: Debugging WMI Providers Pin
krishiyengar29-May-09 6:36
krishiyengar29-May-09 6:36 

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.