Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Map a network drive
Message
De
17/10/2003 09:03:04
 
 
À
17/10/2003 08:59:01
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00839686
Message ID:
00839694
Vues:
23
This message has been marked as the solution to the initial question of the thread.
>hi gregory,
>
>i mean doing this programmatically =) i'd like to be able to map the network drive in my program.
>
>any help?


Evelyn,

I got this from google (have not tried it)
From: Fred Taylor (ftaylor@mvps.org)
Subject: Re: Map network drive ?? 
 
  
View this article only 
Newsgroups: microsoft.public.fox.programmer.exchange
Date: 2001-01-22 12:56:19 PST 
 

DECLARE INTEGER WNetAddConnection IN "mpr.dll" ;
 STRING cRemoteName, ;
 STRING cPassword, ;
 STRING cLocalName


cResource = "\\Server\ShareName"
cPassword = "MyPassword"
cDriveLetter = "Y:"

? WNetAddConnection(cResource, cPassword, cDriveLetter)


cResource = "\\Server\AnotherShare"
cPassword = chr(0)  && important distinction from the original (no password)
cDriveLetter = "Q:"

lnRetval = WNetAddConnection(cResource, cPassword, cDriveLetter)

?lnRetVal

A return of 0 means the connection was made. You get a non-zero value for a
failure to add a new connection. I got an 85 for a connection that already
exists, and a 67 for one that failed.



--
Fred
Microsoft Visual FoxPro MVP
Please respond only to the newsgroups so that all may benefit.
one more
From: William Fields (Bill_Fields@azb.uscourts.gov)
Subject: Re: Map network drive ?? 
 
  
View this article only 
Newsgroups: microsoft.public.fox.programmer.exchange
Date: 2001-01-22 16:30:07 PST 
 


If you have access to the Windows Scripting Host you can do the following

oNet   = CreateObject("Wscript.Network")
oFSO   = CreateObject("Scripting.FileSystemObject")

If oFSO.DriveExists("ShareName")
    oNet.MapNetworkDrive("DriveLetter:", "ShareName")
    MessageBox("Drive DriveLetter mapped to ShareName",0,"Drive mapped")
Else
 MessageBox("ShareName cannot be found",0,"Drive NOT mapped")
EndIf


--
William Fields
MCSD - Microsoft Visual FoxPro
MCP - Win2k Pro
US Bankruptcy Court
Phoenix, AZ
Gregory
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform