Release 1.5.29.
[wine] / programs / taskmgr / run.c
1 /*
2  *  ReactOS Task Manager
3  *
4  *  run.c
5  *
6  *  Copyright (C) 1999 - 2001  Brian Palmer  <brianp@reactos.org>
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21  */
22
23 #include <stdio.h>
24 #include <stdlib.h>
25
26 #include <windows.h>
27 #include <commctrl.h>
28
29 #include "taskmgr.h"
30
31 typedef void (WINAPI *RUNFILEDLG)(
32 HWND    hwndOwner, 
33 HICON   hIcon, 
34 LPCSTR  lpstrDirectory, 
35 LPCSTR  lpstrTitle, 
36 LPCSTR  lpstrDescription,
37 UINT    uFlags); 
38
39 /*
40  * Flags for RunFileDlg
41  */
42
43 #define RFF_NOBROWSE            0x01    /* Removes the browse button. */
44 #define RFF_NODEFAULT           0x02    /* No default item selected. */
45 #define RFF_CALCDIRECTORY       0x04    /* Calculates the working directory from the file name. */
46 #define RFF_NOLABEL                     0x08    /* Removes the edit box label. */
47 #define RFF_NOSEPARATEMEM       0x20    /* Removes the Separate Memory Space check box (Windows NT only). */
48
49 void TaskManager_OnFileNew(void)
50 {
51     HMODULE            hShell32;
52     RUNFILEDLG        RunFileDlg;
53     OSVERSIONINFOW    versionInfo;
54     static const WCHAR wszShell32[] = {'S','H','E','L','L','3','2','.','D','L','L',0};
55
56     hShell32 = LoadLibraryW(wszShell32);
57     RunFileDlg = (void *)GetProcAddress(hShell32, (LPCSTR)61);
58
59     /* Show "Run..." dialog */
60     if (RunFileDlg)
61     {
62         HICON hIcon = LoadIconW(GetModuleHandleW(NULL), MAKEINTRESOURCEW(IDI_TASKMANAGER));
63         versionInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFOW);
64         GetVersionExW(&versionInfo);
65
66         if (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT)
67         {
68             WCHAR wTitle[64];
69             LoadStringW(GetModuleHandleW(NULL), IDS_RUNDLG_CAPTION, wTitle, 64);
70             RunFileDlg(hMainWnd, hIcon, NULL, (LPCSTR)wTitle, NULL, RFF_CALCDIRECTORY);
71         }
72         else
73         {
74             char szTitle[64];
75             LoadStringA(GetModuleHandleW(NULL), IDS_RUNDLG_CAPTION, szTitle, 64);
76             RunFileDlg(hMainWnd, hIcon, NULL, szTitle, NULL, RFF_CALCDIRECTORY);
77         }
78     }
79
80     FreeLibrary(hShell32);
81 }