• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 298
  • Last Modified:

How do I put in parameter in a shellexecute?

0
QC20N
Asked:
QC20N
  • 4
  • 3
  • 3
  • +1
1 Solution
 
MerijnBSr. Software EngineerCommented:
Just add the parameters after the executable:


procedure TForm1.Button1Click(Sender: TObject);
var fileName: string;
    Params: string;
begin
  fileName := IncludeTrailingBackSlash(GetEnvironmentVariable('ProgramFiles')) + 'Internet Explorer\iexplore.exe';
  Params := '"paramter 1" "paramter 2" anotherparameter';
  ShellExecute(0, 'open', PChar(fileName + ' ' + Params), nil, nil, SW_SHOWNORMAL);
end;

Open in new window

0
 
dprochownikCommented:
uses ShellApi;

var
  vAction: String;
  vFileName:String;
  vParams: String;
  vPath: String;

  vAction := 'open';
  vFileName := 'c:\application.exe';
  vParams := 'param1 param2';
  vPath := ExtractFilePath(vFileName);

ShellExecute(0, PChar(vAction), PChar(vFilename), PChar(vParams), PChar(cPath), SW_SHOWNORMAL);

if Params are:
/v /p
then
vParams := '/v /p';

 

0
 
dprochownikCommented:
lol too late
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
QC20NAuthor Commented:
You see guys. I have tried that, but with no result. It dosen't start.

If I don't have any params it starts.


  action := 'open';
  filename := includeTrailingbackslash(getenvironmentvariable('programfiles'))+ 'DameWare Development\DameWare Mini Remote Control\dwrcc.exe';
  params := '-c: -a:1'; // -m:' + listbox1.Items.Strings[listbox1.itemindex];
  ShellExecute(0, 'open', PChar(fileName + ' ' + Params), nil, nil, SW_SHOWNORMAL);

Open in new window

0
 
dprochownikCommented:
No it's wrong, "Params" are separated from file name.
this is wrong:
ShellExecute(0, 'open', PChar(fileName + ' ' + Params), nil, nil, SW_SHOWNORMAL);

It should be:
ShellExecute(0, 'open', PChar(fileName), PChar(Params), nil, SW_SHOWNORMAL);

PS you don't heve set up action variable if you are using "open" parameter direct in shellexecute

0
 
MerijnBSr. Software EngineerCommented:
try:
  action := 'open';
  filename := includeTrailingbackslash(getenvironmentvariable('programfiles'))+ 'DameWare Development\DameWare Mini Remote Control\dwrcc.exe';
  params := '-c: -a:1'; // -m:' + listbox1.Items.Strings[listbox1.itemindex];
  ShellExecute(0, 'open', PChar(fileName), PChar(params), nil, SW_SHOWNORMAL);

Open in new window

0
 
MerijnBSr. Software EngineerCommented:
ok, something strange happened here, I submitted this 25 minutes ago???
0
 
QC20NAuthor Commented:
I can give you 50 point, if you want, for your effort.
0
 
MerijnBSr. Software EngineerCommented:
Don't worry :)
0
 
Geert GruwezOracle dbaCommented:
Be happy
0
 
QC20NAuthor Commented:
I am. :D
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 4
  • 3
  • 3
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now