开发者

How to use WMP engine without Window

开发者 https://www.devze.com 2022-12-18 16:04 出处:网络
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 th

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

精彩评论

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