<HTML><HEAD></HEAD>
<BODY dir=ltr>
<DIV dir=ltr>
<DIV style="FONT-FAMILY: 'Times New Roman'; COLOR: #00002b; FONT-SIZE: 12pt">
<DIV>Hi</DIV>
<DIV> </DIV>
<DIV>I want to open and execute a command line application from a Delphi
interface. (FWTools ogr2ogr to be specific).</DIV>
<DIV> </DIV>
<DIV>When I cd the command prompt to FWTools bin and use the following argument
it converts a dxf file to a PostgreSQL table perfectly.</DIV>
<DIV> </DIV>
<DIV>ogr2ogr -f "PostgreSQL" PG:"host=localhost user=postgres dbname=E5R
password=Password" device.dxf -nln Device';</DIV>
<DIV> </DIV>
<DIV>However when I use Delphi code that I found on the internet, the ogr2ogr
opens with an error .<A
title=http://www.delphicorner.f9.co.uk/articles/wapi4.htm
href="http://www.delphicorner.f9.co.uk/articles/wapi4.htm">http://www.delphicorner.f9.co.uk/articles/wapi4.htm</A></DIV>
<DIV> </DIV>
<DIV>Following is the code I am using.</DIV>
<DIV> </DIV>
<DIV>I have attempted various alternates such as spacing and white space within
the path and argument string, with no success.</DIV>
<DIV> </DIV>
<DIV>I could very well be misinterpreting the instructions.</DIV>
<DIV> </DIV>
<DIV>Any help would be appreciated.</DIV>
<DIV> </DIV>
<DIV>procedure TForm1.Button5Click(Sender: TObject);</DIV>
<DIV> </DIV>
<DIV>var</DIV>
<DIV> StartInfo : TStartupInfo;</DIV>
<DIV> ProcInfo : TProcessInformation;</DIV>
<DIV> CreateOK : Boolean;</DIV>
<DIV> Wait : Boolean;</DIV>
<DIV> ProgramName : String;</DIV>
<DIV> </DIV>
<DIV>begin</DIV>
<DIV> ProgramName := 'C:\Program Files
(x86)\FWTools2.4.7\bin\ogr2ogr -f "PostgreSQL" PG:"host=localhostuser=postgres
dbname=E5R password=Password" device.dxf -nln Device';</DIV>
<DIV> { fill with known state }</DIV>
<DIV> FillChar(StartInfo,SizeOf(TStartupInfo),#0);</DIV>
<DIV> FillChar(ProcInfo,SizeOf(TProcessInformation),#0);</DIV>
<DIV> StartInfo.cb := SizeOf(TStartupInfo);</DIV>
<DIV> </DIV>
<DIV> CreateOK := CreateProcess(nil, PChar(ProgramName), nil,
nil,False,</DIV>
<DIV>
CREATE_NEW_PROCESS_GROUP+NORMAL_PRIORITY_CLASS,</DIV>
<DIV>
nil, nil, StartInfo, ProcInfo);</DIV>
<DIV> { check to see if successful }</DIV>
<DIV> if CreateOK then</DIV>
<DIV> begin</DIV>
<DIV> //may or may not be needed.
Usually wait for child processes</DIV>
<DIV> if Wait then</DIV>
<DIV>
WaitForSingleObject(ProcInfo.hProcess, INFINITE);</DIV>
<DIV> end</DIV>
<DIV> else</DIV>
<DIV> begin</DIV>
<DIV> ShowMessage('Unable to run
'+ProgramName);</DIV>
<DIV> end;</DIV>
<DIV> CloseHandle(ProcInfo.hProcess);</DIV>
<DIV> CloseHandle(ProcInfo.hThread);</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV>end;</DIV></DIV></DIV></BODY></HTML>