WNetAddConnection3 (mpr)
Last changed: 220.10.204.141

.

Check out the formatting tips on the right for help formatting and making links.

Use the template below then delete this header:

Summary
TODO - a short description

C# Signature:

// This must be used if NETRESOURCE is defined as a struct
[DllImport("mpr.dll")]    
public static extern int WNetAddConnection3(int hwnd,
   ref NETRESOURCE netResource, string password, string username, int flags);

// This must be used if NETRESOURCE is defined as a class
[DllImport("mpr.dll")]    
public static extern int WNetAddConnection3(int hwnd,
   NETRESOURCE netResource, string password, string username, int flags);

VB .NET Signature:

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

User-Defined Types:

NETRESOURCE

Notes:

C# Import by Roli.

C# Sample by Roli

Tips & Tricks:

Please add some!

Sample Code:

C# Sample

NETRESOURCE myNetResource = new NETRESOURCE();        
myNetResource.dwScope = 2;                    
myNetResource.dwType = 1 ;                    
myNetResource.dwDisplayType = 3;            
myNetResource.dwUsage = 1;            
myNetResource.lpLocalName = "z:";        
myNetResource.lpRemoteName = @"\\servername\sharename";        
myNetResource.lpProvider = null;    
int ret = WNetAddConnection3(null, myNetResource, "password", "username", 0);

/*
  * if username = null the function uses the default user name
  *    (The user context for the process provides the default user name)
  * if password = null the function uses the current default password
  *    associated with the user specified by the username parameter
  * if password = "" the function does not use a password
  */

Alternative Managed API:

TODO

Documentation