views:

896

answers:

3

I am developing a mobile application for Windows Mobile. I would like that the application is lauched by default by the system at startup and that users cannot minimize it.

So only this application is available, all other features are disabled.

I m sure that I could define a launcher, which is executed at startup. But some problems come into my mind: could there be some memory optimizations ? I mean, because only one application is available and used, maybe some other programs could be disabled, which could allow less memory to be used ?

Do you have any links to this purpose ?

EDIT: Thanks for your answers. I read your links about the kiosk mode and found another very interesting post about this subject: this blog

It says that for kiosk mode applications, it seems to be better on the long run to use Windows CE instead of Windows mobile, because the former is easier to adapt to these needs.

+5  A: 

Might be able to post more useful stuff later on, but for now I can tell you the term you want to search Google for is: "kiosk mode".

Update - Useful stuff (hopefully)

Now to be frank any kiosk mode is more or less a hack. Windows Mobile isn't designed for it and as you get into more and more edge cases you are going to find the odd gap, however for the purpose of most programs the following is sufficient:


Task 1 - Cover the UI and the taskbar so that it can't be accessed:

On your main form set the WindowState to Maximized and FormBorderStyle to None. On older OSes you might need to actually disable the taskbar itself and move the form over the top of it. This is achieved by PInvoking:

FindWindow with the argument "HHTaskBar" (this may depend on platform, HHTaskbar works for Pocket PC 2003) and String.Empty

[DllImport("coredll.dll", EntryPoint="FindWindowW", SetLastError=true)]
private static extern IntPtr FindWindowCE(string lpClassName, string lpWindowName);

EnableWindow with the IntPtr from FindWindow and false

[DllImport("coredll.dll", SetLastError=true)]
public static extern bool EnableWindow(IntPtr hWnd, bool bEnable);

ShowWindow with the IntPtr from FindWindow and 0 (SW_HIDE)

[DllImport("coredll.dll")]
public static extern bool ShowWindow( IntPtr hwnd, int nCmdShow);


Task 2 - Prevent hard-wired app keys.

You know the ones, press orange and left button and it will automatically open Pocket Outlook. To do this I'm going to break rank here and recommend the only viable way I know of doing this which is to use an undocumented Win32 API call. It's a perfectly stable call and I have a range of projects running every day that use it I just figure in some future upgrade I might need to modify the code if it gets removed, so bear that in mind.

You'll want to setup a low-level system wide keyboard hook via the PInvoke call:

[DllImport("coredll.dll")]
private static extern IntPtr SetWindowsHookEx(int idHook, HookHandlerDelegate lpfn, IntPtr hMod, uint dwThreadId);

This is reasonably complex and its probably better just to point to a guide like this one to explain the theory. The basic premise is to discover the keycode of the irritating "special keys" and then block them via the hook (i.e. don't pass them on).

If you're working on CF I suggest also digging into OpenNETCF as I believe it already has a global KeyHook inside it.

As I said before this isn't perfect and IIRC the volume control is not blockable and its possible that a notification such as a new wireless network might intrude upon your kiosk mode if you don't set various flags in the registry (to tell it not to do that :) ).

Still, it's not that much effort and it should be sufficient for most of your apps.


Task 3 - Make your app run from start up

This is the bit that can differ a fair bit depending on the device. If you want to stay in managed code the issue is that the NETCF doesn't come pre-installed on some devices. In most cases you can just write an unmanaged booter that sits in the autorun directory (there should be one, check the manufacturer's docs), and installs .NETCF, your app(s) and then runs your app(s). If you don't want to get your hands dirty with unmanaged code then most hardware manufacturers offer some kind of scripting system to setup a device as you see fit. However these may work with varying degrees of effectiveness.

Quibblesome
+1 for thorough coverage. Minor correction - you said in your update that Windows CE isn't designed for kiosk-mode. That's incorrect. *Windows Mobile* isn't, but Windows CE certainly can be made to be a kiosk - in fact it can be locked to one app or even no UI at all.
ctacke
+3  A: 

You want to run your device in "Kiosk Mode". Actually, Windows Mobile devices aren't intended to run in kiosk mode. If you can select the device you are going to use, select a Windows CE device, for which you can modify the image. Windows CE devices do have an option to run in a kiosk mode. This is the best solution, however you need Platform Builder and a device that an image can be downloaded to.

For a Windows Mobile, you can "simulate" kiosk mode. This is what you need to do:

  • Launch your application at start up.
  • Make your application full screen. The taskbar should be hidden.
  • Intercept hardware buttons that can navigate you away from your application
  • If other programs run on start up, disable them. Usually programs not launch on start up, so you shouldn't worry about this.

This article could be a starting point. I believe that it will be difficult or even impossible to implement a generic solution. Instead focus on a single device.

kgiannakakis
+1  A: 

Here is an article on CodeProject that talks about putting a device into Kiosk mode.

This is at least a starter for you, but be sure to notice the warnings listed in the article about what devices the sample will work on!

Mitchel Sellers