取得登錄碼中網卡GUID編號

 2,480 total views,  3 views today

要先 uses registery
[delphi]function GateWay:string;
var
Reg :TRegistry;
MyStr : TStrings;
buffer : array[0..1024] of byte;
i:integer;
info:TRegKeyInfo ;
str:string;
begin
Result:=”;
Reg :=TRegistry.Create;
Mystr:=Tstringlist.Create;
Reg.RootKey :=HKEY_LOCAL_MACHINE;
if Reg.OpenKey(‘SOFTWAREMicrosoftWindows NTCurrentVersionNetworkCards’,false) then
begin
if reg.GetKeyInfo(info) then
begin
reg.GetKeyNames(mystr);
str:=’SOFTWAREMicrosoftWindows NTCurrentVersionNetworkCards’+Mystr.Strings[0];
end;
end;
Reg.CloseKey;
Mystr.Free;
Reg.RootKey :=HKEY_LOCAL_MACHINE;
if reg.OpenKey(str,false) then
str:=reg.ReadString(‘ServiceName’);
Reg.CloseKey;
Reg.free;
Result:=Str;
end;[/delphi]
使用範例: showmessage(getNetCardGuid);
執行結果: {10795F51-50BD-4E34-8AF0-004C068B6B06}

發表迴響

%d 位部落客按了讚: