Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Is it possible to use local component in DLL?

18 views
Skip to first unread message

mike

unread,
Oct 23, 2008, 3:01:10 PM10/23/08
to
I have a dll that provides decoding capabilities for WMP. In order
not to actually ship the dll and register it, I've created a static
library version of the doc that has the DMO( COM object) in it. I
have an ATL based exe that hosts the WMP active control. Within my
exe, I’ve done the following:

CComObject<CMyDecoderDMO>* m_pDecoder;

ATLVERIFY(
SUCCEEDED(

__objMap_CMyDecoderDMO.RegisterClassObject( CLSCTX_INPROC_SERVER,
REGCLS_MULTI_SEPARATE )
)
);

m_pDecoder = NULL;
hr = CComObject<CMyDecoderDMO>::CreateInstance( &m_pDecoder );
if (FAILMSG(hr))
return 0;

CMyDecoderDMO is linked statically into my exe. Is it possible to
register a component like this within a process and have an activex/
dll load within the process and find this component when it tries to
create it? Thanks - Mike

Brian Muth

unread,
Oct 23, 2008, 3:54:18 PM10/23/08
to
Certainly. Your executable should call LoadLibrary("MyActiveControl.dll") and then call into the DllRegisterServer entry point using
GetProcAddress.

Brian

"mike" <mike...@hotmail.com> wrote in message news:3ed4f221-161a-4fe8...@v13g2000pro.googlegroups.com...

mike

unread,
Oct 23, 2008, 5:26:54 PM10/23/08
to
On Oct 23, 12:54 pm, "Brian Muth" <bm...@mvps.org> wrote:
> Certainly. Your executable should call LoadLibrary("MyActiveControl.dll") and then call into the DllRegisterServer entry point using
> GetProcAddress.
>
> Brian
>
> "mike" <mikebi...@hotmail.com> wrote in messagenews:3ed4f221-161a-4fe8...@v13g2000pro.googlegroups.com...

>
> I have a dll that provides decoding capabilities for WMP.  In order
> not to actually ship the dll and register it, I've created a static
> library version of the doc that has the DMO( COM object) in it.  I
> have an ATL based exe that hosts the WMP active control.  Within my
> exe, I’ve done the following:
>
>     CComObject<CMyDecoderDMO>* m_pDecoder;
>
>     ATLVERIFY(
>         SUCCEEDED(
>
> __objMap_CMyDecoderDMO.RegisterClassObject( CLSCTX_INPROC_SERVER,
> REGCLS_MULTI_SEPARATE )
>         )
>         );
>
>     m_pDecoder = NULL;
>     hr = CComObject<CMyDecoderDMO>::CreateInstance( &m_pDecoder );
>     if (FAILMSG(hr))
>         return 0;
>
> CMyDecoderDMO is linked statically into my exe.  Is it possible to
> register a component like this within a process and have an activex/
> dll load within the process and find this component when it tries to
> create it?  Thanks - Mike

Brian,
Thanks for the quick response. I'm trying to do this without shipping
the dll but it looks like I would have to do this in you solution. Is
this correct?
Mike

Roman Ryl...

unread,
Oct 23, 2008, 10:33:18 PM10/23/08
to
Hi,

DllRegisterServer will definitely register the DLL system wide. If you
make a call to RegisterClassObject for your DMO CLSID, what actually
is the problem for WMP control to find your object? Or maybe you have
made it available through its CLSID but it is still not listed as DMO
or under certain filter category?

If this is the case, I think you can make a call to DMORegister on
initialization of your process and DMOUnregister on its termination.
And also make it as a part of /regserver /unregserver registrations.
Being hosted by EXE, your COM class will not be instantiatable by
other processes as DMO (it makes only sense to have DMO in-process and
you also have control over this through RegisterClassObject
argument).

Roman

mike

unread,
Oct 24, 2008, 12:16:15 PM10/24/08
to

Roman,
Thanks for the response. I've added the DMORegister function and it
looks like all is updated correctly in the registry for the DMO.
However, I'm not sure I understand your next sentence about the "/
regserver /unregserver registrations". The current exe doesn't have
any com registration in it. Would this registration be similar to
what the dmo does? I created the dmo originally using ATL and the
class that handles the COM registration derives from CAtlDllModuleT.
thanks-Mike

Roman Ryl...

unread,
Oct 24, 2008, 1:07:05 PM10/24/08
to
Mike,

> > If this is the case, I think you can make a call to DMORegister on
> > initialization of your process and DMOUnregister on its termination.
> > And also make it as a part of /regserver /unregserver registrations.
> > Being hosted by EXE, your COM class will not be instantiatable by
> > other processes as DMO (it makes only sense to have DMO in-process and
> > you also have control over this through RegisterClassObject
> > argument).
>

> However, I'm not sure I understand your next sentence about the "/
> regserver /unregserver registrations".  The current exe doesn't have
> any com registration in it.  Would this registration be similar to
> what the dmo does?  I created the dmo originally using ATL and the
> class that handles the COM registration derives from CAtlDllModuleT.

Suppose you have DMORegister succeded and then your app crashed. Your
DMO registration will be still valid in registry before you restart
your app and close it gracefully. DMOUnregister in /unregserver could
be cleaning this if the app is being uninstalled... So it is not
critical, just a tiny sanity issue. The main part worked for you.

Roman

mike

unread,
Oct 24, 2008, 1:41:32 PM10/24/08
to

I’m obviously not doing something right and missing some points;-)
I’ve registered the DMO as mentioned in the original post and I’ve
called the DMORegister function. However, I’ve done this by coping
and pasting from the dmo source into my windows application source.
If I register the dmo dll and run my windows application and open an
avi encoded with our codec, it plays. If I unregister the dll and run
the windows application with the code mentioned above to register and
the DMORegister, the same scenario the application crashes stating an
“Invalid handle was specified”.

Mike

Roman Ryl...

unread,
Oct 24, 2008, 3:42:49 PM10/24/08
to
Mike,

> I’m obviously not doing something right  and missing some points;-)
> I’ve registered the DMO as mentioned in the original post and I’ve
> called the DMORegister function.  However, I’ve done this by coping
> and pasting from the dmo source into my windows application source.
> If I register the dmo dll and run my windows application and open an
> avi encoded with our codec, it plays.  If I unregister the dll and run
> the windows application with the code mentioned above to register and
> the DMORegister, the same scenario the application crashes stating an
> “Invalid handle was specified”.

There may be a number of causes but note that you have your CLSID
registered, maybe typelibrary too and additionally DMORegister
registration. Maybe you are unregistering partially and have something
registered as DLL, and something as EXE. Anyway if you have a crash or
exception, post your call stack here to show where exactly it stops
at. You might also want to have different CLSIDs for DLL and EXE, at
least while troublshooting.

Roman

mike

unread,
Oct 24, 2008, 5:44:08 PM10/24/08
to

I've gone through the registry and there does not appear to be any
entries for the dmo dll. Would the exe ever show up in the registry?
I do not have any COM registration in the exe as it started as a
windows app out of the 6.1 sdk samples (wmphost). I got this to work
in the past when I was hosting an dmo in a dshow graph (you helped me
to get this to work too;-) with the same approach. I've trying to
monitor the exe under procmon and to see if I can tell what is
failing. There is not a usable call stack that i can tell.
thanks-Mike

mike

unread,
Oct 24, 2008, 6:51:47 PM10/24/08
to

When I view the exe in procmon, it appears that the query for reg
entries pertaining to the DMO in the mediaobject key is found.
However, it seems that wmp is looking in the reg for the same classid
for the com object to load. The result is:

203405 3:32:33.5117559 PM wmphost.exe 19608 RegOpenKey HKCU\Software
\Classes\CLSID\{C55F312F-7B9F-4EFA-B8BE-CD35D8F21E5D} NAME NOT FOUND
Desired Access: Read

I thought that this call:

ATLVERIFY(
SUCCEEDED(

__objMap_CSILKDecoderDMO.RegisterClassObject( CLSCTX_INPROC_SERVER,
REGCLS_MULTI_SEPARATE )
)
);

would allow the wmp activex control to find the dmo call within my
exe. Is this not correct?

I appreciate the help!

Mike

Roman Ryl...

unread,
Oct 25, 2008, 11:04:48 AM10/25/08
to
Mike,

> When I view the exe in procmon, it appears that the query for reg
> entries pertaining to the DMO in the mediaobject key is found.
> However, it seems that wmp is looking in the reg for the same classid
> for the com object to load.  The result is:
>
> 203405  3:32:33.5117559 PM      wmphost.exe     19608   RegOpenKey      HKCU\Software
> \Classes\CLSID\{C55F312F-7B9F-4EFA-B8BE-CD35D8F21E5D}   NAME NOT FOUND
> Desired Access: Read
>
> I thought that this call:
>
>     ATLVERIFY(
>         SUCCEEDED(
>
> __objMap_CSILKDecoderDMO.RegisterClassObject( CLSCTX_INPROC_SERVER,
> REGCLS_MULTI_SEPARATE )
>         )
>         );
>
> would allow the wmp activex control to find the dmo call within my
> exe.  Is this not correct?

Talking about __objMap_CSILKDecoderDMO, are you referring to another
thread in microsoft.public.win32.programmer.directx.video about how to
ship your DMO and make sure you are the only whom it is available?
http://groups.google.com/group/microsoft.public.win32.programmer.directx.video/browse_thread/thread/c50857317a54b2a/aa827bb9fabfc75b

You are correct, __objMap_CSILKDecoderDMO.RegisterClassObject is to
eliminate the need in having COM registration in registry under the
mentioned key. To make sure, wmphost.exe is your app and
{C55F312F-7B9F-4EFA-B8BE-CD35D8F21E5D} = CSILKDecoderDMO's CLSID?

Are you sure RegisterClassObject succeeded and BTW additionally you
have to call it from MTA thread, which you might be not doing since
you have an EXE. If you are calling RegisterClassObject from "default"
EXE thread, it most likely belongs to STA apartment which might not
work for DMO if it is instantiated from MTA. Did you also check if
constructor of your DMO is ever called?

Roman

Roman Ryl...

unread,
Oct 25, 2008, 5:00:41 PM10/25/08
to
Mike,

This is how I expect it is going to work:

RegisterClassObject // Temporarily register private DMO
DMORegister // Enable DMIO Wrapper Filter to use our DMO
<open and render the file, create the graph, etc.>
DMOUnregister // No more needed

This way:

ATLENSURE_SUCCEEDED(__objMap_CPrivateMediaObject.RegisterClassObject(CLSCTX_INPROC_SERVER,
REGCLS_MULTI_SEPARATE));
DMO_PARTIAL_MEDIATYPE pInputMediaTypes[] = { { MEDIATYPE_Video,
CPrivateMediaObject::GetXxxxSubtype() } };
ATLENSURE_SUCCEEDED(DMORegister(L"Private DMO",
CLSID_PrivateMediaObject, DMOCATEGORY_VIDEO_DECODER, 0,
_countof(pInputMediaTypes), pInputMediaTypes, 0, NULL));
...
ATLVERIFY(SUCCEEDED(DMOUnregister(CLSID_PrivateMediaObject,
DMOCATEGORY_VIDEO_DECODER)));

You can check my code http://trac2.assembla.com/roatl-utilities/browser/trunk/PrivateDmoSample,
also http://alax.info/blog/674 and I expect it to work for you also.
This project takes FOURCC XXXX input video and outputs the same with
changed FOURCC to XVID. test.avi is there to play with. Not playable
originally it is playable through the application.

Note that without DMOUnregister your DMO will be still listed in
global DirectShow filter list even after termination of your
application.

Roman

Roman Ryl...

unread,
Oct 25, 2008, 5:01:56 PM10/25/08
to

Roman Ryl...

unread,
Oct 25, 2008, 5:16:28 PM10/25/08
to

mike

unread,
Oct 28, 2008, 1:12:47 PM10/28/08
to
On Oct 25, 8:04 am, "Roman Ryl..." <rylt...@gmail.com> wrote:
> Mike,
>
>
>
>
>
> > When I view the exe in procmon, it appears that the query for reg
> > entries pertaining to the DMO in the mediaobject key is found.
> > However, it seems that wmp is looking in the reg for the same classid
> > for the com object to load.  The result is:
>
> > 203405  3:32:33.5117559 PM      wmphost.exe     19608   RegOpenKey      HKCU\Software
> > \Classes\CLSID\{C55F312F-7B9F-4EFA-B8BE-CD35D8F21E5D}   NAME NOT FOUND
> > Desired Access: Read
>
> > I thought that this call:
>
> >     ATLVERIFY(
> >         SUCCEEDED(
>
> > __objMap_CSILKDecoderDMO.RegisterClassObject( CLSCTX_INPROC_SERVER,
> > REGCLS_MULTI_SEPARATE )
> >         )
> >         );
>
> > would allow the wmp activex control to find the dmo call within my
> > exe.  Is this not correct?
>
> Talking about __objMap_CSILKDecoderDMO, are you referring to another
> thread in microsoft.public.win32.programmer.directx.video about how to
> ship your DMO and make sure you are the only whom it is available?http://groups.google.com/group/microsoft.public.win32.programmer.dire...

>
> You are correct, __objMap_CSILKDecoderDMO.RegisterClassObject is to
> eliminate the need in having COM registration in registry under the
> mentioned key. To make sure, wmphost.exe is your app and
> {C55F312F-7B9F-4EFA-B8BE-CD35D8F21E5D} = CSILKDecoderDMO's CLSID?
>
> Are you sure RegisterClassObject succeeded and BTW additionally you
> have to call it from MTA thread, which you might be not doing since
> you have an EXE. If you are calling RegisterClassObject from "default"
> EXE thread, it most likely belongs to STA apartment which might not
> work for DMO if it is instantiated from MTA. Did you also check if
> constructor of your DMO is ever called?
>
> Roman- Hide quoted text -
>
> - Show quoted text -

Roman - Wow, thanks for all the help and detailed responses!
Yes, the link to directshow is a thread I had started and what I used
as a base for what I'm doing now. I was trying to do this on same
thread as exe so I've created another thread and CoInit as
COINIT_MULTITHREADED. If I just do the following:
RegisterClassObject
DMORegister

Then in my application, select a video file to play in the hosted WMP
Ax control, I get an invalid handle exception. The constructor of the
DMO is never executed. I've tried creating a global instance of the
DMO in my exe and creating it after registering DMO. Although I can
see the constructor being called, it still fails with the same
error.

When I was creating my own graph and hosting the DMO in it, I was able
to do this without any problems. It seems that WMP Ax control does
not find the dmo when registered as outlined here.

Thanks,

Mike

Roman Ryl...

unread,
Oct 28, 2008, 4:06:30 PM10/28/08
to
Mike,

> I was trying to do this on same
> thread as exe so I've created another thread and CoInit as
> COINIT_MULTITHREADED.  If I just do the following:
> RegisterClassObject
> DMORegister
>
> Then in my application, select a video file to play in the hosted WMP
> Ax control, I get an invalid handle exception.  The constructor of the
> DMO is never executed.

I think the problem was in RegisterClassObject on MTA thread. Later
you CoCreateInstance'd your class on STA thread and thus made
marshaling involved and it broke at that point.

Roman

0 new messages