Interface IMPR
An interface to methods of mpr.dll used by WindowsNetworkFileShare
public interface IMPR
Methods
AddConnection(NetResource, string, string, int)
Makes a connection to a network resource and can redirect a local device to the network resource.
P/Invoke call to mpr.dll - https://docs.microsoft.com/en-us/windows/desktop/api/winnetwk/nf-winnetwk-wnetaddconnection2aint AddConnection(WindowsNetworkFileShare.NetResource netResource, string password, string username, int flags)
Parameters
netResourceWindowsNetworkFileShare.NetResourceNetwork resource to interact with
passwordstringPassword for making the network connection
usernamestringUsername for making the network connection
flagsintA set of connection options - https://docs.microsoft.com/en-us/windows/desktop/api/winnetwk/nf-winnetwk-wnetaddconnection2a#parameters
Returns
- int
An integer representing the result - https://docs.microsoft.com/en-us/windows/desktop/api/winnetwk/nf-winnetwk-wnetaddconnection2a#return-value
CancelConnection(string, int, bool)
Cancels an existing network connection, removes remembered network connections that are not currently connected.
P/Invoke call to mpr.dll - https://docs.microsoft.com/en-us/windows/desktop/api/winnetwk/nf-winnetwk-wnetcancelconnection2aint CancelConnection(string name, int flags, bool force)
Parameters
namestringPointer to a constant null-terminated string that specifies the name of either the redirected local device or the remote network resource to disconnect from.
If this parameter specifies a redirected local device, the function cancels only the specified device redirection. If the parameter specifies a remote network resource, all connections without devices are canceled.flagsintConnection type - https://docs.microsoft.com/en-us/windows/desktop/api/winnetwk/nf-winnetwk-wnetcancelconnection2a#parameters
forceboolSpecifies whether the disconnection should occur if there are open files or jobs on the connection. If this parameter is FALSE, the function fails if there are open files or jobs.
Returns
- int
An integer representing the result - https://docs.microsoft.com/en-us/windows/desktop/api/winnetwk/nf-winnetwk-wnetcancelconnection2a#return-value
GetLastError(out int, out StringBuilder, int, out StringBuilder, int)
Retrieves the most recent extended error code set by a WNet function
P/Invoke call to mpr.dll - https://docs.microsoft.com/en-us/windows/desktop/api/winnetwk/nf-winnetwk-wnetgetlasterroraint GetLastError(out int error, out StringBuilder errorBuf, int errorBufSize, out StringBuilder nameBuf, int nameBufSize)
Parameters
errorintThe error code reported by the network provider.
errorBufStringBuilderString variable to receive the description of the error
errorBufSizeintSize of error buffer
nameBufStringBuilderString variable to receive the network provider raising the error
nameBufSizeintSize of name buffer
Returns
- int
If the function succeeds, and it obtains the last error that the network provider reported, the return value is NO_ERROR.
If the caller supplies an invalid buffer, the return value is ERROR_INVALID_ADDRESS.
UseConnection(IntPtr, NetResource, string, string, int, string, string, string)
Makes a connection to a network resource. Can redirect a local device to a network resource.
P/Invoke call to mpr.dll - https://docs.microsoft.com/en-us/windows/desktop/api/winnetwk/nf-winnetwk-wnetuseconnectionaint UseConnection(IntPtr hwndOwner, WindowsNetworkFileShare.NetResource netResource, string password, string username, int flags, string lpAccessName, string lpBufferSize, string lpResult)
Parameters
hwndOwnerIntPtrHandle to a window that the provider of network resources can use as an owner window for dialog boxes
netResourceWindowsNetworkFileShare.NetResourceNetwork resource to interact with
passwordstringA null-terminated string that specifies a password to be used in making the network connection
usernamestringA null-terminated string that specifies a user name for making the connection
flagsintSet of bit flags describing the connection
lpAccessNamestringPointer to a buffer that receives system requests on the connection
lpBufferSizestringPointer to a variable that specifies the size of the lpAccessName buffer, in characters.
If the call fails because the buffer is not large enough, the function returns the required buffer size in this locationlpResultstringPointer to a variable that receives additional information about the connection
Returns
- int
An integer representing the result - https://docs.microsoft.com/en-us/windows/desktop/api/winnetwk/nf-winnetwk-wnetuseconnectiona#return-value