// Declare winexec (lpcmdline: lpcstr; {file name and parameter; if no path is specified, it will be searched in the following order: Program Directory/current directory/system32/Windows/Path Environment Variable} ucmdshow: uint {startup option}): uint; // return value: greater than 31 {successful call} equal to 0 {insufficient memory} error_file_not_found = 2; {file name error} error_path_not_found = 3; {path name error} error_bad_format = 11; {EXE file invalid} // optional ucmdshow parameter value: sw_hide = 0; {hide, and the taskbar is not minimized.} sw_shownormal = 1; {display with the nearest size and position, activation} sw_normal = 1; {same as sw_shownormal} sw_showminimized = 2; {minimized, activation} optimized = 3; {maximized, activation} sw_maximize = 3; {same as sw_showmaximized} sw_shownoactivate = 4; {display with the nearest size and position, not activated} sw_show = 5; {same as sw_shownormal} sw_minimize = 6; {minimized, not activated} sw_showminnoactive = 7; {same as sw_minimize} sw_showna = 8; {same as sw_shownoactivate} sw_restore = 9; {same as sw_shownormal} sw_showdefault = 10; {same as sw_shownormal} sw_max = 10; {same as sw_show}
// For example, start notepad: Procedure tform1.button1click (Sender: tobject); begin winexec('notepad.exe ', sw_shownormal); end;