I had an issue with a compact framework project where I needed to add a shortcut on the desktop that pointed to my application whose location was \Program Files\MyApplication\.
You need to create a .lnk text file and place it on the device's desktop. However, .lnk files are a bit tricky to use with Visual Studio 2008 because it thinks it is an actual shortcut to a file on your actual desktop machine.
Mike Hall has a blog article that further covers Windows CE shortcuts.
Here are my steps on how to overcome the .lnk issue when using a Smart Device CAB project from within Visual Studio 2008.
My application is called MyApplication.exe and it's full path, once installed on Windows CE, is \Program Files\MyApplication\MyApplication.exe
All my application does is show 'Hello World' in a label on the form.
My Windows CE installer project is called MyWindowsCEInstaller.
First I create the application and installer projects and added the project output of MyApplication to the MyWindowsCEInstaller project. Here is what my solution looks like so far:
Next step is to create the shortcut file that will eventually be placed on the device desktop. To do this I created a new text file within the MyApplication project called MyApplication.lnkx
It's 'Build Action' property should be set to None and 'Copy to Output Directory' property set to Do Not Copy.
It is a lot easier to work with the file having the extension as .lnkx so that Windows doesn't think it is an actual shortcut file.
The MyApplication.lnkx file will contain the command line text and the command line character count separated by a hash (#).
So my Windows CE application full path is \Program Files\MyApplication\MyApplication.exe making the character count 48, below is my MyApplication.lnkx file:
Note:- If the path contains a space it must be enclosed in quotes and they get included in the command character count!!!
Next step is to add our MyApplication.lnkx file to the correct folder in the MyWindowsCEInstaller project.
From the root of the Primary Output File System view of the MyWindowsCEInstaller project add the Windows Special Folder.
Under the Windows folder create a new folder called Desktop
Add the MyApplication.lnkx file to the newly created Desktop folder.
Next, select the MyApplication.lnkx file from the MyWindowsCEInstaller project and change the TargetName to be MyApplication.lnk
This will change the extension off the shortcut file on the target device to be .lnk while on the development machine it will stay as .lnkx
The final files should look like this:
Build the solution, copy the CAB file to the device, install it and now there should be desktop shortcut that points to the MyApplication application
Note that the shortcut will also use the application icon as it's image once this has been set in the application properties, here it is the default image.
Mike Hall Windows CE Shortcuts Blog Article