Search
Module:
Directory

   Desktop Functions:

   Smart Device Functions:


Show Recent Changes
Subscribe (RSS)
Misc. Pages
Comments
FAQ
Helpful Tools
Playground
Suggested Reading
Website TODO List
Download Visual Studio Add-In

VVNetAddConnection2 (mpr)
 
.
Summary
Summary
TODO - a short description

C# Signature:

    [StructLayout(LayoutKind.Sequential)]
[DllImport("mpr.dll", SetLastError=true)]
static extern TODO VVNetAddConnection2(TODO);

VB Signature:

Declare Function VVNetAddConnection2 Lib "mpr.dll" (TODO) As TODO

User-Defined Types:

None.

    private class NETRESOURCE
    {
        public ResourceScope dwScope = 0;
        public ResourceType dwType = 0;
        public ResourceDisplayType dwDisplayType = 0;
        public ResourceUsage dwUsage = 0;
        [MarshalAs(UnmanagedType.LPStr)] public string lpLocalName = null;
        [MarshalAs(UnmanagedType.LPStr)] public string lpRemoteName = null;
        [MarshalAs(UnmanagedType.LPStr)] public string lpComment = null;
        [MarshalAs(UnmanagedType.LPStr)] public string lpProvider;
    };
    public enum ResourceScope
    {
        RESOURCE_CONNECTED = 1,
        RESOURCE_GLOBALNET,
        RESOURCE_REMEMBERED,
        RESOURCE_RECENT,
        RESOURCE_CONTEXT
    };

Alternative Managed API:

Do you know one? Please contribute it!

    public enum ResourceType
    {
        RESOURCETYPE_ANY,
        RESOURCETYPE_DISK,
        RESOURCETYPE_PRINT,
        RESOURCETYPE_RESERVED
    };

Notes:

None.

    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),
    };

Tips & Tricks:

Please add some!

    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
    };
    public enum ResourceConnection
    {
        CONNECT_UPDATE_PROFILE = 1,
        CONNECT_UPDATE_RECENT = 2,
        CONNECT_TEMPORARY = 4,
        CONNECT_INTERACTIVE = 8,
        CONNECT_PROMPT= 0X10,
        CONNECT_REDIRECT = 0X80,
        CONNECT_CURRENT_MEDIA = 0X200,
        CONNECT_COMMAND_LINE = 0X800,
        CONNECT_CMD_SAVECRED = 0X1000,
        CONNECT_CRED_RESET = 0X2000

    };

[DllImport("mpr.dll", CharSet = System.Runtime.InteropServices.CharSet.Ansi)]

private static extern int WNetAddConnection2( NETRESOURCE lpNetResource,

    [MarshalAs(UnmanagedType.LPStr)]  string lpPassword,
    [MarshalAs(UnmanagedType.LPStr)]  string lpUserName, int dwFlags);

VB Signature:

Declare Function VVNetAddConnection2 Lib "mpr.dll" (TODO) As TODO

User-Defined Types:

None.

Alternative Managed API:

Do you know one? Please contribute it!

Notes:

None.

Tips & Tricks:

Please add some!

Sample Code:

NETRESOURCE nr = new NETRESOURCE();

nr.dwType = ResourceType.RESOURCETYPE_DISK;

nr.dwDisplayType = ResourceDisplayType.RESOURCEDISPLAYTYPE_SHARE;

nr.dwScope = ResourceScope.RESOURCE_GLOBALNET;

nr.dwUsage = ResourceUsage.RESOURCEUSAGE_CONNECTABLE;

nr.lpLocalName = @"U:"; // or null

nr.lpRemoteName = @"\\192.168.1.1\files";

int result = WNetAddConnection2(nr, password, user, (int)ResourceConnection.CONNECT_TEMPORARY);

Please add some!

Documentation

Please edit this page!

Do you have...

  • helpful tips or sample code to share for using this API in managed code?
  • corrections to the existing content?
  • variations of the signature you want to share?
  • additional languages you want to include?

Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).

 
Access PInvoke.net directly from VS:
Terms of Use
Edit This Page
Find References
Show Printable Version
Revisions