NPAddConnection function (npapi.h)
The NPAddConnection function connects a local device to a network resource.
Syntax
DWORD NPAddConnection(
[in] LPNETRESOURCEW lpNetResource,
[in] LPWSTR lpPassword,
[in] LPWSTR lpUserName
);
Parameters
[in] lpNetResource
Pointer to a NETRESOURCE structure which specifies the network resource to connect to. The following fields must be set in the NETRESOURCE structure you pass in. The NPAddConnection function ignores the other fields.
[in] lpPassword
Pointer to the password to be used in making the connection, normally the password associated with lpUserName. The NULL value may be passed in to cause the function to use the default password. An empty string may be used to indicate no password. When you have finished using the password, clear it from memory by calling the SecureZeroMemory function. For more information about protecting the password, see Handling Passwords.
[in] lpUserName
Pointer to the user name used to make the connection. If NULL, the default user name (that of the currently logged-on user) is applied. This is used when the user wants to connect to a resource but has a different assigned user name or account for that resource.
For example, if you were logged using the user name "MyAccount" and wanted to connect to a network resource that was available only to a second account, where the user name was "MyOtherAccount", you could specify "MyOtherAccount" in lpUserName in order to connect to the resource. You would also specify the password of this second account in lpPassword.
Return value
If the function succeeds, it should return WN_SUCCESS. Otherwise, it should return an error code, which can be one of the following.
Return code | Description |
---|---|
|
The value of the lpRemoteName member of the structure passed into lpNetResource is not valid for this provider. |
|
The value of the lpLocalName member of the structure passed into lpNetResource is not valid. |
|
The specified password is not valid. |
|
The device specified in the lpLocalName member of the structure passed into lpNetResource is already connected. |
|
Permission to establish the connection is denied. |
|
The network is not present. |
Requirements
Requirement | Value |
---|---|
Minimum supported client | Windows XP [desktop apps only] |
Minimum supported server | Windows Server 2003 [desktop apps only] |
Target Platform | Windows |
Header | npapi.h |