Precautions for exporting DLL Functions in VC

Source: Internet
Author: User

① When DLL is used as a C ++ source file, the exported function must be added to the header file:

 
Extern "C" {// export function declaration ......};

② The above method cannot be recognized by external functions (with xxx @ number). Use the following method:

Set a function to be exported:

 
Lresult callback keyboardproc (INT ncode, wparam, // stores the VK value lparam // stores the number of repetitions, scan codes, extensions ....);

Then:

 
/// Force export function: the alias of _ keyboardproc @ 12 is: keyboardproc // The rule is prefixed with "_ function name @ parameter number of nodes ], you can use the // dependency Walker tool to view the modified name // # pragma comment (linker, "/export: keyboardproc = _ keyboardproc @ 12 ") //// set aside a standard export function interface extern "C" for the external C language {// export function dlltest_api lresult callback keyboardproc (INT ncode, wparam, // stores the VK value lparam // stores the number of repetitions, scan codes, and extensions ....);};

The preceding dlltest_api is defined:

# Define
Dlltest_api _ Declspec(Dllexport)

After the above processing, the export function is named keyboardproc;

As described in the above comment, the export function in dll should be frequently viewed using the VC tool dependencywalker!

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.