Maping Shared default folders/drives...
The Problem here is that i just can map a Shared folder like
\\192.168.0.1\MyFiles
But it does not work for \\192.168.0.1\C$ or any default shared folders/drives.
Is there any solution for this?
Thanks for your time.
VB Code:
Option Explicit
Private Declare Function WNetGetConnection Lib "mpr.dll" Alias "WNetGetConnectionA" (ByVal lpszLocalName As String, ByVal lpszRemoteName As String, cbRemoteName As Long) As Long
Private Declare Function WNetAddConnection2 Lib "mpr.dll" Alias "WNetAddConnection2A" (lpNetResource As NETRESOURCE, ByVal lpPassword As String, ByVal lpUserName As String, ByVal dwFlags As Long) As Long
Private Type NETRESOURCE
dwScope As Long
dwType As Long
dwDisplayType As Long
dwUsage As Long
lpLocalName As String
lpRemoteName As String
lpComment As String
lpProvider As String
End Type
Const RESOURCE_CONNECTED = &H1
Const RESOURCE_PUBLICNET = &H2
Const RESOURCE_REMEMBERED = &H3
Const RESOURCETYPE_ANY = &H0
Const RESOURCETYPE_DISK = &H1
Const RESOURCETYPE_PRINT = &H2
Const RESOURCETYPE_UNKNOWN = &HFFFF
Const RESOURCEUSAGE_CONNECTABLE = &H1
Const RESOURCEUSAGE_CONTAINER = &H2
Const RESOURCEUSAGE_RESERVED = &H80000000
Const RESOURCEDISPLAYTYPE_GENERIC = &H0
Const RESOURCEDISPLAYTYPE_DOMAIN = &H1
Const RESOURCEDISPLAYTYPE_SERVER = &H2
Const RESOURCEDISPLAYTYPE_SHARE = &H3
Const RESOURCEDISPLAYTYPE_FILE = &H4
Const RESOURCEDISPLAYTYPE_GROUP = &H5
Private Sub Form_Load()
Show
Dim N As NETRESOURCE
N.dwScope = RESOURCE_PUBLICNET
N.dwType = RESOURCETYPE_ANY
N.dwDisplayType = RESOURCEDISPLAYTYPE_GENERIC
N.dwUsage = RESOURCEUSAGE_CONNECTABLE
N.lpLocalName = "X:"
N.lpRemoteName = "\\192.168.0.1\C$" + Chr$(0)
N.lpComment = Chr$(0)
N.lpProvider = Chr$(0)
Dim l As Long
l = WNetAddConnection2(N, "123456", "User001", 0)
Print l
Dim RN$
RN$ = Space$(50)
l = WNetGetConnection("X:", RN$, 50)
Print l, RN$
End Sub