Home > Software engineering >  Load the DLL
Load the DLL

Time:10-13

Built before the project is in the WIN32 project directly select DLL, the DLL is loaded up to also have no problem
Recent need to do a load of OCX DLL, so I chose the MFC DLL in the MFC project, after the new, under the dialog box to add ActiveX controls, and add a variable for the controls, the other on the setting of the interface, for example. OpenDevice def files and interface are realized, other did not move, the compiler generates 840 d. DLL, use the DLL view tool can also see the interface
In the same test under the project returns a value when the console program LoadLibrary, but abnormal, the test procedure as follows
 typedef int (* lpopen) (int); 

Int main ()
{
HINSTANCE hDll;
Lpopen func.
//according to the experience of the previous load the DLL, the return value should be problematic
HDll=LoadLibrary (". \ \ 840 d. DLL ");//hDll return values for 840 d. DLL! 0 x0f7d0000 (symbol file lack of type information) {unused=0 x00905a4d}
Int err=GetLastError ();//the return value of 0
Func=(lpopen) GetProcAddress call (hDll, "open_device");//returns a value, but can't get into debugging interface function
Err=GetLastError ();//the return value of 0
return 0;
}

In order to test, I added the printf in the interface to do the test, no output, interface and no call success
 int open_device (/* const char * json, phDevice HDEVICE * */int x) 
{
Printf (" test ");
Driver * Driver=new Driver;
Driver - & gt; OpenLink ();
return 0;
}

CodePudding user response:

Show that you have a problem in the implementation of the interface? Yourself to add some log information see which DLL function call failed?

CodePudding user response:

reference 1st floor VisualEleven response:
means that you have problems in the implementation of the interface? Yourself to add some log information see which DLL function call failed?

The LoadLibrary when the return value is the 840 d. DLL! 0 x0f7d0000 (symbol file lack of type information) {unused=0 x00905a4d}
This is not the problem, I always doubt is when the Load would have failed

CodePudding user response:

refer to the second floor YKlmc response:
Quote: refer to 1st floor VisualEleven response:

Show that you have a problem in the implementation of the interface? Yourself to add some log information see which DLL function call failed?

The LoadLibrary when the return value is the 840 d. DLL! 0 x0f7d0000 (symbol file lack of type information) {unused=0 x00905a4d}
This is not the problem, I always doubt is when the Load failed

As long as the LoadLibrary if fails, the return value is NULL, you can check whether can be NULL,

CodePudding user response:

Under the best initialization of all variables,
Loadlibrary fails hDll should be NULL, returns 0 estimate is normal,
GetProcAddress call failure func is NULL,
If you use the code above, then tell you where is wrong, you only got a function pointer, and didn't call this function, not the output is normal, have the output is a ghost, should be in
 
Func=(lpopen) GetProcAddress call (hDll, "open_device");//returns a value, but can't get into debugging interface function
Err=GetLastError ();//the return value of 0
((lpopen) fun) (0);


In addition to see you
int open_device (/* const char * json, phDevice HDEVICE * */int x)
{
Printf (" test ");
Driver * Driver=new Driver;
Driver - & gt; OpenLink ();
return 0;
}

This code I also feel there is a problem, you this driver is encapsulated the dialog class?

CodePudding user response:

LoadLibrary (_T (" C: \ \ 840 d DLL "));//try to use the full path
Every step and the error return different values for convenient positioning problem

CodePudding user response:

reference 4 floor xuddk727 response:
all variable initialization, the best
Loadlibrary fails hDll should be NULL, returns 0 estimate is normal,
GetProcAddress call failure func is NULL,
If you use the code above, then tell you where is wrong, you only got a function pointer, and didn't call this function, not the output is normal, have the output is a ghost, should be in
 
Func=(lpopen) GetProcAddress call (hDll, "open_device");//returns a value, but can't get into debugging interface function
Err=GetLastError ();//the return value of 0
((lpopen) fun) (0);


In addition to see you
int open_device (/* const char * json, phDevice HDEVICE * */int x)
{
Printf (" test ");
Driver * Driver=new Driver;
Driver - & gt; OpenLink ();
return 0;
}

This code I also feel there is a problem, you this driver is encapsulated the dialog class?


reference 4 floor xuddk727 response:
all variable initialization, the best
Loadlibrary fails hDll should be NULL, returns 0 estimate is normal,
GetProcAddress call failure func is NULL,
If you use the code above, then tell you where is wrong, you only got a function pointer, and didn't call this function, not the output is normal, have the output is a ghost, should be in
 
Func=(lpopen) GetProcAddress call (hDll, "open_device");//returns a value, but can't get into debugging interface function
Err=GetLastError ();//the return value of 0
((lpopen) fun) (0);


In addition to see you
int open_device (/* const char * json, phDevice HDEVICE * */int x)
{
Printf (" test ");
Driver * Driver=new Driver;
Driver - & gt; OpenLink ();
return 0;
}

This code I also feel there is a problem, you this driver is encapsulated the dialog class?

No, this is my driving action class,
Interface function is proved to be the problem of you say, but strange, I used the inside of the building projects under WIN32 DLL, calling, as long as the
Func=(lpopen) GetProcAddress call (hDll, "open_device"); It is ok to
Why in the MFC DLL project need ((lpopen) fun) (0); This sentence, don't understand

CodePudding user response:

refer to 6th floor YKlmc response:
Quote: refer to 4th floor xuddk727 response:

Under the best initialization of all variables,
Loadlibrary fails hDll should be NULL, returns 0 estimate is normal,
GetProcAddress call failure func is NULL,
If you use the code above, then tell you where is wrong, you only got a function pointer, and didn't call this function, not the output is normal, have the output is a ghost, should be in
 
Func=(lpopen) GetProcAddress call (hDll, "open_device");//returns a value, but can't get into debugging interface function
Err=GetLastError ();//the return value of 0
((lpopen) fun) (0);


In addition to see you
int open_device (/* const char * json, phDevice HDEVICE * */int x)
{
Printf (" test ");
Driver * Driver=new Driver;
Driver - & gt; OpenLink ();
return 0;
}

This code I also feel there is a problem, you this driver is encapsulated the dialog class?


reference 4 floor xuddk727 response:
all variable initialization, the best
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related