网站首页  词典首页

请输入您要查询的函数:

 

术语 netservergetinfo
释义 NetServerGetInfo
语法:
C++
NET_API_STATUS NetServerGetInfo(
__in LPWSTR servername,
__in DWORD level,
__out LPBYTE *bufptr
);
NetServerGetInfo功能
该NetServerGetInfo函数检索指定的服务器的当前配置信息。
参数
服务器名 [in]
一个字符串指针,指定的远程服务器上的功能是执行的名称。如果该参数为NULL,则使用本地计算机。
Level [in]
指定的数据信息的Level。此参数可以是下列值之一。
ValueMeaning
100Return服务器名称和平台信息。在bufptr参数指向SERVER_INFO_100结构。
101Return服务器名称,类型和相关软件。在bufptr参数指向SERVER_INFO_101结构。
102Return服务器的名称,类型,相关软件和其他属性。在bufptr参数指向SERVER_INFO_102结构。
bufptr [out]
指针的缓冲区,接收数据。这一数据格式取决于Level的参数值。
此缓冲区分配制度,必须使用NetApiBufferFree释放功能。
返回值
如果函数成功,返回值是NERR_Success。
如果函数失败,返回值可以是下面的错误代码之一。
返回codeDescription
ERROR_ACCESS_DENIEDThe用户没有获得所需的信息。
ERROR_INVALID_LEVELThe价值Level参数指定无效。
ERROR_INVALID_PARAMETERThe指定的参数无效。
ERROR_NOT_ENOUGH_MEMORYInsufficient内存可用。
备注
只有管理员或服务器操作员本地组,或打印或服务器操作员组成员的,可以成功地执行级102 NetServerGetInfo功能。没有特殊组成员是所必需的Level,100或101级要求。
如果您是Active Directory的程序,您可以调用某些Active Directory服务接口(ADSI)的方法来达到同样的功能,您可以通过调用实现网络管理服务器功能。有关更多信息,请参阅IADsComputer。
实例
下面的代码示例演示如何检索的使用调用NetServerGetInfo功能服务器的当前配置信息。该范例调用NetServerGetInfo,指定信息化Level101(SERVER_INFO_101)。如果调用成功,代码试图确定服务器类型。最后,该示例释放的信息缓冲区分配的内存。
#ifndef UNICODE
#define UNICODE
#endif
#pragma comment(lib, "netapi32.lib")
#include
#include
#include
int wmain(int argc, wchar_t *argv[])
{
DWORD dwLevel = 101;
LPSERVER_INFO_101 pBuf = NULL;
NET_API_STATUS nStatus;
LPTSTR pszServerName = NULL;
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 = (LPTSTR) argv[1];
//
// Call the NetServerGetInfo function, specifying level 101.
//
nStatus = NetServerGetInfo(pszServerName,
dwLevel,
(LPBYTE *)&pBuf);
//
// If the call succeeds,
//
if (nStatus == NERR_Success)
{
//
// Check for the type of server.
//
if ((pBuf->sv101_type & SV_TYPE_DOMAIN_CTRL) ||
(pBuf->sv101_type & SV_TYPE_DOMAIN_BAKCTRL) ||
(pBuf->sv101_type & SV_TYPE_SERVER_NT))
printf("This is a server\\n");
else
printf("This is a workstation\\n");
}
//
// Otherwise, print 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;
}
要求:
最低支持:client-Windows 2000专业版
最低支持server-Windows 2000服务器
HeaderLmserver.h(包括Lm.h)
LibraryNetapi32.lib
DLLNetapi32.dll
参见
网络管理概述
网络管理功能
服务器功能
NetServerSetInfo
SERVER_INFO_100
SERVER_INFO_101
SERVER_INFO_102
NetRemoteComputerSupports
如果有任何问题和意见,请发送给微软(wsddocfb@microsoft.com)
生成日期:2009年8月13日
==英文原文==NetServerGetInfo Function
The NetServerGetInfo function retrieves current configuration information for the specified server.
Syntax
C++
NET_API_STATUS NetServerGetInfo(
__in LPWSTR servername,
__in DWORD level,
__out LPBYTE *bufptr
);
Parameters
servername [in]
Pointer to a string that specifies the name of the remote server on which the function is to execute. If this parameter is NULL, the local computer is used.
level [in]
Specifies the information level of the data. This parameter can be one of the following values.
ValueMeaning
100Return the server name and platform information. The bufptr parameter points to a SERVER_INFO_100 structure.
101Return the server name, type, and associated software. The bufptr parameter points to a SERVER_INFO_101 structure.
102Return the server name, type, associated software, and other attributes. The bufptr parameter points to a SERVER_INFO_102 structure.

bufptr [out]
Pointer to the buffer that receives the data. The format of this data depends on the value of the level parameter.
This buffer is allocated by the system and must be freed using the NetApiBufferFree function.
Return Value
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.
Return codeDescription
ERROR_ACCESS_DENIEDThe user does not have access to the requested information.
ERROR_INVALID_LEVELThe value specified for the level parameter is invalid.
ERROR_INVALID_PARAMETERThe specified parameter is invalid.
ERROR_NOT_ENOUGH_MEMORYInsufficient memory is available.

Remarks
Only the Administrators or Server Operators local group, or those with Print or Server Operator group membership, can successfully execute the NetServerGetInfo function at level 102. No special group membership is required for level 100 or level 101 calls.
If you are programming for Active Directory, you may be able to call certain Active Directory Service Interface (ADSI) methods to achieve the same functionality you can achieve by calling the network management server functions. For more information, see IADsComputer .
Examples
The following code sample demonstrates how to retrieve current configuration information for a server using a call to the NetServerGetInfo function. The sample calls NetServerGetInfo, specifying information level 101 ( SERVER_INFO_101 ). If the call succeeds, the code attempts to identify the type of server. Finally, the sample frees the memory allocated for the information buffer.
#ifndef UNICODE
#define UNICODE
#endif
#pragma comment(lib, "netapi32.lib")
#include
#include
#include
int wmain(int argc, wchar_t *argv[])
{
DWORD dwLevel = 101;
LPSERVER_INFO_101 pBuf = NULL;
NET_API_STATUS nStatus;
LPTSTR pszServerName = NULL;
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 = (LPTSTR) argv[1];
//
// Call the NetServerGetInfo function, specifying level 101.
//
nStatus = NetServerGetInfo(pszServerName,
dwLevel,
(LPBYTE *)&pBuf);
//
// If the call succeeds,
//
if (nStatus == NERR_Success)
{
//
// Check for the type of server.
//
if ((pBuf->sv101_type & SV_TYPE_DOMAIN_CTRL) ||
(pBuf->sv101_type & SV_TYPE_DOMAIN_BAKCTRL) ||
(pBuf->sv101_type & SV_TYPE_SERVER_NT))
printf("This is a server\\n");
else
printf("This is a workstation\\n");
}
//
// Otherwise, print 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;
}
Requirements
Minimum supported clientWindows 2000 Professional
Minimum supported serverWindows 2000 Server
HeaderLmserver.h (include Lm.h)
LibraryNetapi32.lib
DLLNetapi32.dll
See Also
Network Management Overview
Network Management Functions
Server Functions
NetServerSetInfo
SERVER_INFO_100
SERVER_INFO_101
SERVER_INFO_102
NetRemoteComputerSupports
Send comments about this topic to Microsoft
Build date: 8/13/2009
==原始网址==http://msdn.microsoft.com/en-us/library/aa370624(VS.85).aspx\n
随便看

 

windows api函数参考手册包含2258条windows api函数文档,详细介绍nodejs、java、rust调用windows api的方法技巧,是学习windows api编程的入门中文文档。

 

Copyright © 2004-2023 Winrtm.com All Rights Reserved
京ICP备2021023879号-40 更新时间:2024/10/6 11:22:50