Board index » delphi » ExecProgram

ExecProgram

Gidday, could anyone tell me how to use the ExecProgram rountine?

I believe this is a macro or so the Delphi help says, what I a m trying
to do at the moment is stick it within a speedbutton. The help file
suggests it is as easy as

ExecProgram("clock.exe",1); except I receive an identifier not
recognised error or something to that extent. Obviously I am doing
something really embarressingly easily wrong but some assistance would
be greatly appreciated.

Else if there is an easier way to execute a windows application, please
share.

Thanks, Matt

P.S. Please email ASAP ter...@ak.planet.co.nz

 

Re:ExecProgram


Try WinExec instead.

Re:ExecProgram


Matthew Comb <ter...@ak.planet.co.nz> wrote in article
<3264AFFC.2...@ak.planet.co.nz>...

Quote
> Gidday, could anyone tell me how to use the ExecProgram rountine?
> P.S. Please email ASAP ter...@ak.planet.co.nz

I would use ShellExecute instead:
HINSTANCE ShellExecute(
    HWND  hwnd, // handle to parent window
    LPCTSTR  lpOperation,       // pointer to string that specifies operation to
perform
    LPCTSTR  lpFile,    // pointer to filename string
    LPTSTR  lpParameters,       // pointer to string that specifies
executable-file parameters
    LPCTSTR  lpDirectory,       // pointer to string that specifies default
directory
    INT  nShowCmd       // whether file is shown when opened
   );  

...or, as Delphians would have it:

function
ShellExecute(hWnd:HWND;lpOperation,lpFile,lpParameters,lpDirectory:LPSTR;nSh
owCmd:Integer):HINSTANCE;

- call like this (if you want to start notepad.exe and load a file):

Result :=
ShellExecute(Handle,'open','c:\windows\notepad.exe','textfile.txt',GetCurren
tDir,SW_SHOWNORMAL);

if you want to use variables, the LPSTR's must be cast to PChar's

Hope this helps,

Peter

Other Threads