Friday Fun: Automating Windows Media Player from .NETCF

Windows Media Player for Pocket PC (and Smartphone) doesn’t have a true object model like it’s desktop cousin, so the ability to use it from your own code is limited. However there is an undocumented method of sending commands to Windows Media Player via a specific series of Windows Messages. These are actually hidden away in the Registry under the curiously named section “Pendant Bus”.

Therefore I put together a simple dll which creates an instance of Media Player if one is not already running, and sends messages to it, to allow you to play, pause, move back and forward through the playlist or adjust the volume. The code requires the Smart Device Framework which is used to P/Invoke a couple of Windows methods e.g. SendMessage. A typical method looks like:-

/// <summary>

/// Skips to the next track in the playlist.
/// </summary>
public void NextTrack()
Win32Window.SendMessage(hwnd, 32972, IntPtr.Zero, 0);


There are some limitations in the code I’ve posted here – it doesn’t start the player with a specific file queued up (this would require a very simple overload to the constructor).

There are currently no events and it is not possible to get information back from the player such as track name, elapsed time etc. I’m still investigating whether such information is output in any way which can be captured. This code should work with all Windows Mobile 2003 devices (inc Smartphone) and possibly earlier Pocket PCs but these have not been tested yet.

Download the full code project with Pocket PC sample application here.

By Peter Foot

Microsoft Windows Development MVP

5 replies on “Friday Fun: Automating Windows Media Player from .NETCF”

You can do both in the same way since Media Player enforces a single application instance – if you call wmplayer.exe with your filename as an argument it will either launch Media Player or open the file in the currently open instance.
You can either use CreateProcess or ShellExecuteEx P/Invokes or use the Process class in the Smart Device Framework


Thanks very much for the sample code . i was trying to get this type of sample for quite some time . Just one query if you happned to read this :

1. How do start the media player with preselected file ?
2. if the media player is already started , how do i provide it with the file to be played ?

Thanks ,

I’d very much like to work with MP10M also, unfortunately I don’t have a device with media player 10 and there is no emulator image with it either to test on.
I asked on a recent chat how this could be done, apparently it implements a subset of the desktop object model which is COM based. The online documentation at least doesn’t clearly indicate what is supported in the mobile version. I believe it supports IWMPPluginUI so you can write a plugin which will be given a pointer to the players IWMPCore interface from which you can automate it. One key differentiater from the desktop is that these plugins cannot be UI plugins. Developing for WMP10M would currently require using the headers from the desktop WMP10 SDK within a device project. Hopefully Orange will release a WMP10M update for the SPV C500 so I can investigate this further…

I’ve been searching (so far, in vain) for a way to control WMP10m programatically. I hear that it has an object model, but even doing it as has been done above (I assume this is for version 9 rather than 10 – it doesn’t work for me anyway) would be OK.

Ideally I want to control it from a .NETCF application, but I can’t even find a C++ source yet!

Any ideas?

Thank for the sample code, this is something that I have been looking for. Now I manage to open the application with my application but I am having a problem.

Currently, my application is supposed to open up an ip address that is supposed to be performing some live streaming via http. How am I suppose to code such that the file that open is actually an URL link.

Thank you.

Comments are closed.