0
votes

I have a Win32 .exe written in Delphi Seattle that implements a COM interface to a function.
I'm confused by the way the server behaves if I call CreateOleObject() from inside the program itself.
The instancing model is set to ciSingleInstance so I would expect a new instance to be created at each call (assuming the previous instances are still running).

What actually happens is the first call does not create a new instance but the second does.
If the first call runs to completion the second instance again creates a new instance even though the program should be back to its default state.

How do I

a) force creation of a second instance on the first call, or
b) return the program to a really default state so that multiple runs to completion do not start a second instance.

1
The default state is "accept exactly one CoCreateInstance call, for the lifetime of this process". In light of this, your program appears to be working as expected. You probably run it by means other than CoCreateInstance, so it still waits for its one and only CoCreateInstance - but once it gets it, it won't take any more, ever.Igor Tandetnik
"once per process lifetime" explains things and means if I call CreateOleObject() once, if the program is not being automated, gives an answer to my first question. Many thanks.user3359525

1 Answers

0
votes

ciSingleInstance is passed as REGCLS_SINGLEUSE to the internal call to CoRegisterClassObject which may be causing this unwanted behaviour.