Z
zhilon
Unregistered / Unconfirmed
GUEST, unregistred user!
下面的这段代码,我单独新做一个程序,就执行下面几句,程序没有任何问题,但只要<br>把完全相似的代码放在我现在项目中就会出问题,CreateProcess执行总是返回FALSE,<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>var<br> StartupInfo: TStartupInfo;<br> ProcessInfo: TProcessInformation;<br> scommad : string;<br>begin<br> scommad := 'bcp etc_center..deal_buf in D:/DATA.BCP -c -Uyangzy -SETC2003 -Pzu1234';<br><br> FillChar(StartupInfo, Sizeof(StartupInfo), #0);<br> StartupInfo.cb := Sizeof(StartupInfo);<br> StartupInfo.dwFlags := STARTF_USESHOWWINDOW;<br> StartupInfo.wShowWindow := 1; <br><br> if CreateProcess(<br> nil,<br> pChar(scommad),<br> nil,<br> nil,<br> false,<br> CREATE_NEW_CONSOLE or NORMAL_PRIORITY_CLASS, { creation flags }<br> nil,<br> nil,<br> StartupInfo,<br> ProcessInfo) then<br> begin<br> WaitforSingleObject(ProcessInfo.hProcess, INFINITE); //等待,直到执行结束才执行下一个 <br> end;<br> showmessage('OK');<br>end;<br><br><br>完全相似的代码放在我现在项目中就会出问题,如下所示,CreateProcess执行总是返回FALSE,这是为什么? 我已看过<br>以前的贴子了,没有找到相关的东西,请高人指点呀!!!<br><br> .<br> .<br> .<br> //scommad 为sybase数据库的BCP命令,如:<br> //bcp etc_center..deal_buf in D:/data.txt -c -Uyangzy -SETC2003 -Pzu1234<br> if scommad <> '' then<br> begin<br> //CreateProcess初始化<br> FillChar(StartupInfo, Sizeof(StartupInfo), #0);<br> StartupInfo.cb := Sizeof(StartupInfo);<br> StartupInfo.dwFlags := STARTF_USESHOWWINDOW;<br> StartupInfo.wShowWindow := 1; //隐藏DOS窗口 0:隐藏 1:显示<br><br> if CreateProcess(<br> nil,<br> pChar(scommad),<br> nil,<br> nil,<br> false,<br> CREATE_NEW_CONSOLE or NORMAL_PRIORITY_CLASS, { creation flags }<br> nil,<br> nil,<br> StartupInfo,<br> ProcessInfo) then<br> begin<br> WaitforSingleObject(ProcessInfo.hProcess, INFINITE); //等待,直到执行结束才执行下一个 <br> end;<br><br> .<br> .<br> .<br><br><br>