Loading multiple libraries with loadlibrary

3

I have two libraries, sph.dll and mydll.dll , and I try to load them using LoadLibrary as shown below:

HMODULE hlib = LoadLibrary("mydll.dll");
if(!hlib){ 
  printf("error");
  MessageBox(NULL, "Erro -> mydll.dll não encontrado." , "Erro IB5 Printer" , MB_ICONERROR | MB_OK);}

HMODULE chlib = LoadLibrary("sph.dll");
if(!chlib){ 
  printf("error");
  MessageBox(NULL, "Erro -> sph.dll não encontrado." , "Erro IB5 Printer" , MB_ICONERROR | MB_OK);}

The problem is that when I compile an error message appears saying that sph.dll was not found. When I call sph.dll first, mydll.dll is not found. I'm using the DEV-C environment to program.

What's the problem here?

    
asked by anonymous 07.08.2015 / 03:46

1 answer

0

The problem with your code is not that it does not find the DLL, but that a segmentation fault is occurring at the time of loading the DLL.

By searching the Microsoft documentation for error code 998 returned by the GetLastError command, this code indicates the error ERROR_NOACCESS , which is the error code mapped to Windows targeting failures.

Check to see if you are using compatible versions of these DLLs; check if your dependencies are correct (maybe they depend on other modules that are causing the initialization of some variable used in the command DllMain , executed in loading the DLL); debug DLLs if you have your source codes; make sure the files are not corrupted (restore from a backup, or download them again).

To help you determine dependencies, use the Dependency Walker program.

    
08.08.2015 / 05:10