>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,