How to check if OleInitialize has already been called?

試著忘記壹切 提交于 2019-12-12 16:16:00

问题


I want to write a Delphi function to register a dll. I want the function to check if OleInitialize has already been called before it does so. I guess I'm trying to avoid the consequences of initializing twice because I'm not sure what they might be. I'm worried that my function won't handle as wide a variety of dlls as regsvr32.exe.


回答1:


Take a look at the documentation:

Return Value
[...]
S_FALSE - The COM library is already initialized on this apartment.

... and also:

Typically, the COM library is initialized on an apartment only once. Subsequent calls will succeed, as long as they do not attempt to change the concurrency model of the apartment, but will return S_FALSE.



来源:https://stackoverflow.com/questions/3278273/how-to-check-if-oleinitialize-has-already-been-called

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!