ShellExecute (hwnd: hwnd; {specify the parent window handle} Operation: pchar; {specify the action, for example, open, print} filename: pchar; {specify the file to open or Program } Parameters: pchar; {specify parameters for the program to be opened; if the file is opened, it should be nil} Directory: pchar; {default directory} showcmd: INTEGER {open option }): hinst; {the application handle will be returned if the execution is successful. If this value is // an example to illustrate more problems (do not forget uses shellapi ;): {open a file in Notepad for example} begin ShellExecute (handle, 'open', 'notepad.exe ', 'c: \ windows \ schedlgu. TXT ', nil, sw_shownormal); end;
{The first parameter is used as the parent window of the error Prompt window. It cannot be nil or 0 (desktop window)} begin ShellExecute (0, 'open ', 'notepad.exe ', 'c: \ windows \ schedlgu. TXT ', nil, sw_shownormal); end;
{If the second parameter is nil, it also defaults to open} begin ShellExecute (0, nil, 'notepad.exe ', 'c: \ windows \ schedlgu. TXT ', nil, sw_shownormal); end;
{File path can be placed in parameter 5} begin ShellExecute (0, nil, 'notepad.exe ', 'schedlgu. txt', 'c: \ Windows', sw_shownormal); end;
{Specify parameter 3 as the file to be opened, and the file will be opened with the corresponding default program; Number Parameter 4 should be nil} begin ShellExecute (0, nil, 'schedlgu. TXT ', nil, 'c: \ Windows', sw_shownormal); end;
{If the file is in the program directory/current directory/system32/Windows/PATH environment variable, you can also set parameter 5 to nil} begin ShellExecute (0, nil, 'schedlgu. TXT ', nil, nil, sw_shownormal); end;
{If parameter 3 is a file, run parameter 2 to print the file.} begin ShellExecute (0, 'print', 'schedlgu. txt ', nil, nil, 1); end;
{Open web page with IE} begin ShellExecute (handle, 'open', 'i0000e. EXE ', 'about: blank', nil, sw_shownormal); end;
{Open web page with Firefox} begin ShellExecute (handle, 'open', 'firefox.exe ', 'about: blank', nil, sw_shownormal); end;
{Open webpage with default browser} begin ShellExecute (handle, 'open', 'cmder.exe ', 'about: blank', nil, sw_shownormal); end;
{Use the default browser to open the webpage} begin ShellExecute (0, nil, 'HTTP: // del.cnblogs.com ', nil, nil, 1); end;