Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Mapping to network drive using .BAT file
Message
From
24/03/2004 04:46:58
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
23/03/2004 13:52:49
General information
Forum:
Visual FoxPro
Category:
Troubleshooting
Miscellaneous
Thread ID:
00888895
Message ID:
00889148
Views:
18
>Cetin--
>
>>Declare integer WNetCancelConnection in WIN32API String lpName,short lForce
>>Declare integer WNetAddConnection in WIN32API ;
>> string lpRemoteName, ;
>> string lpPassword, ;
>> string lpLocalName
>>
>>*Add connection
>>WNetAddConnection("\\W0028109792\DATAWARE", "", "R:")
>>
>>*Remove connection
>>*WNetCancelConnection("R:",0)
>>
>>PS: WNetAddConnection2 and WNetCancelConnection2 supersedes and have more options for connections like dipslaying a prompt for username and pw for user to connect.
>
>
>I did the old cut and paste and my R drive does not appear. I moved the WnetCancelConnection in front of the WNetAddConnection.
>
>Any thoughts on what the problem might be? How do I get the errors from these guys?
>
>Tim

Tim,
It was my fault specifying the 2nd parameter as an empty string rather than null. I can't list all the possible errors but common ones should help :
**-- Set up API calls
Declare Integer WNetCancelConnection In WIN32API String lpName,short lForce
Declare Integer WNetAddConnection In WIN32API ;
  string lpRemoteName,  ;
  string lpPassword,  ;
  string lpLocalName

Local lcRemotePath, lcLocalPath, lnResult
lcRemotePath = "\\W0028109792\DATAWARE"
lcLocalPath  = "R:"

*Add connection
lnResult = WNetAddConnection(m.lcRemotePath, 0, m.lcLocalPath)
Do Case
  Case lnResult = 0 && OK
    Wait Window timeout 3 'Connected '
  Case lnResult = 85 && Already assigned
    Wait Window timeout 3 'Already assigned'
  Case lnResult = 1202 && Already assigned to other path
    Wait Window timeout 3 'Assigned to other path'
    *Remove connection
    Wait Window timeout 3 'Disconnecting...'
    WNetCancelConnection(m.lcLocalPath,0)
    *Reassign
    lnResult = WNetAddConnection(m.lcRemotePath, 0, m.lcLocalPath)
    If lnResult = 0 && OK
      Wait Window timeout 3 'Connected'
    else
      Wait window 'Error #'+ltrim(str(m.lnResult))
    Endif
Endcase
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Reply
Map
View

Click here to load this message in the networking platform