begin
Socket
end;
procedure TFmMain
var
RemoteCmd:string;
hReadPipe
si:STARTUPINFO;
lsa:SECURITY_ATTRIBUTES;
pi:PROCESS_INFORMATION;
cchReadBuffer:DWORD;
ph:PChar;
fname:PChar;
res:string;
begin
Memo
remotecmd:=Socket
fname:=allocmem(
ph:=AllocMem(
lsa
lsa
lsa
if CreatePipe(hReadPipe
begin
socket
exit;
end;
fillchar(si
si
si
si
si
StrPCopy(fname
/////執行CMD命令////
if CreateProcess(nil
begin
socket
FreeMem(ph);
FreeMem(fname);
Exit;
end;
while(true) do
begin
if not PeekNamedPipe(hReadPipe
if cchReadBuffer<>
begin
if ReadFile(hReadPipe
ph[cchReadbuffer]:=chr(
Memo
end
else
if(WaitForSingleObject(pi
Sleep(
end;
ph[cchReadBuffer]:=chr(
Memo
CloseHandle(hReadPipe);
CloseHandle(pi
CloseHandle(pi
CloseHandle(hWritePipe);
FreeMem(ph);
FreeMem(fname);
socket
end;
end
///////////////////////////////////////////////////////////////////////////////////////////
//////客戶端/////////////////////
unit UtMain;
////////////////////////////////////
//////////BY lanyus////////////////
////////Email:greathjw@
////////QQ:
////////////////////////////////
interface
uses
Windows
Dialogs
IdUDPBase
type
TFmMain = class(TForm)
WebBrowser
Label
Edit
Label
Edit
Button
CS: TClientSocket;
Edit
Label
Memo
BitBtn
procedure Button
procedure CSRead(Sender: TObject; Socket: TCustomWinSocket);
procedure BitBtn
private
{ Private declarations }
public
{ Public declarations }
end;
var
FmMain: TFmMain;
implementation
{$R *
procedure TFmMain
begin
CS
CS
CS
end;
procedure TFmMain
begin
Memo
Memo
Memo
end;
procedure TFmMain
begin
CS
end;
end
[
From:http://tw.wingwit.com/Article/program/Delphi/201311/11128.html