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. how to use an interface belong to another library in idl file

how to use an interface belong to another library in idl file

Scheduled Pinned Locked Moved COM
helpcomtutorialquestion
4 Posts 3 Posters 12 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.
  • S Offline
    S Offline
    samfromcn
    wrote on last edited by
    #1

    I have an interface, I1 declared in library A, I use I1 in library B by writing code like ///////////////// begin ///////////////////// import "A.idl" [ object, uuid(...), ...... ] interface I2 : IDispatch{ [propget, id(1), helpstring("...")] HRESULT I1([out, retval] I1** prop); }; ///////////////// end /////////////////// Both project A and project B built all right. Now I import A.tlb and B.tlb in project C, and write following code ///////////////// begin ///////////////////// CComPtr < I1> spI1; ///////////////// end /////////////////// compil failed with message error C2872 : "I1" : ambiguous symbol . While what I hope is only one I1, but now there are two. How to resolve this problem?

    _ V 2 Replies Last reply
    0
    • S samfromcn

      I have an interface, I1 declared in library A, I use I1 in library B by writing code like ///////////////// begin ///////////////////// import "A.idl" [ object, uuid(...), ...... ] interface I2 : IDispatch{ [propget, id(1), helpstring("...")] HRESULT I1([out, retval] I1** prop); }; ///////////////// end /////////////////// Both project A and project B built all right. Now I import A.tlb and B.tlb in project C, and write following code ///////////////// begin ///////////////////// CComPtr < I1> spI1; ///////////////// end /////////////////// compil failed with message error C2872 : "I1" : ambiguous symbol . While what I hope is only one I1, but now there are two. How to resolve this problem?

      _ Offline
      _ Offline
      _Superman_
      wrote on last edited by
      #2

      Since you have import A.idl in B.idl, it would be enough to import only B.tlb.

      «_Superman_» I love work. It gives me something to do between weekends.

      S 1 Reply Last reply
      0
      • _ _Superman_

        Since you have import A.idl in B.idl, it would be enough to import only B.tlb.

        «_Superman_» I love work. It gives me something to do between weekends.

        S Offline
        S Offline
        samfromcn
        wrote on last edited by
        #3

        Is there any other way to use I1 in B.idl except import? ;P What I really wonder is how to build a software structure like MS Office. In Office, the _CommandBars is in mso.dll, WinWord.Application is in WinWord.EXE, when I import MSWORD.OLB I can find there is code like "virtual HRESULT __stdcall get_CommandBars ( /*[out,retval]*/ struct Office::_CommandBars * * prop ) = 0;" in msword.tlh. How it happens?!! In my projects, I import B.tlb, there is only "virtual HRESULT __stdcall get_I1 ( /*[out,retval]*/ struct I1 * * prop ) = 0;", while I am looking for "virtual HRESULT __stdcall get_I1 ( /*[out,retval]*/ struct A::I1 * * prop ) = 0;"

        modified on Saturday, September 26, 2009 11:36 PM

        1 Reply Last reply
        0
        • S samfromcn

          I have an interface, I1 declared in library A, I use I1 in library B by writing code like ///////////////// begin ///////////////////// import "A.idl" [ object, uuid(...), ...... ] interface I2 : IDispatch{ [propget, id(1), helpstring("...")] HRESULT I1([out, retval] I1** prop); }; ///////////////// end /////////////////// Both project A and project B built all right. Now I import A.tlb and B.tlb in project C, and write following code ///////////////// begin ///////////////////// CComPtr < I1> spI1; ///////////////// end /////////////////// compil failed with message error C2872 : "I1" : ambiguous symbol . While what I hope is only one I1, but now there are two. How to resolve this problem?

          V Offline
          V Offline
          Vi2
          wrote on last edited by
          #4

          You should use "importlib" in "library" section instead of "import" or in addition to "import".

          With best wishes, Vita

          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