Solved

CreateProcess and Double Quotes

Posted on 2004-04-30
3
485 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
Comment Utility
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
Comment Utility
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
Comment Utility

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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

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…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

743 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

14 Experts available now in Live!

Get 1:1 Help Now