Mega Code Archive
Getting the Registered Domain (From Registry)
Title: Getting the Registered Domain (From Registry)
Question: Need an easy way to retrieve the network domain name?
Answer:
//{$R *.DFM}
function YourDomain: String;
var
Registry: TRegistry;
begin
Registry:=TRegistry.Create;
try
Registry.RootKey:=HKEY_LOCAL_MACHINE;
Registry.OpenKey('\SECURITY\PROVIDER',False);
Result :=Registry.ReadString('Container');
finally
Registry.Free;
end;
end;
//Be sure to add registry to your form's 'uses' clause
procedure TForm1.Button1Click(Sender: TObject);
begin
Label1.Caption:='The registered domain is: '+YourDomain
end;