?
Solved

CreateProcess and Double Quotes

Posted on 2004-04-30
3
Medium Priority
?
507 Views
Last Modified: 2010-04-05
Hello experts, could somebody please help me!

If i do this everything seems OK and the executable runs with correct command line.

ExecuteString: String;
ExecuteString:='d:\visual pinball\vpinball.exe -play -"d:\visual pinball\tables\addams family 6.3.vpt"';
CreateOK := CreateProcess(Nil, PChar(ExecuteString), nil, nil,False,
              CREATE_NEW_PROCESS_GROUP+NORMAL_PRIORITY_CLASS,
              nil, nil, StartInfo, ProcInfo);

But if I do this (preferred option) the executable runs but does not start the passed command line arg.

ExecuteString: String;
ProgramName:String;
TablesPath:String;
CommandLineArg:String;
ExecuteString:= ProgramName+' -play -"'+TablesPath+'\'+CommandLineArg+'.vpt"';
CreateOK := CreateProcess(Nil, PChar(ExecuteString), nil, nil,False,
              CREATE_NEW_PROCESS_GROUP+NORMAL_PRIORITY_CLASS,
              nil, nil, StartInfo, ProcInfo);

When I do a ShowMessage(ExecuteString) the ExecuteString looks perfect!  I dont know what i'm doing wrong.

I hope this is enough information and thanks in advance.

0
Comment
Question by:dsmatom
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 18

Accepted Solution

by:
Johnjces earned 200 total points
ID: 10964634
Try this...

ExecuteString := ProgramName + ' -play -' + QuotedStr(TablesPath + '\' + CommandLineArg + '.vpt');

Maybe this will help... not sure as I haven't tried it.

Johnjces
0
 

Author Comment

by:dsmatom
ID: 10964694
Thanks Johnjces.
Still same problem in that the vpinball.exe complains about "error opening file".

With your suggestion, the ShowMessage(ExecuteString) reads as follows:

d:\visual pinball\vpinball.exe -play -'d:\visual pinball\tables\addams family 6.3.vpt'

but it should put the command line arg of the table in double quotes not single that is
should be

d:\visual pinball\vpinball.exe -play -"d:\visual pinball\tables\addams famil 6.3.vpt"


Thanks again
0
 

Author Comment

by:dsmatom
ID: 10965062

OK my bad, sorry I worked it out.

My CommandLineArg was being prefaced with a leading space character because I had this
CommandLineArg:= (CommandLineArg+' '+ParamStr(i));
Because the command line arg are multiple words usually separated by spaces.

So I now remove the leading space character and all works well.

Thanks Johnjces.

I'm accepting your reply cause I've learnt something from you anyway...
I'm very green when it comes to Delphi.

Thanks again.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question