WNetAddConnection2
C# Signatures:
// This must be used if NETRESOURCE is defined as a struct
[DllImport("mpr.dll")]
public static extern int WNetAddConnection2(ref NETRESOURCE netResource,
string password, string username, uint flags);
// This must be used if NETRESOURCE is defined as a class
[DllImport("mpr.dll")]
public static extern int WNetAddConnection2(NETRESOURCE netResource,
string password, string username, uint flags);
// by cozmo, it only worked for me this way; .NET 1.1, 11.01.2006
// dont know, what [In] means (some CAST ?), found it in microsoft.public.de.german.entwickler.dotnet.csharp
// my NETRESOURCE is defined as:
// [StructLayout(LayoutKind.Sequential)]
// class NETRESOURCE
// {
// public int dwScope;
// etc...
// }
//by DaManu
//
// public enum ResourceScope
// {
// RESOURCE_CONNECTED = 1,
// RESOURCE_GLOBALNET,
// RESOURCE_REMEMBERED,
// RESOURCE_RECENT,
// RESOURCE_CONTEXT
// };
// public enum ResourceType
// {
// RESOURCETYPE_ANY = 0,
// RESOURCETYPE_DISK = 1,
// RESOURCETYPE_PRINT = 2,
// RESOURCETYPE_RESERVED = 8,
// RESOURCETYPE_UNKNOWN = -1,
// };
// public enum ResourceUsage
// {
// RESOURCEUSAGE_CONNECTABLE = 0x00000001,
// RESOURCEUSAGE_CONTAINER = 0x00000002,
// RESOURCEUSAGE_NOLOCALDEVICE = 0x00000004,
// RESOURCEUSAGE_SIBLING = 0x00000008,
// RESOURCEUSAGE_ATTACHED = 0x00000010,
// RESOURCEUSAGE_ALL = (RESOURCEUSAGE_CONNECTABLE | RESOURCEUSAGE_CONTAINER | RESOURCEUSAGE_ATTACHED),
// };
// public enum ResourceDisplayType
// {
// RESOURCEDISPLAYTYPE_GENERIC,
// RESOURCEDISPLAYTYPE_DOMAIN,
// RESOURCEDISPLAYTYPE_SERVER,
// RESOURCEDISPLAYTYPE_SHARE,
// RESOURCEDISPLAYTYPE_FILE,
// RESOURCEDISPLAYTYPE_GROUP,
// RESOURCEDISPLAYTYPE_NETWORK,
// RESOURCEDISPLAYTYPE_ROOT,
// RESOURCEDISPLAYTYPE_SHAREADMIN,
// RESOURCEDISPLAYTYPE_DIRECTORY,
// RESOURCEDISPLAYTYPE_TREE,
// RESOURCEDISPLAYTYPE_NDSCONTAINER
// };
// [StructLayout(LayoutKind.Sequential)]
// private class NETRESOURCE
// {
// public ResourceScope dwScope = 0;
// public ResourceType dwType = 0;
// public ResourceDisplayType dwDisplayType = 0;
// public ResourceUsage dwUsage = 0;
// public string lpLocalName = null;
// public string lpRemoteName = null;
// public string lpComment = null;
// public string lpProvider = null;
// };
//
// [DllImport("Mpr.dll", EntryPoint="WNetAddConnection2", CallingConvention=CallingConvention.Winapi)]
// private static extern ErrorCodes WNetAddConnection2(NETRESOURCE lpNetResource,ref string lpPassword,ref
// string lpUsername, System.UInt32 dwFlags );C# Signatures:
VB Signatures:
Tips & Tricks:
Sample Code:
Sample Code:
Sample Code:
Sample Code:
Sample Code:
Sample Code:
Sample Code:
Sample Code:
Implimentation of C# Sample 3
Implimentation of C# Sample 3
Última actualización