Associates a drive with a shared network directory.
Syntax
<Result> = NetworkConnect(<Drive letter> , <Network directory> [, <Options>] [, <User> [, <Password>]])
<Result>: Integer
- 0 if the connection was established
- an error code (value greater than 0) otherwise.
<Drive letter>: Character string
Network drive to create, in the following format: "<Drive letter>:".
<Network directory>: Character string
Network directory that must be associated with the network drive.
<Options>: Optional Integer constant
Sets the persistence of the connection: | |
ncOptionNone | No persistence option. |
ncOptionPersistent (default value) | Persistent connection (the connection remains after restarting the computer). |
<User>: Optional character string
Name of user allowed to access the specified directory. This parameter corresponds to Null by default.
<Password>: Optional character string
Password used to access the specified directory. If <User> corresponds to the name of the current user, the password is ignored by Windows. This parameter corresponds to an empty string ("") by default.
Remarks
Error codes
The following error codes are returned:
- 1: The connection is not supported.
- 2: Insufficient memory.
- 3: Wrong pointer.
- 4: Wrong type of device.
- 5: Wrong user profile.
- 7: An entry is already found for this device in the user profile (Already connected)
- 8: Invalid network or wrong path.
- 9: No network.
- 10: Network error.
- 11: Wrong network name.
- 12: The drive letter is invalid.
- 13: Wrong password.
- 14: Access denied.
The error code message can be retrieved using the
ErrorInfo function with the
rrMessage constant.
Use in Windows Vista (and later)
In Windows Vista (and later), when the application is started in "Administrator" mode, the network connections may be lost for the application. If
UAC system is enabled, the network drives are disconnected when the user privileges are increased. To be able to use the drives, you must reconnect them with
NetworkConnect.
Business / UI classification: Business Logic