在VC++中选择Win32 Dynamic-Link Library,建一个empty DLL工程linkdb,分别添加一个linkdb.h和lingdb.cpp. 因为在.cpp中用到了AfxMessageBox()函数和CString,所以在.cpp加入了:
#include <afxwin.h>和#include <afx.h>    同时又因为在.cpp中用到了ado连接数据库和SQLDMO.dll的一些函数,所以在
.h中加入了下面语句:
#import "c:program files\common files\systemado\msado15.dll"
using namespace ADODB;
#import "c:\program File\Microsoft SQL Server\80\Tool\Binn\SQLDMO.dll"
using namespace SQLDMO;   结果编译时出现了windows.h重定义的问题。我估计是SQLDMO.dll和msado15.dll有用到windows.h
于是把
#import "c:program files\common files\systemado\msado15.dll"
using namespace ADODB;
#import "c:\program File\Microsoft SQL Server\80\Tool\Binn\SQLDMO.dll"
using namespace SQLDMO;   屏蔽了,但这样一来,就不能使用ado连接数据库和SQLDMO.dll的一些函数,而要实现功能必须用到。
但是把
#include <afxwin.h>
#include <afx.h>
  屏蔽了,CString类型和AfxMessageBox函数又不能用了。现在真不知怎么办了?

解决方案 »

  1.   

    错误信息看错了,主要有两条错误.1.WINDOWS.H already included. MFC apps must not #include <windows.h>2.cannot not open file '\Debug\linkdb.sbr'
      

  2.   

    MFC本身的#include <afxwin.h>就有#include <windows.h>了所以不要再包含,看看你连接lib文件的路径对没?
      

  3.   

    WINDOWS.H already included. MFC apps must not #include <windows.h>
    不是直接提示你WINDOWS.H在MFC工程里面已经包含了``
    所以,不要再加头文件windows.h~~~
    cannot not open file '\Debug\linkdb.sbr'
    那你把Debug文件目录删除~
    然后Rebuild All~~