INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS
Come Join Us!
Are you a
Computer / IT professional?
Join Tek-Tips now!
- Talk With Other Members
- Be Notified Of Responses
To Your Posts
- Keyword Search
- One-Click Access To Your
- Automated Signatures
On Your Posts
- Best Of All, It's Free!
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.
Partner With Us!
"Best Of Breed" Forums Add Stickiness To Your Site
(Download This Button Today!)
"...This has been the MOST helpful forum that I have been a part of and I want to say thank you. The tips, tricks and helpful advice that you all contribute to have been lifesavers in many instances..."
Where in the world do Tek-Tips members come from?
Tips -N- Tricks
Connecting to Network Drive with Win API
Posted: 19 Aug 02
DECLARE INTEGER WNetAddConnection IN "mpr.dll" ;
STRING cRemoteName, ;
STRING cPassword, ;
DECLARE INTEGER WNetCancelConnection in WIN32API String,integer
#DEFINE NO_ERROR 0
* Error Constants: for connecting
#DEFINE ERROR_ACCESS_DENIED = 5
#DEFINE ERROR_ALREADY_ASSIGNED = 85
#DEFINE ERROR_BAD_DEV_TYPE = 66
#DEFINE ERROR_BAD_DEVICE = 1200
#DEFINE ERROR_BAD_NET_NAME = 67
#DEFINE ERROR_BAD_PROFILE = 1206
#DEFINE ERROR_BAD_PROVIDER = 1204
#DEFINE ERROR_BUSY = 170
#DEFINE ERROR_CANCELLED = 1223
#DEFINE ERROR_CANNOT_OPEN_PROFILE = 1205
#DEFINE ERROR_DEVICE_ALREADY_REMEMBERED = 1202
#DEFINE ERROR_EXTENDED_ERROR = 1208
#DEFINE ERROR_INVALID_PASSWORD = 86
#DEFINE ERROR_NO_NET_OR_BAD_PATH = 1203
* Error Constants: for disconnecting
#DEFINE ERROR_BAD_PROFILE 1206
#DEFINE ERROR_CANNOT_OPEN_PROFILE 1205
#DEFINE ERROR_DEVICE_IN_USE 2404
#DEFINE ERROR_EXTENDED_ERROR 1208
#DEFINE ERROR_NOT_CONNECTED 2250
#DEFINE ERROR_OPEN_FILES 2401
nReturn = 0
lForce = .t. && disconnect even if files or jobs are on connection
lNoForce = .f. && fail to dissconnect if files or jobs are in connection
cResource = "\\Server\ShareName"
cPassword = "MyPassword" && empty if not needed
cDriveLetter = "Y:"
nReturn = WNetAddConnection(cResource,cPassword,cDriveLetter)
if nReturn = NO_ERROR
messagebox('Connection to server Successfull',0,'Shared Connect')
messagebox('Connection to server Failed',0,'Shared Connect')
nReturn = WNetCancelConnection(cDriveLetter,lNoForce)
** if failed you could process the nReturn in a case on the error codes
Back to Microsoft: Visual FoxPro FAQ Index
Back to Microsoft: Visual FoxPro Forum
Join Tek-Tips® Today!
Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.
Here's Why Members Love Tek-Tips Forums:
- Talk To Other Members
- Notification Of Responses To Questions
- Favorite Forums One Click Access
- Keyword Search Of All Posts, And More...
Register now while it's still free!
Already a member? Close this window and log in.
Join Us Close