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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. COM
  4. Help Me! Thank you very much!

Help Me! Thank you very much!

Scheduled Pinned Locked Moved COM
c++comhelptutorialjson
4 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.
  • B Offline
    B Offline
    Best Kiluyar
    wrote on last edited by
    #1

    Hi, friends I tried to build a dll which support COM self-regist using Visual C++ 6.0. I used a API, named LoadTypeLib, to load the dll's typelib: ... CComPtr pTypeLib; HRESULT result = LoadTypeLib(module,&pTypeLib); ... The variable "module" is the DLL's full path name. For example, I use "D:\\temp\\test\\test.dll". But, the return value "result" always is 0x80029c4a (TYPE_E_CANTLOADLIBRARY). If I use "D:\\temp\\test\\test.tlb" as the value of "module", this function should return 0x00000000(S_OK). I have import "test.tlb" into the resource of test.dll. So I don't know how to resolve this problem. Thanks a lot! smalldemon

    L 1 Reply Last reply
    0
    • B Best Kiluyar

      Hi, friends I tried to build a dll which support COM self-regist using Visual C++ 6.0. I used a API, named LoadTypeLib, to load the dll's typelib: ... CComPtr pTypeLib; HRESULT result = LoadTypeLib(module,&pTypeLib); ... The variable "module" is the DLL's full path name. For example, I use "D:\\temp\\test\\test.dll". But, the return value "result" always is 0x80029c4a (TYPE_E_CANTLOADLIBRARY). If I use "D:\\temp\\test\\test.tlb" as the value of "module", this function should return 0x00000000(S_OK). I have import "test.tlb" into the resource of test.dll. So I don't know how to resolve this problem. Thanks a lot! smalldemon

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

      Hello smallbluedemon, 1. Make sure that you have set the resource type to be "TYPELIB" and have also set the resource ID to be 1. 2. Try out the following function to load your resource-embedded type library binary : HRESULT MyLoadTypeLibrary(ITypeLib** ppITypeLibReceiver) { TCHAR szFileName[_MAX_PATH]; memset (szFileName, 0, sizeof(szFileName)); GetModuleFileName ( (HMODULE)NULL, (LPTSTR)szFileName, (DWORD)sizeof(szFileName) ); // Need to concatenate a \1 to the end of the filename // because we are acquiring the type library which is // embedded as the 1st resource of type TYPELIB. strcat (szFileName, "\\1"); return LoadTypeLib((const OLECHAR FAR*)_bstr_t(szFileName), ppITypeLibReceiver); } Use it in your code this way : int main(int argc, char* argv[]) { CComPtr pTypeLib; MyLoadTypeLibrary(&pTypeLib); return 0; } Pls let me know how things go :-) Best Regards, Bio.

      B 1 Reply Last reply
      0
      • L Lim Bio Liong

        Hello smallbluedemon, 1. Make sure that you have set the resource type to be "TYPELIB" and have also set the resource ID to be 1. 2. Try out the following function to load your resource-embedded type library binary : HRESULT MyLoadTypeLibrary(ITypeLib** ppITypeLibReceiver) { TCHAR szFileName[_MAX_PATH]; memset (szFileName, 0, sizeof(szFileName)); GetModuleFileName ( (HMODULE)NULL, (LPTSTR)szFileName, (DWORD)sizeof(szFileName) ); // Need to concatenate a \1 to the end of the filename // because we are acquiring the type library which is // embedded as the 1st resource of type TYPELIB. strcat (szFileName, "\\1"); return LoadTypeLib((const OLECHAR FAR*)_bstr_t(szFileName), ppITypeLibReceiver); } Use it in your code this way : int main(int argc, char* argv[]) { CComPtr pTypeLib; MyLoadTypeLibrary(&pTypeLib); return 0; } Pls let me know how things go :-) Best Regards, Bio.

        B Offline
        B Offline
        Best Kiluyar
        wrote on last edited by
        #3

        Hello, Bio. Thank you very much! By your suggestion, I found my mistakes. In my resource header file "resource.h", I set following macro: #define IDR_TYPELIB 199 But, I forgot to add this to file name. I add your statement: ........ GetModuleFileName(hInstance, ansiPath, MAX_PATH); strcat(ansiPath,"\\199"); MultiByteToWideChar(CP_ACP, 0, ansiPath, strlen(ansiPath) + 1,module, MAX_PATH); ....... Problem resolved ! Thank you again. Thank you very much! Your sincerely Remy (smallbluedemon)

        L 1 Reply Last reply
        0
        • B Best Kiluyar

          Hello, Bio. Thank you very much! By your suggestion, I found my mistakes. In my resource header file "resource.h", I set following macro: #define IDR_TYPELIB 199 But, I forgot to add this to file name. I add your statement: ........ GetModuleFileName(hInstance, ansiPath, MAX_PATH); strcat(ansiPath,"\\199"); MultiByteToWideChar(CP_ACP, 0, ansiPath, strlen(ansiPath) + 1,module, MAX_PATH); ....... Problem resolved ! Thank you again. Thank you very much! Your sincerely Remy (smallbluedemon)

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

          Hello Remy, That's great ! You are most welcome, Remy. Best Regards, Bio.

          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