DLL dynamic link library exported function the way

DLL functions exported ways:. * Def file or __declspec (dllexport) keyword:

① * .def file must contain at least the following module definition statement:

The file must be the first statement LIBRARY statement. This statement .def file identified as belonging to DLL. LIBRARY statement is behind the name of the DLL. The linker places this name in the DLL's import library.

EXPORTS statement lists the name, if possible, also list the ordinal value exported DLL function. By adding the function name @ character and a digit, the sequence number value assigned to the function. When the specified index value, the sequence number value must range from 1 to N, where N is the number of functions exported by the DLL.

Comment statement, the statement in front of the semicolon ";."

例如:
;DLLTest.def : Declares the module parameters for the DLL.
LIBRARY "DLLTest"
EXPORTS
add @1
fun @2

②_declspec (dllexport) Export way:
In order to prevent name mangling, the extern "C" _declspec (dllexport) statement in front of the statement you want to export functions;
for example:
extern "C" _declspec (dllexport) int the Add (int A, int b );

Guess you like

Origin www.cnblogs.com/mktest123/p/12071431.html