Microsoft KB Archive/217159

= INFO: Automatically Starting an Application Upon Flash Card Insertion =

Article ID: 217159

Article Last Modified on 12/17/2003

-

APPLIES TO


 * Microsoft Windows CE 3.0 for the Handheld PC Professional Edition
 * Microsoft Windows CE 2.0 for the Handheld PC
 * Microsoft Windows CE 2.0 for the Handheld PC
 * Microsoft Windows CE 1.0

-



This article was previously published under Q217159



SUMMARY
This article describes how to implement a simulation of the CD-based AutoRun executable so that when a flash card is inserted into the device an application associated with it will run automatically.



MORE INFORMATION
There are two methods that can be used to simulate AutoRun:

1. WM_DEVICECHANGE broadcast message.

-Insert the appropriate code to process this message and execute the desired application.

2. WinCE application notification system event.

-Use the CERunAppEvent function according to the following guidlines:

Syntax

BOOL CeRunAppAtEvent(TCHAR *pwszAppName, LONG lWhichEvent);

Parameters

pwszAppName

Pointer to a null-terminated string that specifies the name of the application to be started.

lWhichEvent

Event at which the application is to be started. This parameter can be one of the following values:

NOTIFICATION_EVENT_NONE

No events--remove all event registrations for this application.

NOTIFICATION_EVENT_SYNC_END

When data synchronization finishes.

NOTIFICATION_EVENT_DEVICE_CHANGE

When a PC Card device is changed.

NOTIFICATION_EVENT_RS232_DETECTED

When an RS232 connection is made.

NOTIFICATION_EVENT_TIME_CHANGE

When the system time is changed.

NOTIFICATION_EVENT_RESTORE_END

When a full device data restore completes.

Return Values

If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE.

Remarks

The application is started with a system-defined command line. If there was already an instance of the application running, the new instance must send a private message to the existing instance and then shut down. The command line, which corresponds to the registered event, can be one of the following string constants.

The string values in this table are processed as command line commands. In some cases, the part of the command line that follows the string is treated as a parameter.

Use the CeRunAppAtEvent function sparingly, because automatically starting an application can confuse the user and cause low-memory conditions on a machine with restricted memory. Ideally, the application should be small and non-intrusive.

The following constants are defined in the header file, but they are not supported:

NOTIFICATION_EVENT_ON_AC_POWER

NOTIFICATION_EVENT_OFF_AC_POWER

NOTIFICATION_EVENT_NET_CONNECT

NOTIFICATION_EVENT_NET_DISCONNECT

NOTIFICATION_EVENT_IR_DISCOVERED

When writing applications for Windows CE version 1.0, use the function PegRunAppAtEvent.

Additional query words: autorun flash cards device detection

Keywords: kbinfo KB217159

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.