strFolder += "\\autoupdateip\\";
if (!CreateDirectory(strFolder,NULL) && GetLastError() != ERROR_ALREADY_EXISTS)
{
MessageBox(_T("创建临时目录失败!"));
return _T("");
}
return strFolder + c_szSettingFilename;
}
LRESULT CUpdateIpDlg::OnNotifyIcon(WPARAM wParam,LPARAM IParam)
{
if ((IParam == WM_LBUTTONDOWN) || (IParam == WM_RBUTTONDOWN))
{
ModifyStyleEx(0,WS_EX_TOPMOST);
ShowWindow(SW_RESTORE);
//Shell_NotifyIcon(NIM_DELETE, &NotifyIcon);
}
return 0;
}
void CUpdateIpDlg::addNotification(){
NotifyIcon.cbSize=sizeof(NOTIFYICONDATA);
NotifyIcon.hIcon=AfxGetApp()->LoadIcon(IDR_MAINFRAME);
NotifyIcon.hWnd=m_hWnd;
lstrcpy(NotifyIcon.szTip,_T("Auto Update IP by weibin"));
NotifyIcon.uCallbackMessage=WM_NC;
NotifyIcon.uFlags=NIF_ICON | NIF_MESSAGE | NIF_TIP;
Shell_NotifyIcon(NIM_ADD,&NotifyIcon);
}
摘自 brainy