网站首页  词典首页

请输入您要查询的函数:

 

术语 netsharesetinfo
释义 NetShareSetInfo
语法:
C++
NET_API_STATUS NetShareSetInfo(
__in LPWSTR servername,
__in LPWSTR netname,
__in DWORD level,
__in LPBYTE buf,
__out LPDWORD parm_err
);
NetShareSetInfo功能
设置一个共享资源的参数。
参数
服务器名 [in]
指针指向一个字符串,它指定的DNS或NetBIOS的远程服务器上的功能是执行的名称。如果该参数为NULL,则使用本地计算机。
网络实名 [in]
一个字符串指针,指定共享的名称设置信息。
Level [in]
指定的数据信息的Level。此参数可以是下列值之一。
ValueMeaning
1Specifies信息共享资源,包括名称和资源的类型,以及与资源相关评论。在buf参数指向一个SHARE_INFO_1结构。
2Specifies信息共享资源,包括资源,类型和权限,密码,姓名和连接数。在buf参数指向一个SHARE_INFO_2结构。
502Specifies信息共享资源,包括名称和资源的类型,所需的权限,连接的数量,以及其他有关资料。在buf参数指向一个SHARE_INFO_502结构。
503Specifies的共享资源的名称。在buf参数指向一个SHARE_INFO_503结构。这除了shi503_servername结构的所有成员都忽略NetShareSetInfo功能。
Windows Server 2003中,Windows XP和Windows 2000 Server和Windows 2000专业版:此信息Level不支持。
1004Specifies评论与共享资源关联。在buf参数指向一个SHARE_INFO_1004结构。
1005Specifies一套描述共享资源的标志。在buf参数指向一个SHARE_INFO_1005结构。
1006Specifies的并发连接,共享资源可以容纳的最大数量。在buf参数指向一个SHARE_INFO_1006结构。
1501Specifies与相关SECURITY_DESCRIPTOR指定的共享。在buf参数指向一个SHARE_INFO_1501结构。
缓冲带 [in]
缓冲区指针指定的数据。这一数据格式取决于Level的参数值。有关更多信息,请参阅网络管理功能的缓冲器。
parm_err [out]
指针的值,它接收的共享的信息结构,导致错误的ERROR_INVALID_PARAMETER第一个成员的索引。如果该参数为NULL,则指数不返回的错误。有关详细信息,请参阅下面的备注部分。
返回值
如果函数成功,返回值是NERR_Success。
如果函数失败,返回值可以是下面的错误代码之一。
返回codeDescription
ERROR_ACCESS_DENIEDThe用户没有获得所需的信息。
ERROR_INVALID_LEVELThe价值Level参数指定无效。
ERROR_INVALID_PARAMETERThe指定的参数无效。有关详细信息,请参阅下面的备注部分。
NERR_NetNameNotFoundThe共享名称不存在。
备注
此功能仅适用于服务器消息块(SMB)的股票。对于其他类型的股票,如分布式文件系统(DFS)或WebDAV共享,使用Windows网络(WNet)功能,它支持所有类型的股份。
的Administrators或Power Users只有会员本地组,或打印或服务器操作员组成员的,可以成功地执行NetShareSetInfo功能。打印操作员可以设置只打印机共享的信息。
如果NetShareSetInfo函数返回ERROR_INVALID_PARAMETER,您可以使用parm_err参数显示共享的信息结构的第一个成员无效。 (A股信息结构开始SHARE_INFO_以及它的形式是指定的Level参数。)下表列出了可以返回的parm_err参数和相应的结构成员,在错误的价值观。 (前缀市* _表明,成员国可以开始与多个前缀,例如,shi2_或shi502_。)
ValueMember
SHARE_NETNAME_PARMNUMshi * _netname
SHARE_TYPE_PARMNUMshi * _type
SHARE_REMARK_PARMNUMshi * _remark
SHARE_PERMISSIONS_PARMNUMshi * _permissions
SHARE_MAX_USES_PARMNUMshi * _max_uses
SHARE_CURRENT_USES_PARMNUMshi * _current_uses
SHARE_PATH_PARMNUMshi * _path
SHARE_PASSWD_PARMNUMshi * _passwd
SHARE_FILE_SD_PARMNUMshi*_security_descriptor
如果您是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结构中指定。
实例
下面的代码示例演示如何设置一个共享使用调用NetShareSetInfo职能资源关联的评论。要做到这一点,该示例指定信息化Level1004(SHARE_INFO_1004)。
#define UNICODE
#include
#include
#include
#pragma comment(lib, "Netapi32.lib");
void wmain( int argc, TCHAR *argv[ ])
{
SHARE_INFO_1004 p;
NET_API_STATUS res;
DWORD parm_err = 0;
if(argc<4)
printf("Usage: SetInfo server share \\"remark\\"\\n");
else
{
//
// Fill in SHARE_INFO_1004 structure member.
//
p.shi1004_remark=argv[3];
//
// Call the NetShareSetInfo function,
// specifying information level 1004.
//
res=NetShareSetInfo(argv[1], argv[2], 1004, (LPBYTE)&p, &parm_err);
//
// Display the result of the call.
//
if(res==0)
printf("Remark set.\\n");
else
printf("Error: %u\\tparmerr=%u\\n", res, parm_err);
}
return;
}
要求:
最低支持:client-Windows 2000专业版
最低支持server-Windows 2000服务器
HeaderLmshare.h(包括Lm.h)
LibraryNetapi32.lib
DLLNetapi32.dll
参见
网络管理概述
网络管理功能
网络共享功能
NetServerTransportAddEx
NetShareGetInfo
SHARE_INFO_1
SHARE_INFO_2
SHARE_INFO_502
SHARE_INFO_503
SHARE_INFO_1004
SHARE_INFO_1006
SHARE_INFO_1501
如果有任何问题和意见,请发送给微软(wsddocfb@microsoft.com)
生成日期:2009年4月9日
==英文原文==NetShareSetInfo Function
Sets the parameters of a shared resource.
Syntax
C++
NET_API_STATUS NetShareSetInfo(
__in LPWSTR servername,
__in LPWSTR netname,
__in DWORD level,
__in LPBYTE buf,
__out LPDWORD parm_err
);
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 to set information on.
level [in]
Specifies the information level of the data. This parameter can be one of the following values.
ValueMeaning
1Specifies information about the shared resource, including the name and type of the resource, and a comment associated with the resource. The buf parameter points to a SHARE_INFO_1 structure.
2Specifies information about the shared resource, including the name of the resource, type and permissions, password, and number of connections. The buf parameter points to a SHARE_INFO_2 structure.
502Specifies information about the shared resource, including the name and type of the resource, required permissions, number of connections, and other pertinent information. The buf parameter points to a SHARE_INFO_502 structure.
503Specifies the name of the shared resource. The buf parameter points to a SHARE_INFO_503 structure. All members of this structure except shi503_servername are ignored by the NetShareSetInfo function.
Windows Server 2003, Windows XP, Windows 2000 Server, and Windows 2000 Professional: This information level is not supported.
1004Specifies a comment associated with the shared resource. The buf parameter points to a SHARE_INFO_1004 structure.
1005Specifies a set of flags describing the shared resource. The buf parameter points to a SHARE_INFO_1005 structure.
1006Specifies the maximum number of concurrent connections that the shared resource can accommodate. The buf parameter points to a SHARE_INFO_1006 structure.
1501Specifies the SECURITY_DESCRIPTOR associated with the specified share. The buf parameter points to a SHARE_INFO_1501 structure.

buf [in]
Pointer to the buffer that specifies the data. The format of this data depends on the value of the level parameter. For more information, see Network Management Function Buffers .
parm_err [out]
Pointer to a value that receives the index of the first member of the share information structure that causes the ERROR_INVALID_PARAMETER error. If this parameter is NULL, the index is not returned on error. For more information, see the following Remarks section.
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. For more information, see the following Remarks section.
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.
Only members of the Administrators or Power Users local group, or those with Print or Server Operator group membership, can successfully execute the NetShareSetInfo function. The Print Operator can set information only about Printer shares.
If the NetShareSetInfo function returns ERROR_INVALID_PARAMETER, you can use the parm_err parameter to indicate the first member of the share information structure that is not valid. (A share information structure begins with SHARE_INFO_ and its format is specified by the level parameter.) The following table lists the values that can be returned in the parm_err parameter and the corresponding structure member that is in error. (The prefix shi*_ indicates that the member can begin with multiple prefixes, for example, shi2_ or shi502_.)
ValueMember
SHARE_NETNAME_PARMNUMshi*_netname
SHARE_TYPE_PARMNUMshi*_type
SHARE_REMARK_PARMNUMshi*_remark
SHARE_PERMISSIONS_PARMNUMshi*_permissions
SHARE_MAX_USES_PARMNUMshi*_max_uses
SHARE_CURRENT_USES_PARMNUMshi*_current_uses
SHARE_PATH_PARMNUMshi*_path
SHARE_PASSWD_PARMNUMshi*_passwd
SHARE_FILE_SD_PARMNUMshi*_security_descriptor

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 set the comment associated with a shared resource using a call to the NetShareSetInfo function. To do this, the sample specifies information level 1004 ( SHARE_INFO_1004 ).
#define UNICODE
#include
#include
#include
#pragma comment(lib, "Netapi32.lib");
void wmain( int argc, TCHAR *argv[ ])
{
SHARE_INFO_1004 p;
NET_API_STATUS res;
DWORD parm_err = 0;
if(argc<4)
printf("Usage: SetInfo server share \\"remark\\"\\n");
else
{
//
// Fill in SHARE_INFO_1004 structure member.
//
p.shi1004_remark=argv[3];
//
// Call the NetShareSetInfo function,
// specifying information level 1004.
//
res=NetShareSetInfo(argv[1], argv[2], 1004, (LPBYTE)&p, &parm_err);
//
// Display the result of the call.
//
if(res==0)
printf("Remark set.\\n");
else
printf("Error: %u\\tparmerr=%u\\n", res, parm_err);
}
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
NetShareGetInfo
SHARE_INFO_1
SHARE_INFO_2
SHARE_INFO_502
SHARE_INFO_503
SHARE_INFO_1004
SHARE_INFO_1006
SHARE_INFO_1501
Send comments about this topic to Microsoft
Build date: 4/9/2009
==原始网址==http://msdn.microsoft.com/en-us/library/bb525389(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:18:55