Algorithm for launching Windows Media Center and browsing to a specific experience
A while back, I posted an item on the Media Center Sandbox blog that described how to directly launch Windows Media Center and have it navigate to a specific experience using some command line parameters available within the Windows Media Center Shell application. Since then, several folks have asked me about those command line parameters and whether there were more.
The specific problem that most people noted was that the command line ehshell.exe /directmedia:tv navigates to the Recorded TV gallery and not to Live TV. Unfortunately, there is not a command line parameter that allows direct navigation to Live TV.
However, there is another mechanism that can be used to launch Windows Media Center and browse to a specific experience, including Live TV. I'm going to describe the algorithm in words here:
- Call the Win32 FindWindow API and pass in Media Center Tray Applet for the class name and NULL for the window name
- If the FindWindow API returns NULL, display an error and exit
- Call the Win32 RegisterWindowMessage API, pass in Media Center Navigate To Page and save the result
- Call the Win32 SendMessageTimeout API and pass in the window returned in step 2, the message registered in step 3, and as the WPARAM and LPARAM, the desired values from the tables listed below
- If the SendMessageTimeout API returns 0, the browse failed
WPARAM values to use for browsing
- WPARAM = 0: Windows Media Center Start Menu
- WPARAM = 1: Live TV
- WPARAM = 2: TV Guide
- WPARAM = 3: My TV
- WPARAM = 4: Recorded TV
- WPARAM = 5: My Music
- WPARAM = 6: My Photos
- WPARAM = 7: Scheduled Recordings
- WPARAM = 8: My Videos
- WPARAM = 9: Radio
- WPARAM = 12: Online Spotlight (this value is only availabe in Update Rollup 2 for Windows XP Media Center Edition 2005 and later)
- WPARAM = 13: Extensibility application (this value is only availabe in Update Rollup 2 for Windows XP Media Center Edition 2005 and later)
LPARAM values to use for browsing
- LPARAM = 0: Start Windows Media Center in the last used state (full-screen or windowed)
- LPARAM = 1: Start Windows Media Center full-screen
Notes:
This algorithm works regardless of whether the Windows Media Center UI is currently running. It also correctly handles bringing the Windows Media Center UI to the foreground. This is the only officially supported method of browsing to the Windows Media Center UI from an external application. This mechanism was first made available in Windows XP Media Center Edition 2004.
New values might be added to the WPARAM and LPARAM tables with new versions of Windows Media Center.
I've also created a sample Win32 application that implements the above algorithm. You can find more information about that sample application and download the source code and the executable from this blog post.
<update date="1/14/2009"> Added a link to the sample application that I created to demonstrate how to implement this algorithm. </update>
Comments
Anonymous
October 12, 2006
Wow, this is great. Thanks for sharing. How is WPARAM 13 used? I am assuming that somehow you should be able to pass an entry point guid to tell Media Center which extensibility application you want to launch?Anonymous
October 13, 2006
Hi Anpark - WPARAM 13 can be used to launch the first application registered in the "OEM Extensibility 1" category. To accomplish this when registering an application, you should include the following string in the registration XML file: <category category="OEM Extensibility 1"/>Anonymous
October 14, 2006
Question: I saw your previous post describing an algorithm for launching Windows Media Center and automaticallyAnonymous
October 15, 2006
A couple of weeks ago, I posted a description of an algorithm that can be used to launch Windows MediaAnonymous
August 21, 2008
PingBack from http://nutscracker.wordpress.com/2008/08/21/mediacenter-dvd-gallery-beim-start-direkt-anspringen/