views:

122

answers:

1

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.

+7  A: 

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.

Georg Fritzsche