diff --git a/PJSysInfo.pas b/PJSysInfo.pas
index 0089eb5..3d22c53 100644
--- a/PJSysInfo.pas
+++ b/PJSysInfo.pas
@@ -987,8 +987,58 @@ TPJOSInfo = class(TObject)
///
TPJComputerInfo = class(TObject)
public
- /// Returns name of host computer.
- class function ComputerName: string;
+ /// Returns the NetBIOS name of host computer.
+ /// The original ComputerName function returned
+ /// the NetBIOS name using the GetComputerName() API function. Now
+ /// it returns the result of TPJComputerInfo.ComputerNameNetBIOS.
+ ///
+ class function ComputerName: string; overload;
+
+ /// Returns the name format requested.
+ class function ComputerName(const AComputerNameFormat: COMPUTER_NAME_FORMAT)
+ : string; overload;
+
+ /// Returns the name of the DNS domain assigned to the local
+ /// computer or the cluster associated with the local computer.
+ ///
+ class function ComputerNameDnsDomain: string;
+
+ /// Returns the fully qualified DNS name that uniquely identifies
+ /// the local computer or the cluster associated with the local computer.
+ ///
+ class function ComputerNameDnsFullyQualified: string;
+
+ /// Returns the DNS name of the local computer or the cluster
+ /// associated with the local computer.
+ ///
+ class function ComputerNameDnsHostname: string;
+
+ /// Returns the NetBIOS name of the local computer or the cluster
+ /// associated with the local computer.
+ ///
+ class function ComputerNameNetBIOS: string;
+
+ /// Returns the name of the DNS domain assigned to the local
+ /// computer. On a cluster, this is the DNS domain of the local
+ /// node on the cluster.
+ ///
+ class function ComputerNamePhysicalDnsDomain: string;
+
+ /// Returns the fully qualified DNS name that uniquely identifies
+ /// the computer. On a cluster, this is the fully qualified DNS name of
+ /// the local node on the cluster.
+ ///
+ class function ComputerNamePhysicalDnsFullyQualified: string;
+
+ /// Returns the DNS host name of the local computer. On a cluster,
+ /// this is the DNS host name of the local node on the cluster.
+ ///
+ class function ComputerNamePhysicalDnsHostname: string;
+
+ /// Returns the NetBIOS name of the local computer. On a cluster,
+ /// this is the NetBIOS name of the local node on the cluster.
+ ///
+ class function ComputerNamePhysicalNetBIOS: string;
/// Returns name of currently logged on user.
class function UserName: string;
@@ -4369,19 +4419,79 @@ class function TPJComputerInfo.BootMode: TPJBootMode;
end;
end;
-class function TPJComputerInfo.ComputerName: string;
+class function TPJComputerInfo.ComputerName(const AComputerNameFormat: COMPUTER_NAME_FORMAT): string;
var
- PComputerName: // buffer for name returned from API
- array[0..MAX_COMPUTERNAME_LENGTH] of Char;
- Size: DWORD; // size of name buffer
-begin
- Size := MAX_COMPUTERNAME_LENGTH;
- if GetComputerName(PComputerName, Size) then
- Result := PComputerName
+ ComputerName: array of Char; // buffer for name returned from API
+ Size: DWORD; // size of name buffer
+begin
+ // Pass nil in the 2nd argument to determine what the size required
+ // for ComputerName. Size must be 0 before making the call.
+ Size := 0;
+ GetComputerNameEx(AComputerNameFormat, nil, Size);
+ if Size > 0 then
+ begin
+ // Size includes space for the null terminator.
+ SetLength(ComputerName, Size);
+ // After calling GetComputerNameEx(), Size is the actual length of the
+ // ComputerName *excluding* the null terminator.
+ if GetComputerNameEx(AComputerNameFormat, @ComputerName[0], Size) then
+ SetString(Result, PChar(@ComputerName[0]), Size)
+ else
+ Result := '';
+ end
else
Result := '';
end;
+// The original TPJComputerInfo.ComputerName function returned the
+// NetBIOS name using the GetComputerName() API function.
+class function TPJComputerInfo.ComputerName: string;
+begin
+ Result := ComputerNameNetBIOS;
+end;
+
+class function TPJComputerInfo.ComputerNameDnsDomain: string;
+begin
+ Result := ComputerName(COMPUTER_NAME_FORMAT.ComputerNameDnsDomain);
+end;
+
+class function TPJComputerInfo.ComputerNameDnsFullyQualified: string;
+begin
+ Result := ComputerName(COMPUTER_NAME_FORMAT.ComputerNameDnsFullyQualified);
+end;
+
+// DnsHostname can up to 63 characters.
+class function TPJComputerInfo.ComputerNameDnsHostname: string;
+begin
+ Result := ComputerName(COMPUTER_NAME_FORMAT.ComputerNameDnsHostname);
+end;
+
+// NetBIOS name will always be truncated to a max of 15 characters.
+class function TPJComputerInfo.ComputerNameNetBIOS: string;
+begin
+ Result := ComputerName(COMPUTER_NAME_FORMAT.ComputerNameNetBIOS);
+end;
+
+class function TPJComputerInfo.ComputerNamePhysicalDnsDomain: string;
+begin
+ Result := ComputerName(COMPUTER_NAME_FORMAT.ComputerNamePhysicalDnsDomain);
+end;
+
+class function TPJComputerInfo.ComputerNamePhysicalDnsFullyQualified: string;
+begin
+ Result := ComputerName(COMPUTER_NAME_FORMAT.ComputerNamePhysicalDnsFullyQualified);
+end;
+
+class function TPJComputerInfo.ComputerNamePhysicalDnsHostname: string;
+begin
+ Result := ComputerName(COMPUTER_NAME_FORMAT.ComputerNamePhysicalDnsHostname);
+end;
+
+class function TPJComputerInfo.ComputerNamePhysicalNetBIOS: string;
+begin
+ Result := ComputerName(COMPUTER_NAME_FORMAT.ComputerNamePhysicalNetBIOS);
+end;
+
class function TPJComputerInfo.Is64Bit: Boolean;
begin
Result := Processor in [paX64, paIA64];