Hi Carlos,
First of all, I would like to confirm my understanding of your issue.
From your description, I understand that you wants to add a map network in
VB.NET.
Have I fully understood you? If there is anything I misunderstood, please
feel free to let me know.
We can use the WNetAddConnection2 API, here goes the code snippet.
<StructLayout(LayoutKind.Sequential)> _
Class NETRESOURCE
Public dwScope As Integer
Public dwType As Integer
Public dwDisplayType As Integer
Public dwUsage As Integer
Public LocalName As String
Public RemoteName As String
Public Comment As String
Public Provider As String
End Class 'NETRESOURCE
Public Declare Function WNetAddConnection2 Lib "mpr.dll" Alias
"WNetAddConnection2A" (ByVal netResource As NETRESOURCE, ByVal password As
[String], ByVal Username As [String], ByVal Flag As Integer) As Integer
Sub Main()
Dim myNetResource As New NETRESOURCE
myNetResource.dwScope = 2 'RESOURCE_GLOBALNET
myNetResource.dwType = 1 'RESOURCETYPE_DISK
myNetResource.dwDisplayType = 3 'RESOURCEDISPLAYTYPE_SHARE
myNetResource.dwUsage = 1 'RESOURCEUSAGE_CONNECTABLE
myNetResource.LocalName = "P:"
myNetResource.RemoteName = "\\sha-dds-01\Products"
myNetResource.Provider = Nothing
Dim ret As Integer = WNetAddConnection2(myNetResource, Nothing,
Nothing, 0)
End Sub
For detailed information about WNetAddConnection2 please refer to the link
below.
WNetAddConnection2
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wnet/wnet/w
netaddconnection2.asp
Best regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! -
www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.