Platform SDK: Network Management |
The NetUseAdd function establishes a connection between the local computer and a remote server. You can specify a local drive letter or a printer device to connect. If you do not specify a local drive letter or printer device, the function authenticates the client with the server for future connections.
Win32-based applications can also use the WNetAddConnection2 and WNetAddConnection3 functions to redirect a local device to a network resource.
No special group membership is required to call the NetUseAdd function. This function cannot be executed on a remote server.
NET_API_STATUS NetUseAdd ( LPWSTR UncServerName, DWORD Level, LPBYTE Buf, LPDWORD ParmError );
Value | Meaning |
---|---|
1 | Specifies information about the connection between a local device and a shared resource, including connection status and type. The Buf parameter is a pointer to a USE_INFO_1 structure. |
2 | Specifies information about the connection between a local device and a shared resource. Information includes the connection status and type, and a user name and domain name. The Buf parameter is a pointer to a USE_INFO_2 structure. |
If the function succeeds, the return value is NERR_Success.
If the function fails, the return value is a Win32 API error code. For a list of error codes, see Error Codes.
If the NetUseAdd function returns ERROR_INVALID_PARAMETER, you can use the ParmError parameter to indicate the first member of the information structure that is invalid. (The information structure begins with USE_INFO_ and its format is specified by the Level parameter.) The following table lists the values that can be returned in the ParmError parameter and the corresponding structure member that is in error. (The prefix ui*_ indicates that the member can begin with multiple prefixes, for example, ui1_ or ui2_.)
Value | Member |
---|---|
USE_LOCAL_PARMNUM | ui*_local |
USE_REMOTE_PARMNUM | ui*_remote |
USE_PASSWORD_PARMNUM | ui*_password |
USE_ASGTYPE_PARMNUM | ui*_asg_type |
USE_USERNAME_PARMNUM | ui*_username |
USE_DOMAINNAME_PARMNUM | ui*_domainname |
Windows NT/2000: Requires Windows NT 3.1 or later.
Windows 95/98: Unsupported.
Header: Declared in Lmuse.h; include Lm.h.
Library: Use Netapi32.lib.
Network Management Overview, Network Management Functions, Use Functions, USE_INFO_1, USE_INFO_2, NetUseDel, WNetAddConnection2, WNetAddConnection3