I would like to know how to get the Full computer name in Inno Setup, for example Win8-CL01.cpx.local
in the following image.
I already know how to get the computer name with GetComputerNameString but I also would like to have the Domain name of the computer. How can I get this full computer name or this domain name ?
There's no built-in function for this in Inno Setup. You can use the GetComputerNameEx
Windows API function:
[Setup]
AppName=My Program
AppVersion=1.5
DefaultDirName={pf}\My Program
[Code]
#ifdef UNICODE
#define AW "W"
#else
#define AW "A"
#endif
const
ERROR_MORE_DATA = 234;
type
TComputerNameFormat = (
ComputerNameNetBIOS,
ComputerNameDnsHostname,
ComputerNameDnsDomain,
ComputerNameDnsFullyQualified,
ComputerNamePhysicalNetBIOS,
ComputerNamePhysicalDnsHostname,
ComputerNamePhysicalDnsDomain,
ComputerNamePhysicalDnsFullyQualified,
ComputerNameMax
);
function GetComputerNameEx(NameType: TComputerNameFormat; lpBuffer: string; var nSize: DWORD): BOOL;
external 'GetComputerNameEx{#AW}@kernel32.dll stdcall';
function TryGetComputerName(Format: TComputerNameFormat; out Output: string): Boolean;
var
BufLen: DWORD;
begin
Result := False;
BufLen := 0;
if not Boolean(GetComputerNameEx(Format, '', BufLen)) and (DLLGetLastError = ERROR_MORE_DATA) then
begin
SetLength(Output, BufLen);
Result := GetComputerNameEx(Format, Output, BufLen);
end;
end;
procedure InitializeWizard;
var
Name: string;
begin
if TryGetComputerName(ComputerNameDnsFullyQualified, Name) then
MsgBox(Name, mbInformation, MB_OK);
end;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With