Members

Technology Zones

IBM Learning Center

Articles

Hosted By

MaximumASP

Info

This resource has not currently been approved, and is not currently linked to from our directory of resources. It is being displayed here for preview by the author and moderators only.
Rated
Read 6,129 times

    Access and Close Network Share Folders - Access and Close Network Share Folder

    khari6579

    Access and Close Network Share Folder

    Option

    Explicit On

    Imports

    System.Runtime.InteropServices

    Module

    modGetServerPathAccess

    Public _DATABASE As String

    Public _INSTANCE As String

    Public _USER As String

    Public _PWD As String

    Public _BACKUPFILE As String

    Const RESOURCETYPE_DISK = &H1

    Public Function MapDrive( ByVal DriveLetter As String , ByVal UNCPath As String , ByVal strUsername As String , ByVal strPassword As String ) As Boolean

    Dim theNetResource As WNet.NETRESOURCE

    Dim result As Integer

    theNetResource =

    New WNet.NETRESOURCE

    theNetResource.lpRemoteName = UNCPath

    theNetResource.lpLocalName = DriveLetter & ":"

    theNetResource.dwType = RESOURCETYPE_DISK

    result = WNet.WNetAddConnection2(theNetResource, strPassword, strUsername, 0)

    If result = 0 Then

    Return True

    Else

    Return False

    End If

    End Function

    Public Sub UnMapDrive( ByVal DriveLetter As String )

    Dim rc As Integer

    Dim theNetResource As WNet.NETRESOURCE

    Dim result As Integer

    theNetResource =

    New WNet.NETRESOURCE

    rc = WNet.WNetCancelConnection2(DriveLetter & ":", 0, 0)

    End Sub

    End

    Module

    ' Class File

    Imports

    System.Runtime.InteropServices

    Class

    WNet

    <StructLayout(LayoutKind.Sequential)> _

    Public Class NETRESOURCE

    Public dwScope As Integer

    Public dwType As Integer

    Public dwDisplayType As Integer

    Public dwUsage As Integer

    Public lpLocalName As String

    Public lpRemoteName As String

    Public lpComment As String

    Public lpProvider As String

    End Class

    Public Declare Ansi Function WNetAddConnection2 Lib "mpr.dll" Alias _

    "WNetAddConnection2A" (

    ByVal lpNetResource As NETRESOURCE, ByVal lpPassword _

    As String , ByVal lpUserName As String , ByVal dwFlags As Integer ) As Integer

    Public Declare Function WNetCancelConnection2 Lib "mpr.dll" Alias _

    "WNetCancelConnection2A" (

    ByVal lpName As String , ByVal dwFlags As Long , _

    ByVal fForce As Long ) As Integer

    End

    Class

     

    I am Hari, SSE in a Pvt Firm. I have knowledge in Dot Net, VB6, Visual Foxpro, Foxpro, SQL Server, Oracle, Access, DBase and Crystal Report.

    Comments