Quote any parameters with spaces in them. On 09/06/2011 6:55 AM, "Bob Pawley" <rjpaw...@shaw.ca> wrote: > Hi > > I want to open and execute a command line application from a Delphi interface. (FWTools ogr2ogr to be specific). > > When I cd the command prompt to FWTools bin and use the following argument it converts a dxf file to a PostgreSQL table perfectly. > > ogr2ogr -f "PostgreSQL" PG:"host=localhost user=postgres dbname=E5R password=Password" device.dxf -nln Device'; > > However when I use Delphi code that I found on the internet, the ogr2ogr opens with an error .http://www.delphicorner.f9.co.uk/articles/wapi4.htm > > Following is the code I am using. > > I have attempted various alternates such as spacing and white space within the path and argument string, with no success. > > I could very well be misinterpreting the instructions. > > Any help would be appreciated. > > procedure TForm1.Button5Click(Sender: TObject); > > var > StartInfo : TStartupInfo; > ProcInfo : TProcessInformation; > CreateOK : Boolean; > Wait : Boolean; > ProgramName : String; > > begin > ProgramName := 'C:\Program Files (x86)\FWTools2.4.7\bin\ogr2ogr -f "PostgreSQL" PG:"host=localhostuser=postgres dbname=E5R password=Password" device.dxf -nln Device'; > { fill with known state } > FillChar(StartInfo,SizeOf(TStartupInfo),#0); > FillChar(ProcInfo,SizeOf(TProcessInformation),#0); > StartInfo.cb := SizeOf(TStartupInfo); > > CreateOK := CreateProcess(nil, PChar(ProgramName), nil, nil,False, > CREATE_NEW_PROCESS_GROUP+NORMAL_PRIORITY_CLASS, > nil, nil, StartInfo, ProcInfo); > { check to see if successful } > if CreateOK then > begin > //may or may not be needed. Usually wait for child processes > if Wait then > WaitForSingleObject(ProcInfo.hProcess, INFINITE); > end > else > begin > ShowMessage('Unable to run '+ProgramName); > end; > CloseHandle(ProcInfo.hProcess); > CloseHandle(ProcInfo.hThread); > > > end;
_______________________________________________ NZ Borland Developers Group - Delphi mailing list Post: delphi@delphi.org.nz Admin: http://delphi.org.nz/mailman/listinfo/delphi Unsubscribe: send an email to delphi-requ...@delphi.org.nz with Subject: unsubscribe