Subscribe

RSS Feed (xml)

Powered By

Skin Design:
Free Blogger Skins

Powered by Blogger

星期四, 8月 30, 2007

取得電腦資訊,以後可供註冊參考~呵


以下為程式碼


unit getinfo;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, sockets, Registry;
type
TForm1 = class(TForm)
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private

{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;
function MacAddress: string;

implementation

{$R *.dfm}


function MacAddress: string;
var
Lib: Cardinal;
Func: function(GUID: PGUID): Longint; stdcall;
GUID1, GUID2: TGUID;
begin
Result := '';
Lib := LoadLibrary('rpcrt4.dll');
if Lib <> 0 then
begin
if Win32Platform <>VER_PLATFORM_WIN32_NT then
@Func := GetProcAddress(Lib, 'UuidCreate')
else @Func := GetProcAddress(Lib, 'UuidCreateSequential');
if Assigned(Func) then
begin
if (Func(@GUID1) = 0) and
(Func(@GUID2) = 0) and
(GUID1.D4[2] = GUID2.D4[2]) and
(GUID1.D4[3] = GUID2.D4[3]) and
(GUID1.D4[4] = GUID2.D4[4]) and
(GUID1.D4[5] = GUID2.D4[5]) and
(GUID1.D4[6] = GUID2.D4[6]) and
(GUID1.D4[7] = GUID2.D4[7]) then
begin
Result :=
IntToHex(GUID1.D4[2], 2) + '-' +
IntToHex(GUID1.D4[3], 2) + '-' +
IntToHex(GUID1.D4[4], 2) + '-' +
IntToHex(GUID1.D4[5], 2) + '-' +
IntToHex(GUID1.D4[6], 2) + '-' +
IntToHex(GUID1.D4[7], 2);
end;
end;
FreeLibrary(Lib);
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
sock : TIpSocket;
GlobalMemoryInfo:TMemoryStatus;
rg:tregistry;
skey:string;
begin

sock := TIpSocket.Create(self);
Edit1.text:=sock.localHostName;

rg:=tregistry.create;
rg.RootKey:=HKEY_LOCAL_MACHINE;
skey:='HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0';
if rg.KeyExists(skey) then
begin
rg.openkey(skey,true);
Edit2.text:=trim(rg.ReadString('ProcessorNameString'));
rg.closekey;
end;
rg.free;

GlobalMemoryStatus(GlobalMemoryInfo);
Edit3.Text:=Format('%.0n',[GlobalMemoryInfo.dwTotalPhys/1024]);

Edit4.text:=MacAddress;
end;

end.

沒有留言: