WinCE7定时器通知
来源:互联网 发布:2017编程一小时 编辑:程序博客网 时间:2024/04/28 17:50
WinCE7定时器通知 by斜风细雨QQ:253786989 2012-01-01
如果想在某个时间点,自动运行一个指定的app,或者将某个event设置为有效状态,而又不需要用户掺和。那这个时候用“定时器通知”就比较适合了。
置“定时器通知”,同样使用CeSetUserNotificationEx函数。关于CeSetUserNotificationEx函数的使用参考“WinCE7用户通知”。
范例1:(定时运行NotificationApp.exe)
SYSTEMTIME st = {0};HANDLE hNotify;CE_NOTIFICATION_TRIGGER nt;TCHAR szExeName[MAX_PATH], szText[128];TCHAR szArgs[128] = TEXT("Timer notification.");GetLocalTime (&st);if (st.wMinute == 59) { st.wHour++; st.wMinute = 0;} else{ st.wMinute++;}memset (&nt, 0, sizeof (CE_NOTIFICATION_TRIGGER));nt.dwSize = sizeof (CE_NOTIFICATION_TRIGGER);nt.dwType = CNT_TIME;nt.lpszApplication = TEXT("NotificationApp.exe");nt.lpszArguments = szArgs;nt.stStartTime = st;// Set the notification.hNotify = CeSetUserNotificationEx (0, &nt, NULL);if (hNotify) { wsprintf (szText, TEXT ("Timer notification set for %d:%02d:%02d"), st.wHour, st.wMinute, st.wSecond);}else{ wsprintf (szText, TEXT ("Timer notification failed. rc = %d"), GetLastError());}MessageBox (szText, TEXT("置定时器通知"), MB_OK | MB_ICONINFORMATION);
范例2:(定时将某个事件设置为有信号状态)
SYSTEMTIME st = {0};HANDLE hNotify;CE_NOTIFICATION_TRIGGER nt;TCHAR szExeName[MAX_PATH], szText[128];TCHAR szArgs[128] = TEXT("Timer notification.");GetLocalTime (&st);if (st.wMinute == 59) { st.wHour++; st.wMinute = 0;} else{ st.wMinute++;}memset (&nt, 0, sizeof (CE_NOTIFICATION_TRIGGER));nt.dwSize = sizeof (CE_NOTIFICATION_TRIGGER);nt.dwType = CNT_TIME;nt.lpszApplication = szExeName;nt.lpszArguments = szArgs;nt.stStartTime = st;StringCchCopy (szExeName, dim(szExeName), NAMED_EVENT_PREFIX_TEXT);StringCchCat (szExeName, dim(szExeName), szEventName);hNotify = CeSetUserNotificationEx (0, &nt, NULL);if (hNotify) { wsprintf (szText, TEXT ("Timer notification set for %d:%02d:%02d"), st.wHour, st.wMinute, st.wSecond);}else{ wsprintf (szText, TEXT ("Timer notification failed. rc = %d"), GetLastError());}MessageBox (hWnd, szText, szAppName, MB_OK);
将要设置为有效态的event赋值给lpszApplication,event名称有一个固定格式:
\\.\Notifications\NamedEvents\<Event Name>
其中Event Name用event名字代替,因为“\”是c/c++语言里面的转义字符,如要设置的event名字为“TimerNotificationEvent”,则:
nt.lpszApplication = TEXT(“\\\\.\\Notifications\\NamedEvents\\ TimerNotificationEvent”);
上面范例代码中用到的NAMED_EVENT_PREFIX_TEXT是一个宏定义:
#define NAMED_EVENT_PREFIX_TEXT TEXT(\\\\.\\Notifications\\NamedEvents\\)
WinCE7定时器通知 by斜风细雨QQ:253786989 2012-01-01
- WinCE7定时器通知
- WinCE7用户通知
- WinCE7系统事件通知
- 系统事件通知 定时器事件通知 用户通知(转)
- swift中的无限循环通知条定时器
- WinCE7 文件系统概要
- WinCE7的Bootpart参考
- WINCE7系统中文显示
- wince7 I am coming
- 初探Silverlight with WinCE7
- WinCE7的Bootpart参考
- Ps回调通知例程、Dpc定时器、内核线程使用方法.
- 利用文件描述符进行通知的定时器:timerfd
- SD Card Driver on wince7
- WinCE7的文件系统注册表设置
- WinCE7碰到的Bug汇总
- wince6 移植 WINCE7 笔记 -- 1
- 艰难的wince7之路
- 求一个二进制数的十进制(4)
- Android中View绘制流程以及invalidate()等相关方法分析
- 驱动程序
- xjoj316 寻找矩形
- 十进制转换成二进制、八进制、十六进制的通用方法
- WinCE7定时器通知
- 黑马程序员—SQL中group by 语句的含义和详细用法
- 第四章 ARP: 地址解析协议
- RedHat Enterprise Linux 5安装hyper-v的集成驱动(支持网络适配器 )
- hyper-v中安装readhat6.x的集成服务(支持网络适配器)
- 红帽Linux启动流程详解
- shell脚本
- Bash初始化文件/etc/profile .bash_pro-file .bash_login .profile .bash_logout /etc/bashrc .bashrc
- SoftKinetic的3D动作开发套件iisu3.0