vc中这个函数CoInitialize()怎么用????我做了一个复制操作,用了COleDataSource 和 CShareFile类,还有CArchive类,复制操作中,提示错误:没有调用Coinitialize()函数。
这个问题我应该怎么解决??
怎么来调用这个函数???????
这个问题我应该怎么解决??
怎么来调用这个函数???????
解决方案 »
- 关于 UpdateLayeredWindow 与WinXP
- 大家来评评理,部长(VisualEleven)天天装菜鸟,让人情以何堪
- DAO 操作ACCESS读取float出错的问题
- 用什么免费工具编写MIB文件好?
- vc2005编写的带有浮点操作的程序用exe压缩软件压缩后运行出现floating point not loaded错误
- 还是关于工具栏.(SDK) 大家都来看看吧
- 界面乱了???
- 系统按钮无效
- 求助,双缓冲机制Bitblt之后显示结果为上下反向
- 各位大虾,小弟急需VC++版的记事本源码,拜谢高手奉献共享!!!!!!!真的很急!!!!!!!!!!1
- 高手门~~~难题来啦
- 大虾们快来救命啊!!
{
CoInitialize(NULL);
}
CoInitialize(NULL);
Initializes the COM library on the current thread and identifies the concurrency model as single-thread apartment (STA). Applications must initialize the COM library before they can call COM library functions other than CoGetMalloc and memory allocation functions. New applications should call CoInitializeEx instead of CoInitialize. HRESULT CoInitialize(
LPVOID pvReserved //Reserved; must be NULL
);
Parameter
pvReserved
[in] Reserved; must be NULL.
Return Values
This function supports the standard return values E_INVALIDARG, E_OUTOFMEMORY, and E_UNEXPECTED, as well as the following: S_OK
The COM library was initialized successfully on this thread.
S_FALSE
The COM library is already initialized on this thread.
RPC_E_CHANGED_MODE
A previous call to CoInitializeEx specified the concurrency model for this thread as multithread apartment (MTA). If running Windows 2000, this could also mean that a change from neutral threaded apartment to single threaded apartment occurred.
Res
CoInitializeEx provides the same functionality as CoInitialize and also provides a parameter to explicitly specify the thread's concurrency model. CoInitialize calls CoInitializeEx and specifies the concurrency model as single-thread apartment. Applications developed today should call CoInitializeEx rather than CoInitialize. You need to initialize the COM library on a thread before you call any of the library functions except CoGetMalloc, to get a pointer to the standard allocator, and the memory allocation functions.Once the concurrency model for a thread is set, it cannot be changed. A call to CoInitialize on an apartment that was previously initialized as multithreaded will fail and return RPC_E_CHANGED_MODE. Typically, the COM library is initialized on a thread only once. Subsequent calls to CoInitialize or CoInitializeEx on the same thread will succeed, as long as they do not attempt to change the concurrency model, but will return S_FALSE. To close the COM library gracefully, each successful call to CoInitialize or CoInitializeEx, including those that return S_FALSE, must be balanced by a corresponding call to CoUninitialize. However, the first thread in the application that calls CoInitialize(0) or CoInitializeEx(COINIT_APARTMENTTHREADED) must be the last thread to call CoUninitialize(). If the call sequence is not in this order, then subsequent calls to CoInitialize on the STA will fail and the application will not work.Because there is no way to control the order in which in-process servers are loaded or unloaded, it is not safe to call CoInitialize, CoInitializeEx, or CoUninitialize from the DllMain function. Requirements
Windows NT/2000: Requires Windows NT 3.1 or later.
Windows 95/98: Requires Windows 95 or later.
Header: Declared in objbase.h.
Library: Use ole32.lib.
用完了记得要关阿
CoUninitialzie();
CoInitialize(NULL);
if(CoCreateInstance(CLSID_Shell, NULL, CLSCTX_INPROC_SERVER,IID_IShellDispatch, (void **)&shl)@=S_OK)
return -1;
shl->FileRun();
shl->Release();
CoUninitialize();