Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Net Use to map a drive?
Message
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Miscellaneous
Thread ID:
00146250
Message ID:
00146979
Views:
27
>Is there an API to map a Windows NT network drive letter? Similar to the NET USE dos prompt command.
>
>-Tim


Tim,

I was using the NET USE command to map to some network drives until I got the following information (from a very knowledgeable George Tasker!)...


DECLARE Integer WNetAddConnection IN WIN32API STRING @, STRING @
DECLARE Integer WNetCancelConnection in WIN32API STRING @, INTEGER

lcRemoteName = "\\Computer\Resource"
lcPassWord = "" && Connect Using No Password
lcLocalName = "T:"

? WNetAddConnection(@lcRemoteName,@lcPassWord,@lcLocalName)
*-- Returns 0 if Ok

*-- Disconnect this way, again returns 0 if Ok
? WNetCancelConnection(@lcLocalName,0)


If you run into a return code of 5 it means "Access Denied".

I had no problems using the NET USE command (shelling out from VFP), but there was no way to tell if I had successfully connected to the remote drive using the NET USE from a DOS Shell, so I was glad George was kind enough to share with me the API call for connecting and disconnecting. It's very reliable and works well.

HTH,
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform