Platform SDK: Network Management |
The NetWkstaGetInfo function returns information about the configuration of a workstation.
Windows NT: You must have Print or Server operator privilege, or be a member of the Administrator or Account local groups to successfully execute the NetWkstaGetInfo function.
Windows 2000: If you call this function on a Windows 2000 domain controller that is running Active Directory, access is allowed or denied based on the access-control list (ACL) for the securable object. The default ACL permits all authenticated users and members of the "Pre-Windows 2000 compatible access" group to view the information. By default, the "Pre-Windows 2000 compatible access" group includes Everyone as a member. This enables anonymous access to the information if the system allows anonymous access.
If you call this function on a Windows 2000 member server or workstation, all authenticated users can view the information. Anonymous access is also permitted if the RestrictAnonymous policy setting allows anonymous access.
For more information about restricting anonymous access, see Security Requirements for the Network Management Functions.
NET_API_STATUS NetWkstaGetInfo( LPWSTR servername, DWORD level, LPBYTE *bufptr );
Value | Meaning |
---|---|
100 | Return information about the workstation environment, including platform-specific information, the name of the domain and the local computer, and information concerning the operating system. The bufptr parameter points to a WKSTA_INFO_100 structure. |
101 | In addition to level 100 information, return the path to the LANMAN directory. The bufptr parameter points to a WKSTA_INFO_101 structure. |
102 | In addition to level 101 information, return the number of users who are logged on to the local computer. The bufptr parameter points to a WKSTA_INFO_102 structure. |
If the function succeeds, the return value is NERR_Success.
If the function fails, the return value can be one of the following error codes.
Value | Meaning |
---|---|
ERROR_ACCESS_DENIED | The user does not have access to the requested information. |
ERROR_INVALID_LEVEL | The level parameter is invalid. |
The following code sample demonstrates how to retrieve information about the configuration elements for a workstation using a call to the NetWkstaGetInfo function. The sample calls NetWkstaGetInfo, specifying information level 102 (WKSTA_INFO_102). If the call succeeds, the sample prints information about the workstation. Finally, the code sample frees the memory allocated for the information buffer.
#ifndef UNICODE #define UNICODE #endif #include <stdio.h> #include <windows.h> #include <lm.h> int wmain(int argc, wchar_t *argv[]) { DWORD dwLevel = 102; LPWKSTA_INFO_102 pBuf = NULL; NET_API_STATUS nStatus; LPTSTR pszServerName = NULL; // // Check command line arguments. // if (argc > 2) { fwprintf(stderr, L"Usage: %s [\\\\ServerName]\n", argv[0]); exit(1); } // The server is not the default local computer. // if (argc == 2) pszServerName = argv[1]; // // Call the NetWkstaGetInfo function, specifying level 102. // nStatus = NetWkstaGetInfo(pszServerName, dwLevel, (LPBYTE *)&pBuf); // // If the call is successful, // print the workstation data. // if (nStatus == NERR_Success) { printf("\n\tPlatform: %d\n", pBuf->wki102_platform_id); wprintf(L"\tName: %s\n", pBuf->wki102_computername); printf("\tVersion: %d.%d\n", pBuf->wki102_ver_major, pBuf->wki102_ver_minor); wprintf(L"\tDomain: %s\n", pBuf->wki102_langroup); wprintf(L"\tLan Root: %s\n", pBuf->wki102_lanroot); wprintf(L"\t# Logged On Users: %d\n", pBuf->wki102_logged_on_users); } // // Otherwise, indicate the system error. // else fprintf(stderr, "A system error has occurred: %d\n", nStatus); // // Free the allocated memory. // if (pBuf != NULL) NetApiBufferFree(pBuf); return 0; }
Windows NT/2000: Requires Windows NT 3.1 or later.
Windows 95/98: Unsupported.
Header: Declared in Lmwksta.h; include Lm.h.
Library: Use Netapi32.lib.
Network Management Overview, Network Management Functions, Workstation and Workstation User Functions, NetWkstaSetInfo, WKSTA_INFO_100, WKSTA_INFO_101, WKSTA_INFO_102