VC6 程序中调用 CoInitializeEx函数
编译错误如下
D:\NicOPCServer\ServerClient\MainFrm.cpp(199) : error C2039: 'CoInitializeEx' : is not a member of '`global namespace''产生错误的CPP已经包含相关头文件了,查了相关帖子,未解决!
// MainFrm.cpp : implementation of the CMainFrame class
//#ifndef _WIN32_DCOM
#define _WIN32_DCOM // WinNT 4.0 or Win95 w/DCOM
#endif
#define _WIN32_WINNT 0x0500
#include <ole2.h>#include "stdafx.h"
#include <objbase.h>
#include <atlbase.h>
大家帮忙!
编译错误如下
D:\NicOPCServer\ServerClient\MainFrm.cpp(199) : error C2039: 'CoInitializeEx' : is not a member of '`global namespace''产生错误的CPP已经包含相关头文件了,查了相关帖子,未解决!
// MainFrm.cpp : implementation of the CMainFrame class
//#ifndef _WIN32_DCOM
#define _WIN32_DCOM // WinNT 4.0 or Win95 w/DCOM
#endif
#define _WIN32_WINNT 0x0500
#include <ole2.h>#include "stdafx.h"
#include <objbase.h>
#include <atlbase.h>
大家帮忙!
#define _WIN32_DCOM // WinNT 4.0 or Win95 w/DCOM
#endif
#define _WIN32_WINNT 0x0500
这些代码写在stdafx.h中?
d:\nicopcserver\serverclient\mainfrm.cpp(5) : warning C4005: '_WIN32_DCOM' : macro redefinition
...To:DentistryDoctor(MVP称号也不能顶上缺失的文凭(厚积薄发))
上述代码写在用到的API函数的CPP文件的前面。
我在一个已有的工程中增加一个和COM相关的操作,引入一些代码,编译错误!
D:\NicOPCServer\ServerClient\MainFrm.cpp(199) : error C2039: 'CoInitializeEx' : is not a member of '`global namespace''
...
帮忙!!!
我试试!!!
现在编译到时通过了,但
// COM initialize
hr = ::CoInitializeEx(NULL,COINIT_MULTITHREADED); // setup COM lib
// new
if (hr != S_OK)
{ if (hr == S_FALSE)
{
MessageBox(NULL, "COM库已经初始化", "COM Error", MB_OK);
}
else
{
MessageBox(NULL, "COM库初始化失败", "COM Error", MB_OK); // 当前产生错误流程
// ?????? 2006.06.15
}
}
运行产生错误!!!
运行可以成功!
COINIT_APARTMENTTHREADED = 0x2, // Apartment model
COINIT_MULTITHREADED = 0x0, // OLE calls objects on any thread.
区别是什么?
// COM initialize
hr = ::CoInitializeEx(NULL,COINIT_MULTITHREADED); // setup COM lib
用这个参数:COINIT_MULTITHREADED初始化失败的原因么?