Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Determining a Net Connection.
Message
 
À
04/09/2001 11:22:08
Information générale
Forum:
Visual FoxPro
Catégorie:
Fonctions Windows API
Divers
Thread ID:
00552078
Message ID:
00552118
Vues:
17
>Hi again.
>
>I have this problem rigth now. In a client we have create a remote sale system, in th system we require that the computer of the vendor be connect to a fisical net unit like: U:\ (where U:\ refers to \\name_server\folder_shared).
>
>I would like to know if exist any API function that allow me to know if the connection exist, and if not then any other function that allow me to reconnect to the user into the net.
>
>Thanks in advance,
>
Melvin,

Daniel has demonstrated how to add a connection via the API. Here's how to determine the connection name.
DECLARE INTEGER WNetGetConnection IN Win32API;
  STRING @lpszLocalName, STRING @lpbuffer, INTEGER @lnbufsize
lcdrive = "F:"
lnsize = 260
lcbuffer = SPACE(lnsize)
= WNetGetConnection(@lcdrive, @lcbuffer, @lnsize)
? LEFT(lcbuffer, lnsize - 1)
Naturally, you should check for the presence of the drive prior to issuing the calls. You can do this via the DRIVETYPE() function.

Easier, however, IMO is to use the Windows Script Host's WScript.Network object, like so:
oNet = CREATEOBJECT("WScript.Network")
oDrives = oNet.EnumNetworkDrives
FOR lni = 1 TO oDrives.Count - 1 STEP 2
  ? oDrives.Item(lni) && Display the share name
NEXT
The WSH, BTW, can also be used to map the drives for you. For details, see last December's issue of the VFUG newsletter. It's the fourth of a five part series that Ed Rauh and I wrote on the WSH. It's available on-line at www.vfug.org.
George

Ubi caritas et amor, deus ibi est
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform