[
private static extern ErrorCodes WNetAddConnection3(IntPtr hWndOwner, NETRESOURCE lpNetResource, string lpPassword, string lpUserName, int dwFlags);
{
RESOURCE_CONNECTED = 1,RESOURCE_GLOBALNET,RESOURCE_REMEMBERED,RESOURCE_RECENT,RESOURCE_CONTEXT};
{RESOURCETYPE_ANY,RESOURCETYPE_DISK,RESOURCETYPE_PRINT,RESOURCETYPE_RESERVED};
RESOURCEUSAGE_CONNECTABLE = 0x00000001,RESOURCEUSAGE_CONTAINER = 0x00000002,RESOURCEUSAGE_NOLOCALDEVICE = 0x00000004,RESOURCEUSAGE_SIBLING = 0x00000008,
RESOURCEUSAGE_ATTACHED = 0x00000010,RESOURCEUSAGE_ALL = (RESOURCEUSAGE_CONNECTABLE | RESOURCEUSAGE_CONTAINER | RESOURCEUSAGE_ATTACHED),
};
RESOURCEDISPLAYTYPE_GENERIC,RESOURCEDISPLAYTYPE_DOMAIN,RESOURCEDISPLAYTYPE_SERVER,RESOURCEDISPLAYTYPE_SHARE,RESOURCEDISPLAYTYPE_FILE,
RESOURCEDISPLAYTYPE_GROUP,RESOURCEDISPLAYTYPE_NETWORK,RESOURCEDISPLAYTYPE_ROOT,RESOURCEDISPLAYTYPE_SHAREADMIN,RESOURCEDISPLAYTYPE_DIRECTORY,
RESOURCEDISPLAYTYPE_TREE,RESOURCEDISPLAYTYPE_NDSCONTAINER
NO_ERROR = 0,
ERROR_NO_MORE_ITEMS = 259,
ERROR_BAD_NETPATH = 53,
ERROR_SESSION_CREDENTIAL_CONFLICT = 1219,
ret =
nr.lpRemoteName = @\\myServer_Name ;
nr.dwScope = ResourceScope.RESOURCE_GLOBALNET;
nr.dwType = ResourceType.RESOURCETYPE_ANY;
nr.dwDisplayType = ResourceDisplayType.RESOURCEDISPLAYTYPE_SHARE;
nr.dwUsage = ResourceUsage.RESOURCEUSAGE_CONNECTABLE;result = WNetAddConnection3(handle, nr, my_password, my_userID, 1);