tlbexp command

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?Utf-8?B?R2Vvcmdl?=

    tlbexp command

    Hello everyone,


    I find that we can use tlbexp command like *tlbexp <dll name>* to export tlb
    file for a C# COM assembly, but can not use it to export tlb file for an
    unmanaged C++ COM DLL. Is that correct?

    I am wondering how to export tlb file of an unmanaged C++ COM DLL?


    thanks in advance,
    George
  • Brian Muth

    #2
    Re: tlbexp command


    "George" <George@discuss ions.microsoft. comwrote in message news:B334F3B5-E321-4580-BD7E-7C7F4D3A9013@mi crosoft.com...
    Hello everyone,
    >
    >
    I find that we can use tlbexp command like *tlbexp <dll name>* to export tlb
    file for a C# COM assembly, but can not use it to export tlb file for an
    unmanaged C++ COM DLL. Is that correct?
    Correct.
    >
    I am wondering how to export tlb file of an unmanaged C++ COM DLL?
    Not all COM DLL's have a type library. If one exists, it might be a separate file or it may be embedded as a resource. You can find
    out by using Oleview. Click on "File", "View Typelib..." and opening the DLL.

    Brian


    Comment

    • =?Utf-8?B?R2Vvcmdl?=

      #3
      Re: tlbexp command

      Thanks Brian,


      When using OLEView to open the native unmanaged COM DLL, there is an error
      message.

      LoadTypeLib (c:\temp\foo.dl l) failed.

      Error loading type library/DLL.

      TYPE_E_CANTLOAD LIBRARY ($80029C4A)

      Do you know what is wrong?


      regards,
      George

      "Brian Muth" wrote:
      >
      "George" <George@discuss ions.microsoft. comwrote in message news:B334F3B5-E321-4580-BD7E-7C7F4D3A9013@mi crosoft.com...
      Hello everyone,


      I find that we can use tlbexp command like *tlbexp <dll name>* to export tlb
      file for a C# COM assembly, but can not use it to export tlb file for an
      unmanaged C++ COM DLL. Is that correct?
      >
      Correct.
      >

      I am wondering how to export tlb file of an unmanaged C++ COM DLL?
      >
      Not all COM DLL's have a type library. If one exists, it might be a separate file or it may be embedded as a resource. You can find
      out by using Oleview. Click on "File", "View Typelib..." and opening the DLL.
      >
      Brian
      >
      >
      >

      Comment

      • Ben Voigt [C++ MVP]

        #4
        Re: tlbexp command


        "George" <George@discuss ions.microsoft. comwrote in message
        news:7D44BE94-6CB1-4A7B-8DDF-1BFBECD8175F@mi crosoft.com...
        Thanks Brian,
        >
        >
        When using OLEView to open the native unmanaged COM DLL, there is an error
        message.
        >
        LoadTypeLib (c:\temp\foo.dl l) failed.
        >
        Error loading type library/DLL.
        >
        TYPE_E_CANTLOAD LIBRARY ($80029C4A)
        >
        Do you know what is wrong?
        Looks like the type library is not embedded in the DLL. To verify, open the
        DLL in Visual Studio's resource editor, if there are any type libraries they
        will show up as custom resources of class "TYPELIB".

        >
        >
        regards,
        George
        >
        "Brian Muth" wrote:
        >
        >>
        >"George" <George@discuss ions.microsoft. comwrote in message
        >news:B334F3B 5-E321-4580-BD7E-7C7F4D3A9013@mi crosoft.com...
        Hello everyone,
        >
        >
        I find that we can use tlbexp command like *tlbexp <dll name>* to
        export tlb
        file for a C# COM assembly, but can not use it to export tlb file for
        an
        unmanaged C++ COM DLL. Is that correct?
        >>
        >Correct.
        >>
        >
        I am wondering how to export tlb file of an unmanaged C++ COM DLL?
        >>
        >Not all COM DLL's have a type library. If one exists, it might be a
        >separate file or it may be embedded as a resource. You can find
        >out by using Oleview. Click on "File", "View Typelib..." and opening the
        >DLL.
        >>
        >Brian
        >>
        >>
        >>

        Comment

        • =?Utf-8?B?R2Vvcmdl?=

          #5
          Re: tlbexp command

          Thanks Ben,


          I have followed your approach and I think there is no typelib embedded in
          the DLL. I am not using ATL and MFC, and developing unmanaged native C++ COM
          DLL from scratch.

          In my situation, how to generate type library? I am using Visual Studio 2005.


          regards,
          George

          "Ben Voigt [C++ MVP]" wrote:
          >
          "George" <George@discuss ions.microsoft. comwrote in message
          news:7D44BE94-6CB1-4A7B-8DDF-1BFBECD8175F@mi crosoft.com...
          Thanks Brian,


          When using OLEView to open the native unmanaged COM DLL, there is an error
          message.

          LoadTypeLib (c:\temp\foo.dl l) failed.

          Error loading type library/DLL.

          TYPE_E_CANTLOAD LIBRARY ($80029C4A)

          Do you know what is wrong?
          >
          Looks like the type library is not embedded in the DLL. To verify, open the
          DLL in Visual Studio's resource editor, if there are any type libraries they
          will show up as custom resources of class "TYPELIB".
          >
          >


          regards,
          George

          "Brian Muth" wrote:
          >
          "George" <George@discuss ions.microsoft. comwrote in message
          news:B334F3B5-E321-4580-BD7E-7C7F4D3A9013@mi crosoft.com...
          Hello everyone,


          I find that we can use tlbexp command like *tlbexp <dll name>* to
          export tlb
          file for a C# COM assembly, but can not use it to export tlb file for
          an
          unmanaged C++ COM DLL. Is that correct?
          >
          Correct.
          >

          I am wondering how to export tlb file of an unmanaged C++ COM DLL?
          >
          Not all COM DLL's have a type library. If one exists, it might be a
          separate file or it may be embedded as a resource. You can find
          out by using Oleview. Click on "File", "View Typelib..." and opening the
          DLL.
          >
          Brian
          >
          >
          >
          >
          >
          >

          Comment

          • Carl Daniel [VC++ MVP]

            #6
            Re: tlbexp command

            George wrote:
            Thanks Ben,
            >
            >
            I have followed your approach and I think there is no typelib
            embedded in the DLL. I am not using ATL and MFC, and developing
            unmanaged native C++ COM DLL from scratch.
            >
            In my situation, how to generate type library? I am using Visual
            Studio 2005.
            You have to build a type library using the MIDL compiler. You can then
            embed that type library as a resource, or keep it as a separate file.

            -cd


            Comment

            • SvenC

              #7
              Re: tlbexp command

              Hi George,
              I have followed your approach and I think there is no typelib embedded in
              the DLL. I am not using ATL and MFC, and developing unmanaged native C++
              COM
              DLL from scratch.
              Do you use an idl file to specify your library, coclasses and interfaces?
              If yes, that idl must be compiled with midl.exe which will create the type
              library.
              In my situation, how to generate type library? I am using Visual Studio
              2005.
              If you are using Visual Studio, why don't you use ATL and its wizards for
              creating COM objects?

              --
              SvenC

              Comment

              • =?Utf-8?B?R2Vvcmdl?=

                #8
                Re: tlbexp command

                Thanks cd,


                I think I should use MIDL compiler and use the COM DLL as input to generate
                type lib, right?

                Do you have any reference materials about how to use MIDL compiler to
                generate type lib and embedded it into COM DLL?


                regards,
                George

                "Carl Daniel [VC++ MVP]" wrote:
                George wrote:
                Thanks Ben,


                I have followed your approach and I think there is no typelib
                embedded in the DLL. I am not using ATL and MFC, and developing
                unmanaged native C++ COM DLL from scratch.

                In my situation, how to generate type library? I am using Visual
                Studio 2005.
                >
                You have to build a type library using the MIDL compiler. You can then
                embed that type library as a resource, or keep it as a separate file.
                >
                -cd
                >
                >
                >

                Comment

                • =?Utf-8?B?R2Vvcmdl?=

                  #9
                  Re: tlbexp command

                  Thanks SvenC,


                  I am using Visual Studio 2005 and I can not find any idl file in the project
                  directory. Could you let me know how to generate type lib through MIDL
                  compiler please?

                  BTW: for some legacy reasons to maintain some code, I can not use ATL or MFC.


                  regards,
                  George

                  "SvenC" wrote:
                  Hi George,
                  >
                  I have followed your approach and I think there is no typelib embedded in
                  the DLL. I am not using ATL and MFC, and developing unmanaged native C++
                  COM
                  DLL from scratch.
                  >
                  Do you use an idl file to specify your library, coclasses and interfaces?
                  If yes, that idl must be compiled with midl.exe which will create the type
                  library.
                  >
                  In my situation, how to generate type library? I am using Visual Studio
                  2005.
                  >
                  If you are using Visual Studio, why don't you use ATL and its wizards for
                  creating COM objects?
                  >
                  --
                  SvenC
                  >

                  Comment

                  • SvenC

                    #10
                    Re: tlbexp command

                    Hi George,
                    I am using Visual Studio 2005 and I can not find any idl file in the
                    project
                    directory. Could you let me know how to generate type lib through MIDL
                    compiler please?
                    >
                    BTW: for some legacy reasons to maintain some code, I can not use ATL or
                    MFC.
                    You could create an ATL test project which does create an idl and will also
                    create/configure the necessary midl compiler settings. That should help you
                    to build the necessary idl for your legacy project.

                    You will find information about IDL files and the midl compiler in the MSDN.

                    --
                    SvenC

                    Comment

                    • =?Utf-8?B?R2Vvcmdl?=

                      #11
                      Re: tlbexp command

                      Thanks SvenC,


                      I am a little confused. You mean I convert my current project into an ATL
                      project? Or using the new empty ATL project to build IDL for my current
                      project?

                      Could you provide more information about how to generate IDL for my current
                      project by using an ATL test project please?


                      regards,
                      George

                      "SvenC" wrote:
                      Hi George,
                      >
                      I am using Visual Studio 2005 and I can not find any idl file in the
                      project
                      directory. Could you let me know how to generate type lib through MIDL
                      compiler please?

                      BTW: for some legacy reasons to maintain some code, I can not use ATL or
                      MFC.
                      >
                      You could create an ATL test project which does create an idl and will also
                      create/configure the necessary midl compiler settings. That should help you
                      to build the necessary idl for your legacy project.
                      >
                      You will find information about IDL files and the midl compiler in the MSDN.
                      >
                      --
                      SvenC
                      >
                      >

                      Comment

                      • SvenC

                        #12
                        Re: tlbexp command

                        Hi George,
                        I am a little confused. You mean I convert my current project into an ATL
                        project? Or using the new empty ATL project to build IDL for my current
                        project?
                        The ATL project gives you an initial IDL file, just to see how a minimal IDL
                        file looks. You can also look at a wizard generated COM object where the
                        corresponding coclass and interface elements are add to that IDL file.
                        I think that such an idl file might help you to understand how to build your
                        own.

                        So: No, you don't need to convert your legacy project to an ATL project. It
                        might just help to figure out which parts of the IDL file and your COM
                        objects must match. Typically its the GUIDs of the library, the coclasses,
                        interfaces, dispinterfaces and dispids which you should find in your legacy
                        C++ project
                        Could you provide more information about how to generate IDL for my
                        current
                        project by using an ATL test project please?
                        Just use Project->Add new item and select "Visual C++ / Code / Midl file".
                        That adds the idl and sets up a midl compiler step. You will then have to
                        define your coclasses, interfaces and library in that idl file. Check your
                        test project how an idl file needs to be filled with content.

                        --
                        SvenC

                        Comment

                        • =?Utf-8?B?R2Vvcmdl?=

                          #13
                          Re: tlbexp command

                          Thanks SvenC,
                          Just use Project->Add new item and select "Visual C++ / Code / Midl file".
                          That adds the idl and sets up a midl compiler step. You will then have to
                          define your coclasses, interfaces and library in that idl file. Check your
                          test project how an idl file needs to be filled with content.
                          I think I can only use the functions you mentioned above in an ATL project,
                          right?

                          (e.g. in normal Visual C++ project which I used to create COM DLL, I can not
                          use this function)

                          For the reference IDL file generated automatically by ATL project, I find it
                          is useful, but I still need to manually write something. :-)

                          I have also researched that MIDL compiler could help to generate IDL file
                          automatically, right?


                          regards,
                          George

                          "SvenC" wrote:
                          Hi George,
                          >
                          I am a little confused. You mean I convert my current project into an ATL
                          project? Or using the new empty ATL project to build IDL for my current
                          project?
                          >
                          The ATL project gives you an initial IDL file, just to see how a minimal IDL
                          file looks. You can also look at a wizard generated COM object where the
                          corresponding coclass and interface elements are add to that IDL file.
                          I think that such an idl file might help you to understand how to build your
                          own.
                          >
                          So: No, you don't need to convert your legacy project to an ATL project. It
                          might just help to figure out which parts of the IDL file and your COM
                          objects must match. Typically its the GUIDs of the library, the coclasses,
                          interfaces, dispinterfaces and dispids which you should find in your legacy
                          C++ project
                          >
                          Could you provide more information about how to generate IDL for my
                          current
                          project by using an ATL test project please?
                          >
                          Just use Project->Add new item and select "Visual C++ / Code / Midl file".
                          That adds the idl and sets up a midl compiler step. You will then have to
                          define your coclasses, interfaces and library in that idl file. Check your
                          test project how an idl file needs to be filled with content.
                          >
                          --
                          SvenC
                          >

                          Comment

                          • SvenC

                            #14
                            Re: tlbexp command

                            Hi George
                            >Just use Project->Add new item and select "Visual C++ / Code / Midl
                            >file".
                            >That adds the idl and sets up a midl compiler step. You will then have to
                            >define your coclasses, interfaces and library in that idl file. Check
                            >your
                            >test project how an idl file needs to be filled with content.
                            >
                            I think I can only use the functions you mentioned above in an ATL
                            project,
                            right?
                            (e.g. in normal Visual C++ project which I used to create COM DLL, I can
                            not
                            use this function)
                            What is a normal Visual C++ project? Did you check if the Project->Add new
                            item menu is available? I would expect it to be.
                            For the reference IDL file generated automatically by ATL project, I find
                            it
                            is useful, but I still need to manually write something. :-)
                            Of course, if you have a project without ATL support you have no ATL
                            wizards, so you have to write code manually.
                            I have also researched that MIDL compiler could help to generate IDL file
                            automatically, right?
                            No, the midl compiler parses IDL files and produces a tlb file which is your
                            binary file representation of a type library.

                            --
                            SvenC

                            Comment

                            • =?Utf-8?B?R2Vvcmdl?=

                              #15
                              Re: tlbexp command

                              Thanks SvenC,


                              From your reply, I think I have to write IDL manually since I am not using
                              ATL. Could you refer some tutorial for me please?


                              regards,
                              George

                              "SvenC" wrote:
                              Hi George
                              Just use Project->Add new item and select "Visual C++ / Code / Midl
                              file".
                              That adds the idl and sets up a midl compiler step. You will then have to
                              define your coclasses, interfaces and library in that idl file. Check
                              your
                              test project how an idl file needs to be filled with content.
                              I think I can only use the functions you mentioned above in an ATL
                              project,
                              right?
                              (e.g. in normal Visual C++ project which I used to create COM DLL, I can
                              not
                              use this function)
                              >
                              What is a normal Visual C++ project? Did you check if the Project->Add new
                              item menu is available? I would expect it to be.
                              >
                              For the reference IDL file generated automatically by ATL project, I find
                              it
                              is useful, but I still need to manually write something. :-)
                              >
                              Of course, if you have a project without ATL support you have no ATL
                              wizards, so you have to write code manually.
                              >
                              I have also researched that MIDL compiler could help to generate IDL file
                              automatically, right?
                              >
                              No, the midl compiler parses IDL files and produces a tlb file which is your
                              binary file representation of a type library.
                              >
                              --
                              SvenC
                              >

                              Comment

                              Working...