CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8
  1. #1
    Join Date
    Nov 2001
    Posts
    11

    Error while executing Load library

    Im encounrering the error "specified module not found" error(ERROR_MOD_NOT_FOUND) while executing the load library function.
    how to proceed?


  2. #2
    Join Date
    Jul 2001
    Posts
    703

    Re: Error while executing Load library

    you must place your dll either in the path ur executing the exe or in the windows -> system folder for the LoadLibrary to function.



    VCVCVC
    "Dont Forget to rate if it helped"

  3. #3
    Join Date
    Nov 2001
    Posts
    11

    Re: Error while executing Load library

    DLL path is hardcoded and the DLL exists in the specified path. I have checked all other possibilities of path settings. At times this gives an error of "Specified procedure could not be found" instead of "Specified module could not found". Please provide me any other sugeestions.


  4. #4
    Join Date
    Jul 2001
    Posts
    703

    Re: Error while executing Load library

    HMODULE gLibMyDll = NULL;//Initialize this first in the starting of the file
    if (gLibMyDll != NULL)
    {
    MessageBox("Already Loaded");
    return;
    }
    gLibMyDll = :: LoadLibrary ("MyDll.dll");//your dll name

    if (gLibMyDll == NULL )
    {
    char msg[300];
    strcpy(msg,"cannot load dll");
    strcat(msg,"check dll");
    MessageBox(msg);
    }
    check out this handling whether ur able to load or not



    VCVCVC
    "Dont Forget to rate if it helped"

  5. #5
    Join Date
    Nov 2001
    Posts
    11

    Re: Error while executing Load library

    This is my code:
    HMODULE hMod = LoadLibrary(c:\\Docmgnt\\Docmgnt.dll"));
    LPVOID lpMessageBuffer;
    FormatMessage
    (FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
    NULL,
    GetLastError(),
    MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
    (LPTSTR) &lpMessageBuffer,
    0,
    NULL);
    char *err_msg = (char*)lpMessageBuffer;
    MessageBox(NULL,err_msg,"Message",MB_OK);
    LocalFree( lpMessageBuffer );

    DLL path is hardcoded


  6. #6
    Join Date
    Jul 2001
    Posts
    703

    Re: Error while executing Load library

    in the def file of the dll u might not have specified the function name.pls do that and compile and then load the dll.also check out with the _declspec(dllexport).



    VCVCVC
    "Dont Forget to rate if it helped"

  7. #7
    Join Date
    Nov 2001
    Posts
    11

    Re: Error while executing Load library

    This DLL works perfectly with applications developed in VC++ 5.0. When i compiled and linked the same DLL in VC++ 6.0 and and used with applications developed in VC++6.0, it gives me error. rather load llibrary returd null. i havent made any code changes, just i compiled and liked the dll in VC++60


  8. #8
    Join Date
    Jul 2001
    Posts
    703

    Re: Error while executing Load library

    These are all the possiblilites given in MSDN did u check with these.

    Windows 95/98/Me: If you are using LoadLibrary to load a module that contains a resource whose numeric identifier is greater than 0x7FFF, LoadLibrary fails. If you are attempting to load a 16-bit DLL directly from 32-bit code, LoadLibrary fails. If you are attempting to load a DLL whose subsystem version is greater than 4.0, LoadLibrary fails. If your DllMain function tries to call the Unicode version of a function, LoadLibrary fails.



    VCVCVC
    "Dont Forget to rate if it helped"

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured