How to check if OleInitialize has already been cal

2019-07-07 04:29发布

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条回答
混吃等死
2楼-- · 2019-07-07 05:20

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.

查看更多
登录 后发表回答