EXE loading DLL file

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.