一般来说需要导入函数的时候要加__declspec(dllimport),若不加,则需要在.def文件中添加相应的项也可以。还有就是添加__declspec(dllimport)可以优化部分代码,以下是msdn的原文:You do not need to use _declspec(dllimport) for your code to compile correctly, but doing so allows the compiler to generate better code. The compiler is able to generate better code because it knows for sure whether a function exists in a DLL or not, so the compiler can produce codes that skip a level of indirection that would normally be present in a function call that crossed a DLL boundary.
#ifdef DLL_OBJECT_EXPORTS#define DLL_OBJECT_API __declspec(dllexport)#else#define DLL_OBJECT_API __declspec(dllimport)#endif
windows核心编程》这么说的
windows核心编程》这么说的
不加也没有错.
http://topic.csdn.net/u/20100322/00/17389242-a3f7-46d1-992b-ae4c4e2976bb.html?6299