取利主机的ip地址。 uses winsock; procedure TForm1.Button1Click(Sender: TObject); var IP:string; IPstr:String; buffer:array[1..32] of char; i:integer; WSData:TWSAdata; Host:PHostEnt; begin if WSAstartup(2,WSData)<>0 then begin showmessage('WS2_32.DLL3?ê??ˉ꧰ü.'); exit; end; try if GetHostname(@buffer[1],32)<>0 then begin showmessage('??óDμ?μ??÷?ú??.'); exit; end; except showmessage('??óD3é1|·μ???÷?ú??'); exit; end; Host:=GetHostbyname(@buffer[1]); if Host=nil then begin showmessage('IPμ??·?a??.'); exit; end else begin edit2.Text:=Host.h_name; edit3.Text:=chr(host.h_addrtype+64); for i:=1 to 4 do begin IP:=inttostr(ord(host.h_addr^[i-1])); if i<4 then ipstr:=ipstr+IP+'.' else edit1.Text:=ipstr+ip; end; end; WSACleanup; end;取得计算机名。 function tform1.get_name:string; var ComputerName: PChar; size: DWord; begin GetMem(ComputerName,255); size:=255; if GetComputerName(ComputerName,size)=False then result:='' else result:=ComputerName; FreeMem(ComputerName); end; procedure TForm1.Button1Click(Sender: TObject); begin label1.Caption:=get_name; end;
取得硬盘序列号。 function tform1.GetHDSerialNumber: LongInt; {$IFDEF WIN32} var pdw : pDWord; mc, fl : dword; {$ENDIF} begin {$IfDef WIN32} New(pdw); GetVolumeInformation('c:\',nil,0,pdw,mc,fl,nil,0); Result := pdw^; dispose(pdw); {$ELSE} Result := GetWinFlags; {$ENDIF} end; procedure TForm1.Button1Click(Sender: TObject); begin edit1.Text:=inttostr(gethdserialnumber); end;
取得硬盘序列号。 function tform1.GetHDSerialNumber: LongInt; {$IFDEF WIN32} var pdw : pDWord; mc, fl : dword; {$ENDIF} begin {$IfDef WIN32} New(pdw); GetVolumeInformation('c:\',nil,0,pdw,mc,fl,nil,0); Result := pdw^; dispose(pdw); {$ELSE} Result := GetWinFlags; {$ENDIF} end; procedure TForm1.Button1Click(Sender: TObject); begin edit1.Text:=inttostr(gethdserialnumber); end;