--u s e r n a m e
Function GetUser : string;
Var
buffer : String;
buffsize : DWORD;
Begin
buffsize := 128;
Setlength(buffer,buffsize);
Getusername(Pchar(buffer),buffsize);
result := buffer;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
label1.Caption := GetUser;
end;
------------------------------------------------
--c o m p u t e r n a m e
procedure TForm1.Button1Click(Sender: TObject);
var
arrCompName : Array[0..255] Of Char;
strCompName : String;
CompNameLen : Cardinal;
// CompNameLen : Cardinal; If using Delphi4
// Thanks to Kurt Troncquo
begin
CompNameLen := MAX_COMPUTERNAME_LENGTH + 1;
If GetComputerName(arrCompName, CompNameLen) Then
Begin
SetLength(strCompName, MAX_COMPUTERNAME_LENGTH + 1);
Label1.Caption := StrPas(arrCompName);
End;
end;
-------------------------------------------------------
--R e g i s t e r e d o r g a n i s a t i o n
function GetOrganisation: string;
var
reg : TRegistry;
begin
reg := TRegistry.Create;
try
reg.Rootkey := HKEY_LOCAL_MACHINE;
reg.Openkey('software\microsoft\windows\currentversion', False);
Result := reg.ReadString('RegisteredOrganization');
finally
reg.Free;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
label1.Caption := (GetOrganisation);
end;
----------------------------------------------------
--r e g i s t e r e d o w n e r
function GetRegowner: string;
var
reg : TRegistry;
begin
reg := TRegistry.Create;
try
reg.Rootkey := HKEY_LOCAL_MACHINE;
reg.Openkey('software\microsoft\windows\currentversion', False);
Result := reg.ReadString('RegisteredOwner');
finally
reg.Free;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
label1.Caption := (GetRegowner);
end;
---------------------------------------------------------------------
- w o r k g r o u p
function GetWorkgroup: string;
var
reg : TRegistry;
begin
reg := TRegistry.Create;
try
reg.Rootkey := HKEY_LOCAL_MACHINE;
reg.Openkey('system\CurrentControlSet\Services\VxD\VNETSUP', False);
Result := reg.ReadString('Workgroup');
finally
reg.Free;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
label1.Caption :=(GetWorkgroup);
end;
----------------------------------------------------------------------
- M e m o r y
var
MemoryStatus: TMemoryStatus;
begin
Memo1.Lines.Clear;
MemoryStatus.dwLength := SizeOf(MemoryStatus);
GlobalMemoryStatus(MemoryStatus);
with MemoryStatus do
begin
{ Size of MemoryStatus record }
Memo1.Lines.Add(IntToStr(dwLength) +
' Size of ''MemoryStatus'' record');
{ Per-Cent of Memory in use by your system }
Memo1.Lines.Add(IntToStr(dwMemoryLoad) +
'% memory in use');
{The amount of Total Physical memory allocated to your system.}
Memo1.Lines.Add(IntToStr(dwTotalPhys) +
' Total Physical Memory in bytes');
{ The amount available of physical memory in your system. }
Memo1.Lines.Add(IntToStr(dwAvailPhys) +
' Available Physical Memory in bytes');
{ The amount of Total Bytes allocated to your page file }
Memo1.Lines.Add(IntToStr(dwTotalPageFile) +
' Total Bytes of Paging File');
{ The amount of available bytes in your page file }
Memo1.Lines.Add(IntToStr(dwAvailPageFile) +
' Available bytes in paging file');
{ The amount of Total bytes allocated to this program
(generally 2 gigabytes of virtual space) }
Memo1.Lines.Add(IntToStr(dwTotalVirtual) +
' User Bytes of Address space');
{ The amount of avalable bytes that is left to your program to use }
Memo1.Lines.Add(IntToStr(dwAvailVirtual) +
' Available User bytes of address space');
end;
end;
-----------------------------------------------------------------------
--p r o c e s s o r n a m e
function GetCpu: string;
var
reg : TRegistry;
begin
reg := TRegistry.Create;
try
reg.Rootkey := HKEY_LOCAL_MACHINE;
reg.Openkey('Hardware\Description\System\CentralProcessor\0', False);
Result := reg.ReadString('Identifier');
finally
reg.Free;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
label1.Caption := GetCpu
end;
---------------------------------------------------------------------
- p r o c e s s o r s p e e d
private
Stop: Boolean;
function GetCPUSpeed: Double;
const
DelayTime = 500; // measure time in ms
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 // rdtsc
mov TimerLo, eax
mov TimerHi, edx
end;
Sleep(DelayTime);
asm
dw 310Fh // rdtsc
sub eax, TimerLo
sbb edx, TimerHi
mov TimerLo, eax
mov TimerHi, edx
end;
SetThreadPriority(GetCurrentThread, Priority);
SetPriorityClass(GetCurrentProcess, PriorityClass);
Result := TimerLo / (1000.0 * DelayTime);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Stop := False;
while not Stop do
begin
Label1.Caption := Format('CPU speed: %f MHz', [GetCPUSpeed]);
Application.ProcessMessages;
sleep(500);
Stop := True;
end;
end;
----------------------------------------------------------------------
-- d i s p l a y r e s o l u t i o n
procedure TForm1.Button1Click(Sender: TObject);
var
scrWidth,
scrHeight : Integer;
begin
scrWidth := GetSystemMetrics(SM_CXSCREEN);
scrHeight := GetSystemMetrics(SM_CYSCREEN);
label1.Caption :=('Screen Resolution: ('+
IntToStr(scrWidth)+
'x'+
IntToStr(scrHeight)+
')');
end;
----------------------------------------------------------------------
-d e f a u l t p r i n t e r
function GetPrinter: string;
var
reg : TRegistry;
begin
reg := TRegistry.Create;
try
reg.Rootkey := HKEY_CURRENT_CONFIG;
reg.Openkey('System\CurrentControlSet\Control\Print\Printers', False);
Result := reg.ReadString('Default');
finally
reg.Free;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
label1.Caption := GetPrinter;
end;
----------------------------------------------------------------------
--h a r d d r i v e
procedure TForm1.Button1Click(Sender: TObject);
Var
RootPath : String;
Sec_Cluster, Bytes_Sec, Free_Clusters, Total_Clusters : DWord;
begin
// Set the Drive to check
RootPath := 'C:\';
GetDiskFreeSpace(PChar(RootPath), Sec_Cluster, Bytes_Sec, Free_Clusters, Total_Clusters);
// Lets put information into a ListBox
ListBox1.Items.Add('RootPath : ' + RootPath);
ListBox1.Items.Add('Sectors Per Cluster : ' + IntToStr(Sec_Cluster));
ListBox1.Items.Add('Bytes Per Sector : ' + IntToStr(Bytes_Sec));
ListBox1.Items.Add('Free Clusters : ' + IntToStr(Free_Clusters));
ListBox1.Items.Add('Total Clusters : ' + IntToStr(Total_Clusters));
ListBox1.Items.Add('Free Bytes : ' + IntToStr(Bytes_Sec * Sec_Cluster * Free_Clusters));
ListBox1.Items.Add('Total Bytes : ' + IntToStr(Bytes_Sec * Sec_Cluster * Total_Clusters));
end;
---------------------------------------------------------------------