Hello, habra-community!
Small lyrical digression
On this wonderful day, all those who are not indifferent to such words as development, code, compilation and debugging, those who are currently typing their anniversary 100 million line of code and those who have successfully compiled and launched the first Hello, World! I want to congratulate you on your professional holiday. I wish you fewer bugs, fast compilers, mutual understanding with the debugger and most importantly, that there should be a number of people able to appreciate your work!
And now - let's start
Recently, I started writing my application under
WMC .
Translation and quoting SDK is boring and not interesting.
Therefore, today I will describe step by step the creation of a simple plug-in.
Let's try to write a simple analog clock.
')
What do we need?
- Windows with MediaCenter installed (I'm using Windows 7 ultimate rtm)
- Microsoft Visual Studio (I will give examples for version 2008)
- Microsoft MediaCenter SDK (Hereinafter we focus on version 6.0)
Installation
Download the SDK
at this address .
The SDK is installed after installing Visual Studio.
The examples included in the development kit are located in the% Program Files% \ Microsoft SDKs \ Windows Media Center \ v6.0 \ Samples folder.
Create a simple empty application template
Launch Visual Studio.
File -> Create -> Project -> New Project
If the installation and integration of the SDK was successful, then you can easily find the Windows Media Center branch in the type tree.
I chose C # as the development language.
Select the template Windows Media Center Application - Fundamental.
We give our project a name, for example habraClock.
Click OK.
What is in front of us?
I think that the Visual Studio interface should not be separately described, we all are very familiar with it.
Let's better see what we see in the solution browser.
In the Code folder is the Launch.cs file. This file describes our class MyAddIn, inheriting the interfaces IAddInModule, IAddInEntryPoint.
The Launch procedure implements the IAddInEntryPoint interface member and is the entry point. This is what is called when launching our application in Media Center.
The basic navigation objects of WMC are pages described in the xml-based markup language
MCML .
The only thing that the Launch procedure will do in our example is to navigate to the Default page described in the Markup folder's Default.mcml file.
Also important for us are DevInstall.cmd files in the project bark and Registration.xml in the Setup folder.
DevInstall.cmd is needed to register our build in the system. Without performing this action, we will not see anything new in WMC applications.
To register our plugin, you need to run the command prompt in administrator mode, go to the project folder, and run there
DevInstall.cmd / debug
The / debug switch is added if the debug build configuration. If the Release configuration is going to be, then the key is not needed.
Another startup option is / u. The key is used to remove information about our plugin from the system.
In order not to suffer with a large number of open windows, I do this - in the project properties on the “Build Events” tab, I add automatic assembly registration to the event after build. Accordingly, Visual Studio runs in administrator mode.
Sign the assembly
In order for the plugin to run in WMC, it must be signed.
In the project properties, go to the “Signing” tab, check the “Sign the build” box and select the snk file with your signature.
If you do not already have such a file, then create it by selecting the "Create" item from the drop-down list.
Putting the project (F6).
Run the command line to get the assembly's public key token. In the command line we execute
% Program Files% \ Microsoft SDKs \ Windows \ v6.0A \ Bin \ sn.exe -T [path to our project] \ Bin \ Debug \ habraClock.dll
At the output we get a string of the form
Public key token: 597ac92eb14461f4
Open the Registration.xml file in the Setup folder and change there
PublicKeyToken = insert_public_key_token_here to
PublicKeyToken = 597ac92eb14461f4
We build the project, install DevInstall'om (unless, of course, you have not registered the automatic installation of my recipe).
We admire the results of our work
Launch Media Center.
If we did everything correctly, then on the page "Applications" we will see, among others, our habraClock.
After its launch, the contents of the Default.mcml file will appear on the screen, namely, the string with the text Hello.
Conclusion
Today we learned how to create, sign and register an application for Windows Media Center.
At this point I want to finish the first part of the article.
And, while I am engaged in its continuation - a small homework.
Since I myself am not a designer at all - think up and change the standard image of the application for something more sane and associated with the habr.
Waiting for your suggestions, suggestions, critics.
2009
lnking . Any use of materials of this article outside the Habr is permitted with the obligatory indication of the source.