Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Net Use to map a drive?
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Fonctions Windows API
Divers
Thread ID:
00146250
Message ID:
00146979
Vues:
28
>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,
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform