At home, I have three PCs wanting to create an identification profile of the PC I connect to. I created a program to be installed on the remote PC that should give me its information, in the code I entered these functions:
function Tipo_cpu: string;
var
aVendor: array[0..2] of DWord;
iI, iJ : Integer;
begin
asm
push ebx
xor eax, eax
dw $A20F // CPUID instruction
mov DWord ptr aVendor, ebx
mov DWord ptr aVendor[ 4], edx
mov DWord ptr aVendor[ 8], ecx
pop ebx
end;
for iI := 0 to 2 do
for iJ := 0 to 3 do
Result := Result Chr((aVendor[iI] and ($000000FF shl (iJ * 8))) shr (iJ * 8));
end;
procedure TForm1.botton1(Sender: TObject);
begin
server.DefaultPort := 2630;
server.Active := true;
end;
Now, how do I, from my program that is the client file installed on my machine, to call the functions in a TMemo?
CodePudding user response:
I'm starting to write the code:
procedure HandleSystemInfo(peer: TIdContext; msgBody: TIdBytes);
var
msgStr: string;
begin
msgStr := BytesToStr(msgBody);
// put msgStr into memo or whatever...
end;
CodePudding user response:
Questo è il sorgente del server:
type
TForm1 = class(TForm)
server: TIdTCPServer;
IdAntiFreeze1: TIdAntiFreeze;
cliente: TIdTCPClient;
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
var connessi:integer;
{$R *.dfm}
function Tipo_cpu: string;
var
aVendor: array[0..2] of DWord;
iI, iJ : Integer;
begin
asm
push ebx
xor eax, eax
dw $A20F // CPUID instruction
mov DWord ptr aVendor, ebx
mov DWord ptr aVendor[ 4], edx
mov DWord ptr aVendor[ 8], ecx
pop ebx
end;
for iI := 0 to 2 do
for iJ := 0 to 3 do
Result := Result Chr((aVendor[iI] and ($000000FF shl (iJ * 8))) shr (iJ * 8));
end;
function GetCPUSpeed: Double;
const
DelayTime = 500;
var
TimerHi, TimerLo: DWORD;
PriorityClass, Priority: Integer;
begin
PriorityClass := GetPriorityClass(GetCurrentProcess);
Priority := GetThreadPriority(GetCurrentThread);
SetPriorityClass(GetCurrentProcess, REALTIME_PRIORITY_CLASS);
SetThreadPriority(GetCurrentThread, THREAD_PRIORITY_TIME_CRITICAL);
Sleep(10);
asm
dw 310Fh
mov TimerLo, eax
mov TimerHi, edx
end;
Sleep(DelayTime);
asm
dw 310Fh
sub eax, TimerLo
sbb edx, TimerHi
mov TimerLo, eax
mov TimerHi, edx
end;
SetThreadPriority(GetCurrentThread, Priority);
SetPriorityClass(GetCurrentProcess, PriorityClass);
Result := TimerLo / (1000 * DelayTime);
end;
function IsSoundCardInstalled: Boolean;
Begin
Result := waveOutGetNumDevs > 0;
End;
function InfoSO: String;
Var piattaforma: string;
win_ver: integer;
Begin
Case (Win32Platform) of VER_PLATFORM_WIN32_WINDOWS:
Begin
piattaforma := 'Windows 9x/Me';
win_ver := Win32BuildNumber AND $0000FFFF;
End;
VER_PLATFORM_WIN32_NT:
Begin
piattaforma := 'Windows NT';
win_ver := Win32BuildNumber;
End;
Else
Begin
piattaforma := 'Windows';
win_ver := 0;
End;
End; // case
If (Win32CSDVersion = '') Then
InfoSO := Format('%s %d.%d (Build %d)', [piattaforma,Win32MajorVersion,
Win32MinorVersion,win_ver])
Else
InfoSO := Format('%s %d.%d (Build %d: %s)', [piattaforma,Win32MajorVersion,
Win32MinorVersion,win_ver,WIN32CSDVersion]);
End;
function SysComputerName: string;
var
I: DWord;
begin
I := MAX_COMPUTERNAME_LENGTH 1;
SetLength(Result, I);
Windows.GetComputerName(PChar(Result), I);
Result := string(PChar(Result));
end;
function SysUserName: string;
var
I: DWord;
begin
I := 255;
SetLength(Result, I);
Windows.GetUserName(PChar(Result), I);
Result := string(PChar(Result));
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
server.DefaultPort:=2630;
server.Active:=true;;
end;
end.