Solved

CreateProcess and Double Quotes

Posted on 2004-04-30
3
486 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
  • 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

895 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now