网站首页  词典首页

请输入您要查询的函数:

 

术语 netservertransportenum
释义 NetServerTransportEnum
语法:
C++
NET_API_STATUS NetServerTransportEnum(
__in LPWSTR servername,
__in DWORD level,
__out LPBYTE *bufptr,
__in DWORD prefmaxlen,
__out LPDWORD entriesread,
__out LPDWORD totalentries,
__inout LPDWORD resumehandle
);
NetServerTransportEnum功能
该NetServerTransportEnum函数提供的信息传输是由服务器管理协议。
参数
服务器名 [in]
指针指向一个字符串,它指定的DNS或NetBIOS的远程服务器上的功能是执行的名称。如果该参数为NULL,则使用本地计算机。
Level [in]
指定的数据信息的Level。此参数可以是下列值之一。
ValueMeaning
0Return信息传输协议,包括姓名,地址和网络上的位置。在bufptr参数指向一个SERVER_TRANSPORT_INFO_0结构的数组。
1Return信息传输协议,包括姓名,地址,网络位置和域。在bufptr参数指向一个SERVER_TRANSPORT_INFO_1结构的数组。
bufptr [out]
指针的缓冲区,接收数据。这一数据格式取决于Level的参数值。此缓冲区分配制度,必须使用NetApiBufferFree释放功能。请注意,您必须释放缓冲区,即使函数ERROR_MORE_DATA失败。
prefmaxlen [in]
指定返回数据的首选的最大字节长度。如果您指定MAX_PREFERRED_LENGTH,功能分配用于数据所需的内存量。如果指定这个参数在另一个值,它可以限制的字节数函数返回。如果缓冲区大小不足以容纳所有作品,该函数返回ERROR_MORE_DATA。有关更多信息,请参阅网络管理功能,缓冲器和网络管理功能缓冲区长度。
entriesread [out]
指针的值,它接收元素计数实际列举。
totalentries [out]
指针的值,它接收了本来可以列举参赛总人数从目前的恢复情况。请注意,应用程序应考虑仅作为提示此值。
resumehandle [ in , out ]
指针的值,它包含简历处理,用于继续现有的服务器传输搜索。手柄应在第一次调用零,离开后续调用不变。如果该参数是NULL,没有恢复处理存储。
返回值
如果函数成功,返回值是NERR_Success。
如果函数失败,返回值可以是下面的错误代码之一。
返回codeDescription
ERROR_INVALID_LEVELThe价值Level参数指定无效。
ERROR_MORE_DATAMore项可用。指定一个足够大的缓冲区接收的所有条目。
ERROR_NOT_ENOUGH_MEMORYInsufficient内存可用。
NERR_BufTooSmallThe提供的缓冲区太小。
备注
只有经过身份验证的用户可以成功地调用这个函数。
Windows XP/2000操作系统:没有特别小组的成员要成功地执行这一职能。
实例
下面的代码示例演示了如何检索有关的运输是由服务器管理协议的信息,使用调用NetServerTransportEnum功能。该范例调用NetServerTransportEnum,指定信息化Level0(SERVER_TRANSPORT_INFO_0)。样本打印每个传输协议的名称,总数枚举。最后,代码示例释放的信息缓冲区分配的内存。
#ifndef UNICODE
#define UNICODE
#endif
#pragma comment(lib, "netapi32.lib")
#include
#include
#include
#include
int wmain(int argc, wchar_t *argv[])
{
LPSERVER_TRANSPORT_INFO_0 pBuf = NULL;
LPSERVER_TRANSPORT_INFO_0 pTmpBuf;
DWORD dwLevel = 0;
DWORD dwPrefMaxLen = MAX_PREFERRED_LENGTH;
DWORD dwEntriesRead = 0;
DWORD dwTotalEntries = 0;
DWORD dwResumeHandle = 0;
DWORD dwTotalCount = 0;
NET_API_STATUS nStatus;
LPTSTR pszServerName = NULL;
DWORD i;
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 NetServerTransportEnum function; specify level 0.
//
do // begin do
{
nStatus = NetServerTransportEnum(pszServerName,
dwLevel,
(LPBYTE *) &pBuf,
dwPrefMaxLen,
&dwEntriesRead,
&dwTotalEntries,
&dwResumeHandle);
//
// If the call succeeds,
//
if ((nStatus == NERR_Success) || (nStatus == ERROR_MORE_DATA))
{
if ((pTmpBuf = pBuf) != NULL)
{
//
// Loop through the entries;
// process access errors.
//
for (i = 0; i < dwEntriesRead; i++)
{
assert(pTmpBuf != NULL);
if (pTmpBuf == NULL)
{
fprintf(stderr, "An access violation has occurred\\n");
break;
}
//
// Print the transport protocol name.
//
wprintf(L"\\tTransport: %s\\n", pTmpBuf->svti0_transportname);
pTmpBuf++;
dwTotalCount++;
}
}
}
//
// Otherwise, indicate a system error.
//
else
fprintf(stderr, "A system error has occurred: %d\\n", nStatus);
//
// Free the allocated buffer.
//
if (pBuf != NULL)
{
NetApiBufferFree(pBuf);
pBuf = NULL;
}
//
// Continue to call NetServerTransportEnum while
// there are more entries.
//
}
while (nStatus == ERROR_MORE_DATA); // end do
// Check again for an allocated buffer.
//
if (pBuf != NULL)
NetApiBufferFree(pBuf);
//
// Print the final count of transports enumerated.
//
fprintf(stderr, "\\nTotal of %d entries enumerated\\n", dwTotalCount);
return 0;
}
要求:
最低支持:client-Windows 2000专业版
最低支持server-Windows 2000服务器
HeaderLmserver.h(包括Lm.h)
LibraryNetapi32.lib
DLLNetapi32.dll
参见
网络管理概述
网络管理功能
服务器和工作站运输功能
SERVER_TRANSPORT_INFO_0
SERVER_TRANSPORT_INFO_1
如果有任何问题和意见,请发送给微软(wsddocfb@microsoft.com)
生成日期:2009年8月13日
==英文原文==NetServerTransportEnum Function
The NetServerTransportEnum function supplies information about transport protocols that are managed by the server.
Syntax
C++
NET_API_STATUS NetServerTransportEnum(
__in LPWSTR servername,
__in DWORD level,
__out LPBYTE *bufptr,
__in DWORD prefmaxlen,
__out LPDWORD entriesread,
__out LPDWORD totalentries,
__inout LPDWORD resumehandle
);
Parameters
servername [in]
Pointer to a string that specifies the DNS or NetBIOS 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
0Return information about the transport protocol, including name, address, and location on the network. The bufptr parameter points to an array of SERVER_TRANSPORT_INFO_0 structures.
1Return information about the transport protocol, including name, address, network location, and domain. The bufptr parameter points to an array of SERVER_TRANSPORT_INFO_1 structures.

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. Note that you must free the buffer even if the function fails with ERROR_MORE_DATA.
prefmaxlen [in]
Specifies the preferred maximum length of returned data, in bytes. If you specify MAX_PREFERRED_LENGTH, the function allocates the amount of memory required for the data. If you specify another value in this parameter, it can restrict the number of bytes that the function returns. If the buffer size is insufficient to hold all entries, the function returns ERROR_MORE_DATA. For more information, see Network Management Function Buffers and Network Management Function Buffer Lengths .
entriesread [out]
Pointer to a value that receives the count of elements actually enumerated.
totalentries [out]
Pointer to a value that receives the total number of entries that could have been enumerated from the current resume position. Note that applications should consider this value only as a hint.
resumehandle [in, out]
Pointer to a value that contains a resume handle which is used to continue an existing server transport search. The handle should be zero on the first call and left unchanged for subsequent calls. If this parameter is NULL, no resume handle is stored.
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_INVALID_LEVELThe value specified for the level parameter is invalid.
ERROR_MORE_DATAMore entries are available. Specify a large enough buffer to receive all entries.
ERROR_NOT_ENOUGH_MEMORYInsufficient memory is available.
NERR_BufTooSmallThe supplied buffer is too small.

Remarks
Only Authenticated Users can successfully call this function.
Windows XP/2000: No special group membership is required to successfully execute this function.
Examples
The following code sample demonstrates how to retrieve information about transport protocols that are managed by the server, using a call to the NetServerTransportEnum function. The sample calls NetServerTransportEnum, specifying information level 0 ( SERVER_TRANSPORT_INFO_0 ). The sample prints the name of each transport protocol and the total number enumerated. Finally, the code sample frees the memory allocated for the information buffer.
#ifndef UNICODE
#define UNICODE
#endif
#pragma comment(lib, "netapi32.lib")
#include
#include
#include
#include
int wmain(int argc, wchar_t *argv[])
{
LPSERVER_TRANSPORT_INFO_0 pBuf = NULL;
LPSERVER_TRANSPORT_INFO_0 pTmpBuf;
DWORD dwLevel = 0;
DWORD dwPrefMaxLen = MAX_PREFERRED_LENGTH;
DWORD dwEntriesRead = 0;
DWORD dwTotalEntries = 0;
DWORD dwResumeHandle = 0;
DWORD dwTotalCount = 0;
NET_API_STATUS nStatus;
LPTSTR pszServerName = NULL;
DWORD i;
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 NetServerTransportEnum function; specify level 0.
//
do // begin do
{
nStatus = NetServerTransportEnum(pszServerName,
dwLevel,
(LPBYTE *) &pBuf,
dwPrefMaxLen,
&dwEntriesRead,
&dwTotalEntries,
&dwResumeHandle);
//
// If the call succeeds,
//
if ((nStatus == NERR_Success) || (nStatus == ERROR_MORE_DATA))
{
if ((pTmpBuf = pBuf) != NULL)
{
//
// Loop through the entries;
// process access errors.
//
for (i = 0; i < dwEntriesRead; i++)
{
assert(pTmpBuf != NULL);
if (pTmpBuf == NULL)
{
fprintf(stderr, "An access violation has occurred\\n");
break;
}
//
// Print the transport protocol name.
//
wprintf(L"\\tTransport: %s\\n", pTmpBuf->svti0_transportname);
pTmpBuf++;
dwTotalCount++;
}
}
}
//
// Otherwise, indicate a system error.
//
else
fprintf(stderr, "A system error has occurred: %d\\n", nStatus);
//
// Free the allocated buffer.
//
if (pBuf != NULL)
{
NetApiBufferFree(pBuf);
pBuf = NULL;
}
//
// Continue to call NetServerTransportEnum while
// there are more entries.
//
}
while (nStatus == ERROR_MORE_DATA); // end do
// Check again for an allocated buffer.
//
if (pBuf != NULL)
NetApiBufferFree(pBuf);
//
// Print the final count of transports enumerated.
//
fprintf(stderr, "\\nTotal of %d entries enumerated\\n", dwTotalCount);
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 and Workstation Transport Functions
SERVER_TRANSPORT_INFO_0
SERVER_TRANSPORT_INFO_1
Send comments about this topic to Microsoft
Build date: 8/13/2009
==原始网址==http://msdn.microsoft.com/en-us/library/aa370630(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 13:20:28