File Associations in Deployment Projects
How do you create a file association using the Setup and Deployment project?
The desktop version has a File Types Editor, but we don't have that for smart devices.
I've been trying to put the required keys in with the Registry editor, but I get the following error in CabWiz.log:
Error: Line 185 - unsupported DirID 11
Error: Line 189 - unsupported DirID 11
Error: File c:\docume~1\andywi~1.cl1\locals~1\temp\wiz19a.inf contains DirIDs, which are not supported
I've tried to specify the path to the icon using %InstallDir%, and with a literal path, but no joy.
Please advise...
Hi Andy,
Could you send me a copy of your project? I'd love to take a look and see what's going on... If you can, please zip the project up and send it to bcham@microsoft.com. Thanks.
Update on this:
Thanks to Brian who looked into this.
For anyone else looking to do the same:
There are some problems with Visual Studio 2005 Beta 2, so this does not work in that build.
On later builds, create a file association for a Smart Device project by Bringing up the Registry editor window. Then add the following keys and values (the example sets up a file association for .xxx files):
HKEY_CLASSES_ROOT
|
+ .xxx (Default Value) xxxfile
|
+ xxxfile
|
+ DefaultIcon (Default Value) %InstallDir%\MyApp.exe, 0
|
+ Shell
|
+ Open
|
+ Command (Default value) ""%InstallDir%\MyApp.exe"" ""%%1""
Note: To create a (Default Value), right-click on a key you've created (for example "Command" and click New then String Value. In the Properties window, delete the value in the (Name) field, and put the string value in the Value field.
This example also sets the icon for all .xxx files to the same icon used for the program (that's what the %InstallDir%\MyApp.exe,0 means). If you want a different icon, that's a bit more complicated. I know one way of doing it which is too complex to explain here - email me at andyw@NO-SPAMMcontentmaster.com for details. I imagine you should be able to use the Project Properties pages to add an icon resource, give it a name such as "1", then the value in the DefaultIcon key becomes %InstallDir%\MyApp.exe,-1 (the '-' before the icon name is important)- but I haven't tried it. Please someone do so and post here!
Andy / Brian
Is it possible to show the code to do this ?
There is no code - just a procedure to do while in your VS deployment project (which creates the CAB file). In VS 2005, select View > Editor > Registry and you'll see the 4 main registry keys (HKLM, etc). Then add the subkeys and values shown above by right-clicking on each key, and adding subkeys/values.
Is this possible in VB2005 ?
Absolutely - the Smart Device Deployment project is a new feature in Visual Studio 2005. Deployment projects are language agnostic, so your question referring to VB2005 is off the mark - I guess you meant VS2005.
I've tried to make to registry keys as provided, but it doesn't work. I am using Visual Studio 2005, C# and I want to register the SVG files to be opened with a specific apllication. Can u tell me more about this. Maybe you have a .reg file?
I think I've managed to associate the file with the application. But now, when I click on a SVG file I get the message: "The file cannot be opened. Either it is not signet with a trusted certificate, or ..." I have turned off the security. If I stat the program manually, it works. I've also signed the cab file with the key provided for tests. Does anyone know what is wrong. Do I need to add more to the registry settings, or is it a security issue?
I had the same problem; be sure to add double quotation marks at the Open > Command key, like here ""%InstallDir%\app.exe"" ""%%1"". The previewer will actually show another two quotation marks (one at the beginning and one at the end), like """%InstallDir%\app.exe"" ""%%1""".
Hope it helped.
I have the same problem if I use the command key with double quotes or without no quotes. Either it is signed .... Could you send a copy of you registry keys?
None of my files are signed, and the association still works (when I click a file in the File Explorer, the app is launched).
I have not found a way to export my registry keys from the deployment project (it may be possible using the ccregedt.exe in the CE Remote Tool, but it would just show the installed reg keys).
So, I opened the cab that cabwiz generates and extracted the _setup.xml file. Inside (at the bottom), you'll find the registry sections:
Here are my registry keys; compare them with yours.
<characteristic type="Registry">
<characteristic type="HKCR\agrofile\Shell\Open\Command">
<parm name="" value=""%InstallDir%\AgroSense.Mobile.exe" "%1"" datatype="string" translation="install" />
</characteristic>
<characteristic type="HKCR\agrofile\DefaultIcon">
<parm name="" value="%InstallDir%\AgroSense.Mobile.exe, 0" datatype="string" translation="install" />
</characteristic>
<characteristic type="HKCR\.agro">
<parm name="Content type" value="application/agro" datatype="string" />
<parm name="" value="agrofile" datatype="string" />
</characteristic>
<characteristic type="HKCR\agrofile">
<parm name="" value="AgroSense Document" datatype="string" />
</characteristic>
</characteristic>
It works. Thanks.
In your application, when you click a file in File Explorer, how do you get the file path in your application. How do you know what file to process (by its path?)
Great! I have the following code in Program.cs:
[
MTAThread]static void Main(string[] args){
if ((args.Length > 0) && File.Exists(args[0]))Application.Run(new FormMain(args[0]));elseApplication.Run(new FormMain());}
Unfortunately, because the app is being kept in memory, it works only once. If I click a file in File Explorer the second time, the app is just brought forward. But, in case the app is launched for the first time, then it works 