Link to home
Start Free TrialLog in
Avatar of Jurica2505
Jurica2505

asked on

Execute programs

how to execute programs(like notepad, wordpad, paint...)?
Avatar of Epsylon
Epsylon

Try this:

ShellExecute(Handle, 'open', 'notepad', '', '', SW_NORMAL);

ShellExecute(Handle, 'open', 'somefile.txt', '', '', SW_NORMAL);

ShellExecute(Handle, 'open', 'somefile.doc', '', '', SW_NORMAL);


Regards,

Epsylon.
Forgot to tell to put ShellAPI in the uses clause.

And here's another example:

ShellExecute(Handle, 'open', 'wordpad', 'c:\autoexec.bat', '', SW_NORMAL);


Cheers,

Epsylon.
you can try this the other way:

WinExec('notepad.exe',2);

You can replace the 2 at 1 or 0:
0 mean invisible
1 mean minimize
2 mean maximize
Epsylon changed the proposed answer to a comment
Uses ShellAPI;

ShellExecute(Handle, 'open', 'notepad', '', '', SW_NORMAL);

ShellExecute(Handle, 'open', 'somefile.txt', '', '', SW_NORMAL);

ShellExecute(Handle, 'open', 'somefile.doc', '', '', SW_NORMAL);

ShellExecute(Handle, 'open', 'wordpad', '', '', SW_NORMAL);

ShellExecute(Handle, 'open', 'paint', '', '', SW_NORMAL);
ASKER CERTIFIED SOLUTION
Avatar of Epsylon
Epsylon

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial