我新建了一个win32 dll工程,刚开始是不支持mfc的,后来由于需要使用一个第三方类需要支持mfc,我把工程选项从原来的"Not using MFC"改成"Use MFC in a static library"和"Use MFC in a shared DLL"都不行。这个类的声明很简单:#ifdef TRACESENDER_DLL
#define TRACESENDER_EXP __declspec(dllexport)
#else
#define TRACESENDER_EXP __declspec(dllimport)
#endif
class TRACESENDER_EXP CTraceSender  
{
private:
   CTraceSender() {}
   virtual ~CTraceSender();
// Attributes
protected:
   static COPYDATASTRUCT m_cds;
// Operations
public:
   static void Send(TraceType::e_TraceType eType, LPCTSTR pszFile, int nLine, LPCTSTR pszText);
   static void SendV(TraceType::e_TraceType eType, LPCTSTR pszFile, int nLine, LPCTSTR pszFormat, ...);
// Implementation
protected:
   static void GetFormattedTimestamp(const SYSTEMTIME& timeStamp, CString& strTimestamp);
};编译错误说CString未定义。

解决方案 »

  1.   

    那你直接引用头文件阿~~
    同时修改你上面的Use MFC in a static library~~
    这样应该可以的~~~
      

  2.   

    加mfc的那几个头文件,是哪几个随便生成一个mfc程序看看就知道了
      

  3.   

    包含相应类的头文件?不行啊,cstring的头文件是afx.h,但包含后报这个错:
    c:\program files\microsoft visual studio\vc98\mfc\include\afxv_w32.h(14) : fatal error C1189: #error :  WINDOWS.H already included.  MFC apps must not #include <windows.h>
      

  4.   

    请在stdafx.h中包含afx.h及afxwin.h,就不要再包含windows.h了。
      

  5.   

    fatal error C1189: #error :  WINDOWS.H already included.  MFC apps must not #include <windows.h>
    不是提示你WINDOWS.H已经在afxwin.h包含了~~
    所以,你直接将win32 dll工程里面的windows.h去掉就可以了~~~
      

  6.   

    谢谢,我在stdafx.h中包含了afx.h及afxwin.h,现在编译错误没了,但连接的时候报
    nafxcwd.lib(dllmodul.obj) : error LNK2005: _DllMain@12 already defined in PassSpyHk.objPassSpyHk是dll工程的名字。各位好人做到底吧,谢谢
      

  7.   

    自己参考一下下面的连接~~~
    http://support.microsoft.com/default.aspx?scid=kb;zh-cn;148652&Product=vccIN1