Click to Rate and Give Feedback
MSDN
MSDN Library
Programming Guide
 Identifying Windows Media Center Ve...

  Switch on low bandwidth view
Identifying Windows Media Center Versions

Windows Media Center Presentation Layer Applications

If you are creating a setup package for a Windows Media Center application, you should detect the presence of Windows Media Center before allowing installation of your application. In addition, if your application has a dependency on a specific version of Windows Media Center, your setup package should also detect the presence of that specific version and block installation if it is not installed. You can detect the presence and version of Windows Media Center by looking at the following registry key:

Key: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Media Center

Registry value name: Ident

Registry value data type: REG_SZ

The Ident value indicates the version of Windows Media Center that is present on the computer:

Windows Media Center Version Ident value
Windows XP Media Center Edition 2002 < 2.7
Windows XP Media Center Edition 2004 2.7 or 2.8
Windows XP Media Center Edition 2005 (incorporating Windows XP SP2) 3.0
Update Rollup 1 for Windows XP Media Center Edition 2005 3.1
Update Rollup 2 for Windows XP Media Center Edition 2005 4.0
Windows Media Center in Windows Vista 5.0

Hosted HTML Applications

Web developers can test for the presence of the MediaCenter object and its properties in their HTML pages to establish whether the page is running inside of Windows Media Center rather than in a separate browser. Subsequent HTML pages can then vary the content they present based on the browser's capabilities.

The following JavaScript function detects the version of Windows Media Center the user is running, returning NULL if the page is running in a separate Web browser outside of Windows Media Center:

// This function detects which version of Windows Media Center the user is running and returns a string.
function showMCEVersion()
{
    // Create a variable for the version.
    var sVersion;
    try
    {
        // Find major and minor versions.
        var nMajVer = window.external.MediaCenter.MajorVersion;
        var nMinVer = window.external.MediaCenter.MinorVersion;
    }
    catch (e)
    {
        return null;
    }
    // Set the return string according to major and minor versions.
    if (nMajVer < 7) sVersion = "2004";
    if (nMajVer == 7 && nMinVer < 5) sVersion = "2005";
    if (nMajVer == 7 && nMinVer == 5) sVersion = "Update Rollup 2";
    if (nMajVer > 7) sVersion = "Vista";
    // Return the correct string.
    return sVersion;
    // If the process above fails, return null.
    return null;
}

From the server, developers can use the "HTTP_USER_AGENT" server variable to identify the version of the Web browser on which the HTML pages run. From an ASP or ASP.NET page, the following line of server-side code produces the User Agent string for the Web browser, from which the necessary information can be parsed:

<%= Request.ServerVariables("HTTP_USER_AGENT") %>

The following table shows the different substrings that appear in the User Agent string for different versions of the Web browser and operating system:

Operating System Internet Explorer Windows Media Center Shell
Windows XP Media Center Edition 2004 (incorporating Windows XP SP1) none MediaCenter 5.1.2600.2096
Windows XP Media Center Edition 2004 (upgraded to Windows XP SP2) Media Center PC 2.8 Media Center PC 2.8
MediaCenter 5.1.2600.2180
Windows XP Media Center Edition 2005 (incorporating Windows XP SP2) Media Center PC 3.0 Media Center PC 3.0
MediaCenter 5.1.2700.2180
Update Rollup 2 for Windows XP Media Center Edition 2005 Media Center PC 4.0 Media Center PC 4.0
MediaCenter 5.1.2710.2732
Windows Vista Ultimate, Windows Vista Home Premium Media Center PC 5.0 Media Center PC 5.0;
MediaCenter 6.0.5505.0

The following example shows the value of the HTTP_USER_AGENT server variable maintained by Windows XP Media Center Edition 2005:

Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; Media Center PC 3.0; .NET CLR 1.0.3705; MediaCenter 5.1.2600.2180)

The following example shows the value of the HTTP_USER_AGENT server variable maintained by Windows Vista:

Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; MediaCenter 6.0.5505.0)

See Also

© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker