diff --git a/reactos/lib/shell32/dialogs.c b/reactos/lib/shell32/dialogs.c index 86e01a41cb1..ea5eebe51ac 100644 --- a/reactos/lib/shell32/dialogs.c +++ b/reactos/lib/shell32/dialogs.c @@ -372,6 +372,63 @@ void FillList (HWND hCb, char *pszLatest) free (pszList) ; } + +/************************************************************************* + * RestartWindowsDialog [SHELL32.730] + */ + +int WINAPI RestartDialogEx(HWND hwndOwner, LPCWSTR lpwstrReason, UINT uFlags, UINT uReason) +{ + TRACE("(%p)\n", hwndOwner); + + /*FIXME: use uReason */ + + if (MessageBoxA(hwndOwner, "Do you want to restart Windows?", "Restart", MB_YESNO|MB_ICONQUESTION) == IDYES) + { + if (SHELL_OsIsUnicode()) + { + HANDLE hToken; + TOKEN_PRIVILEGES npr = {1, {0, 0, SE_PRIVILEGE_ENABLED}}; + + /* enable shutdown privilege for current process */ + OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, &hToken); + LookupPrivilegeValueA(0, "SeShutdownPrivilege", &npr.Privileges[0].Luid); + AdjustTokenPrivileges(hToken, FALSE, &npr, 0, 0, 0); + CloseHandle(hToken); + } + + ExitWindowsEx(EWX_REBOOT, 0); + } + + return 0; +} + + +/************************************************************************* + * RestartWindowsDialog [SHELL32.59] + */ + +int WINAPI RestartDialog(HWND hwndOwner, LPCSTR lpstrReason, UINT uFlags) +{ + LPWSTR lpwcsReason; + int len, ret; + + if (lpstrReason) { + len = MultiByteToWideChar(CP_ACP, 0, lpstrReason, -1, NULL, 0); + lpwcsReason = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); + MultiByteToWideChar(CP_ACP, 0, lpstrReason, -1, lpwcsReason, len); + } else + lpwcsReason = NULL; + + ret = RestartDialogEx(hwndOwner, lpwcsReason, uFlags, 0); + + if (lpwcsReason) + HeapFree(GetProcessHeap(), 0, lpwcsReason); + + return ret; +} + + /************************************************************************* * ExitWindowsDialog [SHELL32.60] * @@ -380,9 +437,24 @@ void FillList (HWND hCb, char *pszLatest) */ void WINAPI ExitWindowsDialog (HWND hWndOwner) { - TRACE("(%p)\n", hWndOwner); - if (MessageBoxA( hWndOwner, "Do you want to exit WINE?", "Shutdown", MB_YESNO|MB_ICONQUESTION) == IDYES) + TRACE("(%p)\n", hWndOwner); + + if (MessageBoxA(hWndOwner, "Do you want to exit Windows?", "Shutdown", MB_YESNO|MB_ICONQUESTION) == IDYES) + { + if (SHELL_OsIsUnicode()) { - SendMessageA ( hWndOwner, WM_QUIT, 0, 0); + HANDLE hToken; + TOKEN_PRIVILEGES npr = {1, {0, 0, SE_PRIVILEGE_ENABLED}}; + + /* enable shutdown privilege for current process */ + OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, &hToken); + LookupPrivilegeValueA(0, "SeShutdownPrivilege", &npr.Privileges[0].Luid); + AdjustTokenPrivileges(hToken, FALSE, &npr, 0, 0, 0); + CloseHandle(hToken); + + ExitWindowsEx(EWX_SHUTDOWN, 0); } + else + SendMessageA(hWndOwner, WM_QUIT, 0, 0); + } } diff --git a/reactos/lib/shell32/iconcache.c b/reactos/lib/shell32/iconcache.c index 924bc5d2e68..9d7d46f2449 100644 --- a/reactos/lib/shell32/iconcache.c +++ b/reactos/lib/shell32/iconcache.c @@ -97,15 +97,14 @@ static INT CALLBACK SIC_CompareEntries( LPVOID p1, LPVOID p2, LPARAM lparam) static INT SIC_IconAppend (LPCSTR sSourceFile, INT dwSourceIndex, HICON hSmallIcon, HICON hBigIcon) { LPSIC_ENTRY lpsice; INT ret, index, index1; - char path[MAX_PATH], fullpath[MAX_PATH]; + char path[MAX_PATH]; TRACE("%s %i %p %p\n", sSourceFile, dwSourceIndex, hSmallIcon ,hBigIcon); lpsice = (LPSIC_ENTRY) SHAlloc (sizeof (SIC_ENTRY)); - SearchPathA(NULL, sSourceFile, NULL, MAX_PATH, path, NULL); - GetFullPathNameA(path, MAX_PATH, fullpath, NULL); - lpsice->sSourceFile = HeapAlloc( GetProcessHeap(), 0, strlen(fullpath)+1 ); - strcpy( lpsice->sSourceFile, fullpath ); + GetFullPathNameA(sSourceFile, MAX_PATH, path, NULL); + lpsice->sSourceFile = HeapAlloc( GetProcessHeap(), 0, strlen(path)+1 ); + strcpy( lpsice->sSourceFile, path ); lpsice->dwSourceIndex = dwSourceIndex; @@ -182,13 +181,12 @@ static INT SIC_LoadIcon (LPCSTR sSourceFile, INT dwSourceIndex) INT SIC_GetIconIndex (LPCSTR sSourceFile, INT dwSourceIndex ) { SIC_ENTRY sice; INT ret, index = INVALID_INDEX; - char path[MAX_PATH], fullpath[MAX_PATH]; + char path[MAX_PATH]; TRACE("%s %i\n", sSourceFile, dwSourceIndex); - SearchPathA(NULL, sSourceFile, NULL, MAX_PATH, path, NULL); - GetFullPathNameA(path, MAX_PATH, fullpath, NULL); - sice.sSourceFile = fullpath; + GetFullPathNameA(sSourceFile, MAX_PATH, path, NULL); + sice.sSourceFile = path; sice.dwSourceIndex = dwSourceIndex; EnterCriticalSection(&SHELL32_SicCS); diff --git a/reactos/lib/shell32/shell32.spec b/reactos/lib/shell32/shell32.spec index fd535f4bc5d..cb0c76a55f3 100644 --- a/reactos/lib/shell32/shell32.spec +++ b/reactos/lib/shell32/shell32.spec @@ -52,7 +52,7 @@ 56 stdcall PathUnquoteSpaces(str) PathUnquoteSpacesAW 57 stdcall PathGetDriveNumber (str) PathGetDriveNumberAW 58 stdcall ParseField(str long ptr long) ParseFieldAW - 59 stub RestartDialog@12 + 59 stdcall RestartDialog(long long long) 60 stdcall ExitWindowsDialog(long) 61 stdcall RunFileDlg(long long long str str long) 62 stdcall PickIconDlg(long long long long) @@ -310,6 +310,8 @@ # >= NT5 714 stdcall @(ptr)SHELL32_714 # PathIsTemporaryW + 730 stdcall RestartDialogEx(long long long long) + 1217 stub FOOBAR1217 # no joke! This is the real name!! # diff --git a/reactos/lib/shell32/shell32_main.h b/reactos/lib/shell32/shell32_main.h index b5ebd958dc7..71dbce926cb 100644 --- a/reactos/lib/shell32/shell32_main.h +++ b/reactos/lib/shell32/shell32_main.h @@ -250,4 +250,7 @@ BOOL WINAPI ShellExecuteExW32 (LPSHELLEXECUTEINFOW sei, SHELL_ExecuteW32 execfun extern WCHAR swShell32Name[MAX_PATH]; extern char sShell32Name[MAX_PATH]; +int WINAPI RestartDialog(HWND hwndOwner, LPCSTR lpstrReason, UINT uFlags); +int WINAPI RestartDialogEx(HWND hwndOwner, LPCWSTR lpwstrReason, UINT uFlags, UINT uReason); + #endif diff --git a/reactos/lib/shell32/systray.c b/reactos/lib/shell32/systray.c index 57af2139cf8..9c6a81ecbda 100644 --- a/reactos/lib/shell32/systray.c +++ b/reactos/lib/shell32/systray.c @@ -4,8 +4,8 @@ * Copyright 1999 Kai Morich * * Manage the systray window. That it actually appears in the docking - * area of KDE or GNOME is delegated to windows/x11drv/wnd.c, - * X11DRV_WND_DockWindow. + * area of KDE is handled in dlls/x11drv/window.c, + * X11DRV_set_wm_hints using KWM_DOCKWINDOW. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/reactos/lib/shell32/undocshell.h b/reactos/lib/shell32/undocshell.h index 69b69424f78..58123e0ba96 100644 --- a/reactos/lib/shell32/undocshell.h +++ b/reactos/lib/shell32/undocshell.h @@ -187,11 +187,6 @@ void WINAPI RunFileDlg( void WINAPI ExitWindowsDialog(HWND hwndOwner); -int WINAPI RestartDialog( - HWND hwndOwner, - LPCSTR lpstrReason, - UINT uFlags); - BOOL WINAPI GetFileNameFromBrowse( HWND hwndOwner, LPSTR lpstrFile,