When PPC is switched on automatically run .NET CF application

L

Lonifasiko

Hi all,

I'm working in a project with handicapped people and as you can
imagine, they are not able to browse through Windows explorer, find the
..exe file and click it in order the application to start.

Therefore, is it possible to automatically start a .NET CF application
when the PocketPC is switched on, without user interaction? How this
should be developed? Any examples, links?

Any information around this issue would be greatly appreciated. Thanks
very much.
 
P

Peter Foot [MVP]

You can register your app with the CeRunAppAtEvent (or
CeSetUserNotificationEx) to launch on the Wakeup event. From NETCF you can
use the OpenNETCF.Win32.Notify.Notify class which wraps these API calls
(www.opennetcf.org/sdf/), or take a look at the source and just pull out the
bits you need (http://vault.netcf.tv/ username: guest, password: guest)

Peter
 
L

Lonifasiko

Thanks both Sergey and Peter, I'll try both solutions.

Anyway, Sergey, the link you provided to the Goole post works but the
other link to OpenNETCF forum does not. I've searched OpenNETCF forums
but I do not find any result for the option of adding a key to
HKLM/Init. Could you please provide the correct link please?

Thanks very much.
 
L

Lonifasiko

I think you have not understood my previous post or my explanation was
not correct:

I know thanks to your post that Registry class from OpenNETCF has to be
used to access registry. In fact, I thougth the link you gave, was a
link with an example of what exact values I have to set in the registry
HKLM/Init section, not a link to explain the workarounds of this class.
I've been looking into my PPC registry but I don't know what key/value
pair I must add. Could be any name and the .exe filename as data. Don't
I need to specify any complete path for the .exe file?

Thanks again and sorry for the inconvenience.
 
P

Peter Foot [MVP]

The format of the init key is very particular - but before you use this I'd
advise some caution because launching managed applications in this way is
very prone to failure, we found that in order to get our app to consistently
run on every soft reset we needed a native exe which would delay launching
the managed application until the shell was fully initialised - it appears
to be a particular problem on phone edition devices where initialisation of
the phone makes the shell very unresponsive for up to 20 seconds or so.
Another way of launching an app is to place a shortcut (or the native
launcher app itself) in the \Windows\Startup folder (the same caveat
applies)

But back to your original request, do I understand that you want your app
initialised every time you wake up the device from sleep state (power button
on the device). If so the Registry init, or \Windows\Startup method is not
enough because these only start the app when the device is soft reset. If
you want to also bring the app to the foreground when the device is woken up
you'll need to use the CeRunAppOnEvent or equivalent also.

Peter
 
L

Lonifasiko

Thanks for your help Peter, I was looking for that kind on information.

I've done a little example with creating a shortcut on windows/startup
folder, but as you cleverly have told me, this only launches the
application during a soft reset. That's not my case.

I also need to bring the app to the foreground when the device is woken
up, so following your expert advice, I'll take a deep look at
CeRunAppOnEvent?

Another related question: Therefore, when I press on/off button, the
PPC it's not switched on/off, it only gets asleep/wakes up. I did not
know that !!! So it's consuming battery.

And consequently, what is the normal behaviour, or the better action:
to press on/off button or make a soft reset everytime I want to "close"
or "switch off" the PPC?

Thanks very much for the aclaration Peter. Regards.
 
P

Peter Foot [MVP]

When the device is suspended it consumes only a very small level of power,
this is necessary to maintain the contents of memory both for ram storage
and any apps you may have running which are suspended. Therefore if you
totally shut down the device it would be like a complete reset to factory
defaults every time - that means reinstalling all your software and
settings, not a desirable task to carry out regularly. This is in contrast
to the Smartphone which does have a true power off mode, with Windows Mobile
5.0 devices are moving towards persistent storage so it's likely that in a
future generation of Windows Mobile, Pocket PC devices use the same power
model and really power down.

Peter
 
L

Lonifasiko

Thanks again for the aclaration Peter.

Do you know any good example of using "CeRunAppOnEvent" event? Alex
Feinman's example is quite complicated to follow although it works
pretty well.

Appart from registering the extern CeRunAppOnEvent function in your
code, when do we have to call it, how, or it is called automatically?
Where can I put code to execute after PPC is switched on?

I have this in my code, but VS-NET does not like "event" keyword:

const int Wakeup = 0x000b;
[DllImport("coredll", EntryPoint="CeRunAppAtEvent", SetLastError=true)]

private static extern bool CeRunAppAtEvent(string appName, int event);

Do I have to code my own event to handle the notification? Any code
snipplet will be greatly appreciated on this issue.

Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top