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 ;
|
2008-06-27 17:08:14 +02:00
|
|
|
LPCWSTR lpstrDirectory ;
|
|
|
|
LPCWSTR lpstrTitle ;
|
|
|
|
LPCWSTR lpstrDescription ;
|
2002-06-10 04:34:36 +02:00
|
|
|
UINT uFlags ;
|
|
|
|
} RUNFILEDLGPARAMS ;
|
2002-07-16 03:15:15 +02:00
|
|
|
|
2008-10-15 15:12:20 +02:00
|
|
|
typedef BOOL (WINAPI * LPFNOFN) (OPENFILENAMEW *) ;
|
2002-06-10 04:34:36 +02:00
|
|
|
|
2002-03-10 00:29:33 +01:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(shell);
|
2007-02-06 23:04:31 +01:00
|
|
|
static INT_PTR CALLBACK RunDlgProc (HWND, UINT, WPARAM, LPARAM) ;
|
2008-06-27 19:03:24 +02:00
|
|
|
static void FillList (HWND, char *, BOOL) ;
|
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
|
|
|
*/
|
2010-03-21 18:08:33 +01:00
|
|
|
INT WINAPI PickIconDlg(
|
2000-04-28 22:21:49 +02:00
|
|
|
HWND hwndOwner,
|
|
|
|
LPSTR lpstrFile,
|
|
|
|
DWORD nMaxFile,
|
|
|
|
LPDWORD lpdwIconIndex)
|
|
|
|
{
|
2006-10-07 20:18:14 +02:00
|
|
|
FIXME("(%p,%s,%08x,%p):stub.\n",
|
2000-04-28 22:21:49 +02:00
|
|
|
hwndOwner, lpstrFile, nMaxFile,lpdwIconIndex);
|
|
|
|
return 0xffffffff;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
2008-06-27 17:08:14 +02:00
|
|
|
* RunFileDlgW [internal]
|
2000-04-28 22:21:49 +02:00
|
|
|
*
|
2008-06-27 17:08:14 +02:00
|
|
|
* The Unicode function that is available as ordinal 61 on Windows NT/2000/XP/...
|
|
|
|
*
|
|
|
|
* SEE ALSO
|
|
|
|
* RunFileDlgAW
|
2000-04-28 22:21:49 +02:00
|
|
|
*/
|
2008-12-03 12:09:38 +01:00
|
|
|
static void RunFileDlgW(
|
2000-04-28 22:21:49 +02:00
|
|
|
HWND hwndOwner,
|
|
|
|
HICON hIcon,
|
2008-06-27 17:08:14 +02:00
|
|
|
LPCWSTR lpstrDirectory,
|
|
|
|
LPCWSTR lpstrTitle,
|
|
|
|
LPCWSTR lpstrDescription,
|
2000-04-28 22:21:49 +02:00
|
|
|
UINT uFlags)
|
|
|
|
{
|
2008-06-27 17:08:14 +02:00
|
|
|
static const WCHAR resnameW[] = {'S','H','E','L','L','_','R','U','N','_','D','L','G',0};
|
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;
|
|
|
|
|
2008-06-27 17:55:48 +02:00
|
|
|
if (!(hRes = FindResourceW(shell32_hInstance, resnameW, (LPWSTR)RT_DIALOG)) ||
|
|
|
|
!(template = LoadResource(shell32_hInstance, hRes)))
|
|
|
|
{
|
|
|
|
ERR("Couldn't load SHELL_RUN_DLG resource\n");
|
2008-06-27 18:16:47 +02:00
|
|
|
ShellMessageBoxW(shell32_hInstance, hwndOwner, MAKEINTRESOURCEW(IDS_RUNDLG_ERROR), NULL, MB_OK | MB_ICONERROR);
|
2002-06-10 04:34:36 +02:00
|
|
|
return;
|
2008-06-27 17:55:48 +02:00
|
|
|
}
|
2002-06-10 04:34:36 +02:00
|
|
|
|
2008-06-27 17:28:57 +02:00
|
|
|
DialogBoxIndirectParamW(shell32_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
|
|
|
}
|
|
|
|
|
2008-10-21 23:07:47 +02:00
|
|
|
/* find the directory that contains the file being run */
|
|
|
|
static LPWSTR RunDlg_GetParentDir(LPCWSTR cmdline)
|
|
|
|
{
|
|
|
|
const WCHAR *src;
|
|
|
|
WCHAR *dest, *result, *result_end=NULL;
|
2008-11-12 08:15:42 +01:00
|
|
|
static const WCHAR dotexeW[] = {'.','e','x','e',0};
|
2008-10-21 23:07:47 +02:00
|
|
|
|
|
|
|
result = HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR)*(strlenW(cmdline)+5));
|
|
|
|
|
|
|
|
src = cmdline;
|
|
|
|
dest = result;
|
|
|
|
|
|
|
|
if (*src == '"')
|
|
|
|
{
|
|
|
|
src++;
|
|
|
|
while (*src && *src != '"')
|
|
|
|
{
|
|
|
|
if (*src == '\\')
|
|
|
|
result_end = dest;
|
|
|
|
*dest++ = *src++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
while (*src)
|
|
|
|
{
|
|
|
|
if (isspaceW(*src))
|
|
|
|
{
|
|
|
|
*dest = 0;
|
|
|
|
if (INVALID_FILE_ATTRIBUTES != GetFileAttributesW(result))
|
|
|
|
break;
|
|
|
|
strcatW(dest, dotexeW);
|
|
|
|
if (INVALID_FILE_ATTRIBUTES != GetFileAttributesW(result))
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else if (*src == '\\')
|
|
|
|
result_end = dest;
|
|
|
|
*dest++ = *src++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (result_end)
|
|
|
|
{
|
|
|
|
*result_end = 0;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
HeapFree(GetProcessHeap(), 0, result);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-06-10 04:34:36 +02:00
|
|
|
/* Dialog procedure for RunFileDlg */
|
2007-02-06 23:04:31 +01:00
|
|
|
static INT_PTR CALLBACK RunDlgProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
2002-06-10 04:34:36 +02:00
|
|
|
{
|
2008-06-27 19:03:24 +02:00
|
|
|
RUNFILEDLGPARAMS *prfdp = (RUNFILEDLGPARAMS *)GetWindowLongPtrW(hwnd, DWLP_USER);
|
2002-07-16 03:15:15 +02:00
|
|
|
|
2002-06-10 04:34:36 +02:00
|
|
|
switch (message)
|
|
|
|
{
|
|
|
|
case WM_INITDIALOG :
|
|
|
|
prfdp = (RUNFILEDLGPARAMS *)lParam ;
|
2008-06-27 19:03:24 +02:00
|
|
|
SetWindowLongPtrW(hwnd, DWLP_USER, (LONG_PTR)prfdp);
|
|
|
|
|
|
|
|
if (prfdp->lpstrTitle)
|
|
|
|
SetWindowTextW(hwnd, prfdp->lpstrTitle);
|
|
|
|
if (prfdp->lpstrDescription)
|
|
|
|
SetWindowTextW(GetDlgItem(hwnd, IDC_RUNDLG_DESCRIPTION), prfdp->lpstrDescription);
|
|
|
|
if (prfdp->uFlags & RFF_NOBROWSE)
|
|
|
|
{
|
|
|
|
HWND browse = GetDlgItem(hwnd, IDC_RUNDLG_BROWSE);
|
|
|
|
ShowWindow(browse, SW_HIDE);
|
|
|
|
EnableWindow(browse, FALSE);
|
|
|
|
}
|
|
|
|
if (prfdp->uFlags & RFF_NOLABEL)
|
|
|
|
ShowWindow(GetDlgItem(hwnd, IDC_RUNDLG_LABEL), SW_HIDE);
|
|
|
|
if (prfdp->uFlags & RFF_CALCDIRECTORY)
|
|
|
|
FIXME("RFF_CALCDIRECTORY not supported\n");
|
|
|
|
|
2008-07-08 16:05:50 +02:00
|
|
|
if (prfdp->hIcon == NULL)
|
|
|
|
prfdp->hIcon = LoadIconW(NULL, (LPCWSTR)IDI_WINLOGO);
|
|
|
|
SendMessageW(hwnd, WM_SETICON, ICON_BIG, (LPARAM)prfdp->hIcon);
|
|
|
|
SendMessageW(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)prfdp->hIcon);
|
|
|
|
SendMessageW(GetDlgItem(hwnd, IDC_RUNDLG_ICON), STM_SETICON, (WPARAM)prfdp->hIcon, 0);
|
|
|
|
|
2008-06-27 19:03:24 +02:00
|
|
|
FillList (GetDlgItem (hwnd, IDC_RUNDLG_EDITPATH), NULL, (prfdp->uFlags & RFF_NODEFAULT) == 0) ;
|
2008-06-27 17:28:57 +02:00
|
|
|
SetFocus (GetDlgItem (hwnd, IDC_RUNDLG_EDITPATH)) ;
|
2002-06-10 04:34:36 +02:00
|
|
|
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 :
|
|
|
|
{
|
2008-06-27 17:08:14 +02:00
|
|
|
int ic ;
|
2008-06-27 17:28:57 +02:00
|
|
|
HWND htxt = GetDlgItem (hwnd, IDC_RUNDLG_EDITPATH);
|
2008-06-27 17:08:14 +02:00
|
|
|
if ((ic = GetWindowTextLengthW (htxt)))
|
2002-06-10 04:34:36 +02:00
|
|
|
{
|
2008-10-21 23:07:47 +02:00
|
|
|
WCHAR *psz, *parent=NULL ;
|
2008-12-18 22:18:47 +01:00
|
|
|
SHELLEXECUTEINFOW sei ;
|
|
|
|
|
|
|
|
ZeroMemory (&sei, sizeof(sei)) ;
|
|
|
|
sei.cbSize = sizeof(sei) ;
|
2008-06-27 17:08:14 +02:00
|
|
|
psz = HeapAlloc( GetProcessHeap(), 0, (ic + 1)*sizeof(WCHAR) );
|
|
|
|
GetWindowTextW (htxt, psz, ic + 1) ;
|
2002-07-16 03:15:15 +02:00
|
|
|
|
2008-06-27 19:03:24 +02:00
|
|
|
/* according to http://www.codeproject.com/KB/shell/runfiledlg.aspx we should send a
|
|
|
|
* WM_NOTIFY before execution */
|
|
|
|
|
2008-12-18 22:18:47 +01:00
|
|
|
sei.hwnd = hwnd;
|
|
|
|
sei.nShow = SW_SHOWNORMAL;
|
|
|
|
sei.lpFile = psz;
|
|
|
|
|
2008-10-21 23:07:47 +02:00
|
|
|
if (prfdp->lpstrDirectory)
|
2008-12-18 22:18:47 +01:00
|
|
|
sei.lpDirectory = prfdp->lpstrDirectory;
|
2008-10-21 23:07:47 +02:00
|
|
|
else
|
2008-12-18 22:18:47 +01:00
|
|
|
sei.lpDirectory = parent = RunDlg_GetParentDir(sei.lpFile);
|
2008-10-21 23:07:47 +02:00
|
|
|
|
2009-06-30 17:43:41 +02:00
|
|
|
if (!ShellExecuteExW( &sei ))
|
|
|
|
{
|
2004-08-09 21:46:47 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, psz);
|
2008-12-18 22:52:52 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, parent);
|
2002-06-10 04:34:36 +02:00
|
|
|
SendMessageA (htxt, CB_SETEDITSEL, 0, MAKELPARAM (0, -1)) ;
|
|
|
|
return TRUE ;
|
2009-06-30 17:43:41 +02:00
|
|
|
}
|
2008-06-27 17:08:14 +02:00
|
|
|
|
|
|
|
/* FillList is still ANSI */
|
|
|
|
GetWindowTextA (htxt, (LPSTR)psz, ic + 1) ;
|
2008-06-27 19:03:24 +02:00
|
|
|
FillList (htxt, (LPSTR)psz, FALSE) ;
|
2008-06-27 17:08:14 +02:00
|
|
|
|
2004-08-09 21:46:47 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, psz);
|
2008-10-21 23:07:47 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, parent);
|
2009-06-30 17:43:41 +02:00
|
|
|
EndDialog (hwnd, 0);
|
2002-06-10 04:34:36 +02:00
|
|
|
}
|
|
|
|
}
|
2011-03-18 22:36:10 +01:00
|
|
|
return TRUE;
|
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
|
|
|
|
2008-06-27 17:28:57 +02:00
|
|
|
case IDC_RUNDLG_BROWSE :
|
2002-06-10 04:34:36 +02:00
|
|
|
{
|
2011-01-13 12:33:44 +01:00
|
|
|
static const WCHAR filterW[] = {'%','s','%','c','*','.','e','x','e','%','c','%','s','%','c','*','.','*','%','c',0};
|
2003-01-15 00:43:41 +01:00
|
|
|
HMODULE hComdlg = NULL ;
|
2002-06-10 04:34:36 +02:00
|
|
|
LPFNOFN ofnProc = NULL ;
|
2008-06-27 17:55:48 +02:00
|
|
|
static const WCHAR comdlg32W[] = {'c','o','m','d','l','g','3','2',0};
|
2008-06-27 17:45:10 +02:00
|
|
|
WCHAR szFName[1024] = {0};
|
2011-01-13 12:33:44 +01:00
|
|
|
WCHAR filter_exe[256], filter_all[256], filter[MAX_PATH], szCaption[MAX_PATH];
|
2008-06-27 17:45:10 +02:00
|
|
|
OPENFILENAMEW ofn;
|
2002-07-16 03:15:15 +02:00
|
|
|
|
2011-01-13 12:33:44 +01:00
|
|
|
LoadStringW(shell32_hInstance, IDS_RUNDLG_BROWSE_FILTER_EXE, filter_exe, 256);
|
|
|
|
LoadStringW(shell32_hInstance, IDS_RUNDLG_BROWSE_FILTER_ALL, filter_all, 256);
|
2008-06-27 18:16:47 +02:00
|
|
|
LoadStringW(shell32_hInstance, IDS_RUNDLG_BROWSE_CAPTION, szCaption, MAX_PATH);
|
2012-02-26 20:05:00 +01:00
|
|
|
snprintfW( filter, MAX_PATH, filterW, filter_exe, 0, 0, filter_all, 0, 0 );
|
2008-06-27 18:16:47 +02:00
|
|
|
|
2008-06-27 17:45:10 +02:00
|
|
|
ZeroMemory(&ofn, sizeof(ofn));
|
|
|
|
ofn.lStructSize = sizeof(OPENFILENAMEW);
|
|
|
|
ofn.hwndOwner = hwnd;
|
2011-01-13 12:33:44 +01:00
|
|
|
ofn.lpstrFilter = filter;
|
2008-06-27 17:45:10 +02:00
|
|
|
ofn.lpstrFile = szFName;
|
|
|
|
ofn.nMaxFile = 1023;
|
|
|
|
ofn.lpstrTitle = szCaption;
|
|
|
|
ofn.Flags = OFN_ENABLESIZING | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_PATHMUSTEXIST;
|
2008-06-27 19:03:24 +02:00
|
|
|
ofn.lpstrInitialDir = prfdp->lpstrDirectory;
|
2002-07-16 03:15:15 +02:00
|
|
|
|
2008-06-27 17:55:48 +02:00
|
|
|
if (NULL == (hComdlg = LoadLibraryExW (comdlg32W, NULL, 0)) ||
|
|
|
|
NULL == (ofnProc = (LPFNOFN)GetProcAddress (hComdlg, "GetOpenFileNameW")))
|
|
|
|
{
|
|
|
|
ERR("Couldn't get GetOpenFileName function entry (lib=%p, proc=%p)\n", hComdlg, ofnProc);
|
2008-06-27 18:16:47 +02:00
|
|
|
ShellMessageBoxW(shell32_hInstance, hwnd, MAKEINTRESOURCEW(IDS_RUNDLG_BROWSE_ERROR), NULL, MB_OK | MB_ICONERROR);
|
2002-06-10 04:34:36 +02:00
|
|
|
return TRUE ;
|
2008-06-27 17:55:48 +02:00
|
|
|
}
|
2002-07-16 03:15:15 +02:00
|
|
|
|
2008-06-27 17:45:10 +02:00
|
|
|
if (ofnProc(&ofn))
|
|
|
|
{
|
|
|
|
SetFocus (GetDlgItem (hwnd, IDOK)) ;
|
2008-06-27 19:03:24 +02:00
|
|
|
SetWindowTextW (GetDlgItem (hwnd, IDC_RUNDLG_EDITPATH), szFName) ;
|
|
|
|
SendMessageW (GetDlgItem (hwnd, IDC_RUNDLG_EDITPATH), CB_SETEDITSEL, 0, MAKELPARAM (0, -1)) ;
|
2008-06-27 17:45:10 +02:00
|
|
|
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 */
|
2008-06-27 19:03:24 +02:00
|
|
|
/* fShowDefault ignored if pszLatest != NULL */
|
|
|
|
static void FillList (HWND hCb, char *pszLatest, BOOL fShowDefault)
|
2002-06-10 04:34:36 +02:00
|
|
|
{
|
|
|
|
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) ;
|
2008-06-27 19:03:24 +02:00
|
|
|
if (!Nix && fShowDefault)
|
2002-06-10 04:34:36 +02:00
|
|
|
{
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2008-06-27 17:08:14 +02:00
|
|
|
/*************************************************************************
|
|
|
|
* RunFileDlgA [internal]
|
|
|
|
*
|
|
|
|
* The ANSI function that is available as ordinal 61 on Windows 9x/Me
|
|
|
|
*
|
|
|
|
* SEE ALSO
|
|
|
|
* RunFileDlgAW
|
|
|
|
*/
|
2008-12-03 12:09:38 +01:00
|
|
|
static void RunFileDlgA(
|
2008-06-27 17:08:14 +02:00
|
|
|
HWND hwndOwner,
|
|
|
|
HICON hIcon,
|
|
|
|
LPCSTR lpstrDirectory,
|
|
|
|
LPCSTR lpstrTitle,
|
|
|
|
LPCSTR lpstrDescription,
|
|
|
|
UINT uFlags)
|
|
|
|
{
|
|
|
|
WCHAR title[MAX_PATH]; /* longer string wouldn't be visible in the dialog anyway */
|
|
|
|
WCHAR description[MAX_PATH];
|
|
|
|
WCHAR directory[MAX_PATH];
|
|
|
|
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, lpstrTitle, -1, title, MAX_PATH);
|
|
|
|
title[MAX_PATH - 1] = 0;
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, lpstrDescription, -1, description, MAX_PATH);
|
|
|
|
description[MAX_PATH - 1] = 0;
|
|
|
|
if (!MultiByteToWideChar(CP_ACP, 0, lpstrDirectory, -1, directory, MAX_PATH))
|
|
|
|
directory[0] = 0;
|
|
|
|
|
2008-06-27 19:03:24 +02:00
|
|
|
RunFileDlgW(hwndOwner, hIcon,
|
|
|
|
lpstrDirectory ? directory : NULL,
|
|
|
|
lpstrTitle ? title : NULL,
|
|
|
|
lpstrDescription ? description : NULL,
|
|
|
|
uFlags);
|
2008-06-27 17:08:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
* RunFileDlgAW [SHELL32.61]
|
|
|
|
*
|
|
|
|
* An undocumented way to open the Run File dialog. A documented way is to use
|
|
|
|
* CLSID_Shell, IID_IShellDispatch (as of Wine 1.0, not implemented under Wine)
|
|
|
|
*
|
|
|
|
* Exported by ordinal. ANSI on Windows 9x and Unicode on Windows NT/2000/XP/etc
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
void WINAPI RunFileDlgAW(
|
|
|
|
HWND hwndOwner,
|
|
|
|
HICON hIcon,
|
|
|
|
LPCVOID lpstrDirectory,
|
|
|
|
LPCVOID lpstrTitle,
|
|
|
|
LPCVOID lpstrDescription,
|
|
|
|
UINT uFlags)
|
|
|
|
{
|
|
|
|
if (SHELL_OsIsUnicode())
|
|
|
|
RunFileDlgW(hwndOwner, hIcon, lpstrDirectory, lpstrTitle, lpstrDescription, uFlags);
|
|
|
|
else
|
|
|
|
RunFileDlgA(hwndOwner, hIcon, lpstrDirectory, lpstrTitle, lpstrDescription, uFlags);
|
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
|
2007-10-28 02:35:51 +02:00
|
|
|
/* FIXME: use lpwstrReason */
|
2004-07-10 00:51:19 +02:00
|
|
|
if (ConfirmDialog(hWndOwner, IDS_RESTART_PROMPT, IDS_RESTART_TITLE))
|
|
|
|
{
|
|
|
|
HANDLE hToken;
|
|
|
|
TOKEN_PRIVILEGES npr;
|
|
|
|
|
2007-11-09 12:37:53 +01:00
|
|
|
/* enable the shutdown privilege for the current process */
|
2004-07-10 00:51:19 +02:00
|
|
|
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);
|
|
|
|
}
|
2007-10-28 02:35:51 +02:00
|
|
|
ExitWindowsEx(EWX_REBOOT, uReason);
|
2004-07-10 00:51:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
}
|