Index: base/applications/taskmgr/taskmgr.c =================================================================== --- base/applications/taskmgr/taskmgr.c (revision 65128) +++ base/applications/taskmgr/taskmgr.c (working copy) @@ -564,6 +564,7 @@ HMENU hMenu; HMENU hEditMenu; HMENU hViewMenu; + HMENU hShutMenu; HMENU hUpdateSpeedMenu; HMENU hCPUHistoryMenu; int nActivePage; @@ -570,7 +571,10 @@ int nParts[3]; RECT rc; WCHAR szTemp[256]; + WCHAR szLogOffItem[MAX_PATH]; + LPTSTR lpUser; TCITEM item; + DWORD len = 0; SendMessageW(hMainWnd, WM_SETICON, ICON_BIG, (LPARAM)LoadIconW(hInst, MAKEINTRESOURCEW(IDI_TASKMANAGER))); @@ -653,8 +657,9 @@ hMenu = GetMenu(hWnd); hEditMenu = GetSubMenu(hMenu, 1); hViewMenu = GetSubMenu(hMenu, 2); + hShutMenu = GetSubMenu(hMenu, 4); hUpdateSpeedMenu = GetSubMenu(hViewMenu, 1); - hCPUHistoryMenu = GetSubMenu(hViewMenu, 7); + hCPUHistoryMenu = GetSubMenu(hViewMenu, 7); /* Check or uncheck the always on top menu item */ if (TaskManagerSettings.AlwaysOnTop) { @@ -704,6 +709,24 @@ TabCtrl_SetCurFocus/*Sel*/(hTabWnd, 2); TabCtrl_SetCurFocus/*Sel*/(hTabWnd, nActivePage); + /* Set the username in the "Log Off %s" item of the Shutdown menu */ + + /* 1- get the menu item text and store it temporarily */ + GetMenuStringW(hShutMenu, ID_SHUTDOWN_LOGOFF, szTemp, 256, MF_BYCOMMAND); + + /* 2- retrieve the username length first, then allocate a buffer for it and call it again */ + GetUserNameW(NULL, &len); + + if((lpUser = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len))) + { + GetUserNameW(lpUser, &len); + wsprintfW(szLogOffItem, szTemp, lpUser); + + /* 3- set the menu item text to its formatted counterpart */ + ModifyMenuW(hShutMenu, ID_SHUTDOWN_LOGOFF, MF_BYCOMMAND|MF_STRING, ID_SHUTDOWN_LOGOFF, szLogOffItem); + HeapFree(GetProcessHeap(), 0, lpUser); + } + /* Setup update speed */ SetUpdateSpeed(hWnd);