Link to home
Start Free TrialLog in
Avatar of QC20N
QC20NFlag for Denmark

asked on

How do I put in parameter in a shellexecute?

Avatar of MerijnB
MerijnB
Flag of Netherlands image

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

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';

 

lol too late
Avatar of QC20N

ASKER

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

ASKER CERTIFIED SOLUTION
Avatar of dprochownik
dprochownik
Flag of Poland image

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
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

ok, something strange happened here, I submitted this 25 minutes ago???
Avatar of QC20N

ASKER

I can give you 50 point, if you want, for your effort.
Don't worry :)
Be happy
Avatar of QC20N

ASKER

I am. :D