The original thought is not to use the. def file in the DLL, and add __declspec (dllexport) adornments directly before the function that needs to be exported. But when it comes to exporting stdapi __declspec (dllexport) DllGetClassObject, Just prompt"warning C4518: "__declspec (dllexport)": Unexpected storage class or type descriptor encountered here; ignored"(I'm using vc.net.2003). STDAPI This macro expands out to be extern"C"HRESULT __stdcall.extern "C"Must be placed at the front of the function declaration, and __declspec (dllexport) can not be placed after __stdcall (my test results here, __declspec (dllexport) Stdapi and STDAPI __ Declspec (dllexport) is not, the former error, because extern"C"be sure to put it first; the latter is the warning mentioned above. The first is to find out how to export stdapi functions, but nothing to find. Confused on the internet search for a while. The search results are recorded as follows (possibly confusing)1The export of the STDAPI function needs to be declared in the. def (module definition file), and with the private adornment, the private adornment's exported function can only be called dynamically because it is not compiled into the export file. 2A function exported with a. def file whose name is defined as we wish, and when exported with __declspec (dellexport), there is a corresponding decorated name, depending on the compiler, its decorated name is different. 3The export defined by __declspec (dllexport) is used for implicit chaining (static invocation) of the same compiler, while the. def export function can determine that the exported function name will not be different for different compilers and can be used for other development tool calls. In general, the. def is used in COM to derive the function.
Reprinted from: http://blog.csdn.net/mimong_lin/article/details/2628408
__declspec (dllexport) and. def (module definition files) Define the difference between the exported functions in a DLL