CoUninitialize

编辑:功夫网互动百科 时间:2020-05-25 05:41:10
编辑 锁定
本词条缺少名片图,补充相关内容使词条更完整,还能快速升级,赶紧来编辑吧!
CoUninitialize Closes the COM library on the current thread, unloads all DLLs loaded by the thread, frees any other resources that the thread maintains, and forces all RPC connections on the thread to close.
外文名
CoUninitialize
作    用
关闭当前线程的COM
Library
使用 ole32.dll
系    统
Windows 95及以上版本

目录

CoUninitialize原文

编辑
void CoUninitialize( );Remarks A thread must call CoUninitialize once for each successful call it has made to CoInitialize or CoInitializeEx. Only the CoUninitialize call corresponding to the CoInitialize or CoInitializeEx call that initialized the library can close it.
Calls to OleInitialize must be balanced by calls to OleUninitialize. The OleUninitialize function calls CoUninitialize internally, so applications that call OleUninitialize do not also need to call CoUninitialize.
CoUninitialize should be called on application shutdown, as the last call made to the COM library after the application hides its main windows and falls through its main message loop. If there are open conversations remaining, CoUninitialize starts a modal message loop and dispatches any pending messages from the containers or server for this COM application. By dispatching the messages, CoUninitialize ensures that the application does not quit before receiving all of its pending messages. Non-COM messages are discarded.
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.dll.

CoUninitialize中文详解

编辑
CoUninitialize关闭当前线程的COM库,卸载线程加载的所有dll,释放任何其他的资源,关闭在线程上维护所有的RPC连接。
void CoUninitialize();
备注:
一个线程必须调用 CoUninitialize 一次在每次成功调用CoInitialize或CoInitializeEx。只有CoUninitialize对应于CoInitialize调用对应CoInitialize或CoInitializeEx调用他们初始化库能关闭它。
调用OleInitialize必须通过调用OleUninitialize平衡。OleUninitialize 函数调用的OleUninitialize内部,所以应用程序调用OleUninitialize不也需要调用CoUninitialize。
CoUninitialize应该在应用程序关闭后调用,作为最后一次调用COM库在应用程序主窗户隐藏,消息循环结束之后。如果有剩余的对话开着,CoUninitialize开始了模态消息循环和派发任何挂起的消息在容器或服务器里对于这个COM应用程序。通过派发信息,CoUninitialize 在确保应用程序等待所有它的消息接收之前不退出。Non-COM信息被丢弃。
因为没有办法控制顺序进程内服务器加载或卸载, 从DllMain函数中调用CoInitialize, CoInitializeEx,或者 CoUninitialize 是不安全的。
要求Windows NT / 2000: 要求Windows NT 3.1及以上版本。
Windows 95 / 98: 需要Windows 95及以上版本。
标头: 在 objbase.h头文件里宣布。
Library:使用 ole32.dll。
词条标签:
计算机学