@msdn=http://search.microsoft.com/search/results.aspx?qu=$$$ @pinvoke=http://pinvoke.net/$$$.htm Summary: The NetDfsAdd function creates a new Distributed File System (Dfs) link or adds targets to an existing link in a Dfs root. !!!!C# Signature: [DllImport("Netapi32.dll", CharSet=CharSet.Auto, SetLastError=true)] static extern int NetDfsAdd( [MarshalAs(UnmanagedType.LPWStr)] string DfsEntryPath, [MarshalAs(UnmanagedType.LPWStr)] string ServerName, [MarshalAs(UnmanagedType.LPWStr)] string PathName, [MarshalAs(UnmanagedType.LPWStr)] string Comment, int Flags); !!!!VB6 Signature: Declare Function NetDfsAdd Lib "NETAPI32.DLL" (ByVal DfsEntryPath As String, ByVal ServerName As String, ByVal ShareName As String, ByVal Comment As String, ByVal Flags As Long) As Long Go here for example code for VB6: http://gethelp.devx.com/techtips/nt_pro/10_minute_solutions/10minNT0501-3.asp !!!!VB.NET Signature: Declare Function NetDfsAdd Lib "NETAPI32.DLL" (<Runtime.InteropServices.MarshalAs(Runtime.InteropServices.UnmanagedType.LPWStr)> ByVal DfsEntryPath As String, <Runtime.InteropServices.MarshalAs(Runtime.InteropServices.UnmanagedType.LPWStr)> ByVal ServerName As String, <Runtime.InteropServices.MarshalAs(Runtime.InteropServices.UnmanagedType.LPWStr)> ByVal ShareName As String, <Runtime.InteropServices.MarshalAs(Runtime.InteropServices.UnmanagedType.LPWStr)> ByVal Comment As String, ByVal Flags As Uint32) As Long !!!!User-Defined Types: None. !!!!Notes: I had a mapping error using the flag as a long. A DWORD is a unsigned 32 bit int. I modified this to match. The DFSEntryPath MUST have "\\" at the beginning. The ServerName conversely must NOT have "\\" at the beginning. !!!!Tips & Tricks: With a Flags value of 1 (DFS_ADD_VOLUME), the call to NetDfsAdd will fail if the link (DFSEntryPath) already exists, even if the target (ServerName, PathName) is new. Use a Flags value of 0 to add multiple targets to the same DFS link. Please add some! !!!!Sample Code: // DFS_ADD_VOLUME has a value of 1 - see MSDN docs NetDfsAdd("\\DfsRoot\Path\Dir", "FileServer", "Share", "Comment", 1); !!!!Alternative Managed API: Do you know one? Please contribute it! Documentation: NetDfsAdd@msdn on MSDN Also on MSDN, there is a more detailed example of using this API: http://msdn2.microsoft.com/en-us/library/aa380434.aspx http://msdn.microsoft.com/en-us/library/bb524805(v=VS.85).aspx
Edit netapi32.NetDfsAdd
You do not have permission to change this page. If you feel this is in error, please send feedback with the contact link on the main page.