type
SystemInfoRecord = record
Version, // 윈도우 버전
Plattform : shortstring; // 윈도우 종류
PlattId : DWORD; // 현 플랫폼 ID
ComputerName, // 컴퓨터 이름
UserName, // 사용자 이름
CompanyName, // 회사이름
end;
var
SysInfoRec: SystemInfoRecord;
function GetAllSystemInfo: SystemInfoRecord; stdcall;
implementation
var
OSVerInfo: TOSVersionInfo;
procedure GetComputerName;
var
Computer : PChar;
CSize : DWORD;
begin
CSize := MAX_COMPUTERNAME_LENGTH + 1;
try
GetMem( Computer, CSize );
if Windows.GetComputerName( Computer, CSize ) then
SysInfoRec.ComputerName := Computer;
finally
FreeMem( Computer );
end;
end;
procedure GetRegisterInfo;
const
FPPKey = 'hardwareDESCRIPTIONSystemFloatingPointProcessor';
var
CurVerKey : PChar;
begin
With SysInfoRec Do
Begin
Case PlattID of
VER_PLATFORM_WIN32_WINDOWS : CurVerKey := 'SOFTWAREMicrosoftWindowsCurrentVersion';
VER_PLATFORM_WIN32_NT : CurVerKey := 'SOFTWAREMicrosoftWindows NTCurrentVersion';
Else CurVerKey := nil;
End;
With TRegistry.Create do
Try
RootKey := HKEY_LOCAL_MACHINE;
IF OpenKey(FPPKey, False) Then
FPU := 'Yes'
Else FPU := 'No';
Finally
Free;
End;
IF PlattID = VER_PLATFORM_WIN32_WINDOWS Then
CDSerial := GetRegStr(CurVerKey,'ProductID');
End;
end;
procedure GetOSVersionInfo;
function Plat(Pl: DWORD): string;
begin
case Pl of
VER_PLATFORM_WIN32s: result := 'Windows 3.1';
VER_PLATFORM_WIN32_WINDOWS: result := 'Windows 95';
VER_PLATFORM_WIN32_NT: result := 'Windows NT';
else result := '???';
end;
end;
begin
with OSVerInfo, SysInfoRec do begin
dwOSVersionInfoSize := SizeOf(OSVerInfo);
if GetVersionEx(OSVerInfo) then;
Version := Format('%d.%d (%d.%s)',[dwMajorVersion, dwMinorVersion,
(dwBuildNumber and $FFFF), szCSDVersion]);
Plattform := Plat(dwPlatformId);
PlattID := dwPlatformId;
end;
end;
end.
function GetAllSystemInfo: SystemInfoRecord; stdcall;
begin
GetOSVersionInfo;
GetComputerName;
GetRegisterInfo;
result := SysInfoRec;
end;
저두 찾아서 사용해보았던 자료에서 발췌했습니다.
uses
Windows, Messages, SysUtils, Classes, Registry;
type
SystemInfoRecord = record
Version, // 윈도우 버전
Plattform : shortstring; // 윈도우 종류
PlattId : DWORD; // 현 플랫폼 ID
ComputerName, // 컴퓨터 이름
UserName, // 사용자 이름
CompanyName, // 회사이름
end;
var
SysInfoRec: SystemInfoRecord;
function GetAllSystemInfo: SystemInfoRecord; stdcall;
implementation
var
OSVerInfo: TOSVersionInfo;
procedure GetComputerName;
var
Computer : PChar;
CSize : DWORD;
begin
CSize := MAX_COMPUTERNAME_LENGTH + 1;
try
GetMem( Computer, CSize );
if Windows.GetComputerName( Computer, CSize ) then
SysInfoRec.ComputerName := Computer;
finally
FreeMem( Computer );
end;
end;
procedure GetRegisterInfo;
const
FPPKey = 'hardwareDESCRIPTIONSystemFloatingPointProcessor';
var
CurVerKey : PChar;
begin
With SysInfoRec Do
Begin
Case PlattID of
VER_PLATFORM_WIN32_WINDOWS : CurVerKey := 'SOFTWAREMicrosoftWindowsCurrentVersion';
VER_PLATFORM_WIN32_NT : CurVerKey := 'SOFTWAREMicrosoftWindows NTCurrentVersion';
Else CurVerKey := nil;
End;
With TRegistry.Create do
Try
RootKey := HKEY_LOCAL_MACHINE;
IF OpenKey(FPPKey, False) Then
FPU := 'Yes'
Else FPU := 'No';
Finally
Free;
End;
UserName := GetRegStr(CurVerKey,'RegisteredOwner');
CompanyName := GetRegStr(CurVerKey,'RegisteredOrganization');
IF PlattID = VER_PLATFORM_WIN32_WINDOWS Then
CDSerial := GetRegStr(CurVerKey,'ProductID');
End;
end;
procedure GetOSVersionInfo;
function Plat(Pl: DWORD): string;
begin
case Pl of
VER_PLATFORM_WIN32s: result := 'Windows 3.1';
VER_PLATFORM_WIN32_WINDOWS: result := 'Windows 95';
VER_PLATFORM_WIN32_NT: result := 'Windows NT';
else result := '???';
end;
end;
begin
with OSVerInfo, SysInfoRec do begin
dwOSVersionInfoSize := SizeOf(OSVerInfo);
if GetVersionEx(OSVerInfo) then;
Version := Format('%d.%d (%d.%s)',[dwMajorVersion, dwMinorVersion,
(dwBuildNumber and $FFFF), szCSDVersion]);
Plattform := Plat(dwPlatformId);
PlattID := dwPlatformId;
end;
end;
end.
function GetAllSystemInfo: SystemInfoRecord; stdcall;
begin
GetOSVersionInfo;
GetComputerName;
GetRegisterInfo;
result := SysInfoRec;
end;