网站首页  词典首页

请输入您要查询的函数:

 

术语 netshareadd
释义 NetShareAdd
语法:
C++
NET_API_STATUS NetShareAdd(
__in LPWSTR servername,
__in DWORD level,
__in LPBYTE buf,
__out LPDWORD parm_err
);
NetShareAdd功能
共享一个服务器资源。
参数
服务器名 [in]
指针指向一个字符串,它指定的DNS或NetBIOS的远程服务器上的功能是执行的名称。如果该参数为NULL,则使用本地计算机。
Level [in]
指定的数据信息的Level。此参数可以是下列值之一。
ValueMeaning
2Specifies信息共享资源,包括资源,类型和权限的名称,连接数。在buf参数指向一个SHARE_INFO_2结构。
502Specifies信息共享资源,包括资源,类型和权限,名称的连接的数量,以及其他有关资料。在buf参数指向一个SHARE_INFO_502结构。
503Specifies信息共享资源,包括资源,类型和权限,名称的连接的数量,以及其他有关资料。在buf参数指向一个SHARE_INFO_503结构。
缓冲带 [in]
缓冲区指针指定的数据。这一数据格式取决于Level的参数值。有关更多信息,请参阅网络管理功能的缓冲器。
parm_err [out]
指针的值,它接收的共享的信息结构,导致错误的ERROR_INVALID_PARAMETER第一个成员的索引。如果该参数为NULL,则指数不返回的错误。有关详细信息,请参阅NetShareSetInfo功能。
返回值
如果函数成功,返回值是NERR_Success。
如果函数失败,返回值可以是下面的错误代码之一。
返回codeDescription
ERROR_ACCESS_DENIEDThe用户没有获得所需的信息。
ERROR_INVALID_LEVELThe价值Level参数指定无效。
ERROR_INVALID_NAMEThe字符或文件系统的名称是无效的。
ERROR_INVALID_PARAMETERThe指定的参数无效。
NERR_DuplicateShareThe共享名称已经在使用此服务器上。
NERR_RedirectedPathThe操作不适用于重定向的资源。指定的设备名被分配到一个共享资源。
NERR_UnknownDevDirThe设备或目录不存在。
备注
此功能仅适用于服务器消息块(SMB)的股票。对于其他类型的股票,如分布式文件系统(DFS)或WebDAV共享,使用Windows网络(WNet)功能,它支持所有类型的股份。
系统管理员,系统操作员,或Power Users组的成员才可以添加本地文件,以函数调用的NetShareAdd股。打印操作员可以添加打印机共享。
如果您是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结构中指定。
实例
下面的代码示例演示了如何共享网络资源使用调用NetShareAdd功能。此代码示例填充在SHARE_INFO_2结构的成员,并呼吁NetShareAdd,明确信息化Level2。密码是没有必要,因为这些平台不支持共享级安全性。
#define UNICODE
#include
#include
#include
#pragma comment(lib, "Netapi32.lib");
void wmain( int argc, TCHAR *argv[ ])
{
NET_API_STATUS res;
SHARE_INFO_2 p;
DWORD parm_err = 0;
if(argc<2)
printf("Usage: NetShareAdd server\\n");
else
{
//
// Fill in the SHARE_INFO_2 structure.
//
p.shi2_netname = TEXT("TESTSHARE");
p.shi2_type = STYPE_DISKTREE; // disk drive
p.shi2_remark = TEXT("TESTSHARE to test NetShareAdd");
p.shi2_permissions = 0;
p.shi2_max_uses = 4;
p.shi2_current_uses = 0;
p.shi2_path = TEXT("C:\\\\");
p.shi2_passwd = NULL; // no password
//
// Call the NetShareAdd function,
// specifying level 2.
//
res=NetShareAdd(argv[1], 2, (LPBYTE) &p, &parm_err);
//
// If the call succeeds, inform the user.
//
if(res==0)
printf("Share created.\\n");

// Otherwise, print an error,
// and identify the parameter in error.
//
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
NetShareDel
NetShareDelEx
NetShareSetInfo
SHARE_INFO_2
SHARE_INFO_502
SHARE_INFO_503
如果有任何问题和意见,请发送给微软(wsddocfb@microsoft.com)
生成日期:2009年7月30日
==英文原文==NetShareAdd Function
Shares a server resource.
Syntax
C++
NET_API_STATUS NetShareAdd(
__in LPWSTR servername,
__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.
level [in]
Specifies the information level of the data. This parameter can be one of the following values.
ValueMeaning
2Specifies information about the shared resource, including the name of the resource, type and permissions, and number of connections. The buf parameter points to a SHARE_INFO_2 structure.
502Specifies 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_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.

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 NetShareSetInfo 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 not valid.
ERROR_INVALID_NAMEThe character or file system name is not valid.
ERROR_INVALID_PARAMETERThe specified parameter is not valid.
NERR_DuplicateShareThe share name is already in use on this server.
NERR_RedirectedPathThe operation is not valid for a redirected resource. The specified device name is assigned to a shared resource.
NERR_UnknownDevDirThe device or directory 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, System Operators, or Power Users local group can add file shares with a call to the NetShareAdd function. The Print Operator can add printer shares.
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 share a network resource using a call to the NetShareAdd function. The code sample fills in the members of the SHARE_INFO_2 structure and calls NetShareAdd, specifying information level 2. A password is not required because these platforms do not support share-level security.
#define UNICODE
#include
#include
#include
#pragma comment(lib, "Netapi32.lib");
void wmain( int argc, TCHAR *argv[ ])
{
NET_API_STATUS res;
SHARE_INFO_2 p;
DWORD parm_err = 0;
if(argc<2)
printf("Usage: NetShareAdd server\\n");
else
{
//
// Fill in the SHARE_INFO_2 structure.
//
p.shi2_netname = TEXT("TESTSHARE");
p.shi2_type = STYPE_DISKTREE; // disk drive
p.shi2_remark = TEXT("TESTSHARE to test NetShareAdd");
p.shi2_permissions = 0;
p.shi2_max_uses = 4;
p.shi2_current_uses = 0;
p.shi2_path = TEXT("C:\\\\");
p.shi2_passwd = NULL; // no password
//
// Call the NetShareAdd function,
// specifying level 2.
//
res=NetShareAdd(argv[1], 2, (LPBYTE) &p, &parm_err);
//
// If the call succeeds, inform the user.
//
if(res==0)
printf("Share created.\\n");

// Otherwise, print an error,
// and identify the parameter in error.
//
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
NetShareDel
NetShareDelEx
NetShareSetInfo
SHARE_INFO_2
SHARE_INFO_502
SHARE_INFO_503
Send comments about this topic to Microsoft
Build date: 7/30/2009
==原始网址==http://msdn.microsoft.com/en-us/library/bb525384(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:26:07