I'm trying change host name (like My Computer properties --> Computer Name).
I did this:
Delphi-Quellcode:
if OpenKey('SYSTEM\CurrentControlSet\services\Tcpip\Parameters', True) then
try
WriteString('NV Hostname', FHostName);
WriteString('Hostname', FHostName);
finally
CloseKey;
end;
but raises
exception that failed to set data for these values.
So, I tried this:
Delphi-Quellcode:
function SetComputerNameEx(NameType: TComputerNameFormat; lpComputerName: PWideChar): BOOL; stdcall;
external 'kernel32.dll' name 'SetComputerNameExW';
SetComputerNameEx(ComputerNamePhysicalDnsHostname, 'NewName');
Returns false. I'm administrator.