(1)GetComputerName
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.
If the local computer is a node in a cluster, GetComputerName returns the name of the node.
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.
Windows 2000: Additional information is provided by the IADsADSystemInfo interface.
BOOL GetComputerName(
LPTSTR lpBuffer, // computer name
LPDWORD lpnSize // size of name buffer
);
Parameters
lpBuffer
[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.
lpnSize
[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.
If the buffer is too small, the function fails and GetLastError returns ERROR_BUFFER_OVERFLOW.
Windows 95/98: GetComputerName fails if the input size is less than MAX_COMPUTERNAME_LENGTH + 1.
--------
or
--------
(2)NetServerEnum
The NetServerEnum function lists all servers of the specified type that are visible in a domain. For example, an application can call NetServerEnum to list all domain controllers only or all SQL servers only.
You can combine bit masks to list several types. For example, a value of 0x00000003 combines the bit masks for SV_TYPE_WORKSTATION (0x00000001) and SV_TYPE_SERVER (0x00000002).
If you require more information for a specific server, call the WNetEnumResource function.
Security Requirements
No special group membership is required to successfully execute the NetServerEnum function.
NET_API_STATUS NetServerEnum(
LPCWSTR servername,
DWORD level,
LPBYTE *bufptr,
DWORD prefmaxlen,
LPDWORD entriesread,
LPDWORD totalentries,
DWORD servertype,
LPCWSTR domain,
LPDWORD resume_handle
);
Main Topics
Browse All Topics





by: jhancePosted on 2003-06-04 at 03:34:02ID: 8647003
One way is to use the NetServerEnum() API with the SV_TYPE_WORKSTATION parameter. This works on NT4/2000/XP but not Win9x. Alternatively, you can use the WNetOpenEnum()/WNetEnumRes ource APIs