Solved

CreateProcess and Double Quotes

Posted on 2004-04-30
3
498 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 50 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

Technology Partners: 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

Suggested Solutions

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
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…

732 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