views:

36

answers:

1

I'm writing a simple audio playback application, to save the codec fee, so we are using WMP ActiveX to play all music files, but it needs to create a window for ActiveX, and the thread of creating the ActiveX should have message loop. I would like to know if there is a way for WMP without ActiveX and Window? Thanks in advance.

A: 

Yes, you don't have to use the ActiveX control. Just use Project + Add Reference, Browse tab, select c:\windows\system32\wmp.dll

But you really do need a thread that is initialized with [STAThread] or Thread.SetApartmentState() and a message loop (Application.Run). Is is required for COM servers (like wmp.dll) that have a Single Threaded Apartment requirement. COM uses the message loop to marshal calls and generate events. Without a loop, the server will deadlock.

Hans Passant