Sorry for the cross post, but I noticed this thread after posting my
question in another newsgroup. I figured it's on topic here, so I'm posting
it here too.
When I call WaitForNotificationEvent(NOTIFICATION_EVENT_TIME_CHANGE) or
WaitForNotificationEvent(NOTIFICATION_EVENT_TZ_CHANGE) in the code below,
Then open control panel and change the system time or time zone, the named
event never signals. I wait forever at the WaitForSingleObject() line. Is
there something else I need to do differently with CeRunAppAtEvent? Does the
control panel applet somehow change the time or timezone without this
notification?
I noticed that the CE.NET 4.2 docs on CeRunAppAtEvent at
http://msdn.microsoft.com/library/d...y/en-us/wceui40/html/cerefcerunappatevent.asp
say that pwszAppName can refer to a named event, and that named events are
supported in CE.NET 4.0 and later, but I'm wondering if the functionality of
having CeRunAppAtEvent signal a named event is new in CE.NET 4.2, or if it's
also supported in 4.1. I don't see this functionality described in the
CeRunAppAtEvent docs for 4.1. Does anyone have any experience with using
CeRunAppAtEvent this way? I tried having it run an executable too, but no
better luck.
[DllImport("coredll.dll", EntryPoint="CeRunAppAtEvent", SetLastError=true)]
private static extern int CeRunAppAtEvent(string pwszAppName,
NOTIFICATION_EVENT lWhichEvent);
public enum NOTIFICATION_EVENT : int
{
NOTIFICATION_EVENT_NONE = 0,
NOTIFICATION_EVENT_TIME_CHANGE = 1,
NOTIFICATION_EVENT_SYNC_END = 2,
NOTIFICATION_EVENT_ON_AC_POWER = 3,
NOTIFICATION_EVENT_OFF_AC_POWER = 4,
NOTIFICATION_EVENT_NET_CONNECT = 5,
NOTIFICATION_EVENT_NET_DISCONNECT = 6,
NOTIFICATION_EVENT_DEVICE_CHANGE = 7,
NOTIFICATION_EVENT_IR_DISCOVERED = 8,
NOTIFICATION_EVENT_RS232_DETECTED = 9,
NOTIFICATION_EVENT_RESTORE_END = 10,
NOTIFICATION_EVENT_WAKEUP = 11,
NOTIFICATION_EVENT_TZ_CHANGE = 12,
NOTIFICATION_EVENT_MACHINE_NAME_CHANGE = 13
}
private void WaitForNotificationEvent(NOTIFICATION_EVENT notificationEvent)
string szEventName = "\\\\.\\Notifications\\NamedEvents\\" +
notificationEvent.ToString() + "\0";
hEvent = CreateEvent(IntPtr.Zero, 1, 0, szEventName);
if(0 != hEvent)
{
if(0 != CeRunAppAtEvent(szEventName, NotificationEvent))
{
WaitForSingleObject( hEvent, 0xFFFFFFFF );
Console.Writeline(notificationEvent.ToString());
ResetEvent(hEvent);
}
CloseHandle(hEvent);
hEvent = 0;
}
}
Thanks,
Dave
Jose Luis Balsera said:
Maybe you can use P/Invoke to call CeRunAppAtEvent and listen to the
NOTIFICATION_EVENT_TIME_CHANGE event to do your logging
Hope that helps
"Scott Johnson" <sjohnson_at_softaltern_dot_comDIESPAM> escribió en el
mensaje news:
[email protected]...