Authors: Martin Fuchs <martin-fuchs@gmx.net>, Ge van Geldorp <gvg@reactos.com>
Implement MessageBox-based RestartDialog() and RestartDialogEx(), use string resources for ExitWindowsDialog() to allow internationalization.
This commit is contained in:
parent
a7a6f5f31c
commit
b74089091b
|
@ -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 @@ void FillList (HWND hCb, char *pszLatest)
|
|||
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, DWORD uFlags, DWORD uReason)
|
||||
{
|
||||
TRACE("(%p)\n", hWndOwner);
|
||||
|
||||
/*FIXME: use uReason */
|
||||
|
||||
if (ConfirmDialog(hWndOwner, IDS_RESTART_PROMPT, IDS_RESTART_TITLE))
|
||||
{
|
||||
HANDLE hToken;
|
||||
TOKEN_PRIVILEGES npr;
|
||||
|
||||
/* enable shutdown privilege for current process */
|
||||
if (OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, &hToken))
|
||||
{
|
||||
LookupPrivilegeValueA(0, "SeShutdownPrivilege", &npr.Privileges[0].Luid);
|
||||
npr.PrivilegeCount = 1;
|
||||
npr.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
|
||||
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, DWORD uFlags)
|
||||
{
|
||||
return RestartDialogEx(hWndOwner, lpstrReason, uFlags, 0);
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
* ExitWindowsDialog [SHELL32.60]
|
||||
*
|
||||
|
@ -380,9 +439,22 @@ 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)
|
||||
{
|
||||
SendMessageA ( hWndOwner, WM_QUIT, 0, 0);
|
||||
}
|
||||
TRACE("(%p)\n", hWndOwner);
|
||||
|
||||
if (ConfirmDialog(hWndOwner, IDS_SHUTDOWN_PROMPT, IDS_SHUTDOWN_TITLE))
|
||||
{
|
||||
HANDLE hToken;
|
||||
TOKEN_PRIVILEGES npr;
|
||||
|
||||
/* enable shutdown privilege for current process */
|
||||
if (OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, &hToken))
|
||||
{
|
||||
LookupPrivilegeValueA(0, "SeShutdownPrivilege", &npr.Privileges[0].Luid);
|
||||
npr.PrivilegeCount = 1;
|
||||
npr.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
|
||||
AdjustTokenPrivileges(hToken, FALSE, &npr, 0, 0, 0);
|
||||
CloseHandle(hToken);
|
||||
}
|
||||
ExitWindowsEx(EWX_SHUTDOWN, 0);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 wstr 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 wstr long long)
|
||||
|
||||
1217 stub FOOBAR1217 # no joke! This is the real name!!
|
||||
|
||||
|
|
|
@ -177,3 +177,12 @@ BEGIN
|
|||
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 simulate a Windows reboot?"
|
||||
IDS_SHUTDOWN_TITLE "Shutdown"
|
||||
IDS_SHUTDOWN_PROMPT "Do you want to shutdown your Wine session?"
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -132,11 +132,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,
|
||||
|
|
|
@ -45,6 +45,9 @@ HRESULT WINAPI SHILCreateFromPath(LPCWSTR,LPITEMIDLIST*,DWORD*);
|
|||
LPITEMIDLIST WINAPI SHSimpleIDListFromPath(LPCWSTR);
|
||||
int WINAPI SHMapPIDLToSystemImageListIndex(IShellFolder*,LPCITEMIDLIST,int*);
|
||||
|
||||
int WINAPI RestartDialog(HWND,LPCWSTR,DWORD);
|
||||
int WINAPI RestartDialogEx(HWND,LPCWSTR,DWORD,DWORD);
|
||||
|
||||
|
||||
/* SHObjectProperties flags */
|
||||
#define SHOP_PRINTERNAME 0x01
|
||||
|
|
Loading…
Reference in New Issue