<br> Platform SDK: Windows System Information <br>GetComputerName<br>The GetComputerName function retrieves the NetBIOS name of the local computer. This name is established at system startup, when the system reads it from the registry. <br><br>If the local computer is a node in a cluster, GetComputerName returns the name of the node. <br><br>Windows 2000: GetComputerName retrieves only the NetBIOS name of the local computer. To retrieve the DNS host name, DNS domain name, or the fully qualified DNS name, call the GetComputerNameEx function.<br><br>Windows 2000: Additional information is provided by the IADsADSystemInfo interface. <br><br>BOOL GetComputerName(<br> LPTSTR lpBuffer, // computer name<br> LPDWORD lpnSize // size of name buffer<br>);<br>Parameters<br>lpBuffer <br>[out] Pointer to a buffer that receives a null-terminated string containing the computer name. The buffer size should be large enough to contain MAX_COMPUTERNAME_LENGTH + 1 characters. <br>lpnSize <br>[in/out] On input, specifies the size, in TCHARs, of the buffer. On output, receives the number of TCHARs copied to the destination buffer, not including the terminating null character. <br>If the buffer is too small, the function fails and GetLastError returns ERROR_BUFFER_OVERFLOW. <br><br>Windows 95/98: GetComputerName fails if the input size is less than MAX_COMPUTERNAME_LENGTH + 1. <br><br>Return Values<br>If the function succeeds, the return value is a nonzero value. <br><br>If the function fails, the return value is zero. To get extended error information, call GetLastError. <br><br>Remarks<br>The GetComputerName function retrieves the NetBIOS name established at system startup. Name changes made by the SetComputerName or SetComputerNameEx functions do not take effect until the user restarts the computer.<br><br>Requirements <br> Windows NT/2000: Requires Windows NT 3.1 or later.<br> Windows 95/98: Requires Windows 95 or later.<br> Header: Declared in Winbase.h; include Windows.h.<br> Library: Use Kernel32.lib.<br> Unicode: Implemented as Unicode and ANSI versions on Windows NT/2000.<br><br>See Also<br>System Information Overview, System Information Functions, GetComputerNameEx, SetComputerName, SetComputerNameEx <br><br>Built on Thursday, May 11, 2000Requirements <br> Windows NT/2000: Requires Windows NT 3.1 or later.<br> Windows 95/98: Requires Windows 95 or later.<br> Header: Declared in Winbase.h; include Windows.h.<br> Library: Use Kernel32.lib.<br> Unicode: Implemented as Unicode and ANSI versions on Windows NT/2000.<br>See Also<br>System Information Overview, System Information Functions, GetComputerNameEx, SetComputerName, SetComputerNameEx <br>1.CnameBuffer就是計算機名稱保存的地址。<br>2.是的。是的,第一個參數是計算機名稱將要保存地址,第二個是字符長度。