2000-04-28 22:21:49 +02:00
|
|
|
/*
|
|
|
|
* common shell dialogs
|
2002-03-10 00:29:33 +01:00
|
|
|
*
|
|
|
|
* Copyright 2000 Juergen Schmied
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2000-04-28 22:21:49 +02:00
|
|
|
*/
|
2002-03-10 00:29:33 +01:00
|
|
|
|
2002-08-29 01:42:34 +02:00
|
|
|
#include "config.h"
|
|
|
|
#include "wine/port.h"
|
|
|
|
|
2000-04-28 22:21:49 +02:00
|
|
|
#include <string.h>
|
2003-09-06 01:08:26 +02:00
|
|
|
#include <stdarg.h>
|
2000-04-28 22:21:49 +02:00
|
|
|
#include <stdio.h>
|
|
|
|
#include "winerror.h"
|
2003-09-06 01:08:26 +02:00
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
2002-06-10 04:34:36 +02:00
|
|
|
#include "winreg.h"
|
2003-09-06 01:08:26 +02:00
|
|
|
#include "wingdi.h"
|
|
|
|
#include "winuser.h"
|
2002-06-10 04:34:36 +02:00
|
|
|
#include "commdlg.h"
|
2002-03-10 00:29:33 +01:00
|
|
|
#include "wine/debug.h"
|
2000-04-28 22:21:49 +02:00
|
|
|
|
|
|
|
#include "shellapi.h"
|
|
|
|
#include "shlobj.h"
|
|
|
|
#include "shell32_main.h"
|
2004-07-10 00:51:19 +02:00
|
|
|
#include "shresdef.h"
|
2001-08-16 20:49:56 +02:00
|
|
|
#include "undocshell.h"
|
2000-04-28 22:21:49 +02:00
|
|
|
|
2002-07-16 03:15:15 +02:00
|
|
|
typedef struct
|
2002-06-10 04:34:36 +02:00
|
|
|
{
|
|
|
|
HWND hwndOwner ;
|
|
|
|
HICON hIcon ;
|
|
|
|
LPCSTR lpstrDirectory ;
|
|
|
|
LPCSTR lpstrTitle ;
|
|
|
|
LPCSTR lpstrDescription ;
|
|
|
|
UINT uFlags ;
|
|
|
|
} RUNFILEDLGPARAMS ;
|
2002-07-16 03:15:15 +02:00
|
|
|
|
2002-06-10 04:34:36 +02:00
|
|
|
typedef BOOL (*LPFNOFN) (OPENFILENAMEA *) ;
|
|
|
|
|
2002-03-10 00:29:33 +01:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(shell);
|
2002-10-31 02:04:39 +01:00
|
|
|
INT_PTR CALLBACK RunDlgProc (HWND, UINT, WPARAM, LPARAM) ;
|
2002-06-10 04:34:36 +02:00
|
|
|
void FillList (HWND, char *) ;
|
2000-04-28 22:21:49 +02:00
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
* PickIconDlg [SHELL32.62]
|
2002-06-01 01:06:46 +02:00
|
|
|
*
|
2000-04-28 22:21:49 +02:00
|
|
|
*/
|
|
|
|
BOOL WINAPI PickIconDlg(
|
|
|
|
HWND hwndOwner,
|
|
|
|
LPSTR lpstrFile,
|
|
|
|
DWORD nMaxFile,
|
|
|
|
LPDWORD lpdwIconIndex)
|
|
|
|
{
|
2002-11-22 00:56:42 +01:00
|
|
|
FIXME("(%p,%s,%08lx,%p):stub.\n",
|
2000-04-28 22:21:49 +02:00
|
|
|
hwndOwner, lpstrFile, nMaxFile,lpdwIconIndex);
|
|
|
|
return 0xffffffff;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
* RunFileDlg [SHELL32.61]
|
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* Original name: RunFileDlg (exported by ordinal)
|
|
|
|
*/
|
|
|
|
void WINAPI RunFileDlg(
|
|
|
|
HWND hwndOwner,
|
|
|
|
HICON hIcon,
|
|
|
|
LPCSTR lpstrDirectory,
|
|
|
|
LPCSTR lpstrTitle,
|
|
|
|
LPCSTR lpstrDescription,
|
|
|
|
UINT uFlags)
|
|
|
|
{
|
2002-06-10 04:34:36 +02:00
|
|
|
|
2002-07-16 03:15:15 +02:00
|
|
|
RUNFILEDLGPARAMS rfdp;
|
2002-06-10 04:34:36 +02:00
|
|
|
HRSRC hRes;
|
|
|
|
LPVOID template;
|
|
|
|
TRACE("\n");
|
|
|
|
|
2002-07-16 03:15:15 +02:00
|
|
|
rfdp.hwndOwner = hwndOwner;
|
|
|
|
rfdp.hIcon = hIcon;
|
|
|
|
rfdp.lpstrDirectory = lpstrDirectory;
|
|
|
|
rfdp.lpstrTitle = lpstrTitle;
|
|
|
|
rfdp.lpstrDescription = lpstrDescription;
|
|
|
|
rfdp.uFlags = uFlags;
|
|
|
|
|
2003-09-10 05:56:47 +02:00
|
|
|
if(!(hRes = FindResourceA(shell32_hInstance, "SHELL_RUN_DLG", (LPSTR)RT_DIALOG)))
|
2002-06-10 04:34:36 +02:00
|
|
|
{
|
|
|
|
MessageBoxA (hwndOwner, "Couldn't find dialog.", "Nix", MB_OK) ;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if(!(template = (LPVOID)LoadResource(shell32_hInstance, hRes)))
|
|
|
|
{
|
|
|
|
MessageBoxA (hwndOwner, "Couldn't load dialog.", "Nix", MB_OK) ;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2004-09-22 21:14:08 +02:00
|
|
|
DialogBoxIndirectParamA((HINSTANCE)GetWindowLongPtrW( hwndOwner,
|
|
|
|
GWLP_HINSTANCE ),
|
2002-11-22 00:56:42 +01:00
|
|
|
template, hwndOwner, RunDlgProc, (LPARAM)&rfdp);
|
2002-06-10 04:34:36 +02:00
|
|
|
|
2000-04-28 22:21:49 +02:00
|
|
|
}
|
|
|
|
|
2002-06-10 04:34:36 +02:00
|
|
|
/* Dialog procedure for RunFileDlg */
|
2002-10-31 02:04:39 +01:00
|
|
|
INT_PTR CALLBACK RunDlgProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
2002-06-10 04:34:36 +02:00
|
|
|
{
|
|
|
|
int ic ;
|
|
|
|
char *psz, szMsg[256] ;
|
|
|
|
static RUNFILEDLGPARAMS *prfdp = NULL ;
|
2002-07-16 03:15:15 +02:00
|
|
|
|
2002-06-10 04:34:36 +02:00
|
|
|
switch (message)
|
|
|
|
{
|
|
|
|
case WM_INITDIALOG :
|
|
|
|
prfdp = (RUNFILEDLGPARAMS *)lParam ;
|
|
|
|
SetWindowTextA (hwnd, prfdp->lpstrTitle) ;
|
2005-02-15 22:51:06 +01:00
|
|
|
SetClassLongPtrW (hwnd, GCLP_HICON, (LPARAM)prfdp->hIcon) ;
|
|
|
|
SendMessageW (GetDlgItem (hwnd, 12297), STM_SETICON,
|
|
|
|
(WPARAM)LoadIconW (NULL, (LPCWSTR)IDI_WINLOGO), 0);
|
2002-06-10 04:34:36 +02:00
|
|
|
FillList (GetDlgItem (hwnd, 12298), NULL) ;
|
|
|
|
SetFocus (GetDlgItem (hwnd, 12298)) ;
|
|
|
|
return TRUE ;
|
2002-07-16 03:15:15 +02:00
|
|
|
|
2002-06-10 04:34:36 +02:00
|
|
|
case WM_COMMAND :
|
|
|
|
switch (LOWORD (wParam))
|
|
|
|
{
|
|
|
|
case IDOK :
|
|
|
|
{
|
2002-12-02 19:10:57 +01:00
|
|
|
HWND htxt = NULL ;
|
2002-06-10 04:34:36 +02:00
|
|
|
if ((ic = GetWindowTextLengthA (htxt = GetDlgItem (hwnd, 12298))))
|
|
|
|
{
|
2004-09-27 22:34:49 +02:00
|
|
|
psz = HeapAlloc( GetProcessHeap(), 0, (ic + 2) );
|
2002-06-10 04:34:36 +02:00
|
|
|
GetWindowTextA (htxt, psz, ic + 1) ;
|
2002-07-16 03:15:15 +02:00
|
|
|
|
2004-08-02 20:48:21 +02:00
|
|
|
if (ShellExecuteA(NULL, "open", psz, NULL, NULL, SW_SHOWNORMAL) < (HINSTANCE)33)
|
2002-06-10 04:34:36 +02:00
|
|
|
{
|
|
|
|
char *pszSysMsg = NULL ;
|
|
|
|
FormatMessageA (
|
|
|
|
FORMAT_MESSAGE_ALLOCATE_BUFFER |
|
|
|
|
FORMAT_MESSAGE_FROM_SYSTEM |
|
|
|
|
FORMAT_MESSAGE_IGNORE_INSERTS,
|
|
|
|
NULL, GetLastError (),
|
|
|
|
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
|
|
|
(LPSTR)&pszSysMsg, 0, NULL
|
|
|
|
) ;
|
|
|
|
sprintf (szMsg, "Error: %s", pszSysMsg) ;
|
|
|
|
LocalFree ((HLOCAL)pszSysMsg) ;
|
|
|
|
MessageBoxA (hwnd, szMsg, "Nix", MB_OK | MB_ICONEXCLAMATION) ;
|
2002-07-16 03:15:15 +02:00
|
|
|
|
2004-08-09 21:46:47 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, psz);
|
2002-06-10 04:34:36 +02:00
|
|
|
SendMessageA (htxt, CB_SETEDITSEL, 0, MAKELPARAM (0, -1)) ;
|
|
|
|
return TRUE ;
|
|
|
|
}
|
|
|
|
FillList (htxt, psz) ;
|
2004-08-09 21:46:47 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, psz);
|
2002-06-10 04:34:36 +02:00
|
|
|
EndDialog (hwnd, 0) ;
|
|
|
|
}
|
|
|
|
}
|
2002-07-16 03:15:15 +02:00
|
|
|
|
2002-06-10 04:34:36 +02:00
|
|
|
case IDCANCEL :
|
|
|
|
EndDialog (hwnd, 0) ;
|
|
|
|
return TRUE ;
|
2002-07-16 03:15:15 +02:00
|
|
|
|
2002-06-10 04:34:36 +02:00
|
|
|
case 12288 :
|
|
|
|
{
|
2003-01-15 00:43:41 +01:00
|
|
|
HMODULE hComdlg = NULL ;
|
2002-06-10 04:34:36 +02:00
|
|
|
LPFNOFN ofnProc = NULL ;
|
|
|
|
static char szFName[1024] = "", szFileTitle[256] = "", szInitDir[768] = "" ;
|
|
|
|
static OPENFILENAMEA ofn =
|
|
|
|
{
|
|
|
|
sizeof (OPENFILENAMEA),
|
2002-12-02 19:10:57 +01:00
|
|
|
NULL,
|
|
|
|
NULL,
|
2002-06-10 04:34:36 +02:00
|
|
|
"Executable Files\0*.exe\0All Files\0*.*\0\0\0\0",
|
2003-01-15 00:43:41 +01:00
|
|
|
NULL,
|
2002-06-10 04:34:36 +02:00
|
|
|
0,
|
|
|
|
0,
|
|
|
|
szFName,
|
|
|
|
1023,
|
|
|
|
szFileTitle,
|
|
|
|
255,
|
|
|
|
(LPCSTR)szInitDir,
|
|
|
|
"Browse",
|
|
|
|
OFN_ENABLESIZING | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_PATHMUSTEXIST,
|
|
|
|
0,
|
2002-07-16 03:15:15 +02:00
|
|
|
0,
|
2003-01-15 00:43:41 +01:00
|
|
|
NULL,
|
2002-06-10 04:34:36 +02:00
|
|
|
0,
|
2002-07-16 03:15:15 +02:00
|
|
|
(LPOFNHOOKPROC)NULL,
|
2003-01-15 00:43:41 +01:00
|
|
|
NULL
|
2002-06-10 04:34:36 +02:00
|
|
|
} ;
|
2002-07-16 03:15:15 +02:00
|
|
|
|
2002-06-10 04:34:36 +02:00
|
|
|
ofn.hwndOwner = hwnd ;
|
2002-07-16 03:15:15 +02:00
|
|
|
|
2003-01-15 00:43:41 +01:00
|
|
|
if (NULL == (hComdlg = LoadLibraryExA ("comdlg32", NULL, 0)))
|
2002-06-10 04:34:36 +02:00
|
|
|
{
|
|
|
|
MessageBoxA (hwnd, "Unable to display dialog box (LoadLibraryEx) !", "Nix", MB_OK | MB_ICONEXCLAMATION) ;
|
|
|
|
return TRUE ;
|
|
|
|
}
|
2002-07-16 03:15:15 +02:00
|
|
|
|
2002-06-10 04:34:36 +02:00
|
|
|
if ((LPFNOFN)NULL == (ofnProc = (LPFNOFN)GetProcAddress (hComdlg, "GetOpenFileNameA")))
|
|
|
|
{
|
|
|
|
MessageBoxA (hwnd, "Unable to display dialog box (GetProcAddress) !", "Nix", MB_OK | MB_ICONEXCLAMATION) ;
|
|
|
|
return TRUE ;
|
|
|
|
}
|
2002-07-16 03:15:15 +02:00
|
|
|
|
2002-06-10 04:34:36 +02:00
|
|
|
ofnProc (&ofn) ;
|
2002-07-16 03:15:15 +02:00
|
|
|
|
2002-06-10 04:34:36 +02:00
|
|
|
SetFocus (GetDlgItem (hwnd, IDOK)) ;
|
|
|
|
SetWindowTextA (GetDlgItem (hwnd, 12298), szFName) ;
|
|
|
|
SendMessageA (GetDlgItem (hwnd, 12298), CB_SETEDITSEL, 0, MAKELPARAM (0, -1)) ;
|
|
|
|
SetFocus (GetDlgItem (hwnd, IDOK)) ;
|
2002-07-16 03:15:15 +02:00
|
|
|
|
2002-06-10 04:34:36 +02:00
|
|
|
FreeLibrary (hComdlg) ;
|
2002-07-16 03:15:15 +02:00
|
|
|
|
2002-06-10 04:34:36 +02:00
|
|
|
return TRUE ;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return TRUE ;
|
|
|
|
}
|
|
|
|
return FALSE ;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* This grabs the MRU list from the registry and fills the combo for the "Run" dialog above */
|
|
|
|
void FillList (HWND hCb, char *pszLatest)
|
|
|
|
{
|
|
|
|
HKEY hkey ;
|
|
|
|
/* char szDbgMsg[256] = "" ; */
|
|
|
|
char *pszList = NULL, *pszCmd = NULL, cMatch = 0, cMax = 0x60, szIndex[2] = "-" ;
|
|
|
|
DWORD icList = 0, icCmd = 0 ;
|
2002-12-13 01:36:52 +01:00
|
|
|
UINT Nix ;
|
2002-07-16 03:15:15 +02:00
|
|
|
|
2002-06-10 04:34:36 +02:00
|
|
|
SendMessageA (hCb, CB_RESETCONTENT, 0, 0) ;
|
2002-07-16 03:15:15 +02:00
|
|
|
|
2002-06-10 04:34:36 +02:00
|
|
|
if (ERROR_SUCCESS != RegCreateKeyExA (
|
|
|
|
HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\RunMRU",
|
2006-08-07 20:03:40 +02:00
|
|
|
0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hkey, NULL))
|
2002-06-10 04:34:36 +02:00
|
|
|
MessageBoxA (hCb, "Unable to open registry key !", "Nix", MB_OK) ;
|
2002-07-16 03:15:15 +02:00
|
|
|
|
2002-06-29 01:30:07 +02:00
|
|
|
RegQueryValueExA (hkey, "MRUList", NULL, NULL, NULL, &icList) ;
|
|
|
|
|
2002-06-10 04:34:36 +02:00
|
|
|
if (icList > 0)
|
|
|
|
{
|
2004-08-09 21:46:47 +02:00
|
|
|
pszList = HeapAlloc( GetProcessHeap(), 0, icList) ;
|
2005-07-06 21:08:05 +02:00
|
|
|
if (ERROR_SUCCESS != RegQueryValueExA (hkey, "MRUList", NULL, NULL, (LPBYTE)pszList, &icList))
|
2002-06-10 04:34:36 +02:00
|
|
|
MessageBoxA (hCb, "Unable to grab MRUList !", "Nix", MB_OK) ;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2004-08-09 21:46:47 +02:00
|
|
|
icList = 1 ;
|
|
|
|
pszList = HeapAlloc( GetProcessHeap(), 0, icList) ;
|
2002-06-10 04:34:36 +02:00
|
|
|
pszList[0] = 0 ;
|
|
|
|
}
|
2002-07-16 03:15:15 +02:00
|
|
|
|
2002-06-10 04:34:36 +02:00
|
|
|
for (Nix = 0 ; Nix < icList - 1 ; Nix++)
|
|
|
|
{
|
|
|
|
if (pszList[Nix] > cMax)
|
|
|
|
cMax = pszList[Nix] ;
|
2002-07-16 03:15:15 +02:00
|
|
|
|
2002-06-10 04:34:36 +02:00
|
|
|
szIndex[0] = pszList[Nix] ;
|
2002-07-16 03:15:15 +02:00
|
|
|
|
2002-06-10 04:34:36 +02:00
|
|
|
if (ERROR_SUCCESS != RegQueryValueExA (hkey, szIndex, NULL, NULL, NULL, &icCmd))
|
|
|
|
MessageBoxA (hCb, "Unable to grab size of index", "Nix", MB_OK) ;
|
2004-08-09 21:46:47 +02:00
|
|
|
if( pszCmd )
|
|
|
|
pszCmd = HeapReAlloc(GetProcessHeap(), 0, pszCmd, icCmd) ;
|
|
|
|
else
|
|
|
|
pszCmd = HeapAlloc(GetProcessHeap(), 0, icCmd) ;
|
2005-07-06 21:08:05 +02:00
|
|
|
if (ERROR_SUCCESS != RegQueryValueExA (hkey, szIndex, NULL, NULL, (LPBYTE)pszCmd, &icCmd))
|
2002-06-10 04:34:36 +02:00
|
|
|
MessageBoxA (hCb, "Unable to grab index", "Nix", MB_OK) ;
|
2002-07-16 03:15:15 +02:00
|
|
|
|
2002-06-10 04:34:36 +02:00
|
|
|
if (NULL != pszLatest)
|
|
|
|
{
|
2005-03-07 12:05:03 +01:00
|
|
|
if (!lstrcmpiA(pszCmd, pszLatest))
|
2002-06-10 04:34:36 +02:00
|
|
|
{
|
|
|
|
/*
|
|
|
|
sprintf (szDbgMsg, "Found existing (%d).\n", Nix) ;
|
|
|
|
MessageBoxA (hCb, szDbgMsg, "Nix", MB_OK) ;
|
|
|
|
*/
|
|
|
|
SendMessageA (hCb, CB_INSERTSTRING, 0, (LPARAM)pszCmd) ;
|
|
|
|
SetWindowTextA (hCb, pszCmd) ;
|
|
|
|
SendMessageA (hCb, CB_SETEDITSEL, 0, MAKELPARAM (0, -1)) ;
|
2002-07-16 03:15:15 +02:00
|
|
|
|
2002-06-10 04:34:36 +02:00
|
|
|
cMatch = pszList[Nix] ;
|
|
|
|
memmove (&pszList[1], pszList, Nix) ;
|
|
|
|
pszList[0] = cMatch ;
|
|
|
|
continue ;
|
|
|
|
}
|
|
|
|
}
|
2002-07-16 03:15:15 +02:00
|
|
|
|
2002-06-10 04:34:36 +02:00
|
|
|
if (26 != icList - 1 || icList - 2 != Nix || cMatch || NULL == pszLatest)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
sprintf (szDbgMsg, "Happily appending (%d).\n", Nix) ;
|
|
|
|
MessageBoxA (hCb, szDbgMsg, "Nix", MB_OK) ;
|
|
|
|
*/
|
|
|
|
SendMessageA (hCb, CB_ADDSTRING, 0, (LPARAM)pszCmd) ;
|
|
|
|
if (!Nix)
|
|
|
|
{
|
|
|
|
SetWindowTextA (hCb, pszCmd) ;
|
|
|
|
SendMessageA (hCb, CB_SETEDITSEL, 0, MAKELPARAM (0, -1)) ;
|
|
|
|
}
|
2002-07-16 03:15:15 +02:00
|
|
|
|
2002-06-10 04:34:36 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
sprintf (szDbgMsg, "Doing loop thing.\n") ;
|
|
|
|
MessageBoxA (hCb, szDbgMsg, "Nix", MB_OK) ;
|
|
|
|
*/
|
|
|
|
SendMessageA (hCb, CB_INSERTSTRING, 0, (LPARAM)pszLatest) ;
|
|
|
|
SetWindowTextA (hCb, pszLatest) ;
|
|
|
|
SendMessageA (hCb, CB_SETEDITSEL, 0, MAKELPARAM (0, -1)) ;
|
2002-07-16 03:15:15 +02:00
|
|
|
|
2002-06-10 04:34:36 +02:00
|
|
|
cMatch = pszList[Nix] ;
|
|
|
|
memmove (&pszList[1], pszList, Nix) ;
|
|
|
|
pszList[0] = cMatch ;
|
|
|
|
szIndex[0] = cMatch ;
|
2005-07-06 21:08:05 +02:00
|
|
|
RegSetValueExA (hkey, szIndex, 0, REG_SZ, (LPBYTE)pszLatest, strlen (pszLatest) + 1) ;
|
2002-06-10 04:34:36 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!cMatch && NULL != pszLatest)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
sprintf (szDbgMsg, "Simply inserting (increasing list).\n") ;
|
|
|
|
MessageBoxA (hCb, szDbgMsg, "Nix", MB_OK) ;
|
|
|
|
*/
|
|
|
|
SendMessageA (hCb, CB_INSERTSTRING, 0, (LPARAM)pszLatest) ;
|
|
|
|
SetWindowTextA (hCb, pszLatest) ;
|
|
|
|
SendMessageA (hCb, CB_SETEDITSEL, 0, MAKELPARAM (0, -1)) ;
|
2002-07-16 03:15:15 +02:00
|
|
|
|
2002-06-10 04:34:36 +02:00
|
|
|
cMatch = ++cMax ;
|
2004-08-09 21:46:47 +02:00
|
|
|
if( pszList )
|
|
|
|
pszList = HeapReAlloc(GetProcessHeap(), 0, pszList, ++icList) ;
|
|
|
|
else
|
|
|
|
pszList = HeapAlloc(GetProcessHeap(), 0, ++icList) ;
|
2002-06-10 04:34:36 +02:00
|
|
|
memmove (&pszList[1], pszList, icList - 1) ;
|
|
|
|
pszList[0] = cMatch ;
|
|
|
|
szIndex[0] = cMatch ;
|
2005-07-06 21:08:05 +02:00
|
|
|
RegSetValueExA (hkey, szIndex, 0, REG_SZ, (LPBYTE)pszLatest, strlen (pszLatest) + 1) ;
|
2002-06-10 04:34:36 +02:00
|
|
|
}
|
|
|
|
|
2005-07-06 21:08:05 +02:00
|
|
|
RegSetValueExA (hkey, "MRUList", 0, REG_SZ, (LPBYTE)pszList, strlen (pszList) + 1) ;
|
2002-07-16 03:15:15 +02:00
|
|
|
|
2004-08-09 21:46:47 +02:00
|
|
|
HeapFree( GetProcessHeap(), 0, pszCmd) ;
|
|
|
|
HeapFree( GetProcessHeap(), 0, pszList) ;
|
2002-06-10 04:34:36 +02:00
|
|
|
}
|
|
|
|
|
2004-07-10 00:51:19 +02:00
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
* 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);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-04-28 22:21:49 +02:00
|
|
|
/*************************************************************************
|
|
|
|
* ExitWindowsDialog [SHELL32.60]
|
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* exported by ordinal
|
|
|
|
*/
|
|
|
|
void WINAPI ExitWindowsDialog (HWND hWndOwner)
|
|
|
|
{
|
2004-07-10 00:51:19 +02:00
|
|
|
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);
|
|
|
|
}
|
2000-04-28 22:21:49 +02:00
|
|
|
}
|