Advertisement
Black_Fox

taskmgr menu - add the username - naive attempt

Oct 8th, 2014
233
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.75 KB | None | 0 0
  1. #include <Lmcons.h>
  2. #include <wchar.h>
  3. ...
  4.  
  5. void TaskManager_OnMenuSelect(
  6. ...
  7. if (LoadStringW(hInst, nItemID, str, 100)) {
  8.     /* load appropriate string */
  9.     LPWSTR lpsz;
  10.     if (nItemID == ID_SHUTDOWN_LOGOFF)
  11.     {
  12.         /* fill in the username we'll log off */
  13.         WCHAR szUserName[UNLEN+1];
  14.         DWORD dwUsernameLen = UNLEN+1;
  15.         WCHAR szLogoffUser[200];
  16.  
  17.         GetUserName(szUserName, &dwUsernameLen);
  18.         swprintf(szLogoffUser, str, szUserName);
  19.         lpsz = szLogoffUser;
  20.     }
  21.     else
  22.     {
  23.         lpsz = str;
  24.     }
  25.     /* first newline terminates actual string */
  26.     lpsz = wcschr(lpsz, '\n');
  27.     if (lpsz != NULL)
  28.         *lpsz = '\0';
  29. }
  30.  
  31. ...
  32.     SendMessageW(hStatusWnd, SB_SETTEXT, 0, (LPARAM)lpsz);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement