当前位置:首页 > 网络编程 > 软件语言 > DELPHI > 如何在DELPHI5中通过程序获取计算机一系列硬件信息

如何在DELPHI5中通过程序获取计算机一系列硬件信息

点击次数:45 次 发布日期:2008-11-09 08:38:42 作者:源代码网
源代码网推荐
广告载入中
1、申明部份:
源代码网推荐 uses ….Winsock,Registry,NB30….
源代码网推荐 ……
源代码网推荐 implementation
源代码网推荐 ……
源代码网推荐 var s4,s5:string;
源代码网推荐 type
源代码网推荐 TNBLanaResources = (lrAlloc, lrFree);
源代码网推荐 type
源代码网推荐 PMACAddress = ^TMACAddress;
源代码网推荐 TMACAddress = array[0..5] of Byte;
源代码网推荐 type
源代码网推荐 TGate = record
源代码网推荐 Off2,op,seg,off1:WORD;
源代码网推荐 end;
源代码网推荐 LONGDWORD = INT64;
源代码网推荐 var
源代码网推荐 IDTR: LONGDWORD;
源代码网推荐 SavedGate:TGate;
源代码网推荐 OurGate: TGate;
源代码网推荐 dd: array [0..256] of word;
源代码网推荐 dsn:array [0..20] of char;
源代码网推荐 {$R *.DFM}
源代码网推荐 //以下函数用以获得硬盘出厂序列号。
源代码网推荐 procedure Ring0Proc();
源代码网推荐 asm
源代码网推荐 // Wait for controller not busy
源代码网推荐 mov dx,01f7h
源代码网推荐 @1:in al,dx
源代码网推荐 cmp al,050h
源代码网推荐 jne @1
源代码网推荐
源代码网推荐 // Get first/second drive
源代码网推荐 dec dx
源代码网推荐 mov al,0a0h
源代码网推荐 out dx,al
源代码网推荐
源代码网推荐 // Get drive info data
源代码网推荐 inc dx
源代码网推荐 mov al,0ech
源代码网推荐 out dx,al
源代码网推荐 nop
源代码网推荐 nop
源代码网推荐
源代码网推荐 // Wait for data ready
源代码网推荐 @2:in al,dx
源代码网推荐 cmp al,058h
源代码网推荐 jne @2
源代码网推荐 nop
源代码网推荐 nop
源代码网推荐 // Read sector
源代码网推荐 xor ecx,ecx
源代码网推荐 mov dx,01f0h
源代码网推荐 @3:in ax,dx
源代码网推荐 mov word ptr dd[ecx*2],ax


源代码网推荐 inc ecx
源代码网推荐 cmp ecx,256
源代码网推荐 jne @3
源代码网推荐
源代码网推荐 iretd
源代码网推荐 end;
源代码网推荐
源代码网推荐 procedure Change2Ring0();
源代码网推荐 begin
源代码网推荐 asm
源代码网推荐 mov eax, offset Ring0Proc
源代码网推荐 mov OurGate.off2, ax
源代码网推荐 shr eax, 16
源代码网推荐 mov OurGate.off1, ax
源代码网推荐 mov OurGate.op,0028h
源代码网推荐 mov OurGate.seg,0ee00h
源代码网推荐 mov ebx,offset IDTR
源代码网推荐 sidt [ebx]
源代码网推荐 mov ebx, dword ptr [IDTR 2]
源代码网推荐 add ebx, 8*3
源代码网推荐 mov edi, offset SavedGate
源代码网推荐 mov esi, ebx
源代码网推荐 movsd
源代码网推荐 movsd
源代码网推荐 mov edi, ebx
源代码网推荐 mov esi, offset OurGate
源代码网推荐 cli
源代码网推荐 movsd
源代码网推荐 movsd
源代码网推荐 sti
源代码网推荐 mov eax,6200h
源代码网推荐 mov ecx,0
源代码网推荐 int 3h
源代码网推荐 mov edi, ebx
源代码网推荐 mov esi, offset SavedGate
源代码网推荐 cli
源代码网推荐 movsd
源代码网推荐 movsd
源代码网推荐 sti
源代码网推荐 end;
源代码网推荐 asm
源代码网推荐 xor ecx,ecx
源代码网推荐 mov ebx,offset dd[10*2]
源代码网推荐 @4:mov ax,[ebx]
源代码网推荐 mov byte ptr dsn[ecx],ah
源代码网推荐 inc ecx
源代码网推荐 mov byte ptr dsn[ecx],al
源代码网推荐 inc ebx
源代码网推荐 inc ebx
源代码网推荐 inc ecx
源代码网推荐 cmp ecx,10
源代码网推荐 jne @4
源代码网推荐 end;
源代码网推荐 showmessage(dsn);
源代码网推荐 end;
源代码网推荐 //以下函数用以获得系统时间。
源代码网推荐 function GetSystemTime : AnsiString;
源代码网推荐 var
源代码网推荐 stSystemTime : TSystemTime;
源代码网推荐 begin
源代码网推荐 Windows.GetSystemTime( stSystemTime );

源代码网推荐 Result := DateTimeToStr( SystemTimeToDateTime( stSystemTime ) );
源代码网推荐 end;
源代码网推荐 //以下函数用以获得本地时间。
源代码网推荐 function GetLocalTime : AnsiString;
源代码网推荐 var
源代码网推荐 stSystemTime : TSystemTime;
源代码网推荐 begin
源代码网推荐 Windows.GetLocalTime( stSystemTime );
源代码网推荐 Result := DateTimeToStr( SystemTimeToDateTime( stSystemTime ) );
源代码网推荐 end;
源代码网推荐 //以下函数用以获得计算机名。
源代码网推荐 function GetComputerName: AnsiString;
源代码网推荐 var lpBuffer: array[0..MAX_PATH] of char;
源代码网推荐 dwSize: DWORD;
源代码网推荐 begin
源代码网推荐 dwSize:= MAX_PATH;
源代码网推荐 if not Windows.GetComputerName(lpBuffer, dwSize) then
源代码网推荐 raise
源代码网推荐 Exception.Create(SysErrorMessage(GetLastError()));
源代码网推荐 Result:= StrPas(lpBuffer);
源代码网推荐 end;
源代码网推荐 {function GetUserName: AnsiString;
源代码网推荐 var lpBuffer: array[0..MAX_PATH] of char;
源代码网推荐 dwSize: DWORD;
源代码网推荐 begin
源代码网推荐 dwSize:= MAX_PATH;
源代码网推荐
源代码网推荐 if not Windows.GetUserName(lpBuffer, dwSize) then
源代码网推荐 raise Exception.Create(SysErrorMessage(GetLastError()));
源代码网推荐
源代码网推荐 Result:= StrPas(lpBuffer);
源代码网推荐 end;}
源代码网推荐 //以下函数用以获得计算机BIOS系统信息。
源代码网推荐 function GetBios(value: integer): String;


源代码网推荐 // 1...Bios Type
源代码网推荐 // 2.. Bios Copyright
源代码网推荐 // 3.. Bios Date
源代码网推荐 // 4.. Bios Extended Info
源代码网推荐 // 5.. Bustype
源代码网推荐 // 6.. MachineType
源代码网推荐 begin
源代码网推荐 result:="(unavailable)";
源代码网推荐 case value of
源代码网推荐 1: result:=String(Pchar(Ptr($FE061)));
源代码网推荐 2: result:=String(Pchar(Ptr($FE091)));
源代码网推荐 3: result:=String(Pchar(Ptr($FFFF5)));
源代码网推荐 4: result:=String(Pchar(Ptr($FEC71)));
源代码网推荐 end;
源代码网推荐 end;
源代码网推荐 //以下函数是用以获得WINDOWS序列号函数中所调用的函数。
源代码网推荐 Function HexByte( b : Byte ) : String;
源代码网推荐 Const
源代码网推荐 Hex : Array[ $0..$F ] Of Char = "0123456789ABCDEF";
源代码网推荐 Begin
源代码网推荐 HexByte := Hex[ b Shr 4 ] Hex[ b And $F ];
源代码网推荐 End;
源代码网推荐
源代码网推荐 Function HexWord( w : Word ) : String;
源代码网推荐 Begin
源代码网推荐 HexWord := HexByte( Hi( w ) ) HexByte( Lo( w ) );
源代码网推荐 End;
源代码网推荐 Function 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("SoftwareMicrosoftWindowsCurrentVersion", 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[3];
源代码网推荐 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[1], MACAddress[2],
源代码网推荐 MACAddress[3], MACAddress[4], MACAddress[5]]);
源代码网推荐 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, @SerialN, MaxCLength,FileSysFlag, FileSysName, 255);
源代码网推荐 label7.caption:="你的硬盘卷标是:" VolName;
源代码网推荐 label8.caption:="你的硬盘序列号是:" DecToHex(SerialN);
源代码网推荐 label9.caption:="你的计算机名是:" getcomputername;
源代码网推荐
源代码网推荐 IF getbios(1)<>"" then
源代码网推荐 label10.caption:="你的BIOS版本号是:" getbios(1)
源代码网推荐 else
源代码网推荐 label10.caption:="未取得BIOS版本号";
源代码网推荐
源代码网推荐 if getbios(2)<>"" then
源代码网推荐 label11.caption:="你的BIOS序列号是:" getbios(4)
源代码网推荐 else
源代码网推荐 label11.caption:="未取得BIOS序列号";
源代码网推荐
源代码网推荐 if getsystemtime<>"" then
源代码网推荐 label12.caption:="你的系统时间是:" getsystemtime
源代码网推荐 else
源代码网推荐 label12.Caption:="未取得系统时间";
源代码网推荐
源代码网推荐 if getlocaltime<>"" then
源代码网推荐 label13.caption:="你的本地时间是:" getlocaltime

源代码网推荐 else
源代码网推荐 label13.caption:="未取得本地时间";
源代码网推荐
源代码网推荐 if inttostr(DiskSize(3) div 1024)<>"" then
源代码网推荐 label14.caption:="你的系统硬盘空间是:" inttostr(DiskSize(3) div 1024)
源代码网推荐 else
源代码网推荐 label14.caption:="未取得系统硬盘间";
源代码网推荐
源代码网推荐 procedure TForm2.Button2Click(Sender: TObject);
源代码网推荐 begin
源代码网推荐 Change2Ring0();
源代码网推荐 end;
源代码网推荐 以上有部份引用了网友的代码,在此申明.
源代码网推荐 由于以上操作需要在申明处加入:Winsock,Registry,NB30
源代码网推荐 以上方法在DELPHI5、WINDOWS98下通过。


源代码网推荐

源代码网供稿.
网友评论 (0)
会员中心
网络编程
本站推荐
网络编程之精华