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

Search Results for "wnet" in [All]

Constants

.

    public static PropertyKey PKEY_WNET_Scope = new PropertyKey(0xdebda43a, 0x37b3, 0x4383, 0x91, 0xE7, 0x44, 0x98, 0xda, 0x29, 0x95, 0xab, 0x00000001); // VT_UINT

.

    public static PropertyKey PKEY_WNET_Type = new PropertyKey(0xdebda43a, 0x37b3, 0x4383, 0x91, 0xE7, 0x44, 0x98, 0xda, 0x29, 0x95, 0xab, 0x00000002); // VT_UINT

.

    public static PropertyKey PKEY_WNET_DisplayType = new PropertyKey(0xdebda43a, 0x37b3, 0x4383, 0x91, 0xE7, 0x44, 0x98, 0xda, 0x29, 0x95, 0xab, 0x00000003); // VT_UINT

.

    public static PropertyKey PKEY_WNET_Usage = new PropertyKey(0xdebda43a, 0x37b3, 0x4383, 0x91, 0xE7, 0x44, 0x98, 0xda, 0x29, 0x95, 0xab, 0x00000004); // VT_UINT

.

    public static PropertyKey PKEY_WNET_LocalName = new PropertyKey(0xdebda43a, 0x37b3, 0x4383, 0x91, 0xE7, 0x44, 0x98, 0xda, 0x29, 0x95, 0xab, 0x00000005); // VT_LPWSTR

.

    public static PropertyKey PKEY_WNET_RemoteName = new PropertyKey(0xdebda43a, 0x37b3, 0x4383, 0x91, 0xE7, 0x44, 0x98, 0xda, 0x29, 0x95, 0xab, 0x00000006); // VT_LPWSTR

.

    public static PropertyKey PKEY_WNET_Comment = new PropertyKey(0xdebda43a, 0x37b3, 0x4383, 0x91, 0xE7, 0x44, 0x98, 0xda, 0x29, 0x95, 0xab, 0x00000007); // VT_LPWSTR

.

    public static PropertyKey PKEY_WNET_Provider = new PropertyKey(0xdebda43a, 0x37b3, 0x4383, 0x91, 0xE7, 0x44, 0x98, 0xda, 0x29, 0x95, 0xab, 0x00000008); // VT_LPWSTR

comdlg32

.

    Private m_bShowNetwork As Boolean = False

.

    Private m_bShowNetwork As Boolean = False

rasapi32

.

          public int       dwNetworkOutageTime;

Structures

.

Without the Structlayout the WNetAddConnection2 does not work !!!

advapi32

.
Summary
The WNetGetUniversalName function takes a drive-based path for a network resource and returns an information structure that contains a more universal form of the name. What this means is that you can take a file name from a network drive can be converted to a UNC version that may be used from other computers on the network that do not have the same drive mappings.
.

static extern int WNetGetUniversalName(

.

Private Shared Function WNetGetUniversalName(lpLocalPath As String, <MarshalAs(UnmanagedType.U4)> dwInfoLevel As Integer, lpBuffer As IntPtr, <MarshalAs(UnmanagedType.U4)> ByRef lpBufferSize As Integer) As <MarshalAs(UnmanagedType.U4)> Integer

.

        // First, call WNetGetUniversalName to get the size.

.

        int apiRetVal = WNetGetUniversalName(localPath, UNIVERSAL_NAME_INFO_LEVEL, (IntPtr) IntPtr.Size, ref size);

.

        apiRetVal = WNetGetUniversalName(localPath, UNIVERSAL_NAME_INFO_LEVEL, buffer, ref size);

.

public class WNet

.

    private static extern int WNetGetUniversalNameW(

.

            // First, call WNetGetUniversalName to get the size.

.

            int apiRetVal = WNetGetUniversalNameW(localPath, REMOTE_NAME_INFO_LEVEL, (IntPtr)IntPtr.Size, ref size);

.

            apiRetVal = WNetGetUniversalNameW(localPath, REMOTE_NAME_INFO_LEVEL, buffer, ref size);

.
Summary
This utilizes the WNetGetUniversalName method in MPR.dll. Once implemented, all you have to do is create an instance of the MPR_DotNET_Version class and use the GetUniversalName method. You can also add on to this class for other functionality if you choose. Hope this helps.
.

    <DllImport("mpr.dll", Entrypoint:="WNetGetUniversalName", CharSet:=CharSet.Auto, SetLastError:=False)> _

.

             _error = WNetGetUniversalName(_origpath, REMOTE_NAME_INFO_LEVEL, CType(IntPtr.Size, IntPtr), size)

.

                If _error.Assign(WNetGetUniversalName(_origpath, REMOTE_NAME_INFO_LEVEL, lpBuffer, size)) = NO_ERROR Then

.

       ''' DLL Header for the WNetGetUniversalName

.

       <DllImport("mpr.dll", Entrypoint:="WNetGetUniversalName", CharSet:=CharSet.Unicode, SetLastError:=False)> _

.

       Private Shared Function WNetGetUniversalName(ByVal lpLocalPath As String, _

.

       ''' Remote Name Info Structure for use with the WNetGetUniveralName API Call

.
Documentation
[WNetGetUniversalName] on MSDN

mpr

.
Summary
.

private static extern int WNetAddConnection2( NETRESOURCE lpNetResource,

.

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

.

private static extern int WNetAddConnection3(IntPtr hWndOwner,

.

    Private Shared Function WNetAddConnection3(ByVal hWndOwner As IntPtr, _

.

WNetAddConnection3(hWnd, ref ConnInf, null, null,

.
Documentation
[WNetAddConnection3] on MSDN
.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wnet/wnet/wnetaddconnection2.asp

.
Summary
The WNetAddConnection2 function makes a connection to a network resource. The function can redirect a local device to the network resource.
.

The WNetAddConnection2 function supersedes the WNetAddConnection function. If you can pass a handle to a window that the provider of network resources can use as an owner window for dialog boxes, call the WNetAddConnection3 function instead.

.

public static extern int WNetAddConnection2(ref NETRESOURCE netResource,

.

public static extern int WNetAddConnection2(NETRESOURCE netResource,

.

  //    [DllImport("Mpr.dll", EntryPoint="WNetAddConnection2", CallingConvention=CallingConvention.Winapi)]

.

  //      private static extern ErrorCodes WNetAddConnection2(NETRESOURCE lpNetResource,ref string lpPassword,ref

.

public static extern int WNetAddConnection2( [In] NETRESOURCE netResource,

.

Declare Function WNetAddConnection2 Lib "mpr.dll" (ByRef netResource As _

.

Declare Function WNetAddConnection2 Lib "mpr.dll" (netResource As _

.

// int ret = WNetAddConnection2( myNetResource, "username", "password", 0);

.

int ret = WNetAddConnection2( myNetResource, "password", "username", 0); //by honglinlee

.

    var result = WNetAddConnection2(

.

    WNetCancelConnection2(_networkName, 0, true);

.

    private static extern int WNetAddConnection2(NetResource netResource,

.

    private static extern int WNetCancelConnection2(string name, int flags,

.

    private static extern int WNetAddConnection2(NETRESOURCE lpNetResource, string lpPassword, string lpUsername, int dwFlags);

.

        int result = WNetAddConnection2(myNetResource, password, user, 0);

.

    returnValue = WNetAddConnection2(myResource, password, username, 0)

.
Documentation
[WNetAddConnection2] on MSDN
.

private static extern int WNetAddConnection3(IntPtr hWndOwner,

.

    Private Shared Function WNetAddConnection3(ByVal hWndOwner As IntPtr, _

.

WNetAddConnection3(hWnd, ref ConnInf, null, null,

.
Documentation
[WNetAddConnection3] on MSDN
.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wnet/wnet/wnetaddconnection2.asp

.
Summary
The WNetCancelConnection2 function cancels an existing network connection. You can also call the function to remove remembered network connections that are not currently connected.
.

static extern int WNetCancelConnection2(string lpName, Int32 dwFlags, bool bForce);

.

Declare Function WNetCancelConnection2 Lib "mpr.dll" Alias "WNetCancelConnection2A" (ByVal lpName As String, ByVal dwFlags As Integer, ByVal fForce As Integer) As Integer

.

    ''' The WNetCancelConnection2 function cancels an existing network connection.

.

    Private Shared Function WNetCancelConnection2(ByVal lpName As String, _

.

public static extern int WNetCancelConnection2(string lpName, Int32 dwFlags, bool fForce);

.

int result=WNetCancelConnection2("Y:", CONNECT_UPDATE_PROFILE, true);

.
Documentation
[WNetCancelConnection2] on MSDN
.
Summary
The WNetCancelConnection2 function cancels an existing network connection. You can also call the function to remove remembered network connections that are not currently connected.
.

static extern int WNetCancelConnection2(string lpName, Int32 dwFlags, bool bForce);

.

Declare Function WNetCancelConnection2 Lib "mpr.dll" Alias "WNetCancelConnection2A" (ByVal lpName As String, ByVal dwFlags As Long, ByVal fForce As Long) As Long

.

    ''' The WNetCancelConnection2 function cancels an existing network connection.

.

    Private Shared Function WNetCancelConnection2(ByVal lpName As String, _

.

public static extern int WNetCancelConnection2(string lpName, Int32 dwFlags, bool fForce);

.

int result=WNetCancelConnection2("Y:", CONNECT_UPDATE_PROFILE, true);

.
Documentation
[WNetCancelConnection2] on MSDN
.

WNetCloseEnum

.

public static extern uint WNetCloseEnum(IntPtr hEnum);

.

Private Shared Function WNetCloseEnum(hEnum As IntPtr) As UInteger

.
Documentation
[WNetCloseEnum] on MSDN
.

WNetEnumResource

.

public static extern uint WNetEnumResource(IntPtr hEnum, ref int lpcCount, IntPtr lpBuffer, ref uint lpBufferSize);

.

Public Shared Function WNetEnumResource(hEnum As IntPtr, ByRef lpcCount As Integer, lpBuffer As IntPtr, ByRef lpBufferSize As UInteger) As UInteger

.

  public static extern int WNetEnumResource(

.

  public static extern int WNetOpenEnum(

.

  public static extern int WNetCloseEnum( IntPtr hEnum );

.

public static void WNETOE(Object o)

.

       iRet =WNetOpenEnum(

.

     iRet =WNetEnumResource( ptrHandle, ref entries, ptrBuffer, ref buffer );

.

         WNETOE(nr);

.

       iRet =WNetCloseEnum( ptrHandle );

.

WNETOE(null);

.

    Public Function WNetEnumResource(ByVal hEnum As IntPtr, ByRef lpcCount As Integer, ByVal lpBuffer As IntPtr, ByRef lpBufferSize As Integer) As Integer

.

    Public Function WNetOpenEnum(ByVal dwScope As RESOURCE_SCOPE, ByVal dwType As RESOURCE_TYPE, ByVal dwUsage As RESOURCE_USAGE, ByRef lpNetResource As NETRESOURCE, ByRef lphEnum As IntPtr) As Integer

.

    Public Function WNetCloseEnum(ByVal hEnum As IntPtr) As Integer

.

        iRet = WNetOpenEnum(RESOURCE_SCOPE.RESOURCE_REMEMBERED, RESOURCE_TYPE.RESOURCETYPE_ANY, RESOURCE_USAGE.RESOURCEUSAGE_ATTACHED, o, ptrHandle)

.

        iRet = WNetEnumResource(ptrHandle, entries, ptrBuffer, buffer)

.

        iRet = WNetCloseEnum(ptrHandle)

.

        iRet = WNetOpenEnum(RESOURCE_SCOPE.RESOURCE_GLOBALNET, RESOURCE_TYPE.RESOURCETYPE_ANY, RESOURCE_USAGE.RESOURCEUSAGE_CONTAINER, o, ptrHandle)

.

        iRet = WNetEnumResource(ptrHandle, entries, ptrBuffer, buffer)

.

        iRet = WNetCloseEnum(ptrHandle)

.

    Public Function WNETOE(ByRef o As NETRESOURCE, ByRef resourceCollection As List(Of String)) As Boolean

.

        iRet = WNetOpenEnum(RESOURCE_SCOPE.RESOURCE_GLOBALNET, RESOURCE_TYPE.RESOURCETYPE_ANY, RESOURCE_USAGE.RESOURCEUSAGE_CONTAINER, o, ptrHandle)

.

        iRet = WNetEnumResource(ptrHandle, entries, ptrBuffer, buffer)

.

            If Not WNETOE(nr, resourceCollection) Then

.

        iRet = WNetCloseEnum(ptrHandle)

.
Documentation
[WNetEnumResource] on MSDN
.

    public static extern int WNetGetConnection([MarshalAs(UnmanagedType.LPTStr)] string localName, [MarshalAs(UnmanagedType.LPTStr)] StringBuilder remoteName, ref int length);

.

    Shared Function WNetGetConnection(<MarshalAs(UnmanagedType.LPTStr)> _

.

    Declare Function WNetGetConnection Lib "mpr.dll" Alias "WNetGetConnectionA" (ByVal localName As String, ByVal remoteName As System.Text.StringBuilder, ByRef length As Integer) As Integer

.

rc = WNetGetConnection("p:", rname, ref bsize);

.

    Declare Function WNetGetConnection Lib "mpr.dll" Alias "WNetGetConnectionA" (ByVal localName As String, _

.

        WNetGetConnection(Microsoft.VisualBasic.Left(path, 2), UNC, length)

.

Declare Function WNetGetConnection Lib "mpr.dll" Alias "WNetGetConnectionA" _

.

        Dim err As Integer = WNetGetConnection(theDriveName, uncPathBuf, uncPathBuf.Capacity)

.

static extern TODO WNetGetLastErrorA(ref int lpError,ref string lpErrorBuf,int nErrorBufSize,string lpNameBuf,int nNameBufSize);

.

public static extern uint WNetGetLastError(ref int lpError,StringBuilder lpErrorBuf,int nErrorBufSize,StringBuilder lpNameBuf,int nNameBufSize);

.

Declare Function WNetGetLastError Lib "mpr.dll" Alias "WNetGetLastErrorA" (ByRef lpError As Integer, ByVal lpErrorBuf As String, ByVal nErrorBufSize As Integer, ByVal lpNameBuf As String, ByVal nNameBufSize As Integer) As Integer

.
Documentation
[WNetGetLastError] on MSDN
.

WNetOpenEnum

.

public static extern UInt32 WNetOpenEnum(ResourceScope dwScope, ResourceType dwType, ResourceUsage dwUsage, NetResource lpNetResource, ref IntPtr lphEnum);

.

Public Shared Function WNetOpenEnum(dwScope As ResourceScope, dwType As ResourceType, dwUsage As ResourceUsage, lpNetResource As NetResource, ByRef lphEnum As IntPtr) As UInteger

.
Documentation
[WNetOpenEnum] on MSDN
.

private static extern int WNetUseConnection

.

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

.

    ThrowIfError(WNetUseConnection(IntPtr.Zero, nr, password, username, 0, null, null, null));

.

    ThrowIfError(WNetUseConnection(IntPtr.Zero, nr, null, null, promptUser ? Connect.INTERACTIVE | Connect.PROMPT : 0, null, null, null));

.
Documentation
[WNetUseConnection] on MSDN

netapi32

.

You can also use the WNetAddConnection2 and WNetAddConnection3 functions to redirect a local device to a network resource. Connections added by NetUseAdd are not shown in the Explorer. You should use one of the WNetAddConnection methods to make the networkdrive visible in the explorer.

.

You can also use the WNetCancelConnection2 function to terminate a network connection.


 
Access PInvoke.net directly from VS: