IgnoranceIsBliss continues his series on creating a Windows Media Center application using managed code (C#) and Media Center Markup Language (MCML). In his most recent post Stage 10 - Installing It he has the following to say about writing registry keys directly instead of using the Registration API:

1. Charlie, the Microsoft product director for Media Center extensibility (IE. the Media Center SDK) has informed me that MS won't guarantee that the method of registering plugins will remain the same. Of course, I then asked 'OK - then why do you TELL us to register them that way?' and there wasn't much of a response. I'm yet to see if this is still true in the newer version of the Media Center SDK.

2. If you run a 32 bit installation on a 64 bit version of Windows, your registry entries are placed in an entirely different tree. So the 64 bit version of Media Center can't actually see the keys you've created.. This means you MUST produce both a 64 and 32 bit version of your installer.

Microsoft themselves suggest you use WiX, which is an open source product of theirs that allows you to create installers - but since it's a complicated platform and I want to be able to take you through the basics without needing any additional software, I'm going to take you through the easy, but perhaps not officially supported method of adding registry keys directly.

In response...

A) The reason we provide an abstraction layer for the registry keys is simple: We can change the underlying methodologies for registering experiences without breaking the apps (or their installers). For example, suppose we change where Windows Media Center looks in the registry for applications. By writing registry keys yourself they may end up in a location we aren't polling -- and therefore the app won't appear. Using the API will always work even if we change things under the covers. Abstraction is good -- it helps you maintain forward compatibility.

B) There are a very few select OEM scenarios where writing the registry keys directly makes sense. Specifically, where you are using a single image for thousands of preinstalled machines. Outside of this specific scenario (i.e. if you aren't an OEM using this to prep machine images) there is no good reason to write the registry keys themselves, and to do so only increases the risk the installer will be possibly broken at some later date. I've even advised OEMs to use the Registration API during the preinstall phase rather than write registry keys.

C) We include writing the registry keys directly for those who are committed to only using a Visual Studio setup project. Effectively, the Windows Media Center Platform team does not recommend using the Visual Studio setup project because of it's inherent limitations (which are more than just this singular issue). As a bonus, using WiX also makes the installation solution accessible to folks using free tools (Visual C# 2005 Express Edition) as well.

D) WiX does carry a higher learning curve. Along with that comes much more granular control over the installer and, perhaps more importantly, a fundamental understand of what is happening when the user installs the application. FWIW, I personally found it difficult at first, but now that I've got a pretty good understanding of the pattern in the WXS file it's much more 'friendly' to me compared to a Visual Studio setup project -- which abstracts everything out too much in my opinion, and I'm not even a setup guru and love the abstraction to make it easier (just ask Aaron).

D) If you do follow IgnoranceIsBliss logic, just remember it's pretty unfriendly to force a user to figure out which installer to use (32 bit or 64 bit) -- especially given the actual library is identical for both (you don't need to compile for each in the context of a Windows Media Center application). Make it simple -- have a single installer. That means using the Registration API and WiX.

E) We revised this SDK documentation with the last release (see http://msdn2.microsoft.com/en-us/library/bb189827.aspx) which quickly vectors the reader back to 'use the Registration API'. We will make further clarifying changes in the future.

IgnoranceIsBliss has done a pretty good job of giving you a guide to creating a Windows Media Center application -- just make sure you use his documents as a supplement to the information in the Software Development Kit -- not in lieu of.

Charlie



Categories: SDK | Comments [3] | # | Posted on Monday, June 18, 2007 8:23:23 PM (GMT Daylight Time, UTC+01:00)   
Friday, June 22, 2007 9:11:20 PM (GMT Daylight Time, UTC+01:00)
Charlie,

In a recent Media Center application I worked on I used WiX for the installer (by your recommendation).

However I found the following challenge: I needed the application to find files installed with it in the install path, but as the application executable itself is installed and registered in the GAC and the path where the assembly loads from is the same as the Media Center Shell Application; there was no relationship whatsoever between the Assembly and the folder that the user chose at installing time.

I tried to find a place in the registry where I could find the install path for my application and found the following:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Media Center\Extensibility\Entry Points\[AppEntryPoint]\ImageUrl

As you mention in your post this is not a forward compatible method and if anything on this path changes (or disappears) the application will no longer work.

So my question is, what method do you recommend for us to determine the path the application was installed? Does WiX provide a mechanism for the application to find where the user decided to install the application?
Saturday, June 23, 2007 5:41:01 AM (GMT Daylight Time, UTC+01:00)
Hi Marvin -- good to hear from you. Hope all is well.

Take a look at the Z sample application -- it has the solution you seek. Basically, the MSI writes a location to a registry key your application maintains (not a Microsoft registry key) and the application reads that registry key.

WXS:<RegistryValue Name="InstallLocation" Type="string" Value="[ZROOTDIRECTORY]"/>

Application.cs: string installLocation = Registry.GetValue(@"HKEY_LOCAL_MACHINE\Software\Microsoft\Z", @"InstallLocation", null) as string;

Generally speaking, you shouldn't read and write data in Program Files -- use ProgramData instead -- Z also demonstrates this as well...

ApplicationExperience.cs: protected const string DataDirectory = @"\ProgramData\Microsoft\Z\Data\";
Monday, July 02, 2007 10:00:28 PM (GMT Daylight Time, UTC+01:00)
Thanks, this info have been usefull for my first apps developed for Windows Media Center. Im starting using WiX and Registration Api, so this posts will be a nice source for me.

I don't know if this is the right place to ask questions, in that case, does exist any way to change de Windows Media Center Background Image? I can't change it... only the desktop wallpaper but i've been asked to do this...

In any case, this its a great place to learn WMCE stuff. Thank You for providing Us a contact space!!

Greetz!!!
Comments are closed.
RSS
RSS 2.0
Search
Sign In | All Content © 2013 Charlie Owen

This is a personal weblog. The opinions expressed here represent my own and not those of my employer.


Powered by newtelligence dasBlog 2.3.9074.18820