添加托盘
NOTIFYICONDATAW nd;
nd.cbSize = sizeof(nd);
nd.uFlags = NIF_ICON|NIF_MESSAGE|NIF_TIP;
nd.hWnd = m_hWnd;
nd.uID = IDR_MAINFRAME;
nd.hIcon = m_hIcon;
nd.uCallbackMessage = WM_TRAY;
wcscpy( nd.szTip, L"这里是提示信息" );
Shell_NotifyIconW( NIM_ADD, &nd );
WM_TRAY 是个自定义消息,比如我可以定义它为 #define WM_TRAY (WM_USER+1)
删除托盘
NOTIFYICONDATA nd;
nd.cbSize = sizeof(nd);
nd.uFlags = NIF_ICON;
nd.hWnd = m_hWnd;
nd.uID = IDR_MAINFRAME;
nd.hIcon = m_hIcon;
Shell_NotifyIcon( NIM_DELETE, &nd );
具体参见:https://docs.