//***************************************************************************************** // 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_Function32 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; Type SHELLEXECUTEINFO Field SHELLEXECUTEINFO.cbSize as DWORD Field SHELLEXECUTEINFO.fMask as Pointer // ULong Field SHELLEXECUTEINFO.hWnd as Handle Field SHELLEXECUTEINFO.lpVerb as Pointer Field SHELLEXECUTEINFO.lpFile as Pointer Field SHELLEXECUTEINFO.lpParameters as Pointer Field SHELLEXECUTEINFO.lpDirectory as Pointer Field SHELLEXECUTEINFO.nShow as integer Field SHELLEXECUTEINFO.hInstApp as Handle Field SHELLEXECUTEINFO.lpIDList as Pointer Field SHELLEXECUTEINFO.lpClass as Pointer Field SHELLEXECUTEINFO.hkeyClass as Handle Field SHELLEXECUTEINFO.dwHotKey as DWord Field SHELLEXECUTEINFO.hIconMonitor as Handle // it's a union so each field in same space Field SHELLEXECUTEINFO.hProcess as Handle End_Type External_Function32 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 String sInfo Move ("properties"+character(0)) To sVerb Get Window_Handle To hWnd ZeroString 10 To sParams Move (SEE_MASK_INVOKEIDLIST iOr SEE_MASK_FLAG_NO_UI iOr SEE_MASK_DOENVSUBST) To fMask ZeroType SHELLEXECUTEINFO To sInfo Put SHELLEXECUTEINFO_SIZE To sInfo At SHELLEXECUTEINFO.cbSize Put hWnd To sInfo At SHELLEXECUTEINFO.hWnd Put fMask To sInfo At SHELLEXECUTEINFO.fMask Put (AddressOf(sVerb)) To sInfo At SHELLEXECUTEINFO.lpVerb Put (AddressOf(sFile)) To sInfo At SHELLEXECUTEINFO.lpFile Put (AddressOf(sParams)) To sInfo At SHELLEXECUTEINFO.lpParameters Put SW_SHOW To sInfo At SHELLEXECUTEINFO.nShow Move (ShellExecuteExEf(AddressOf(sInfo))) To iVoid GetBuff From sInfo At 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 Pointer pP Move sPrg To sP GetAddress Of sP To pP Move (WinExecEf(pP,iMode)) To iRet Function_Return iRet End_Function