gpt4 book ai didi

COM:我可以在不调用 Release 的情况下调用 CoUninitialize 吗?

转载 作者:行者123 更新时间:2023-12-04 21:44:47 24 4
gpt4 key购买 nike

我有个疑问。我初始化 COM,做 CoCreateInstance 并使用一些接口(interface)。我可以在不调用 Release 的情况下调用 CoUninitialize 吗?它会导致任何内存/资源泄漏吗?

提前致谢,
-玛尼。

最佳答案

来自 MSDN:

http://msdn.microsoft.com/en-us/library/ms688715%28VS.85%29.aspx

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.



你应该只在关机时调用 CoUninitialize,到那时你是否有内存泄漏都没有关系。

关于COM:我可以在不调用 Release 的情况下调用 CoUninitialize 吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1431261/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com