Discussion:
CoCreateInstance and the CLSCTX_ALL flag
(too old to reply)
mannson
2007-01-20 21:48:54 UTC
Permalink
Hi,
I'm using the CoCreateInstance method of the ATL smart pointer to
create COM objects in my DirectShow application. Looking at the
documentation of this method, I came across the CLSCTX_ALL flag. This
equals a collection of flags and lets COM choose the appropriate
server. Now I'm curious to know, if there is difference between this
two calls:

IGraphBuilder pGraphBuilder;
CoCreateInstance (CLSID_FilterGraph, Null, CLSCTX_INPROC_SERVER,
IID_IGraphBuilder, (void **)&pGraphBuilder);

and

CComPtr<IGraphBuilder> pGraphBuilder;
pGraphBuilder.CoCreateInstance(CLSID_FilterGraph);

How do I know, what threading model COM is actually using for the
filter graph manager, if I'm going with the second version?

Thanks in advance
Stefan
Michel Roujansky - DirectShow Consultant and Trainer
2007-01-20 23:01:54 UTC
Permalink
The flag refers to where the COM object gets activated (in process,
local server, remote).
CLSTCTX_ALL gives the freedom for the factory to try all possibilities
and take the first one that works.
However, this is purely theoretical in the case of the Filtergraph
manager, because if you look for its class in the registry, you will
see that it gets implemented by quatrz.dll, which means it can only run
in-process.
Re threading, you actually choose threading by using CLSID_FilterGraph
or CLSID_FilterGraphNoThread
see : http://msdn2.microsoft.com/en-gb/library/ms783670.aspx

rgds,
mannson
2007-01-21 00:28:56 UTC
Permalink
On 21 Jan., 00:01, "Michel Roujansky - DirectShow Consultant and
Post by Michel Roujansky - DirectShow Consultant and Trainer
The flag refers to where the COM object gets activated (in process,
local server, remote).
CLSTCTX_ALL gives the freedom for the factory to try all possibilities
and take the first one that works.
However, this is purely theoretical in the case of the Filtergraph
manager, because if you look for its class in the registry, you will
see that it gets implemented by quatrz.dll, which means it can only run
in-process.
Re threading, you actually choose threading by using CLSID_FilterGraph
or CLSID_FilterGraphNoThread
see :http://msdn2.microsoft.com/en-gb/library/ms783670.aspx
rgds,
Thanks. That whas exactly what I wanted to know. :)

Regrads
Stefan
f***@berlinet.de
2016-04-15 17:07:33 UTC
Permalink
Post by Michel Roujansky - DirectShow Consultant and Trainer
CLSTCTX_ALL gives the freedom for the factory to try all possibilities
and take the first one that works.
This is not quite correct; the implementation follows a strict protocol and deviates from the in-process server instantiation only in specific cases.

See the "Remarks" section here for a description of the algorithm which decides about the context:
https://msdn.microsoft.com/en-us/library/windows/desktop/ms693716(v=vs.85).aspx
Loading...