本人想写一个简单的COM组件,从最基本的开始写不使用MFC或ATL,自己根据需要自己写了一个IDL文件,使用midl.exe编译,生成5个文件,其中有存_p.c文件与一个dlldata.c文件,查阅资料说是这两个文件中存放代理与存根代码,还有时行列集与散集代码,但是不知道这两个文件怎么使用,我将_p.c与dlldata.c文件引入工程中编译时出错,错误出现在_p.c文件是一个条件编译,如下:_p.c文件中的出错位置:
#if !(TARGET_IS_NT40_OR_LATER)
#error You need a Windows NT 4.0 or later to run this stub because it uses these features:
#error -Oif or -Oicf.
#error However, your C/C++ compilation flags indicate you intend to run this app on earlier systems.
#error This app will die there with the RPC_X_WRONG_STUB_VERSION error.
#endif
错误信息:
d:\program\comtest\comtest\test_p.c(94) : fatal error C1189: #error : You need a Windows NT 4.0 or later to run this stub because it uses these features:不知道这两个文件如何使用,谢谢了!
#if !(TARGET_IS_NT40_OR_LATER)
#error You need a Windows NT 4.0 or later to run this stub because it uses these features:
#error -Oif or -Oicf.
#error However, your C/C++ compilation flags indicate you intend to run this app on earlier systems.
#error This app will die there with the RPC_X_WRONG_STUB_VERSION error.
#endif
错误信息:
d:\program\comtest\comtest\test_p.c(94) : fatal error C1189: #error : You need a Windows NT 4.0 or later to run this stub because it uses these features:不知道这两个文件如何使用,谢谢了!
如果想使用分离的代理存根,不要把两个c文件添加到项目中,只能创建一个新的DLL项目来使用它(参考第二个测试项目的文件和编译选项);
如果想在自己的组件中同时包含代理存根,则参考一下第一个测试项目代码中的调用,把代码复制过来用。
#define _WIN32_WINNT 0x0500 //对于 WinNT 4.0 或安装了 DCOM 的 Win95
我也依照着将两个文件直接包含进了我的工作的.cpp文件中,也定义这个宏,但还是出现开始所提出的问题中的错误,我使用的WinXP系统,IDE环境是VS2005.
#include "XXXi_C"
#incluce "XXX.H"就可以了