网站首页  词典首页

请输入您要查询的函数:

 

术语 netserverdiskenum
释义 NetServerDiskEnum
语法:
C++
NET_API_STATUS NetServerDiskEnum(
__in LPWSTR servername,
__in DWORD level,
__out LPBYTE *bufptr,
__in DWORD prefmaxlen,
__out LPDWORD entriesread,
__out LPDWORD totalentries,
__inout LPDWORD resume_handle
);
NetServerDiskEnum功能
该NetServerDiskEnum函数检索的磁盘驱动器上的服务器列表。该函数返回一个数组的三个字符的字符串(驱动器号,冒号和一个终止空字符)。
参数
服务器名 [in]
一个字符串,它指定的DNS或NetBIOS的远程服务器上的功能是执行名称的指针。如果该参数为NULL,则使用本地计算机。
Level [in]
所需的信息化Level。值为零,是唯一有效的Level。
bufptr [out]
一个缓冲区,接收数据的指针。该数据是3阵列的字符串(驱动器号,冒号和一个终止空字符)。此缓冲区分配制度,必须使用NetApiBufferFree释放功能。请注意,您必须释放缓冲区,即使函数ERROR_MORE_DATA失败。
prefmaxlen [in]
返回的数据的更好的最大长度,以字节为单位。如果您指定MAX_PREFERRED_LENGTH,功能分配用于数据所需的内存量。如果指定这个参数在另一个值,它可以限制的字节数函数返回。如果缓冲区大小不足以容纳所有作品,该函数返回ERROR_MORE_DATA。有关更多信息,请参阅网络管理功能,缓冲器和网络管理功能缓冲区长度。
注意:此参数是目前被忽略。
entriesread [out]
一个值,接收元素计数实际列举的指针。
totalentries [out]
一个值,得到了本来可以参赛作品总数的指针从当前列举的恢复状况。请注意,应用程序应考虑仅作为提示此值。
resume_handle [ in , out ]
一个值,包含一个恢复处理,用于继续现有的服务器磁盘搜索指针。手柄应在第一次调用零,离开后续调用不变。如果resume_handle参数是NULL指针,那么任何恢复处理存储。
返回值
如果函数成功,返回值是NERR_Success。
如果函数失败,返回值可以是下面的错误代码之一。
返回codeDescription
ERROR_ACCESS_DENIEDThe用户没有获得所需的信息。
ERROR_INVALID_LEVELThe价值Level参数指定无效。
ERROR_MORE_DATAMore项可用。指定一个足够大的缓冲区接收的所有条目。
ERROR_NOT_ENOUGH_MEMORYInsufficient内存可用。
ERROR_NOT_SUPPORTEDThe不支持请求。返回此错误,如果远程服务器是服务器名参数指定的远程服务器只支持远程RPC调用使用传统的远程访问协议机制,而这个请求不支持。
备注
管理员或服务器操作员本地组的成员才可以成功地执行远程计算机上的NetServerDiskEnum功能。
如果您是Active Directory的程序,您可以调用某些Active Directory服务接口(ADSI)的方法,可以达到同样的结果,您可以通过调用实现网络管理服务器功能。有关详细信息,请参阅IADsComputer接口的引用。
实例
下面的代码示例演示如何调用NetServerDiskEnum函数检索服务器上的磁盘驱动器列表。该范例调用NetServerDiskEnum,指定信息级别0(必需)。如果有项返回,用户可访问的信息,它打印在一个三格式的驱动器列表中,字符的字符串:驱动器号,冒号和一个终止空字符。该示例还打印的项的,以及未对项目的数量提示总数实际列举。最后,代码示例为缓冲区释放分配的内存。
#ifndef UNICODE
#define UNICODE
#endif
#include
#include
#include
#include
#pragma comment(lib, "netapi32.lib")
int wmain(int argc, wchar_t *argv[])
{
const int ENTRY_SIZE = 3; // Drive letter, colon, NULL
LPTSTR pBuf = NULL;
DWORD dwLevel = 0; // level must be zero
DWORD dwPrefMaxLen = MAX_PREFERRED_LENGTH;
DWORD dwEntriesRead = 0;
DWORD dwTotalEntries = 0;
NET_API_STATUS nStatus;
LPWSTR 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 NetServerDiskEnum function.
//
nStatus = NetServerDiskEnum(pszServerName,
dwLevel,
(LPBYTE *) &pBuf,
dwPrefMaxLen,
&dwEntriesRead,
&dwTotalEntries,
NULL);
//
// If the call succeeds,
//
if (nStatus == NERR_Success)
{
LPTSTR pTmpBuf;
if ((pTmpBuf = pBuf) != NULL)
{
DWORD i;
DWORD dwTotalCount = 0;
//
// Loop through the entries.
//
for (i = 0; i < dwEntriesRead; i++)
{
assert(pTmpBuf != NULL);
if (pTmpBuf == NULL)
{
// On a remote computer, only members of the
// Administrators or the Server Operators
// local group can execute NetServerDiskEnum.
//
fprintf(stderr, "An access violation has occurred\\n");
break;
}
//
// Print drive letter, colon, NULL for each drive;
// the number of entries actually enumerated; and
// the total number of entries available.
//
fwprintf(stdout, L"\\tDisk: %S\\n", pTmpBuf);
pTmpBuf += ENTRY_SIZE;
dwTotalCount++;
}
fprintf(stderr, "\\nEntries enumerated: %d\\n", dwTotalCount);
}
}
else
fprintf(stderr, "A system error has occurred: %d\\n", nStatus);
//
// Free the allocated buffer.
//
if (pBuf != NULL)
NetApiBufferFree(pBuf);
return 0;
}
要求:
最低支持:client-Windows 2000专业版
最低支持server-Windows 2000服务器
HeaderLmserver.h(包括Lm.h)
LibraryNetapi32.lib
DLLNetapi32.dll
参见
IADsComputer
网络管理概述
网络管理功能
服务器功能
的NetServerEnum
如果有任何问题和意见,请发送给微软(wsddocfb@microsoft.com)
生成日期:2009年8月13日
==英文原文==NetServerDiskEnum Function
The NetServerDiskEnum function retrieves a list of disk drives on a server. The function returns an array of three-character strings (a drive letter, a colon, and a terminating null character).
Syntax
C++
NET_API_STATUS NetServerDiskEnum(
__in LPWSTR servername,
__in DWORD level,
__out LPBYTE *bufptr,
__in DWORD prefmaxlen,
__out LPDWORD entriesread,
__out LPDWORD totalentries,
__inout LPDWORD resume_handle
);
Parameters
servername [in]
A 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]
The level of information required. A value of zero is the only valid level.
bufptr [out]
A pointer to the buffer that receives the data. The data is an array of three-character strings (a drive letter, a colon, and a terminating null character). 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]
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 .
Note This parameter is currently ignored.
entriesread [out]
A pointer to a value that receives the count of elements actually enumerated.
totalentries [out]
A 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.
resume_handle [in, out]
A pointer to a value that contains a resume handle which is used to continue an existing server disk search. The handle should be zero on the first call and left unchanged for subsequent calls. If the resume_handle parameter is a NULL pointer, then 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_ACCESS_DENIEDThe user does not have access to the requested information.
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.
ERROR_NOT_SUPPORTEDThe request is not supported. This error is returned if a remote server was specified in servername parameter, the remote server only supports remote RPC calls using the legacy Remote Access Protocol mechanism, and this request is not supported.

Remarks
Only members of the Administrators or Server Operators local group can successfully execute the NetServerDiskEnum function on a remote computer.
If you are programming for Active Directory, you may be able to call certain Active Directory Service Interface (ADSI) methods to achieve the same results you can achieve by calling the network management server functions. For more information, see the IADsComputer interface reference.
Examples
The following code sample demonstrates how to call the NetServerDiskEnum function to retrieve a list of disk drives on a server. The sample calls NetServerDiskEnum, specifying the information level 0 (required). If there are entries to return, and the user has access to the information, it prints a list of the drives, in the format of a three-character string: a drive letter, a colon, and a terminating null character. The sample also prints the total number of entries that are available and a hint about the number of entries actually enumerated. Finally, the code sample frees the memory allocated for the buffer.
#ifndef UNICODE
#define UNICODE
#endif
#include
#include
#include
#include
#pragma comment(lib, "netapi32.lib")
int wmain(int argc, wchar_t *argv[])
{
const int ENTRY_SIZE = 3; // Drive letter, colon, NULL
LPTSTR pBuf = NULL;
DWORD dwLevel = 0; // level must be zero
DWORD dwPrefMaxLen = MAX_PREFERRED_LENGTH;
DWORD dwEntriesRead = 0;
DWORD dwTotalEntries = 0;
NET_API_STATUS nStatus;
LPWSTR 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 NetServerDiskEnum function.
//
nStatus = NetServerDiskEnum(pszServerName,
dwLevel,
(LPBYTE *) &pBuf,
dwPrefMaxLen,
&dwEntriesRead,
&dwTotalEntries,
NULL);
//
// If the call succeeds,
//
if (nStatus == NERR_Success)
{
LPTSTR pTmpBuf;
if ((pTmpBuf = pBuf) != NULL)
{
DWORD i;
DWORD dwTotalCount = 0;
//
// Loop through the entries.
//
for (i = 0; i < dwEntriesRead; i++)
{
assert(pTmpBuf != NULL);
if (pTmpBuf == NULL)
{
// On a remote computer, only members of the
// Administrators or the Server Operators
// local group can execute NetServerDiskEnum.
//
fprintf(stderr, "An access violation has occurred\\n");
break;
}
//
// Print drive letter, colon, NULL for each drive;
// the number of entries actually enumerated; and
// the total number of entries available.
//
fwprintf(stdout, L"\\tDisk: %S\\n", pTmpBuf);
pTmpBuf += ENTRY_SIZE;
dwTotalCount++;
}
fprintf(stderr, "\\nEntries enumerated: %d\\n", dwTotalCount);
}
}
else
fprintf(stderr, "A system error has occurred: %d\\n", nStatus);
//
// Free the allocated buffer.
//
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
IADsComputer
Network Management Overview
Network Management Functions
Server Functions
NetServerEnum
Send comments about this topic to Microsoft
Build date: 8/13/2009
==原始网址==http://msdn.microsoft.com/en-us/library/aa370622(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:28:04