Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Removing the sharing of a drive
Message
De
29/12/1999 06:19:31
 
 
À
29/12/1999 02:33:41
Shaheer Shamsi
Boston Education & Software Technologies
Mumbai, Inde
Information générale
Forum:
Visual FoxPro
Catégorie:
Fonctions Windows API
Divers
Thread ID:
00309735
Message ID:
00309754
Vues:
20
>Is there any way by which I can remove the sharing and again set it back of a particular drive through a VFP program using API calls.
>

The Win32API call WNetCancelConnection2() will delete a drive mapping, and WNetAddConnection() or WNetAddConnection2() or WNetAddConnection3() will create a new drive mapping. It'd be your responsibility to track any drive mappings in effect before your application started.

A better (or at least easier approach) if you're willing to assure that the Windows Script Host is installed on all target systems is to use the automation object Wscript.Network to do this work. The Wscript.Network object has the methods MapNetworkDrive and RemoveNetworkDrive, and a method EnumNetworkDrives that will return an array of current drive mappings, which makes it relatively easy to restore the state before your app started running (on entry, grab the list of drive mapings using EnumNetworkDrives, save the array somewhere, and if you have to restore the state later, issue another EnumNetworkDrives and compare the current reality with the way the world worked before you started.)

You can get more information on the WSH at msdn.microsoft.com/scripting and I'd recommend picking up the book Windows Script Host Programmer's Reference or VBSCRIPT Programmer's Reference (both published by WROX Press, www.wrox.com or through Amazon or B&N) if you aren't familiar the WSH and scripting.
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