views:

238

answers:

1

Hi

How can I detect that application was automatically started (auto-start when device turned on) or user has started it manually (from Programs etc)?

Thanks

+2  A: 

Quick hint: You can use Arguments to distinguish between both, and put those arguments in the shortcut.
check Command Line Argument to know how to use arguments, and in the shortcut write

path\executable.exe autostart

for the shortcut in startup folder, after that in your application check this...

EDIT1: the path in windows mobile start from \ this is the root, now to get the startup folder you can write:

\widnows\startup

and the complete path will be

\widnows\startup\executable.exe autostart

Edit2: Open the setup project, right click on "file system and target machine, then "Add Special Folder" then choose "startup Folder", after that put your shortcut with arguments there...

Edit3:

you are right, there is no place to put arguments, so we should create the shortcut manually:

1- create text file and change the extension to be lnk

2- edit the file by drag& drop it to notepad, and write inside it the following line:

43#"\widnows\startup\executable.exe autostart"

3- take care about the first number, it's the character count after the #, if you change the path so you should recalculate the character count again and put it in the first. 4- add this file to the start up folder in VS....

Wael Dalloul
Where can I specify this. When I created installer for application, I am telling installer to make this application auto-start. As in windows, we specify in "Environment Variables", how can I add arguments to my application in Windows-Mobile 6.1?
ZHS
I don't see any option to put shortcut with arguments. How can I specify that to run this shortcut with such such arguments?
ZHS
Thanks! it works in that way! at the same time I found same solution at: http://www.johandekoning.nl/index.php/2008/08/04/command-line-arguments-windows-mobile/
ZHS
Wael, a small correction in your code that is; argument 'autostart' will come outside quotations, so it will become like this:43#"\widnows\startup\executable.exe" autostart
ZHS