Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Need an API call
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00364159
Message ID:
00364316
Vues:
47
>>Anyone know of an API call to Map/Unmap a network drive?
>>
>>TIA
>
>In addition to the WSH that was previously mention, you could also use UNCs. However, to answer the question directly:
    DECLARE INTEGER WNetAddConnection IN Win32API;
>  STRING @lpszRemoteName, STRING @lpszPassword, STRING @lpszLocalName
>DECLARE INTEGER WNetCancelConnection IN Win32API;
> STRING @lpszName, INTEGER fForce
>* Map a drive
>* lcserver is the server name
>* lcdrive is the drive specifier.
>* The below uses the "remembered" password name
>* If the mapping was successful lnresult will equal 0
>lnresult = WNetAddConnection(@lcserver, 0, @lcdrive)
>* Below uses provided password.
>lnresult = WNetAddConnection(@lcserver, @lcpassword, @lcdrive)
>* Unmap/Disconnect
>lnresult = WNetCancelConnection(lcdrive, 0) && 0 if success.
To expand on this WnetAddConnection2() or WNetAddConnection3() may be needed to attach resources is a different domain or under another user name - there's sample code in my NETRESOURCE class. THe WSH approach is strongly preferable.
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform