Rare error on Tray icon creation, after a user log out / log in
问题 I create a systray icon with: BOOL TrayMessage(HWND hWnd, DWORD dwMessage) { NOTIFYICONDATA nid; nid.cbSize = sizeof(nid); nid.hWnd = hWnd; nid.uID = 1; nid.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP; nid.hIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_MYAPP)); lstrcpy(nid.szTip, L"MyApp"); nid.uCallbackMessage = WM_NOTIFYICON; return Shell_NotifyIcon(dwMessage, &nid); } when the app starts / the window is created: case WM_CREATE: if (!TrayMessage(hWnd, NIM_ADD)) MessageBox(hMainWnd, L"Tray error.