网站首页  词典首页

请输入您要查询的函数:

 

术语 netsharegetinfo
释义 NetShareGetInfo
语法:
C++
NET_API_STATUS NetShareGetInfo(
__in LPWSTR servername,
__in LPWSTR netname,
__in DWORD level,
__out LPBYTE *bufptr
);
NetShareGetInfo功能
Retrieves information about a particular shared resource on a server.
参数
服务器名 [in]
指针指向一个字符串,它指定的DNS或NetBIOS的远程服务器上的功能是执行的名称。如果该参数为NULL,则使用本地计算机。
网络实名 [in]
一个字符串指针,指定的份额要返回的信息的名称。
Level [in]
指定的数据信息的Level。此参数可以是下列值之一。
ValueMeaning
0Return共享名。在bufptr参数指向SHARE_INFO_0结构。
1Return信息共享资源,包括名称和资源的类型,以及与资源相关评论。在bufptr参数指向SHARE_INFO_1结构。
2Return信息共享资源,包括资源,类型和权限,密码,姓名和连接数。在bufptr参数指向SHARE_INFO_2结构。
501Return的名称和资源的类型,以及与资源相关评论。在bufptr参数指向SHARE_INFO_501结构。
502Return信息共享资源,包括资源,类型和权限,名称的连接的数量,以及其他有关资料。在bufptr参数指向SHARE_INFO_502结构。
503Specifies信息共享资源,包括资源,类型和权限,名称的连接的数量,以及其他有关资料。在buf参数指向一个SHARE_INFO_503结构。如果这个结构shi503_servername成员是“*”,并没有配置服务器的名称。
Windows Server 2003中,Windows XP和Windows 2000 Server和Windows 2000专业版:此信息Level不支持。
1005Return一个值,指示是否份额是一个Dfs树状结构的根量。在bufptr参数指向SHARE_INFO_1005结构。
bufptr [out]
指针的缓冲区,接收数据。这一数据格式取决于Level的参数值。有关更多信息,请参阅网络管理功能,缓冲器和网络管理功能缓冲区长度。
此缓冲区分配制度,必须使用NetApiBufferFree释放功能。请注意,您必须释放缓冲区,即使函数ERROR_MORE_DATA失败。
返回值
如果函数成功,返回值是NERR_Success。
如果函数失败,返回值可以是下面的错误代码之一。
返回codeDescription
ERROR_ACCESS_DENIEDThe用户没有获得所需的信息。
ERROR_INVALID_LEVELThe价值Level参数指定无效。
ERROR_INVALID_PARAMETERThe指定的参数无效。
ERROR_MORE_DATAMore项可用。指定一个足够大的缓冲区接收的所有条目。
ERROR_NOT_ENOUGH_MEMORYInsufficient内存可用。
NERR_BufTooSmallThe提供的缓冲区太小。
NERR_NetNameNotFoundThe共享名称不存在。
备注
此功能仅适用于服务器消息块(SMB)的股票。对于其他类型的股票,如分布式文件系统(DFS)或WebDAV共享,使用Windows网络(WNet)功能,它支持所有类型的股份。
对于(谁是用户在本地登录到机器交互式用户),没有特别小组的成员必须执行NetShareGetInfo功能。对于非交互式用户,管理员,高级用户,打印操作,或服务器操作员组成员必须在各级成功执行2,502 NetShareEnum功能和503。没有特殊组成员,是需要0级或1级要求。
Windows Server 2003中,Windows XP和Windows 2000 Server和Windows 2000 Professional的:对于所有用户,管理员,高级用户,打印操作,或服务器操作员组成员必须在各级成功执行2和502 NetShareGetInfo功能。
如果您是Active Directory的程序,您可以调用某些Active Directory服务接口(ADSI)的方法来达到同样的功能,您可以通过调用实现网络管理共享功能。有关更多信息,请参阅IADsFileShare。
如果503的Level参数指定的远程服务器上指定在SHARE_INFO_503结构shi503_servername成员必须被绑定到传输协议使用NetServerTransportAddEx功能。在对NetServerTransportAddEx电话,2或3必须是指定的Level参数,以及SVTI2_SCOPED_NAME标志必须已在为传输协议SERVER_TRANSPORT_INFO_2结构中指定。
实例
下面的代码示例演示如何检索有关特定的共享使用调用NetShareGetInfo资源信息的功能。该范例调用NetShareGetInfo,指定信息化Level502(SHARE_INFO_502)。如果调用获得成功,该代码打印检索到的数据。该示例还调用IsValidSecurityDescriptor函数来验证shi502_security_descriptor成员。最后,该示例释放的信息缓冲区分配的内存。
#define UNICODE
#include
#include
#include
#pragma comment(lib, "Netapi32.lib")
void wmain( int argc, TCHAR *lpszArgv[ ])
{
PSHARE_INFO_502 BufPtr;
NET_API_STATUS res;
LPTSTR lpszServer = NULL, lpszShare;
//
// Check command line arguments.
//
switch(argc)
{
case 3:
lpszServer = lpszArgv[2];
case 2:
lpszShare = lpszArgv[1];
break;
default:
printf("Usage: NetShareGetInfo sharename \\n");
return;
}
//
// Call the NetShareGetInfo function, specifying level 502.
//
if((res = NetShareGetInfo (lpszServer,lpszShare,502,(LPBYTE *) &BufPtr)) == ERROR_SUCCESS)
{
//
// Print the retrieved data.
//
printf("%S\\t%S\\t%u\\n",BufPtr->shi502_netname, BufPtr->shi502_path, BufPtr->shi502_current_uses);
//
// Validate the value of the
// shi502_security_descriptor member.
//
if (IsValidSecurityDescriptor(BufPtr->shi502_security_descriptor))
printf("It has a valid Security Descriptor.\\n");
else
printf("It does not have a valid Security Descriptor.\\n");
//
// Free the allocated memory.
//
NetApiBufferFree(BufPtr);
}
else
printf("Error: %ld\\n",res);
return;
}
要求:
最低支持:client-Windows 2000专业版
最低支持server-Windows 2000服务器
HeaderLmshare.h(包括Lm.h)
LibraryNetapi32.lib
DLLNetapi32.dll
参见
网络管理概述
网络管理功能
网络共享功能
NetServerTransportAddEx
SHARE_INFO_0
SHARE_INFO_1
SHARE_INFO_2
SHARE_INFO_501
SHARE_INFO_502
SHARE_INFO_1005
SECURITY_DESCRIPTOR
如果有任何问题和意见,请发送给微软(wsddocfb@microsoft.com)
生成日期:2009年4月9日
==英文原文==NetShareGetInfo Function
Retrieves information about a particular shared resource on a server.
Syntax
C++
NET_API_STATUS NetShareGetInfo(
__in LPWSTR servername,
__in LPWSTR netname,
__in DWORD level,
__out LPBYTE *bufptr
);
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.
netname [in]
Pointer to a string that specifies the name of the share for which to return information.
level [in]
Specifies the information level of the data. This parameter can be one of the following values.
ValueMeaning
0Return the share name. The bufptr parameter points to a SHARE_INFO_0 structure.
1Return information about the shared resource, including the name and type of the resource, and a comment associated with the resource. The bufptr parameter points to a SHARE_INFO_1 structure.
2Return information about the shared resource, including name of the resource, type and permissions, password, and number of connections. The bufptr parameter points to a SHARE_INFO_2 structure.
501Return the name and type of the resource, and a comment associated with the resource. The bufptr parameter points to a SHARE_INFO_501 structure.
502Return information about the shared resource, including name of the resource, type and permissions, number of connections, and other pertinent information. The bufptr parameter points to a SHARE_INFO_502 structure.
503Specifies information about the shared resource, including the name of the resource, type and permissions, number of connections, and other pertinent information. The buf parameter points to a SHARE_INFO_503 structure. If the shi503_servername member of this structure is "*", there is no configured server name.
Windows Server 2003, Windows XP, Windows 2000 Server, and Windows 2000 Professional: This information level is not supported.
1005Return a value that indicates whether the share is the root volume in a Dfs tree structure. The bufptr parameter points to a SHARE_INFO_1005 structure.

bufptr [out]
Pointer to the buffer that receives the data. The format of this data depends on the value of the level parameter. For more information, see Network Management Function Buffers and Network Management Function Buffer Lengths .
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.
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 not valid.
ERROR_INVALID_PARAMETERThe specified parameter is not valid.
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.
NERR_NetNameNotFoundThe share name does not exist.

Remarks
This function applies only to Server Message Block (SMB) shares. For other types of shares, such as Distributed File System (DFS) or WebDAV shares, use Windows Networking (WNet) functions , which support all types of shares.
For interactive users (users who are logged on locally to the machine), no special group membership is required to execute the NetShareGetInfo function. For non-interactive users, Administrator, Power User, Print Operator, or Server Operator group membership is required to successfully execute the NetShareEnum function at levels 2, 502, and 503. No special group membership is required for level 0 or level 1 calls.
Windows Server 2003, Windows XP, Windows 2000 Server, and Windows 2000 Professional: For all users, Administrator, Power User, Print Operator, or Server Operator group membership is required to successfully execute the NetShareGetInfo function at levels 2 and 502.
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 share functions. For more information, see IADsFileShare .
If 503 is specified for the level parameter, the remote server specified in the shi503_servername member of the SHARE_INFO_503 structure must have been bound to a transport protocol using the NetServerTransportAddEx function. In the call to NetServerTransportAddEx, either 2 or 3 must have been specified for the level parameter, and the SVTI2_SCOPED_NAME flag must have been specified in the SERVER_TRANSPORT_INFO_2 structure for the transport protocol.
Examples
The following code sample demonstrates how to retrieve information about a particular shared resource using a call to the NetShareGetInfo function. The sample calls NetShareGetInfo, specifying information level 502 ( SHARE_INFO_502 ). If the call succeeds, the code prints the retrieved data. The sample also calls the IsValidSecurityDescriptor function to validate the shi502_security_descriptor member. Finally, the sample frees the memory allocated for the information buffer.
#define UNICODE
#include
#include
#include
#pragma comment(lib, "Netapi32.lib")
void wmain( int argc, TCHAR *lpszArgv[ ])
{
PSHARE_INFO_502 BufPtr;
NET_API_STATUS res;
LPTSTR lpszServer = NULL, lpszShare;
//
// Check command line arguments.
//
switch(argc)
{
case 3:
lpszServer = lpszArgv[2];
case 2:
lpszShare = lpszArgv[1];
break;
default:
printf("Usage: NetShareGetInfo sharename \\n");
return;
}
//
// Call the NetShareGetInfo function, specifying level 502.
//
if((res = NetShareGetInfo (lpszServer,lpszShare,502,(LPBYTE *) &BufPtr)) == ERROR_SUCCESS)
{
//
// Print the retrieved data.
//
printf("%S\\t%S\\t%u\\n",BufPtr->shi502_netname, BufPtr->shi502_path, BufPtr->shi502_current_uses);
//
// Validate the value of the
// shi502_security_descriptor member.
//
if (IsValidSecurityDescriptor(BufPtr->shi502_security_descriptor))
printf("It has a valid Security Descriptor.\\n");
else
printf("It does not have a valid Security Descriptor.\\n");
//
// Free the allocated memory.
//
NetApiBufferFree(BufPtr);
}
else
printf("Error: %ld\\n",res);
return;
}
Requirements
Minimum supported clientWindows 2000 Professional
Minimum supported serverWindows 2000 Server
HeaderLmshare.h (include Lm.h)
LibraryNetapi32.lib
DLLNetapi32.dll
See Also
Network Management Overview
Network Management Functions
Network Share Functions
NetServerTransportAddEx
SHARE_INFO_0
SHARE_INFO_1
SHARE_INFO_2
SHARE_INFO_501
SHARE_INFO_502
SHARE_INFO_1005
SECURITY_DESCRIPTOR
Send comments about this topic to Microsoft
Build date: 4/9/2009
==原始网址==http://msdn.microsoft.com/en-us/library/bb525388(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:22:58