gui化程序问题,creatprocess 急! 急! 急! ( 积分: 50 )

  • 主题发起人 主题发起人 asoftforg
  • 开始时间 开始时间
A

asoftforg

Unregistered / Unconfirmed
GUEST, unregistred user!
最近在写一个nmap的gui程序,知道怎样运行,但却不知道怎样停止....<br><br>go的代码如下,但怎样编写stop的代码呢?<br><br>关键步骤是creatprocess,也能得到返回值,但一旦运行,nmap运行中,程序就会失去响应,stop也点不上了....<br>那位大侠能帮一下忙?或者是提示一下新的方法?<br><br>procedure TForm1.FlatButton1Click(Sender: TObject);<br>var<br> &nbsp;ChrTmp: Array[0..256] of Char;<br> &nbsp;BufRead: Array[0..1024 * 16] of Char;<br> &nbsp;NumRead: DWORD;<br> &nbsp;PipeSA: SECURITY_ATTRIBUTES;<br>begin<br> &nbsp; n:=1;<br> &nbsp; self.Timer1.Enabled:=true;<br> &nbsp; self.FlatButton1.Enabled := False;<br> &nbsp; self.FlatMemo1.Lines.Clear;<br> &nbsp; self.FlatMemo1.Lines.Add('Starting nmap................ ');<br> &nbsp; self.FlatMemo1.Lines.Add('Nmap is working, just wait... ');<br><br> &nbsp; self.PageControl1.TabIndex:=0;<br> &nbsp; ZeroMemory(@BufRead,1024 * 16);<br><br> &nbsp; PipeSA.nLength := sizeof(SECURITY_ATTRIBUTES);<br> &nbsp; PipeSA.bInheritHandle := True;<br> &nbsp; PipeSA.lpSecurityDescriptor := nil;<br><br> &nbsp; if False = CreatePipe(hRead,hWrite,@PipeSA,0) then<br> &nbsp; &nbsp; &nbsp;FlatMemo1.Lines.Add('Pipe Create Error~!');<br><br> &nbsp; hStdTmp := GetStdHandle(STD_OUTPUT_HANDLE);<br> &nbsp; SetStdHandle(STD_OUTPUT_HANDLE,hWrite);<br><br> &nbsp; GetStartupInfo(SI);<br> &nbsp; SI.dwFlags := STARTF_USESHOWWINDOW or STARTF_USESTDHANDLES;<br> &nbsp; SI.hStdOutput := hWrite;<br> &nbsp; SI.hStdError := hWrite;<br> &nbsp; SI.wShowWindow := SW_HIDE;<br> &nbsp; &nbsp; &nbsp;StrCopy(ChrTmp,PChar('nmap'));<br> &nbsp; &nbsp;CreateProcess(nil,<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ChrTmp,<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; nil,<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; nil,<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; True,<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 0,<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; nil,<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; nil,<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SI,<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ProcessInfo);<br><br> &nbsp; SetStdHandle(STD_OUTPUT_HANDLE,hStdTmp);<br> &nbsp; CloseHandle(hWrite);<br> &nbsp; while ReadFile(hRead,BufRead,1024 * 16,NumRead,nil) do begin<br> &nbsp; &nbsp; &nbsp; &nbsp; Sleep(1);<br> &nbsp; &nbsp; &nbsp; &nbsp; FlatMemo1.Lines.Add(BufRead);<br> &nbsp; &nbsp; &nbsp; &nbsp; ZeroMemory(@BufRead,1024 * 16);<br> &nbsp; &nbsp; &nbsp; &nbsp;end;<br><br> &nbsp; &nbsp;CloseHandle(hRead);<br> &nbsp; &nbsp;self.FlatButton1.Enabled := True;<br> &nbsp; &nbsp;self.Timer1.Enabled:=false;<br> &nbsp; &nbsp;n:=1;<br> &nbsp; &nbsp;self.FlatProgressBar1.Position:=0;<br>end;
 
最近在写一个nmap的gui程序,知道怎样运行,但却不知道怎样停止....<br><br>go的代码如下,但怎样编写stop的代码呢?<br><br>关键步骤是creatprocess,也能得到返回值,但一旦运行,nmap运行中,程序就会失去响应,stop也点不上了....<br>那位大侠能帮一下忙?或者是提示一下新的方法?<br><br>procedure TForm1.FlatButton1Click(Sender: TObject);<br>var<br> &nbsp;ChrTmp: Array[0..256] of Char;<br> &nbsp;BufRead: Array[0..1024 * 16] of Char;<br> &nbsp;NumRead: DWORD;<br> &nbsp;PipeSA: SECURITY_ATTRIBUTES;<br>begin<br> &nbsp; n:=1;<br> &nbsp; self.Timer1.Enabled:=true;<br> &nbsp; self.FlatButton1.Enabled := False;<br> &nbsp; self.FlatMemo1.Lines.Clear;<br> &nbsp; self.FlatMemo1.Lines.Add('Starting nmap................ ');<br> &nbsp; self.FlatMemo1.Lines.Add('Nmap is working, just wait... ');<br><br> &nbsp; self.PageControl1.TabIndex:=0;<br> &nbsp; ZeroMemory(@BufRead,1024 * 16);<br><br> &nbsp; PipeSA.nLength := sizeof(SECURITY_ATTRIBUTES);<br> &nbsp; PipeSA.bInheritHandle := True;<br> &nbsp; PipeSA.lpSecurityDescriptor := nil;<br><br> &nbsp; if False = CreatePipe(hRead,hWrite,@PipeSA,0) then<br> &nbsp; &nbsp; &nbsp;FlatMemo1.Lines.Add('Pipe Create Error~!');<br><br> &nbsp; hStdTmp := GetStdHandle(STD_OUTPUT_HANDLE);<br> &nbsp; SetStdHandle(STD_OUTPUT_HANDLE,hWrite);<br><br> &nbsp; GetStartupInfo(SI);<br> &nbsp; SI.dwFlags := STARTF_USESHOWWINDOW or STARTF_USESTDHANDLES;<br> &nbsp; SI.hStdOutput := hWrite;<br> &nbsp; SI.hStdError := hWrite;<br> &nbsp; SI.wShowWindow := SW_HIDE;<br> &nbsp; &nbsp; &nbsp;StrCopy(ChrTmp,PChar('nmap'));<br> &nbsp; &nbsp;CreateProcess(nil,<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ChrTmp,<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; nil,<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; nil,<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; True,<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 0,<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; nil,<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; nil,<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SI,<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ProcessInfo);<br><br> &nbsp; SetStdHandle(STD_OUTPUT_HANDLE,hStdTmp);<br> &nbsp; CloseHandle(hWrite);<br> &nbsp; while ReadFile(hRead,BufRead,1024 * 16,NumRead,nil) do begin<br> &nbsp; &nbsp; &nbsp; &nbsp; Sleep(1);<br> &nbsp; &nbsp; &nbsp; &nbsp; FlatMemo1.Lines.Add(BufRead);<br> &nbsp; &nbsp; &nbsp; &nbsp; ZeroMemory(@BufRead,1024 * 16);<br> &nbsp; &nbsp; &nbsp; &nbsp;end;<br><br> &nbsp; &nbsp;CloseHandle(hRead);<br> &nbsp; &nbsp;self.FlatButton1.Enabled := True;<br> &nbsp; &nbsp;self.Timer1.Enabled:=false;<br> &nbsp; &nbsp;n:=1;<br> &nbsp; &nbsp;self.FlatProgressBar1.Position:=0;<br>end;
 
后退
顶部