昨晚由于需要,把一个BCB项目转换为VC项目,95%的时间都花费在怎样使用CString上面:==============================1、建立一个“A simple Dll Project”类型的DLL。2、在Dll.Cpp中输入 CString Str,
   
(1)编译错误:#include "stdafx.h"Dll.cpp(7) : error C2146: syntax error : missing ';' before identifier 'Str'
Dll.cpp(7) : error C2501: 'CString' : missing storage-class or type specifiers
Dll.cpp(7) : fatal error C1004: unexpected end of file found(2)改为//#include "stdafx.h"
#include <afx.h>继续错:atal error C1010: unexpected end of file while looking for precompiled header directive
Error executing cl.exe.
(3)同时包括#include "stdafx.h"
#include <afx.h>还是错:afxv_w32.h(14) : fatal error C1189: #error :  WINDOWS.H already included.  MFC apps must not #include <windows.h>
Error executing cl.exe.
靠!服了!!!最后不得不使用STL里边的string类,VC Fans说一说这种错误到底是怎么回事???

解决方案 »

  1.   

    你生成dll的时候选择支持mfc就是了用MFC dll向导
      

  2.   

    本来想说用string的 没想到你自己做了工程设置里面选择mfc dll 动态链接或者是静态链接
    (默认是not  use mfc)
      

  3.   

    要与其它程序通信吗?
    可以用
    typedef unsigned short *String;实现BSTR
      

  4.   

    To :  beijingshizi(菜青虫) 如果使用MFC AppWizard(DLL),怎么生成的项目中没有DllMain函数?而且会自动添加CDll1App类!这个类用来干什么?
      

  5.   

    我和你遇到一样的问题
    创建MFC的DLL(包括与MFC静态链接的常规DLL.与MFC动态链接的常规DLL.与MFC动态链接的扩展DLL)
      

  6.   

    实用“创建MFC的DLL -> MFC动态链接的扩展DLL”包含了DllMain函数,只是为什么又有了这些代码: if (!AfxInitExtensionModule(Dll1DLL, hInstance))
    return 0; new CDynLinkLibrary(Dll1DLL);能不能删掉?如果删掉的话,对程序有没有影响?
      

  7.   

    我已经决定以后都使用STL里边的string了.