CoUninitialize

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及以上版本
原文,中文詳解,

原文

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關閉當前執行緒的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。

相關詞條

熱門詞條

聯絡我們