{"id":211,"date":"2007-11-20T01:51:46","date_gmt":"2007-11-20T01:51:46","guid":{"rendered":"http:\/\/dalelane.co.uk\/blog\/?p=211"},"modified":"2007-11-20T01:51:46","modified_gmt":"2007-11-20T01:51:46","slug":"registering-file-extensions-with-windows-mobile-apps","status":"publish","type":"post","link":"https:\/\/dalelane.co.uk\/blog\/?p=211","title":{"rendered":"Registering file extensions with Windows Mobile apps"},"content":{"rendered":"<p>I took a break from playing with the <a href=\"http:\/\/code.google.com\/android\/\" target=\"_blank\">Android SDK<\/a> for the first time tonight by making a quick update to my <a href=\"http:\/\/dalelane.co.uk\/page.php?id=40\">Windows Mobile notepad<\/a> app. <\/p>\n<p>Previously, to open files I&#8217;ve had to launch the notepad, then use File -> Open and choose my file. I wanted to register the <code>.txt<\/code> file extension with the notepad app, so that I can open files in the notepad by clicking on them. It&#8217;s a fairly straightforward thing to do, but I thought it might be helpful to share.<\/p>\n<p>I couldn&#8217;t find much information about it, but it&#8217;s fairly simple to work out if you use Visual Studio&#8217;s <a href=\"http:\/\/msdn2.microsoft.com\/en-us\/library\/ms894590.aspx\">Remote Registry Editor<\/a> to see how other apps do it. <\/p>\n<p><!--more-->In short, you have to get your CAB installer file to write some entries to the HKEY_CLASSES_ROOT subtree of the registry. There are two bits: the first is a key that identifies the file extension in question and associates it with the second &#8211; a key that describes it, and how to open it. <\/p>\n<p>I&#8217;m assuming you already know how to create an installer CAB file and that you&#8217;re using Visual Studio 2005 (or something similar). Here is how you add the ability to register a custom file extension.<\/p>\n<p>Right-click on the Installer &#8216;Smart Device Deployment&#8217; project in the &#8216;Solution Explorer&#8217;, and click on &#8216;View&#8217; -> &#8216;Registry&#8217;.<\/p>\n<p>Right-click on HKEY_CLASSES_ROOT, and add a new key. Rename the new key to <code>.xxx<\/code> (where xxx is your new file extension)<\/p>\n<p>Right-click on the new .xxx key, and add a new string value. Delete the string value&#8217;s name (so that is named <code>(Default)<\/code>). Set the value to <code>xxxfile<\/code><\/p>\n<p>Right-click on HKEY_CLASSES_ROOT, and add a new key. Rename the new key to <code>xxxfile<\/code><\/p>\n<p>Keep adding new keys to build the following subtree:<\/p>\n<pre><code>\r\n+--- xxxfile\r\n       |\r\n       +--- Shell\r\n              |\r\n              +--- Open\r\n              |       |\r\n              |       +--- Command\r\n              |\r\n              +--- OpenDoc\r\n                      |\r\n                      +--- Command              \r\n<\/code><\/pre>\n<p>Add new <code>(Default)<\/code> string values to the two &#8216;Command&#8217; keys. <\/p>\n<p>For HKCR\\xxxfile\\Shell\\Open\\Command set the string value to<br \/>\n<code>\"\"%InstallDir%\\YourApp.exe\"\" \"\"%%1\"\"<\/code><br \/>\n(<em>including all the double-quotes<\/em>)<\/p>\n<p>For HKCR\\xxxfile\\Shell\\OpenDoc\\Command set the string value to<br \/>\n<code>\"\"%InstallDir%\\YourApp.exe\"\" -opendoc \"\"%%1\"\"<\/code><br \/>\n(<em>including all the double-quotes<\/em>)<\/p>\n<p>That&#8217;s it. \ud83d\ude42<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I took a break from playing with the Android SDK for the first time tonight by making a quick update to my Windows Mobile notepad app. Previously, to open files I&#8217;ve had to launch the notepad, then use File -> Open and choose my file. I wanted to register the .txt file extension with the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[20,26,25,21,23,24,27,22,19],"class_list":["post-211","post","type-post","status-publish","format-standard","hentry","category-code","tag-net","tag-cab","tag-deployment","tag-dotnet","tag-file-extension","tag-install","tag-registry","tag-visual-studio","tag-windows-mobile"],"_links":{"self":[{"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/posts\/211","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=211"}],"version-history":[{"count":0,"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/posts\/211\/revisions"}],"wp:attachment":[{"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=211"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=211"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=211"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}