网站首页  词典首页

请输入您要查询的函数:

 

术语 netdfsadd
释义 NetDfsAdd
语法:
C++
NET_API_STATUS NetDfsAdd(
__in LPWSTR DfsEntryPath,
__in LPWSTR ServerName,
__in LPWSTR PathName,
__in_opt LPWSTR Comment,
__in DWORD Flags
);
NetDfsAdd功能
创建一个新的分布式文件系统(DFS)链接或添加到一个目标,在DFS名称现有的链接。
参数
DfsEntryPath [in]
一个字符串指针,指定通用命名约定(UNC)的DFS名称空间中的DFS链接路径。
该字符串可以两种形式之一。第一种形式如下:
\\ \\服务器\\ DfsName \\ link_path
其中ServerName是根目标服务器承载独立的DFS命名空间的名称; DfsName是DFS名称空间的名称和link_path是DFS链接。
第二种形式是如下:
\\ \\域名\\ DomDfsname \\ link_path
其中DomainName是域的承载基于域的DFS命名空间的名称; DomDfsname是该域名的DFS名称空间和link_path是DFS链接。
此参数是必需的。
服务器名 [in]
一个字符串指针,指定链接目标服务器的名称。此参数是必需的。
路径名 [in]
一个字符串指针,指定链接的目标共享名称。这也可以是共享的名称与路径相对于共享。例如,share1 \\ mydir1 \\ mydir2。此参数是必需的。
评论[中,可选]
指针指向一个字符串,指定一个可选的评论与DFS链接相关联。忽略此参数时,函数将一个目标,现有的链接。
标志 [in]
此参数可以指定以下值,也可以指定不挂零。
ValueMeaning
DFS_ADD_VOLUME
0x00000001Create DFS链接。如果DFS链接已经存在,NetDfsAdd函数失败。有关详细信息,请参见备注部分。
Windows 2000服务器:此标志必须指定一个新的链接,如果要创建。
DFS_RESTORE_VOLUME
0x00000002This标志不支持。
Windows 2000服务器:此标志恢复该卷或复制。
返回值
如果函数成功,返回值是NERR_Success。
如果函数失败,返回值是一个系统错误代码。对于一个错误代码的列表,请参见系统错误代码。
备注
DFS名称空间必须已经存在。此函数不创建新的DFS命名空间。
调用者必须具有在DFS服务器的管理员特权。如需有关通话功能,需要管理员权限的信息,请运行特权。
DFS_ADD_VOLUME国旗的使用是可选的。如果您指定DFS_ADD_VOLUME和已经存在的联系,NetDfsAdd失败。如果您不指定DFS_ADD_VOLUME,NetDfsAdd创建连接,如果需要,并且增加了目标的链接。您应该指定此值当您需要确定何时创建新的联系。
实例
下面的代码示例演示如何创建一个新的DFS链接使用调用NetDfsAdd功能。由于样本中的指定参数值DFS_ADD_VOLUME旗,呼吁NetDfsAdd失败如果DFS链接已经存在。要添加一个额外的目标,以现有的DFS链接,您可以指定在flags参数为零。
#define UNICODE
#include
#include
#include
#include
#pragma comment(lib, "NetApi32.lib")
void wmain(int argc, wchar_t *argv[ ])
{
DWORD res;
LPTSTR lpszComment;
lpszComment = argc < 5 ? NULL : argv[4];
//
// Check for required parameters.
//
if (argc < 4)
wprintf(L"Syntax: %s DfsEntryPath ServerName ShareName [\\"Comment\\"]\\n", argv[0]);
else
{
//
// Call the NetDfsAdd function; fail the call
// if the DFS link already exists (DFS_ADD_VOLUME).
  //
// To add a second storage to a DFS link, change
// the last parameter to 0.
//
res = NetDfsAdd(argv[1], argv[2], argv[3], argv[4], DFS_ADD_VOLUME);
//
// If the call succeeds,
//
if(res == 0)
printf("Added DFS link\\n");
else
printf("Error: %u\\n", res);
}
return;
}
要求:
最低支持:client-Windows 2000专业版
最低支持server-Windows 2000服务器
HeaderLmDfs.h(包括LmDfs.h或Lm.h)
LibraryNetApi32.lib
DLLNetApi32.dll
参见
网络管理概述
网络管理功能
分布式文件系统(DFS)功能
NetDfsEnum
NetDfsRemove
NetDfsAddStdRoot
NetDfsAddFtRoot
如果有任何问题和意见,请发送给微软(wsddocfb@microsoft.com)
生成日期:2009年7月30日
==英文原文==NetDfsAdd Function
Creates a new Distributed File System (DFS) link or adds targets to an existing link in a DFS namespace.
Syntax
C++
NET_API_STATUS NetDfsAdd(
__in LPWSTR DfsEntryPath,
__in LPWSTR ServerName,
__in LPWSTR PathName,
__in_opt LPWSTR Comment,
__in DWORD Flags
);
Parameters
DfsEntryPath [in]
Pointer to a string that specifies the Universal Naming Convention (UNC) path of a DFS link in a DFS namespace.
The string can be in one of two forms. The first form is as follows:
\\\\ServerName\\DfsName\\link_path
where ServerName is the name of the root target server that hosts a stand-alone DFS namespace; DfsName is the name of the DFS namespace; and link_path is a DFS link.
The second form is as follows:
\\\\DomainName\\DomDfsname\\link_path
where DomainName is the name of the domain that hosts a domain-based DFS namespace; DomDfsname is the name of the domain-based DFS namespace; and link_path is a DFS link.
This parameter is required.
ServerName [in]
Pointer to a string that specifies the link target server name. This parameter is required.
PathName [in]
Pointer to a string that specifies the link target share name. This can also be a share name with a path relative to the share. For example, share1\\mydir1\\mydir2. This parameter is required.
Comment [in, optional]
Pointer to a string that specifies an optional comment associated with the DFS link. This parameter is ignored when the function adds a target to an existing link.
Flags [in]
This parameter can specify the following value, or you can specify zero for no flags.
ValueMeaning
DFS_ADD_VOLUME
0x00000001Create a DFS link. If the DFS link already exists, the NetDfsAdd function fails. For more information, see the Remarks section.
Windows 2000 Server: This flag must be specified if a new link is to be created.
DFS_RESTORE_VOLUME
0x00000002This flag is not supported.
Windows 2000 Server: This flag restores the volume or replica.

Return Value
If the function succeeds, the return value is NERR_Success.
If the function fails, the return value is a system error code. For a list of error codes, see System Error Codes .
Remarks
The DFS namespace must already exist. This function does not create a new DFS namespace.
The caller must have Administrator privilege on the DFS server. For more information about calling functions that require administrator privileges, see Running with Special Privileges .
Use of the DFS_ADD_VOLUME flag is optional. If you specify DFS_ADD_VOLUME and the link already exists, NetDfsAdd fails. If you do not specify DFS_ADD_VOLUME, NetDfsAdd creates the link, if required, and adds the target to the link. You should specify this value when you need to determine when new links are created.
Examples
The following code sample demonstrates how to create a new DFS link using a call to the NetDfsAdd function. Because the sample specifies the value DFS_ADD_VOLUME in the Flags parameter, the call to NetDfsAdd fails if the DFS link already exists. To add additional targets to an existing DFS link, you can specify zero in the Flags parameter.
#define UNICODE
#include
#include
#include
#include
#pragma comment(lib, "NetApi32.lib")
void wmain(int argc, wchar_t *argv[ ])
{
DWORD res;
LPTSTR lpszComment;
lpszComment = argc < 5 ? NULL : argv[4];
//
// Check for required parameters.
//
if (argc < 4)
wprintf(L"Syntax: %s DfsEntryPath ServerName ShareName [\\"Comment\\"]\\n", argv[0]);
else
{
//
// Call the NetDfsAdd function; fail the call
// if the DFS link already exists (DFS_ADD_VOLUME).
  //
// To add a second storage to a DFS link, change
// the last parameter to 0.
//
res = NetDfsAdd(argv[1], argv[2], argv[3], argv[4], DFS_ADD_VOLUME);
//
// If the call succeeds,
//
if(res == 0)
printf("Added DFS link\\n");
else
printf("Error: %u\\n", res);
}
return;
}
Requirements
Minimum supported clientWindows 2000 Professional
Minimum supported serverWindows 2000 Server
HeaderLmDfs.h (include LmDfs.h or Lm.h)
LibraryNetApi32.lib
DLLNetApi32.dll
See Also
Network Management Overview
Network Management Functions
Distributed File System (DFS) Functions
NetDfsEnum
NetDfsRemove
NetDfsAddStdRoot
NetDfsAddFtRoot
Send comments about this topic to Microsoft
Build date: 7/30/2009
==原始网址==http://msdn.microsoft.com/en-us/library/bb524805(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:17:09