我想在后台进程上添加托盘图标。顺便说一句,如果不是用户帐户(例如 SYSTEM)来运行程序,则不要添加托盘图标。如果使用我的帐户,它可以工作。如何通过非用户帐户添加托盘图标来运行程序?
NOTIFYICONDATA nid;
ZeroMemory(&nid, sizeof(NOTIFYICONDATA));
nid.cbSize = sizeof(NOTIFYICONDATA);
nid.hWnd = hWnd;
nid.uFlags = NIF_INFO|NIF_ICON|NIF_TIP;
sprintf(nid.szInfoTitle, "title");
sprintf(nid.szInfo, "infomation");
sprintf(nid.szTip, "tip");
nid.dwInfoFlags = NIIF_INFO;
if(g_UpdaterInfo.osver == cWinXP)
{
nid.uTimeout = 3000;
}
nid.uID = IDI_ICON;
nid.hIcon = LoadIcon(_AtlBaseModule.GetModuleInstance(), MAKEINTRESOURCE(IDI_ICON));
BOOL add = Shell_NotifyIcon(NIM_ADD, &nid);
DWORD result = GetLastError();
CString msg;
msg.Format("Tray AddIcon: %d", result);
FileLog(LOG_FILE, msg);
if(!add)
return FALSE;
return TRUE;