|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
|
|
#1
|
|||
|
|||
|
Executing .exe?
Hey, i was wondering what the best way to accomplish this was...
I'd like to execute an exe with extra commands... Example: Run "test.exe" -r 123.txt Hopefully you understand what i am saying :P. |
|
#2
|
|||
|
|||
|
Here's a little number I knocked up a few years ago. I knew I still had it.
If memory serves I think it uses ShellAPI or something similar. Anyway, help yourself and please let me know if it works ok for you. RunFile('file.exe {ARGS} argument'); function TForm.RunFile(f: string): boolean; var pos, res: LongInt; t, args: string; begin Result:=True; args:=''; pos:=Instr('{ARGS}',f,1); if pos>0 then begin args:=Trim(Copy(f,pos+6,255)); f:=Copy(f,1,pos-1); end; if args='' then res:=ShellExecute(Application.MainForm.Handle,nil,PChar(f), nil,PChar(PathN(f)),SW_SHOW) else res:=ShellExecute(Application.MainForm.Handle,nil,PChar(f), PChar(args),PChar(PathN(f)),SW_SHOW); if res<=32 then begin case res of 0: t:='The operating system is out of memory or resources.'; ERROR_FILE_NOT_FOUND: t:='The specified file was not found.'; ERROR_PATH_NOT_FOUND: t:='The specified path was not found.'; ERROR_BAD_FORMAT: t:='The .EXE file is invalid (non-Win32 .EXE or error in .EXE image).'; SE_ERR_ACCESSDENIED: t:='The operating system denied access to the specified file.'; SE_ERR_ASSOCINCOMPLETE: t:='The filename association is incomplete or invalid.'; SE_ERR_DDEBUSY: t:='The DDE transaction could not be completed because other DDE transactions were being processed.'; SE_ERR_DDEFAIL: t:='The DDE transaction failed.'; SE_ERR_DDETIMEOUT: t:='The DDE transaction could not be completed because the request timed out.'; SE_ERR_DLLNOTFOUND: t:='The specified dynamic-link library was not found.'; //SE_ERR_FNF: t:='The specified file was not found.'; SE_ERR_NOASSOC: t:='There is no application associated with the given filename extension.'; SE_ERR_OOM: t:='There was not enough memory to complete the operation.'; //SE_ERR_PNF: t:='The specified path was not found.' SE_ERR_SHARE: t:='A sharing violation occurred.'; end; MessageDlg(t,mtConfirmation,[mbOK],0); Result:=False; end; end; |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > Delphi Programming > Executing .exe? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|