SunQuest
           Delphi Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreDelphi Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
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  
Old March 22nd, 2008, 10:39 PM
fmwyso fmwyso is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2007
Posts: 6 fmwyso User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 3 m 41 sec
Reputation Power: 0
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.

Reply With Quote
  #2  
Old May 2nd, 2008, 01:57 PM
parasaur parasaur is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2008
Posts: 8 parasaur User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 15 m 37 sec
Reputation Power: 0
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;

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreDelphi Programming > Executing .exe?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway