Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problems with win32 API conncet to network drive.

Status
Not open for further replies.

Stieberth

IS-IT--Management
Jun 3, 2002
2
0
0
SE
Hi!

I use this API:
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

And i use this in the code:
G1 = WNetAddConnection(share_path1, "", "G:")
K1 = WNetAddConnection(share_path3, "", "K:")

The problem is that if I try to connect i get an error.
If I first manuelly connect to a different drive on the same server and then run my program it works.



help me, please !!
 
I'd check on the 2nd parameter as if I read the documentation correctly, you are neither passing a NULL value nor an empty string. I think you either need to modify your API Declaration to

Code:
Declare Function WNetAddConnection Lib "MPR.DLL" Alias "WNetAddConnectionA" (ByVal lpszNetPath As String, ByVal lpszPassword As [b]Long[/b], ByVal lpszLocalName As String) As Long

an dthe call to
Code:
G1 = WNetAddConnection(share_path1, 0&, "G:")

Likewise what does the value of G1 show after you run rhe code?

Take Care

Matt
If at first you don't succeed, skydiving is not for you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top