用向导穿件的win32 DLL
DLL头文件如下(红色部分为自己加的):
#ifdef SYSTIME_EXPORTS
#define SYSTIME_API __declspec(dllexport)
#else
#define SYSTIME_API __declspec(dllimport)
#endif// This class is exported from the SysTime.dll
class SYSTIME_API CSysTime {
public:
CSysTime(void);
// TODO: add your methods here.
};extern SYSTIME_API int nSysTime;SYSTIME_API int fnSysTime(void);SYSTIME_API void GetTime( SYSTEMTIME* lpSystemTime );DLL源文件如下(红色部分为自己加的):
#include "stdafx.h"
#include "SysTime.h"BOOL APIENTRY DllMain( HANDLE hModule, 
                       DWORD  ul_reason_for_call, 
                       LPVOID lpReserved
 )
{
    switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
    }
    return TRUE;
}
// This is an example of an exported variable
SYSTIME_API int nSysTime=0;// This is an example of an exported function.
SYSTIME_API int fnSysTime(void)
{
return 42;
}// This is the constructor of a class that has been exported.
// see SysTime.h for the class definition
CSysTime::CSysTime()

return; 
}SYSTIME_API void GetTime( SYSTEMTIME* lpSystemTime )
{
GetLocalTime( lpSystemTime );
}
编译出现如下信息:
:\SysTime\SysTime.cpp(25) : error C2491: 'nSysTime' : definition of dllimport data not allowed
H:\SysTime\SysTime.cpp(29) : error C2491: 'fnSysTime' : definition of dllimport function not allowed
H:\SysTime\SysTime.cpp(36) : warning C4273: 'CSysTime::CSysTime' : inconsistent dll linkage.  dllexport assumed.
H:\SysTime\SysTime.cpp(41) : error C2491: 'GetTime' : definition of dllimport function not allowed
Error executing xicl6.exe.大家帮我看看到底哪里出现问题了,我是照书上敲的啊。