ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Addd Net Connect Win98 vs W2K (https://www.excelbanter.com/excel-programming/296466-addd-net-connect-win98-vs-w2k.html)

Tom Rudski[_2_]

Addd Net Connect Win98 vs W2K
 
In Win98 I knew how this code works, now on W2K
Professional I am getting an error.
Code:
Status = WNetAddConnection(SvrName,Password,DriveLetter)

Error:
"The local device name is invalid."

In Win98, I use to use:
SvrName = "\\<Server name\IPC$", also used the IP Addr.
Password as "11111' or "Guest"
Drive <any available drive letter

Is the error from W2K OS?
I tries assigning a drive to my within my own PC and still
get the error.
I think I don't know how to format the NCname param.
I tried attaching to known drive letter server name i.e.
\\law\trudski$\. That produced the same error.
Why can't I even attach to my own internal address?

Any ideas.

TIA


Rob Bovey

Addd Net Connect Win98 vs W2K
 
Hi Tom,

The following works for me. Substitute your own share name and unused
drive letter. Also note that for Windows 2000/XP the password must be the
same password you are logged in with.

Private Declare Function WNetAddConnectionA Lib "mpr.dll" _
(ByVal lpRemoteName As String, _
ByVal lpPassword As String, _
ByVal lpLocalName As String) As Long


Sub TestConnect()

Dim lReturn As Long
Dim szRemoteName As String
Dim szPassword As String
Dim szLocalName As String

szRemoteName = "\\Server\Share"
szPassword = "password"
szLocalName = "Z:"

lReturn = WNetAddConnectionA(szRemoteName, szPassword, szLocalName)

If lReturn < 0 Then MsgBox "Connection failed."

End Sub

--
Rob Bovey, MCSE, MCSD, Excel MVP
Application Professionals
http://www.appspro.com/

* Please post all replies to this newsgroup *
* I delete all unsolicited e-mail responses *


"Tom Rudski" wrote in message
...
In Win98 I knew how this code works, now on W2K
Professional I am getting an error.
Code:
Status = WNetAddConnection(SvrName,Password,DriveLetter)

Error:
"The local device name is invalid."

In Win98, I use to use:
SvrName = "\\<Server name\IPC$", also used the IP Addr.
Password as "11111' or "Guest"
Drive <any available drive letter

Is the error from W2K OS?
I tries assigning a drive to my within my own PC and still
get the error.
I think I don't know how to format the NCname param.
I tried attaching to known drive letter server name i.e.
\\law\trudski$\. That produced the same error.
Why can't I even attach to my own internal address?

Any ideas.

TIA





All times are GMT +1. The time now is 03:59 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com