Loading DLL files
1. Switch to the path where the DLL file is located at the command prompt
2.dumpbin (If you cannot use the DUMPBIN command, go to the VS installation directory (for example: E:\vs2010chi\VC\bin) where there is Dumpbin.exe) find the Vcvars32.bat batch file and drag it to an open command prompt
3. Then enter the DUMPBIN command to be able to use (note the next time you want to use the DUMPBIN command to do the above, he is only valid for the current window)
4. Add _declspec (dllexport) before the function that needs to be exported
5. Enter Dumpbin-exports XXX.dll (case insensitive) to get the function information to be exported
6. Declare the extern int getcpurate (HANDLE hprocess) in the. cpp file to invoke the function in the DLL.
_declspec (dllimport) int getcpurate (HANDLE hprocess)//--hints that functions loaded from DLL files are more efficient
7. Copy the XXX.dll and XXX.lib to the place you need and link to the file #pragma comment (lib, "XXX.lib")
8. The program can load functions in the DLL
9. Create a new XXX.h header file that contains
Add the #include<xxx.h> file where needed to remove the 6th step
In the. dll source file
#define DLLCPU_API _declspec (dllexport)
#include "XXX.h"
int Get_cpu_usage (HANDLE hprocess);
{
.......
}
EXE loading DLL file