關于PPC Today界面(今日插件、
PPC Today Screen),有兩個例程大家可以參考一下 ,一個是在Windows CE Tools\wce500\Windows Mobile 5.0 Pocket PC SDK\Samples\CPP\Win32下有Memwatcher的例子,另一個是網上的例子
http://www.codeguru.com/cpp/wp/ce/pocketpc/article.php/c9269__1/.網上的那個例子其實和第一個沒什么區別,代碼也都差不多的,不過它能更詳細些。PPC Today界面上可以放應用程序的快捷方式或是按時更新的數據都可以。
關于PPC Today界面的調試,起初我將安裝包安裝后重啟,后來發現完全可以不必這樣,在SDK的WIN32的例子中有個Setupdll的程序,這個程序中的codeINSTALL_EXIT Install_Exit函數中除了注冊PPC Today界面以外,關鍵的是SendMessage(HWND_BROADCAST, WM_WININICHANGE, (WPARAM)0xF2, 0),有了這一句我們立即就可以看到程序的效果。我們可以把安裝完后要執行動作放到這個函數下(包括程序的啟動),下面是這個函數的示例代碼:
codeINSTALL_EXIT Install_Exit(HWND hwndparent,
LPCTSTR pszinstalldir,
WORD cfaileddirs,
WORD cfailedfiles,
WORD cfailedregkeys,
WORD cfailedregvals,
WORD cfailedshortcuts)
{
HKEY hOpenKey = NULL;
long lResult = 0;
DWORD dwOpenStyle = 0;
DWORD iValueType = 0;
DWORD iLen = 0;
DWORD iTemp = 0;
TCHAR szPath[MAX_PATH] = {'\0'};
TCHAR szLinkPath[MAX_PATH] = {0};
TCHAR szAppPath[MAX_PATH] = {0};
LPCTSTR keyName = _T("Software\\CabSample");
LPCTSTR csAppPath = _T("AppPath");
LPCTSTR csTodaykey = _T("Software\\Microsoft\\Today\\Items\\\"打包示例\"");
LPCTSTR csPlugName = _T("MyToday.dll"); // 你的插件名
LPCTSTR csAppName = _T("CabSample.exe"); // 你的程序名
if(cfaileddirs || cfailedfiles || cfailedregkeys
|| cfailedregvals || cfailedshortcuts)
goto Failed;
//獲取主程序安裝路徑
_tcscpy(szPath, pszinstalldir);
_tcscat(szPath, _T("\\"));
_tcscat(szPath, csAppName);
//設置主程序快捷方式的執行路徑
_tcscpy(szAppPath, _T("\""));
_tcscat(szAppPath, szPath);
_tcscat(szAppPath, _T("\""));
// 將主程序安裝路徑寫入注冊表
lResult = ::RegCreateKeyEx(HKEY_CURRENT_USER, keyName, 0, _T(""), REG_OPTION_NON_VOLATILE,
0,NULL,&hOpenKey, &dwOpenStyle);
if(lResult != ERROR_SUCCESS)
goto Success;
::RegSetValueEx(hOpenKey, csAppPath, 0, REG_SZ, (BYTE*)&szPath, sizeof(TCHAR) * _tcslen(szPath));
::RegCloseKey(hOpenKey);
memset(szPath, 0x00, sizeof(TCHAR) * MAX_PATH);
_tcscpy(szPath, pszinstalldir);
_tcscat(szPath, _T("\\"));
_tcscat(szPath, csPlugName);
::CopyFile(szPath, _T("\\Windows\\MyToday.dll"), FALSE);
// 安裝 “今日插件”
hOpenKey = NULL;
lResult = ::RegCreateKeyEx(HKEY_LOCAL_MACHINE, csTodaykey, 0, _T(""), REG_OPTION_NON_VOLATILE,
0, NULL, &hOpenKey, &dwOpenStyle);
if(lResult != ERROR_SUCCESS)
goto Success; //如果讀寫注冊表失敗, 放棄安裝 “今日插件”
// 注冊插件
iTemp = 0;
::RegSetValueEx(hOpenKey, _T("Flags"), 0, REG_DWORD, (BYTE*)&iTemp, sizeof(iTemp));
::RegSetValueEx(hOpenKey, _T("Options"), 0, REG_DWORD, (BYTE*)&iTemp, sizeof(iTemp));
iTemp = 1;
::RegSetValueEx(hOpenKey, _T("Enabled"), 0, REG_DWORD, (BYTE*)&iTemp, sizeof(iTemp));
::RegSetValueEx(hOpenKey, _T("Order"), 0, REG_DWORD, (BYTE*)&iTemp, sizeof(iTemp));
::RegSetValueEx(hOpenKey, _T("Selectability"), 0, REG_DWORD, (BYTE*)&iTemp, sizeof(iTemp));
iTemp = 4;
::RegSetValueEx(hOpenKey, _T("Type"), 0, REG_DWORD, (BYTE*)&iTemp, sizeof(iTemp));
::RegSetValueEx(hOpenKey, _T("DLL"), 0, REG_SZ, (BYTE*)_T("\\Windows\\MyToday.dll"), sizeof(TCHAR) * _tcslen(szPath));
// 發送系統消息
::SendMessage(HWND_BROADCAST, WM_WININICHANGE, (WPARAM)0xF2, 0);
::RegCloseKey(hOpenKey);
//創建快捷方式
if(SHGetSpecialFolderPath(NULL, szLinkPath, CSIDL_PROGRAMS,FALSE))
{
_tcscat(szLinkPath, _T("\\"));
_tcscat(szLinkPath, _T("打包示例.lnk"));
if(SHCreateShortcut(szLinkPath, szAppPath) == FALSE)
{
MessageBox(NULL, _T("安裝快捷方式失敗"), _T("提示"), MB_OK);
}
}
else
MessageBox(NULL, _T("獲取系統文件路徑失敗"), _T("提示"), MB_OK);
//return value
Success:
return codeINSTALL_EXIT_DONE;
Failed:
return codeINSTALL_EXIT_UNINSTALL;
}
然后在Setupdll程序生成的安裝包中把你的今日插件放進來,然后在PPC上運行Setupdll安裝包就可以了,關于注冊表的值,請看下表:
Value Name and Type |
Description |
DWORD: Type |
Custom Items must have Type = 4 |
DWORD: Enabled |
0 or 1; 1 causes Today panel to show your component; nevertheless, the user can control it via the Today applet in the Control Panel |
DWORD: Options |
if equals 1, the "Options" button in the Today applet will be enabled |
SZ: DLL |
Pull path to your component |
DWORD : Selectability |
New feature in Win Mobile 2003 SE; allows receiving additional notifications Values are used as follows:
- 0 or does not exist—component cannot be selected at all
- 1—selections are manages automatically. In other words, your component will receive messages like WM_LBUTTONXXX
- 2—the Today screen will send notification messages to your component when the user sets/releases focus or presses navigation keys
|
Order表示的是插件的位置,可以選的。放到最上端的值應該是9,具體的根據需要來調整