Programming Microsoft Windows Ce Net 3Rd [Electronic resources] نسخه متنی

اینجــــا یک کتابخانه دیجیتالی است

با بیش از 100000 منبع الکترونیکی رایگان به زبان فارسی ، عربی و انگلیسی

Programming Microsoft Windows Ce Net 3Rd [Electronic resources] - نسخه متنی

| نمايش فراداده ، افزودن یک نقد و بررسی
افزودن به کتابخانه شخصی
ارسال به دوستان
جستجو در متن کتاب
بیشتر
تنظیمات قلم

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

روز نیمروز شب
جستجو در لغت نامه
بیشتر
لیست موضوعات
توضیحات
افزودن یادداشت جدید






System Event Notifications

Sometimes, you might want an application to be automatically started. Windows CE supports a third type of notification, known as a system event notification. This notification starts an application when one of a set of system events occurs, such as after the system has completed synchronizing with its companion PC. To set a system event notification, you again use the omnibus CeSetUserNotificationEx function. This time, you specify the type of event you want to monitor in the dwEvent field of the notification trigger structure, as in

CE_NOTIFICATION_TRIGGER nt;
TCHAR szExeName[MAX_PATH];
TCHAR szArgs[128] = TEXT("This is my event notification string.");
memset (&nt, 0, sizeof (CE_NOTIFICATION_TRIGGER));
nt.dwSize = sizeof (CE_NOTIFICATION_TRIGGER);
nt.dwType = CNT_EVENT;
nt.dwEvent = dwMyEventFlags;
nt.lpszApplication = szExeName;
nt.lpszArguments = szArgs;
GetModuleFileName (hInst, szExeName, sizeof (szExeName));
CeSetUserNotificationEx (0, &nt, NULL);

The event flags are the following:



NOTIFICATION_EVENT_SYNC_END Notify when sync complete.



NOTIFICATION_EVENT_DEVICE_CHANGENotify when a device driver is loaded or unloaded.



NOTIFICATION_EVENT_RS232_DETECTEDNotify when an RS232 connection is detected.



NOTIFICATION_EVENT_TIME_CHANGE Notify when the system time is changed.



NOTIFICATION_EVENT_TZ_CHANGE Notify when time zone is changed[1]



NOTIFICATION_EVENT_RESTORE_END Notify when a device restore is complete.



NOTIFICATION_EVENT_WAKEUP Notify when a device wakes up.



For each of these events, the application is launched with a specific command line parameter indicating why the application was launched. In the case of a device change notification, the specified command line string is followed by either /ADD or /REMOVE and the name of the device being added or removed. For example, if the user inserts a modem card, the command line for the notification would look like this:

My event command line string /ADD COM3:

A number of additional system events are defined in Notify.h, but OEMs must provide support for these additional notifications and at this point few, if any, of the additional notification events are supported.

Once an application has registered for a system event notification, Windows CE will start or signal the application again if the event that caused the notification is repeated.

Clearing out system event notifications is best done with what might be thought of as an obsolete function, the old CeRunAppAtEvent function, prototyped as

BOOL CeRunAppAtEvent (TCHAR *pwszAppName, LONG lWhichEvent);

The parameters are the application to run and the event flag for the event of which you want to be notified. While the function has been superseded by CeSetUserNotificationEx, it does still have one use—clearing out all the system notifications for a specific application. If you pass your application name along with the flag NOTIFICATION_EVENT_NONE in the lWhichEvent parameter, Windows CE clears out all event notifications assigned to that application. While you would think you could pass the same flag to CeSetUserNotificationEx to clear out the events, it doesn't unless you pass the original handle returned by that function when you originally scheduled the notification.

[1] The NOTIFICATION_EVENT_TZ_CHANGE notification flag isn’t supported on some Pocket PCs.

/ 169