我在做一个练习的时候遇到一个问题,使用一个 .dll,在 stdafx.h 里面加入如下代码,希望高手指点指点:
#import "C:\Program Files\Common Files\SYSTEM\ADO\msado15.dll" no_namespace \
rename("EOF","EndOfFile")\
rename("LockTypeEnum","newLockTypeEnum")\
rename("DataTypeEnum","newDataTypeEnum")\
rename("FieldAttributeEnum","newFieldAttributeEnum")\
rename("EditModeEnum","newEditModeEnum")\
rename("RecordStatusEnum","newRecordStatusEnum")\
rename("ParameterDirectionEnum","newParameterDirectionEnum")在应用程序类所在的头文件里面加入 变量和 函数的生明,如下:
public:
_RecordsetPtr m_pADOSet;
// int m_iLoginCount;
CString m_sCurrentUser;
CHotel_MISApp();
private:
bool ADOExecute(_RecordsetPtr &ADOSet,_variant_t &strSQL);
_ConnectionPtr ADOConn;
编译后出现如下错误提示。我不明白,不知道是否还要加 什么头文件什么的东西。
Compiling...
StdAfx.cpp
g:\hotel_mis\hotel_mis.h(25) : error C2146: syntax error : missing ';' before identifier 'm_pADOSet'
g:\hotel_mis\hotel_mis.h(25) : error C2501: '_RecordsetPtr' : missing storage-class or type specifiers
g:\hotel_mis\hotel_mis.h(25) : error C2501: 'm_pADOSet' : missing storage-class or type specifiers
g:\hotel_mis\hotel_mis.h(46) : error C2061: syntax error : identifier '_RecordsetPtr'
g:\hotel_mis\hotel_mis.h(47) : error C2146: syntax error : missing ';' before identifier 'ADOConn'
g:\hotel_mis\hotel_mis.h(47) : error C2501: '_ConnectionPtr' : missing storage-class or type specifiers
g:\hotel_mis\hotel_mis.h(47) : error C2501: 'ADOConn' : missing storage-class or type specifiers
Error executing cl.exe.
很急。!!!在先等待,!!
#import "C:\Program Files\Common Files\SYSTEM\ADO\msado15.dll" no_namespace \
rename("EOF","EndOfFile")\
rename("LockTypeEnum","newLockTypeEnum")\
rename("DataTypeEnum","newDataTypeEnum")\
rename("FieldAttributeEnum","newFieldAttributeEnum")\
rename("EditModeEnum","newEditModeEnum")\
rename("RecordStatusEnum","newRecordStatusEnum")\
rename("ParameterDirectionEnum","newParameterDirectionEnum")在应用程序类所在的头文件里面加入 变量和 函数的生明,如下:
public:
_RecordsetPtr m_pADOSet;
// int m_iLoginCount;
CString m_sCurrentUser;
CHotel_MISApp();
private:
bool ADOExecute(_RecordsetPtr &ADOSet,_variant_t &strSQL);
_ConnectionPtr ADOConn;
编译后出现如下错误提示。我不明白,不知道是否还要加 什么头文件什么的东西。
Compiling...
StdAfx.cpp
g:\hotel_mis\hotel_mis.h(25) : error C2146: syntax error : missing ';' before identifier 'm_pADOSet'
g:\hotel_mis\hotel_mis.h(25) : error C2501: '_RecordsetPtr' : missing storage-class or type specifiers
g:\hotel_mis\hotel_mis.h(25) : error C2501: 'm_pADOSet' : missing storage-class or type specifiers
g:\hotel_mis\hotel_mis.h(46) : error C2061: syntax error : identifier '_RecordsetPtr'
g:\hotel_mis\hotel_mis.h(47) : error C2146: syntax error : missing ';' before identifier 'ADOConn'
g:\hotel_mis\hotel_mis.h(47) : error C2501: '_ConnectionPtr' : missing storage-class or type specifiers
g:\hotel_mis\hotel_mis.h(47) : error C2501: 'ADOConn' : missing storage-class or type specifiers
Error executing cl.exe.
很急。!!!在先等待,!!
在hotel-mis.h 里面有两句向导自动加入的语句,#ifndef __AFXWIN_H__
#error include 'stdafx.h' before including this file for PCH
#endif
那位能解释一下是什么意思?
#error include 'stdafx.h' before including this file for PCH
#endif这句话的意思是,如果你没有定义 __AFXWIN_H__ ,编译器就会在你的output窗口内出现
include 'stdafx.h' before including this file for PCH
这行错误提示
PCH 是啥子文件哟?
我那个错误又回因为什么引起的呢?
不行,我这个按照你那中办法不能行。
又有了另外的错误:g:\hotel_mis\stdafx.cpp(9) : error C2857: '#include' statement specified with the /Ycstdafx.h command-line option was not found in the source file
Error executing cl.exe.
搞不懂是怎么回事。
以下两种解决方法:
1.在stdafx.h中包含 <comdef.h>文件
2.不要import msado15.dll文件,而要import msado20.tlb文件
DLGBookIn.cpp
g:\hotel_misffffff\dlgbookin.cpp(4) : fatal error C1083: Cannot open precompiled header file: 'Debug/Hotel_MIS.pch': No such file or directory
在每个文件里的 #include "stdafx.h" 处都有这个错误提示。请问高手,这是什么原因?可不可仪把 .aps .ncb 和.opt 这几个文件删了再建。
谢谢你。
你发给我的代码我看了,现在问题基本解决了,我原来是在 stdafx.h里面加入 了 “#include ‘chotel-mis。h’
extern chotel-misap theapp;”
我把这两句删了就行了。