on DecToHex( aValue : LongInt ) : String;
Var
w : Array[ 1..2 ] Of Word Absolute aValue;
Begin
Result := HexWord( w[ 2 ] ) + HexWord( w[ 1 ] );
End;
//以下函数用以获得网卡地址。
function GetMACAddress(LanaNum: Byte; MACAddress: PMACAddress): Byte;
var
AdapterStatus: PAdapterStatus;
StatNCB: PNCB;
begin
New(StatNCB);
ZeroMemory(StatNCB, SizeOf(TNCB));
StatNCB.ncb_length := SizeOf(TAdapterStatus) + 255 * SizeOf(TNameBuffer);
GetMem(AdapterStatus, StatNCB.ncb_length);
try
with StatNCB^ do
begin
ZeroMemory(MACAddress, SizeOf(TMACAddress));
ncb_buffer := PChar(AdapterStatus);
ncb_callname := ''* '' + #0;
ncb_lana_num := Char(LanaNum);
ncb_command := Char(NCBASTAT);
NetBios(StatNCB);
Result := Byte(ncb_cmd_cplt);
if Result = NRC_GOODRET then
MoveMemory(MACAddress, AdapterStatus, SizeOf(TMACAddress));
end;
finally
FreeMem(AdapterStatus);
Dispose(StatNCB);
end;
end;
function GetLanaEnum(LanaEnum: PLanaEnum): Byte;
var
LanaEnumNCB: PNCB;
begin
New(LanaEnumNCB);
ZeroMemory(LanaEnumNCB, SizeOf(TNCB));
try
with LanaEnumNCB^ do
begin
ncb_buffer := PChar(LanaEnum);
ncb_length := SizeOf(TLanaEnum);
ncb_command := Char(NCBENUM);
NetBios(LanaEnumNCB);
Result := Byte(ncb_cmd_cplt);
end;
finally
Dispose(LanaEnumNCB);
end;
end;
//以下函数用以得本机IP地址。
function LocalIP : string;
type
TaPInAddr = array [0..10] of PInAddr;
PaPInAddr = ^TaPInAddr;
var
phe : PHostEnt;
pptr : PaPInAddr;
Buffer : array [0..63] of char;
I : Integer;
GInitData : TWSADATA;
begin
WSAStartup($101, GInitData);
Result := '''';
GetHostName(Buffer, SizeOf(Buffer));
phe :=GetHostByName(buffer);
if phe = nil then Exit;
pptr := PaPInAddr(Phe^.h_addr_list);
I := 0;
while pptr^[I] <> nil do begin
result:=StrPas(inet_ntoa(pptr^[I]^));
Inc(I);
end;
WSACleanup;
end;
//以下函数用以获得WINDOWSID号。
function GetWindowsProductID: string;
var
reg:TRegistry;
begin
Result := '''';
reg := TRegistry.Create;
with reg do
begin
RootKey := HKEY_LOCAL_MACHINE;
OpenKey(''Software\Microsoft\Windows\CurrentVersion'', False);
Result := ReadString(''ProductID'');
end;
reg.Free;
end;
//以下是在窗口出现时,显示
计算机的硬件信息。
procedure TForm2.FormCreate(Sender: TObject);
var s0,s1,s2,s3:string;
//s4,s5:string为全程变量
n1,n2:longint;
myfile:textfile;
users:pchar;
i:dword;
MACAddress: PMACAddress;
RetCode: Byte;
var fulldrive :string;
tmp_drive :array[0..2] of char;
VolName :array[0..255] of Char;
SerialN :DWORD;
MaxCLength :DWORD;
FileSysFlag :DWORD;
FileSysName :array[0..255] of Char;
begin
Label2.Caption:=''你的IP地址是: ''+LocalIP;
label3.caption:=''你的windowsID是:''+GetWindowsProductID;
New(MACAddress);
try
RetCode := GetMACAddress(0, MACAddress);
if RetCode = NRC_GOODRET then
begin
label5.caption := ''你的网卡地址是:''+Format(''%2.2x-%2.2x-%2.2x-%2.2x-%2.2x-%2.2x'',
[MACAddress[0], MACAddress, MACAddress,
MACAddress, MACAddress, MACAddress]);
end;
finally
Dispose(MACAddress);
end;
i:=255;
getmem(users,255);
getusername(users,i); //获得Windows用户名
label6.caption:=''你登录windows的用户名是 :''+users;
freemem(users);
fulldrive:=''c:\'';
strpcopy(tmp_drive,fulldrive);
GetVolumeInformation(tmp_drive, VolName, 255, @Ser