run.c 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. #include <stdio.h>
  23. #include <stdlib.h>
  24. #include <windows.h>
  25. #include <commctrl.h>
  26. #include "taskmgr.h"
  27. typedef void (WINAPI *RUNFILEDLG)(
  28. HWND hwndOwner,
  29. HICON hIcon,
  30. LPCSTR lpstrDirectory,
  31. LPCSTR lpstrTitle,
  32. LPCSTR lpstrDescription,
  33. UINT uFlags);
  34. /*
  35. * Flags for RunFileDlg
  36. */
  37. #define RFF_NOBROWSE 0x01 /* Removes the browse button. */
  38. #define RFF_NODEFAULT 0x02 /* No default item selected. */
  39. #define RFF_CALCDIRECTORY 0x04 /* Calculates the working directory from the file name. */
  40. #define RFF_NOLABEL 0x08 /* Removes the edit box label. */
  41. #define RFF_NOSEPARATEMEM 0x20 /* Removes the Separate Memory Space check box (Windows NT only). */
  42. void TaskManager_OnFileNew(void)
  43. {
  44. HMODULE hShell32;
  45. RUNFILEDLG RunFileDlg;
  46. OSVERSIONINFOW versionInfo;
  47. static const WCHAR wszShell32[] = {'S','H','E','L','L','3','2','.','D','L','L',0};
  48. hShell32 = LoadLibraryW(wszShell32);
  49. RunFileDlg = (void *)GetProcAddress(hShell32, (LPCSTR)61);
  50. /* Show "Run..." dialog */
  51. if (RunFileDlg)
  52. {
  53. HICON hIcon = LoadIconW(GetModuleHandleW(NULL), MAKEINTRESOURCEW(IDI_TASKMANAGER));
  54. versionInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFOW);
  55. GetVersionExW(&versionInfo);
  56. if (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT)
  57. {
  58. WCHAR wTitle[64];
  59. LoadStringW(GetModuleHandleW(NULL), IDS_RUNDLG_CAPTION, wTitle, 64);
  60. RunFileDlg(hMainWnd, hIcon, NULL, (LPCSTR)wTitle, NULL, RFF_CALCDIRECTORY);
  61. }
  62. else
  63. {
  64. char szTitle[64];
  65. LoadStringA(GetModuleHandleW(NULL), IDS_RUNDLG_CAPTION, szTitle, 64);
  66. RunFileDlg(hMainWnd, hIcon, NULL, szTitle, NULL, RFF_CALCDIRECTORY);
  67. }
  68. }
  69. FreeLibrary(hShell32);
  70. }