dbf3b9f7ff953d95264fe90d6b4e7f2e8b0f578a
[reactos.git] / rosapps / winfile / 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 program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program 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
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */
22
23 #ifdef _MSC_VER
24 #include "stdafx.h"
25 #else
26 #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
27 #include <windows.h>
28 #include <commctrl.h>
29 #include <stdlib.h>
30 #include <malloc.h>
31 #include <memory.h>
32 #include <tchar.h>
33 #include <process.h>
34 #include <stdio.h>
35 #endif
36
37 #include "winfile.h"
38 #include "run.h"
39
40
41 void OnFileRun(void)
42 {
43 HMODULE hShell32;
44 RUNFILEDLG RunFileDlg;
45 OSVERSIONINFO versionInfo;
46 WCHAR wTitle[40];
47 WCHAR wText[256];
48 char szTitle[40] = "Create New Task";
49 char szText[256] = "Type the name of a program, folder, document, or Internet resource, and Task Manager will open it for you.";
50
51 hShell32 = LoadLibrary("SHELL32.DLL");
52 RunFileDlg = (RUNFILEDLG)(FARPROC)GetProcAddress(hShell32, (char*)((long)0x3D));
53
54 // Show "Run..." dialog
55 if (RunFileDlg)
56 {
57 versionInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
58 GetVersionEx(&versionInfo);
59
60 if (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT)
61 {
62 MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, szTitle, -1, wTitle, 40);
63 MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, szText, -1, wText, 256);
64 RunFileDlg(Globals.hMainWnd, 0, NULL, (LPCSTR)wTitle, (LPCSTR)wText, RFF_CALCDIRECTORY);
65 }
66 else
67 RunFileDlg(Globals.hMainWnd, 0, NULL, szTitle, szText, RFF_CALCDIRECTORY);
68 }
69
70 FreeLibrary(hShell32);
71 }