dlls/shell32 RestartDialog and RestartDialogEx()

Ge van Geldorp gvg at reactos.com
Wed Jun 30 16:19:48 CDT 2004


Changelog:
  Martin Fuchs <martin-fuchs at gmx.net> / Ge van Geldorp <gvg at reactos.com>
  Implement MessageBox-based RestartDialog() and RestartDialogEx(), use
  string resources for ExitWindowsDialog() to allow internationalization.

Index: dlls/shell32/dialogs.c
===================================================================
RCS file: /home/wine/wine/dlls/shell32/dialogs.c,v
retrieving revision 1.17
diff -u -r1.17 dialogs.c
--- dlls/shell32/dialogs.c	10 Sep 2003 03:56:48 -0000	1.17
+++ dlls/shell32/dialogs.c	30 Jun 2004 21:14:58 -0000
@@ -36,6 +36,7 @@
 #include "shellapi.h"
 #include "shlobj.h"
 #include "shell32_main.h"
+#include "shresdef.h"
 #include "undocshell.h"
 
 typedef struct
@@ -372,6 +373,64 @@
     free (pszList) ;
     }
 
+
+/*************************************************************************
+ * ConfirmDialog				[internal]
+ *
+ * Put up a confirm box, return TRUE if the user confirmed
+ */
+static BOOL ConfirmDialog(HWND hWndOwner, UINT PromptId, UINT TitleId)
+{
+  WCHAR Prompt[256];
+  WCHAR Title[256];
+
+  LoadStringW(shell32_hInstance, PromptId, Prompt, sizeof(Prompt) / sizeof(WCHAR));
+  LoadStringW(shell32_hInstance, TitleId, Title, sizeof(Title) / sizeof(WCHAR));
+  return MessageBoxW(hWndOwner, Prompt, Title, MB_YESNO|MB_ICONQUESTION) == IDYES;
+}
+
+
+/*************************************************************************
+ * RestartDialogEx				[SHELL32.730]
+ */
+
+int WINAPI RestartDialogEx(HWND hWndOwner, LPCWSTR lpwstrReason, UINT uFlags, UINT uReason)
+{
+    TRACE("(%p)\n", hWndOwner);
+
+    /*FIXME: use uReason */
+
+    if (ConfirmDialog(hWndOwner, IDS_RESTART_PROMPT, IDS_RESTART_TITLE))
+    {
+	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;
+}
+
+
+/*************************************************************************
+ * RestartDialog				[SHELL32.59]
+ */
+
+int WINAPI RestartDialog(HWND hWndOwner, LPCWSTR lpstrReason, UINT uFlags)
+{
+    return RestartDialogEx(hWndOwner, lpstrReason, uFlags, 0);
+}
+
+
 /*************************************************************************
  * ExitWindowsDialog				[SHELL32.60]
  *
@@ -380,9 +439,24 @@
  */
 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 (ConfirmDialog(hWndOwner, IDS_SHUTDOWN_PROMPT, IDS_SHUTDOWN_TITLE))
+    {
+	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);
+    }
 }
Index: dlls/shell32/shell32_En.rc
===================================================================
RCS file: /home/wine/wine/dlls/shell32/shell32_En.rc,v
retrieving revision 1.13
diff -u -r1.13 shell32_En.rc
--- dlls/shell32/shell32_En.rc	21 Jun 2004 23:54:19 -0000	1.13
+++ dlls/shell32/shell32_En.rc	30 Jun 2004 21:14:58 -0000
@@ -177,3 +177,12 @@
 	IDS_SHV_COLUMN8		"Name"
 	IDS_SHV_COLUMN9		"Comments"
 END
+
+/* message box strings */
+STRINGTABLE DISCARDABLE
+{
+       IDS_RESTART_TITLE       "Restart"
+       IDS_RESTART_PROMPT      "Do you want to restart the system?"
+       IDS_SHUTDOWN_TITLE      "Shutdown"
+       IDS_SHUTDOWN_PROMPT     "Do you want to shutdown?"
+}
Index: dlls/shell32/shresdef.h
===================================================================
RCS file: /home/wine/wine/dlls/shell32/shresdef.h,v
retrieving revision 1.11
diff -u -r1.11 shresdef.h
--- dlls/shell32/shresdef.h	16 Jan 2004 04:46:05 -0000	1.11
+++ dlls/shell32/shresdef.h	30 Jun 2004 21:14:58 -0000
@@ -51,6 +51,11 @@
 #define IDS_OVERWRITEFILE_CAPTION 36
 #define IDS_OVERWRITEFILE_TEXT	37
 
+#define IDS_RESTART_TITLE      40
+#define IDS_RESTART_PROMPT     41
+#define IDS_SHUTDOWN_TITLE     42
+#define IDS_SHUTDOWN_PROMPT    43
+
 /* browse for folder dialog box */
 #define IDD_STATUS		0x3743
 #define IDD_TITLE		0x3742
Index: dlls/shell32/undocshell.h
===================================================================
RCS file: /home/wine/wine/dlls/shell32/undocshell.h,v
retrieving revision 1.23
diff -u -r1.23 undocshell.h
--- dlls/shell32/undocshell.h	11 Feb 2004 06:21:45 -0000	1.23
+++ dlls/shell32/undocshell.h	30 Jun 2004 21:14:58 -0000
@@ -132,11 +132,6 @@
 
 void WINAPI ExitWindowsDialog(HWND hwndOwner);
 
-int  WINAPI RestartDialog(
-	HWND hwndOwner,
-	LPCSTR lpstrReason,
-	UINT uFlags);
-
 BOOL WINAPI GetFileNameFromBrowse(
 	HWND hwndOwner,
 	LPSTR lpstrFile,
Index: dlls/shell32/shell32.spec
===================================================================
RCS file: /home/wine/wine/dlls/shell32/shell32.spec,v
retrieving revision 1.84
diff -u -r1.84 shell32.spec
--- dlls/shell32/shell32.spec	14 Jun 2004 16:56:39 -0000	1.84
+++ dlls/shell32/shell32.spec	30 Jun 2004 21:14:58 -0000
@@ -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
+  59 stdcall RestartDialog(long str long)
   60 stdcall ExitWindowsDialog(long)
   61 stdcall RunFileDlg(long long long str str long)
   62 stdcall PickIconDlg(long long long long)
@@ -309,6 +309,7 @@
 
 # >= NT5
  714 stdcall @(ptr)SHELL32_714 # PathIsTemporaryW
+ 730 stdcall RestartDialogEx(long str long long)
 
 1217 stub FOOBAR1217   # no joke! This is the real name!!
 
Index: include/shlobj.h
===================================================================
RCS file: /home/wine/wine/include/shlobj.h,v
retrieving revision 1.86
diff -u -r1.86 shlobj.h
--- include/shlobj.h	30 Jun 2004 18:13:09 -0000	1.86
+++ include/shlobj.h	30 Jun 2004 21:14:59 -0000
@@ -45,6 +45,9 @@
 LPITEMIDLIST WINAPI SHSimpleIDListFromPath(LPCWSTR);
 int          WINAPI SHMapPIDLToSystemImageListIndex(IShellFolder*,LPCITEMIDLIST,int*);
 
+int          WINAPI RestartDialog(HWND,LPCWSTR,UINT);
+int          WINAPI RestartDialogEx(HWND,LPCWSTR,UINT,UINT);
+
 
 /* SHObjectProperties flags */
 #define SHOP_PRINTERNAME 0x01



More information about the wine-patches mailing list