开发者

How to use WMP engine without Window

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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜