Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. COM
  4. Get ProgID or CLSID if i have only pointer to some IDispatch interface

Get ProgID or CLSID if i have only pointer to some IDispatch interface

Scheduled Pinned Locked Moved COM
helptutorialquestionannouncement
11 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I IWannaTalk

    How i can get ProgID or CLSID if i have only pointer to some IDispatch interface. For example: CComPtr< ISome > spSome; I was trying to do the next: CComPtr spTypeInfo; hr = m_spSome->GetTypeInfo( 100, LOCALE_SYSTEM_DEFAULT, &spTypeInfo ); if( FAILED( hr = PrepareFuncInfo() ) ) { return hr; } TYPEATTR *pattr = NULL; hr = spTypeInfo->GetTypeAttr( &pattr ); if( FAILED( hr = PrepareFuncInfo() ) ) { spTypeInfo.Release(); return hr; } CComPtr spTypeInfo2; HREFTYPE hrType = 0; while( SUCCEEDED( hr = spTypeInfo->GetRefTypeInfo( hrType, &spTypeInfo2 ) ) ) { TYPEATTR *pattr2 = NULL; hr = spTypeInfo2->GetTypeAttr( &pattr2 ); if( FAILED( hr = PrepareFuncInfo() ) ) { spTypeInfo2.Release(); spTypeInfo.Release(); return hr; } if( pattr2->typekind == TKIND_COCLASS ) { BSTR bsCLSID; ProgIDFromCLSID( pattr2->guid, &bsCLSID ); m_bsProgIDName = bsCLSID; spTypeInfo2.Release(); spTypeInfo.Release(); return S_OK; } hrType++; } But it doesn't work in variant, when i have in type lib more then 1 coclass :) I can to do this using type lib, but i want to find another way for solving this problem. If it's exists - please tell? how i can to do this :) Because i so tired with this...... :)

    ISQ 469907496

    M Offline
    M Offline
    Mike Dimmick
    wrote on last edited by
    #2

    Use QueryInterface to discover whether the class implements IProvideClassInfo. From there you can discover the type information of the class.


    DoEvents: Generating unexpected recursion since 1991

    I 1 Reply Last reply
    0
    • M Mike Dimmick

      Use QueryInterface to discover whether the class implements IProvideClassInfo. From there you can discover the type information of the class.


      DoEvents: Generating unexpected recursion since 1991

      I Offline
      I Offline
      IWannaTalk
      wrote on last edited by
      #3

      Thanks, but not all objects implement this interface. I need reliable method wich will be suitable for all objects!

      ISQ 469907496

      CPalliniC L 2 Replies Last reply
      0
      • I IWannaTalk

        Thanks, but not all objects implement this interface. I need reliable method wich will be suitable for all objects!

        ISQ 469907496

        CPalliniC Offline
        CPalliniC Offline
        CPallini
        wrote on last edited by
        #4

        vippavlo wrote:

        Thanks, but not all objects implement this interface. I need reliable method wich will be suitable for all objects!

        You cannot do that! :)

        If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.

        In testa che avete, signor di Ceprano?

        1 Reply Last reply
        0
        • I IWannaTalk

          Thanks, but not all objects implement this interface. I need reliable method wich will be suitable for all objects!

          ISQ 469907496

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #5

          Why do you need this functionality? If you can share the problem you are trying to solve, folks here can possibly tell you a better solution.

          Sohail

          I 1 Reply Last reply
          0
          • L Lost User

            Why do you need this functionality? If you can share the problem you are trying to solve, folks here can possibly tell you a better solution.

            Sohail

            I Offline
            I Offline
            IWannaTalk
            wrote on last edited by
            #6

            it's very long story... :) i want to save progID in XMLDOM attribute when i have only pointer to interface and than create object using this progid from XMLDOM file.

            ISQ 469907496

            L 1 Reply Last reply
            0
            • I IWannaTalk

              it's very long story... :) i want to save progID in XMLDOM attribute when i have only pointer to interface and than create object using this progid from XMLDOM file.

              ISQ 469907496

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #7

              vippavlo wrote:

              it's very long story...

              I'll leave it for tomorrow, heading home in few minutes :)

              vippavlo wrote:

              i want to save progID in XMLDOM attribute when i have only pointer to interface and than create object using this progid from XMLDOM file.

              What about COM DLLs that support only DispInterface? Is this so called pointer passed to you by external application or it's created in your own application?

              Sohail

              I 1 Reply Last reply
              0
              • L Lost User

                vippavlo wrote:

                it's very long story...

                I'll leave it for tomorrow, heading home in few minutes :)

                vippavlo wrote:

                i want to save progID in XMLDOM attribute when i have only pointer to interface and than create object using this progid from XMLDOM file.

                What about COM DLLs that support only DispInterface? Is this so called pointer passed to you by external application or it's created in your own application?

                Sohail

                I Offline
                I Offline
                IWannaTalk
                wrote on last edited by
                #8

                /*What about COM DLLs that support only DispInterface? */ What you mean??

                ISQ 469907496

                L 1 Reply Last reply
                0
                • I IWannaTalk

                  /*What about COM DLLs that support only DispInterface? */ What you mean??

                  ISQ 469907496

                  L Offline
                  L Offline
                  Lost User
                  wrote on last edited by
                  #9

                  Sorry, just went off track :) I was talking about Dispatch Interfaces as in http://www.microsoft.com/msj/0898/idl/idl.aspx[^]

                  Sohail

                  I 1 Reply Last reply
                  0
                  • L Lost User

                    Sorry, just went off track :) I was talking about Dispatch Interfaces as in http://www.microsoft.com/msj/0898/idl/idl.aspx[^]

                    Sohail

                    I Offline
                    I Offline
                    IWannaTalk
                    wrote on last edited by
                    #10

                    It's you sorry me, maybe i said somthing wrong? because i dont know english perfect - my grammar is bad :) I'm know perfect what is mean "IDispatch" :)))) I don't understand your question, what you whant to tolk with this words about DDL's - what's problem with DDL's?????? I was not read you last sentence :) sory :) .... It's a component for SDK - it save program settings to XML file and one of parameters can to be an interface and i put into XML properties of this object and want to put ProgID for in future create object using this ProgID. Now i have this code and it work without some p'roblems, but if some other compiler, VisualBasic for example, generate type lib with another way.... it will not be working..... Where m_spObj - its smart pointer CCOmPtr, for example... :) CComPtr spTypeInfo; UINT uiCount = 0; GUID guidOfInterface; hr = m_spObj->GetTypeInfo( 100, LOCALE_SYSTEM_DEFAULT, &spTypeInfo ); TYPEATTR *pattr1 = NULL; hr = spTypeInfo->GetTypeAttr( &pattr1 ); guidOfInterface = pattr1->guid; CComPtr< ITypeLib > spTypeLib; hr = spTypeInfo->GetContainingTypeLib( &spTypeLib, &uiCount ); uiCount = spTypeLib->GetTypeInfoCount(); CLSID clsidOfCoclass; for( UINT i = 0; i < uiCount; i++ ) { CComPtr< ITypeInfo > spTI; hr = spTypeLib->GetTypeInfo( i, &spTI ); TYPEATTR *pattr = NULL; hr = spTI->GetTypeAttr( &pattr ); if( pattr->typekind == TKIND_COCLASS ) { clsidOfCoclass = pattr->guid; } if( pattr->typekind == TKIND_DISPATCH ) { if( guidOfInterface == pattr->guid ) { CComBSTR bsCLSID; ProgIDFromCLSID( clsidOfCoclass, &bsCLSID ); m_bsProgIDName = bsCLSID.Detach(); spTI.Release(); spTypeLib.Release(); spTypeInfo.Release(); return S_OK; } } spTI.Release(); } spTypeLib.Release(); spTypeInfo.Release(); return hr;

                    ISQ 469907496

                    N 1 Reply Last reply
                    0
                    • I IWannaTalk

                      It's you sorry me, maybe i said somthing wrong? because i dont know english perfect - my grammar is bad :) I'm know perfect what is mean "IDispatch" :)))) I don't understand your question, what you whant to tolk with this words about DDL's - what's problem with DDL's?????? I was not read you last sentence :) sory :) .... It's a component for SDK - it save program settings to XML file and one of parameters can to be an interface and i put into XML properties of this object and want to put ProgID for in future create object using this ProgID. Now i have this code and it work without some p'roblems, but if some other compiler, VisualBasic for example, generate type lib with another way.... it will not be working..... Where m_spObj - its smart pointer CCOmPtr, for example... :) CComPtr spTypeInfo; UINT uiCount = 0; GUID guidOfInterface; hr = m_spObj->GetTypeInfo( 100, LOCALE_SYSTEM_DEFAULT, &spTypeInfo ); TYPEATTR *pattr1 = NULL; hr = spTypeInfo->GetTypeAttr( &pattr1 ); guidOfInterface = pattr1->guid; CComPtr< ITypeLib > spTypeLib; hr = spTypeInfo->GetContainingTypeLib( &spTypeLib, &uiCount ); uiCount = spTypeLib->GetTypeInfoCount(); CLSID clsidOfCoclass; for( UINT i = 0; i < uiCount; i++ ) { CComPtr< ITypeInfo > spTI; hr = spTypeLib->GetTypeInfo( i, &spTI ); TYPEATTR *pattr = NULL; hr = spTI->GetTypeAttr( &pattr ); if( pattr->typekind == TKIND_COCLASS ) { clsidOfCoclass = pattr->guid; } if( pattr->typekind == TKIND_DISPATCH ) { if( guidOfInterface == pattr->guid ) { CComBSTR bsCLSID; ProgIDFromCLSID( clsidOfCoclass, &bsCLSID ); m_bsProgIDName = bsCLSID.Detach(); spTI.Release(); spTypeLib.Release(); spTypeInfo.Release(); return S_OK; } } spTI.Release(); } spTypeLib.Release(); spTypeInfo.Release(); return hr;

                      ISQ 469907496

                      N Offline
                      N Offline
                      Nathan Holt at EMOM
                      wrote on last edited by
                      #11

                      vippavlo wrote:

                      It's a component for SDK - it save program settings to XML file and one of parameters can to be an interface and i put into XML properties of this object and want to put ProgID for in future create object using this ProgID. Now i have this code and it work without some p'roblems, but if some other compiler, VisualBasic for example, generate type lib with another way.... it will not be working.....

                      I think you should be allowed to insist that such objects support an appropriate IPersist interface. I recall that the plain IPersist interface has just one method which returns the class ID. The reason that you can't use the type info for this is because there can be any number of COCLASSes in the type library that implement the interface. There is no provision for doing what you want in that case. Nathan

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups