Shell exeCall$, vbNormalFocus
Delphi 5.0
ShellExecute
ShellExecute(Self.Handle, nil, 'notepad.exe', nil, nil, SW_SHOWNORMAL); var temp: string; A: array[0..300] of Char; begin temp := 'path\ComponentHelp.html'; StrPCopy(A, temp); ShellExecute(Self.Handle, nil, a, nil, nil, SW_SHOWNORMAL); end;There are 12 possible constants for nShowCmd, though several of them are assigned the same value. To use them, you must also include windows in the uses clause. This is just a sample.
SW_HIDE SW_SHOW SW_RESTORE SW_SHOWNORMAL SW_MINIMIZE SW_SHOWMINIMIZED SW_MAXIMIZE SW_SHOWMAXIMIZED
WinExec
WinExec('notepad.exe', SW_SHOW);
CreateProcess
CreateProcess is a pain - It took me several hours to get only basic functionality. (There are no examples in the help.)
var x : STARTUPINFO; y : PROCESS_INFORMATION; j : Longbool; z : DWORD; b : array[1..100] of char; s : string; begin x.cb := sizeof(x); x.lpReserved := nil ; //required x.lpDesktop := nil ; //required x.lpTitle := nil ; //required x.dwFlags := STARTF_USESHOWWINDOW ; x.wShowWindow := SW_SHOW; x.cbReserved2 := 0 ; // required x.lpReserved2 := nil; // lpCommandLine finds the application in the current path j := CreateProcess(nil, 'notepad.exe', nil, nil, false, CREATE_NEW_CONSOLE + NORMAL_PRIORITY_CLASS, nil, 'c:', x, y); if j=false then begin z := GetLastError() ; FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,nil,z,0,@b, 99, nil); s := b; ShowMessage(s); end; end; // With lpApplicationName, the full path must be specified j := CreateProcess('c:\windows\notepad.exe', '', nil, nil, false, CREATE_NEW_CONSOLE + NORMAL_PRIORITY_CLASS, nil, 'c:\', x, y);
JavaScript
In test_me,
whenever I comment out the
obShell.ShellExecute commands, the Alert command opens a dialog box.
When any one of those commands is present, clicking jstest opens a new browser window.
I am assuming that this indicates some kind of programming error
since
vbtest fails in the same manner.
References:
ExecProgram
ExecProgram("command-line", display-state)The supported display-state values are
Value Meaning 0 Normal 1 Minimized 2 Maximized
ShellExecute and ShellExecuteEx
HINSTANCE ShellExecute( HWND hwnd, // The parent window LPCTSTR lpOperation, // "open", "print", "explorer", null LPCTSTR lpFile, // The file name LPCTSTR lpParameters, // Command line parameters or null LPCTSTR lpDirectory, // The default directory or null INT nShowCmd // One of 12 options - max, min, default ... );ShellExecuteEx requires that you build a record first.
WinExec
UINT WinExec( LPCSTR lpCmdLine, // address of command line UINT uCmdShow // window style for new application );
CreateProcess
BOOL CreateProcess( LPCTSTR lpApplicationName, // pointer to name of executable module LPTSTR lpCommandLine, // pointer to command line string LPSECURITY_ATTRIBUTES lpProcessAttributes, // pointer to process security attributes LPSECURITY_ATTRIBUTES lpThreadAttributes, // pointer to thread security attributes BOOL bInheritHandles, // handle inheritance flag DWORD dwCreationFlags, // creation flags LPVOID lpEnvironment, // pointer to new environment block LPCTSTR lpCurrentDirectory, // pointer to current directory name LPSTARTUPINFO lpStartupInfo, // pointer to STARTUPINFO LPPROCESS_INFORMATION lpProcessInformation // pointer to PROCESS_INFORMATION );Author: Robert Clemenzi - clemenzi@cpcug.org