It may be because no-one has an answer. Here is a snippet of an article I
found that should setup a mapped connection using VB. I haven't tried it but
I hope it may help.
[Article]
This can be easily done by using map network drive in Network Neighbourhood
or My Computer but it can be useful to be able to do this in Visual Basic. I
had a letter asking whether this was possible doing Send Keys (A beginners
response), but I will now show you how to do this using Windows API
Here is the example: Also includes how to delete a connection
1. Start a new Standard-EXE project, form1 is created by default
2. Add a standard module and add a command button to form1
3. Type the following in the standard module. NB.
Option Explicit
Declare Function WNetAddConnection Lib "mpr.dll" Alias "WNetAddConnectionA"
(ByVal lpszNetPath As String, ByVal lpszPassword As String, ByVal
lpszLocalName As String) As Long
Declare Function WNetCancelConnection Lib "mpr.dll" Alias
"WNetCancelConnectionA" (ByVal lpszName As String, ByVal bForce As Long) As
Long
Const WN_SUCCESS = 0 ' The function was successful.
Const WN_NET_ERROR = 2 ' An error occurred on the network.
Const WN_BAD_PASSWORD = 6 ' The password was invalid.
Function AddConnection(MyShareName As String, MyPWD As String, UseLetter As
String) As Integer
On Local Error GoTo AddConnection1_Err
AddConnection = WNetAddConnection(MyShareName, MyPWD, UseLetter)
AddConnection_End:
Exit Function
AddConnection_Err:
AddConnection = Err
MsgBox Error$
Resume AddConnection_End
End Function
Function CancelConnection(DriveLetter As String, Force As Integer) As
Integer
On Local Error GoTo CancelConnection_Err
CancelConnection = WNetCancelConnection(DriveLetter, Force)
CancelConnection_End:
Exit Function
CancelConnection_Err:
CancelConnection = Err
MsgBox Error$
Resume CancelConnection_End
End Function
4. to add a connection call by:
variable = AddConnection(<SharePath>, <Password>, <DriveLetter>)
To cancel a connection type
variable = CancelConnection(<SharePath, <Force>)
5. Run the project.
"Bryan" <ke****@ieee.spamnot.org> wrote in message
news:pK*********************@twister.tampabay.rr.c om...
Can anyone give me a code fragment in visual basic that will read from a
device on my LAN?
I looked in several books at B&N and found nothing.
I posted this question two days ago and received absolutely no response.
This is a visual basic forum and my question is visual basic. Is there
maybe something else wrong with my post?
Thanks for your time,
Bryan