GetComputerObjectNameA function (secext.h)

Retrieves the local computer's name in a specified format.


BOOLEAN SEC_ENTRY GetComputerObjectNameA(
  [in]      EXTENDED_NAME_FORMAT NameFormat,
  [out]     LPSTR                lpNameBuffer,
  [in, out] PULONG               nSize


[in] NameFormat

The format for the name. This parameter is a value from the EXTENDED_NAME_FORMAT enumeration type. It cannot be NameUnknown.

[out] lpNameBuffer

A pointer to a buffer that receives the name in the specified format.

If this parameter is NULL, either the function succeeds and the lpnSize parameter receives the required size, or the function fails with ERROR_INSUFFICIENT_BUFFER and lpnSize receives the required size. The behavior depends on the value of NameFormat and the version of the operating system.

[in, out] nSize

On input, specifies the size of the lpNameBuffer buffer, in TCHARs. On success, receives the size of the name copied to the buffer. If the lpNameBuffer buffer is too small to hold the name, the function fails and lpnSize receives the required buffer size.

Return value

If the function succeeds, the return value is a nonzero value.

If the function fails, the return value is zero. To get extended error information, call GetLastError.



The secext.h header defines GetComputerObjectName as an alias which automatically selects the ANSI or Unicode version of this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions for Function Prototypes.


Requirement Value
Minimum supported client Windows 2000 Professional [desktop apps only]
Minimum supported server Windows 2000 Server [desktop apps only]
Target Platform Windows
Header secext.h (include Security.h)
Library Secur32.lib
DLL Secur32.dll
API set ext-ms-win-secur32-translatename-l1-1-0 (introduced in Windows 8)

See also



System Information Functions