//***************************************************************************************** // Copyright (c) 2000 Michael Kurz // All rights reserved. // If you want to use this source in your applications conatct: // // $FileName : mExecute.pkg // $ProjectName : Shared Methods // $Author : Michael Kurz // $Created : 04-20-2001 @ 13:00 // // Contents: // Covers some uses of the ShellExecute function (Win32) // -Open the Shell's search window. // -Open a file with the default program // -Print a file with the default program // // $Rev History // //***************************************************************************************** // *WvA: Added ShellExecuteExA functionality to have a file properties option. //TH-RevisionStart //TH-RevisionEnd External_FunctionEx ShellExecute "ShellExecuteA" SHELL32.DLL ; Handle hwnd String lpszOp String lpszFile String lpszParams ; String lpszDir Integer FsShowCmd returns Integer Define SEE_MASK_DEFAULT For |CI$00000000 Define SEE_MASK_CLASSNAME For |CI$00000001 Define SEE_MASK_CLASSKEY For |CI$00000003 Define SEE_MASK_IDLIST For |CI$00000004 Define SEE_MASK_INVOKEIDLIST For |CI$0000000C Define SEE_MASK_ICON For |CI$00000010 Define SEE_MASK_HOTKEY For |CI$00000020 Define SEE_MASK_NOCLOSEPROCESS For |CI$00000040 Define SEE_MASK_CONNECTNETDRV For |CI$00000080 Define SEE_MASK_NOASYNC For |CI$00000100 Define SEE_MASK_FLAG_DDEWAIT For |CI$00000100 // do not use Define SEE_MASK_DOENVSUBST For |CI$00000200 Define SEE_MASK_FLAG_NO_UI For |CI$00000400 Define SEE_MASK_UNICODE For |CI$00004000 Define SEE_MASK_NO_CONSOLE For |CI$00008000 Define SEE_MASK_ASYNCOK For |CI$00100000 Define SEE_MASK_NOQUERYCLASSSTORE For |CI$01000000 Define SEE_MASK_HMONITOR For |CI$00200000 Define SEE_MASK_NOZONECHECKS For |CI$00800000 Define SEE_MASK_WAITFORINPUTIDLE For |CI$02000000 Define SEE_MASK_FLAG_LOG_USAGE For |CI$04000000 Define SEE_MASK_FLAG_HINST_IS_SITE For |CI$08000000 // // // http://msdn.microsoft.com/en-us/library/windows/desktop/bb759784%28v=vs.85%29.aspx // //typedef struct _SHELLEXECUTEINFO { // DWORD cbSize; // ULONG fMask; // HWND hwnd; // LPCTSTR lpVerb; // LPCTSTR lpFile; // LPCTSTR lpParameters; // LPCTSTR lpDirectory; // int nShow; // HINSTANCE hInstApp; // LPVOID lpIDList; // LPCTSTR lpClass; // HKEY hkeyClass; // DWORD dwHotKey; // union { // HANDLE hIcon; // HANDLE hMonitor; // } DUMMYUNIONNAME; // HANDLE hProcess; //} SHELLEXECUTEINFO, *LPSHELLEXECUTEINFO; Struct tShellExecuteInfo DWORD cbSize Pointer fMask // ULong Handle hWnd Pointer lpVerb Pointer lpFile Pointer lpParameters Pointer lpDirectory integer nShow Handle hInstApp Pointer lpIDList Pointer lpClass Handle hkeyClass DWord dwHotKey Handle hIconMonitor // it's a union so each field in same space Handle hProcess End_Struct External_FunctionEx ShellExecuteExEf "ShellExecuteExA" SHELL32.DLL ; Pointer pExecInfo returns Integer Procedure SHExecute string sMode string sFile integer iShow integer iRet handle hwnd move (GetDesktopWindow()) to hwnd // Defined in WinUser.pkg move (ShellExecute(hwnd,sMode,sFile,"","",iShow)) to iRet Procedure_Return iRet End_Procedure // Starts a Search in Files in the given Directory. Procedure SHStartFindFiles Global string sDirE string sDir If Num_Arguments gt 0 move sDirE to sDir send SHExecute "find" sDir 0 End_Procedure // Opens a File. Procedure SHOpenFile global String sFile integer iShowModeE integer iShowMode IF Num_Arguments gt 1 move iShowModeE to iShowMode Else move SW_Normal to iShowMode send SHExecute "Open" sFile iShowMode End_Procedure // Prints a File. Procedure SHPrintFile global String sFile integer iShowModeE integer iShowMode IF Num_Arguments gt 1 move iShowModeE to iShowMode Else move SW_Normal to iShowMode send SHExecute "Print" sFile iShowMode End_Procedure // Shows properties of a file. Procedure SHPropertiesFile global String sFile Boolean bError Handle hInstApp Handle hWnd DWord fMask Integer iVoid String sVerb String sParams tShellExecuteInfo ShellExecuteInfo Move ("properties"+character(0)) To sVerb Get Window_Handle To hWnd Move (ZeroString(10)) To sParams Move (SEE_MASK_INVOKEIDLIST iOr SEE_MASK_FLAG_NO_UI iOr SEE_MASK_DOENVSUBST) To fMask Move 0 To ShellExecuteInfo.hWnd Move (SizeOfType(tShellExecuteInfo)) To ShellExecuteInfo.cbSize Move hWnd To ShellExecuteInfo.hWnd Move fMask To ShellExecuteInfo.fMask Move (AddressOf(sVerb)) To ShellExecuteInfo.lpVerb Move (AddressOf(sFile)) To ShellExecuteInfo.lpFile Move (AddressOf(sParams)) To ShellExecuteInfo.lpParameters Move SW_SHOW To ShellExecuteInfo.nShow Move (ShellExecuteExEf(AddressOf(ShellExecuteInfo))) To iVoid Move ShellExecuteInfo.hInstApp To hInstApp If (hInstApp<32) Begin Move True To bError End End_Procedure // Got this declaration from dosbox.src // External_Function WinExecEf "WinExec" KERNEL32.DLL Pointer pCmdL Integer iShow Returns Integer Function WinExec Global String sPrg Integer iMode Returns Integer Integer iRet String sP Move sPrg To sP Move (WinExecEf(AddressOf(sP),iMode)) To iRet Function_Return iRet End_Function