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. ATL / WTL / STL
  4. How to remove type library informationn from atl dll?

How to remove type library informationn from atl dll?

Scheduled Pinned Locked Moved ATL / WTL / STL
questionc++comtutorial
12 Posts 2 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.
  • K Offline
    K Offline
    kcynic
    wrote on last edited by
    #1

    By default, type library information is compiled into my ATL dll project. While I do want the .tlb file, I don't want it compiled into the dll. How do I turn that off?

    L 1 Reply Last reply
    0
    • K kcynic

      By default, type library information is compiled into my ATL dll project. While I do want the .tlb file, I don't want it compiled into the dll. How do I turn that off?

      L Offline
      L Offline
      Lim Bio Liong
      wrote on last edited by
      #2

      Hello kcynic, The type library information is stored as a resource in your ATL-based COM executable (i.e. DLL or EXE). To remove it, open the resource script file for your ATL project (i.e. <project name>.rc). In your .rc file, look for a resource typed as "TYPELIB". It will usually be of the following form : 1 TYPELIB "<project name>.tlb" Simply comment out this line. By the way, besides removing type libs from your project's resource, you can also add more type libraries into your resource, e.g. : 2 TYPELIB "<some other type library>.tlb" In this case, you must either supply a full path to the new type library or indicate a path to it in the "Resources" section of your project settings. - Bio.

      K 2 Replies Last reply
      0
      • L Lim Bio Liong

        Hello kcynic, The type library information is stored as a resource in your ATL-based COM executable (i.e. DLL or EXE). To remove it, open the resource script file for your ATL project (i.e. <project name>.rc). In your .rc file, look for a resource typed as "TYPELIB". It will usually be of the following form : 1 TYPELIB "<project name>.tlb" Simply comment out this line. By the way, besides removing type libs from your project's resource, you can also add more type libraries into your resource, e.g. : 2 TYPELIB "<some other type library>.tlb" In this case, you must either supply a full path to the new type library or indicate a path to it in the "Resources" section of your project settings. - Bio.

        K Offline
        K Offline
        kcynic
        wrote on last edited by
        #3

        Thanks, i have tried successfully. And another question, in some of my code, i use another interface witch is provided by ms, the code looks like following: CComPtr pI; HRESULT hr = pI.CoCreateInstance(CLSID_SomeInterface); Here, if the code was used in my Atl dll project, i would got hr with E_NOINTERFACE error; but if i use that code in a normal project(Not atl com dll), hr will be S_OK. why?

        L 1 Reply Last reply
        0
        • K kcynic

          Thanks, i have tried successfully. And another question, in some of my code, i use another interface witch is provided by ms, the code looks like following: CComPtr pI; HRESULT hr = pI.CoCreateInstance(CLSID_SomeInterface); Here, if the code was used in my Atl dll project, i would got hr with E_NOINTERFACE error; but if i use that code in a normal project(Not atl com dll), hr will be S_OK. why?

          L Offline
          L Offline
          Lim Bio Liong
          wrote on last edited by
          #4

          >> And another question, in some of my code, i use another interface witch is provided by ms... Do you mean that in your ATL COM object class, you implement the MS interface ? E.g. : class ATL_NO_VTABLE CMyClass :    public ...    public ISomeMSInterface,    public ... Or do you mean that the actual code : >> CComPtr pI; >> HRESULT hr = pI.CoCreateInstance(CLSID_SomeInterface); is called in some function of your ATL COM object source codes ? E.g. : STDMETHODIMP CMyClass::SomeMethod() {    CComPtr pI;    HRESULT hr = pI.CoCreateInstance(CLSID_SomeInterface);    ... } - Bio.

          K 1 Reply Last reply
          0
          • L Lim Bio Liong

            >> And another question, in some of my code, i use another interface witch is provided by ms... Do you mean that in your ATL COM object class, you implement the MS interface ? E.g. : class ATL_NO_VTABLE CMyClass :    public ...    public ISomeMSInterface,    public ... Or do you mean that the actual code : >> CComPtr pI; >> HRESULT hr = pI.CoCreateInstance(CLSID_SomeInterface); is called in some function of your ATL COM object source codes ? E.g. : STDMETHODIMP CMyClass::SomeMethod() {    CComPtr pI;    HRESULT hr = pI.CoCreateInstance(CLSID_SomeInterface);    ... } - Bio.

            K Offline
            K Offline
            kcynic
            wrote on last edited by
            #5

            No. I really import the interface from the component. so i directly use that interface like that.

            L 1 Reply Last reply
            0
            • K kcynic

              No. I really import the interface from the component. so i directly use that interface like that.

              L Offline
              L Offline
              Lim Bio Liong
              wrote on last edited by
              #6

              To confirm, the creation of object of coclass CLSID_SomeInterface is actually called in some function of your ATL COM object source codes, e.g. : STDMETHODIMP CMyClass::SomeMethod() {    CComPtr pI;    HRESULT hr = pI.CoCreateInstance();    ... } - Bio.

              K 1 Reply Last reply
              0
              • L Lim Bio Liong

                To confirm, the creation of object of coclass CLSID_SomeInterface is actually called in some function of your ATL COM object source codes, e.g. : STDMETHODIMP CMyClass::SomeMethod() {    CComPtr pI;    HRESULT hr = pI.CoCreateInstance();    ... } - Bio.

                K Offline
                K Offline
                kcynic
                wrote on last edited by
                #7

                Yes. I packed this code in a static library as .lib. But, it's strangely that if i direct use the static library, the code will work well( CoCreateInstance returns S_OK). but, if i use the static library in my atl com object and i call that code via the com dll, the CoCreateInstance would returns E_NOINTERFACE.

                L 1 Reply Last reply
                0
                • K kcynic

                  Yes. I packed this code in a static library as .lib. But, it's strangely that if i direct use the static library, the code will work well( CoCreateInstance returns S_OK). but, if i use the static library in my atl com object and i call that code via the com dll, the CoCreateInstance would returns E_NOINTERFACE.

                  L Offline
                  L Offline
                  Lim Bio Liong
                  wrote on last edited by
                  #8

                  The use of a static library makes no difference as far as the creation of COM objects is concerned. Here's what I suggest : 1. Make sure that the correct interface ID is passed in. You'll have to check your source codes to be sure of this. 2. Make sure that the correct version of the target COM DLL is loaded. In debug run mode, use the VC++ "Modules" menu item. Best of luck, Bio.

                  K 1 Reply Last reply
                  0
                  • L Lim Bio Liong

                    The use of a static library makes no difference as far as the creation of COM objects is concerned. Here's what I suggest : 1. Make sure that the correct interface ID is passed in. You'll have to check your source codes to be sure of this. 2. Make sure that the correct version of the target COM DLL is loaded. In debug run mode, use the VC++ "Modules" menu item. Best of luck, Bio.

                    K Offline
                    K Offline
                    kcynic
                    wrote on last edited by
                    #9

                    Of course, they are OK. Although the problem still remains, but i think it should due to my own fault. Just take it easy. ;) Thanks

                    1 Reply Last reply
                    0
                    • L Lim Bio Liong

                      Hello kcynic, The type library information is stored as a resource in your ATL-based COM executable (i.e. DLL or EXE). To remove it, open the resource script file for your ATL project (i.e. <project name>.rc). In your .rc file, look for a resource typed as "TYPELIB". It will usually be of the following form : 1 TYPELIB "<project name>.tlb" Simply comment out this line. By the way, besides removing type libs from your project's resource, you can also add more type libraries into your resource, e.g. : 2 TYPELIB "<some other type library>.tlb" In this case, you must either supply a full path to the new type library or indicate a path to it in the "Resources" section of your project settings. - Bio.

                      K Offline
                      K Offline
                      kcynic
                      wrote on last edited by
                      #10

                      hi, Bio. I use this method to remove type library information from the dll file successfully. but the target dll(without type library) can't be register successfully without the .tlb file and returns "Error loading library/DLL"

                      L 1 Reply Last reply
                      0
                      • K kcynic

                        hi, Bio. I use this method to remove type library information from the dll file successfully. but the target dll(without type library) can't be register successfully without the .tlb file and returns "Error loading library/DLL"

                        L Offline
                        L Offline
                        Lim Bio Liong
                        wrote on last edited by
                        #11

                        Hello kcynic, If you want to remove the type library information from your COM DLL and yet be able to register your COM DLL, the you need to do some more tweaking in your DllRegisterServer() code. This function is generated for you by ATL and it generally looks like the following : STDAPI DllRegisterServer(void) {       // registers object, typelib and all interfaces in typelib       return _Module.RegisterServer(/*TRUE*/ FALSE); } Here, as suggested by my code above, comment out the TRUE value and insert in FALSE. The issue is that _Module.RegisterServer() will attempt to perform 2 things : 1. Writes information of the COM objects in your DLL into the registry. 2. Registers the type library (the *.tlb) file generated for you by the MIDL compiler into the registry. In order to do (2), the type library binary must be part of the resource of your DLL. Now, if you do not wish to register your type library, the FALSE value of the parameter to _Module.RegisterServer() will specifically not register your type library. - Bio.

                        K 1 Reply Last reply
                        0
                        • L Lim Bio Liong

                          Hello kcynic, If you want to remove the type library information from your COM DLL and yet be able to register your COM DLL, the you need to do some more tweaking in your DllRegisterServer() code. This function is generated for you by ATL and it generally looks like the following : STDAPI DllRegisterServer(void) {       // registers object, typelib and all interfaces in typelib       return _Module.RegisterServer(/*TRUE*/ FALSE); } Here, as suggested by my code above, comment out the TRUE value and insert in FALSE. The issue is that _Module.RegisterServer() will attempt to perform 2 things : 1. Writes information of the COM objects in your DLL into the registry. 2. Registers the type library (the *.tlb) file generated for you by the MIDL compiler into the registry. In order to do (2), the type library binary must be part of the resource of your DLL. Now, if you do not wish to register your type library, the FALSE value of the parameter to _Module.RegisterServer() will specifically not register your type library. - Bio.

                          K Offline
                          K Offline
                          kcynic
                          wrote on last edited by
                          #12

                          Cool. It really works. Before post this question, I only know atl only register the component's AppID and clsid, so it would not work if i remove the type library information from the resource. I want to write my own code to register the interfaces by hand before. Now, i know i only just modify a parameter in the existent code. Thanks very much. Regards.

                          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