NPAddConnection3 function (npapi.h)
The NPAddConnection3 function connects a local device to a network resource. It performs the same operation as NPAddConnection but in addition lets you specify a handle to the window that should own any resulting dialog boxes and specify how the connection should be established.
Syntax
DWORD NPAddConnection3(
[in] HWND hwndOwner,
[in] LPNETRESOURCEW lpNetResource,
[in] LPWSTR lpPassword,
[in] LPWSTR lpUserName,
[in] DWORD dwFlags
);
Parameters
[in] hwndOwner
A handle to a window that should own any messages or dialog boxes. This handle is valid only if CONNECT_INTERACTIVE is set in dwFlags, and the handle should only be used to produce dialog boxes needed for authentication.
[in] lpNetResource
Pointer to a NETRESOURCE structure that specifies the network resource to connect to. The following fields must be set when making a connection. The others are ignored.
[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.
[in] dwFlags
Any combination of the following values. The provider should ignore any other bits of dwFlags that may be set.
Value | Meaning |
---|---|
|
The connection is being established for browsing purposes and will probably be released quickly. |
|
The connection may have interaction with the user for authentication purposes. |
|
Do not use any defaults for user names or passwords without offering the user a chance to supply an alternative. This flag is only valid if CONNECT_INTERACTIVE is also set. |
|
Do not perform any remote network operations to make the network connection; instead, restore the connection in a "disconnected state." Attempt the actual connection only when some process attempts to use the connection. If this bit is set, the caller must supply lpLocalName.
This feature is used to speed the restoring of network connections at logon. A provider that supports it should return the WNNC_CON_DEFERRED bit in NPGetCaps. |
Return value
If the function succeeds, it will return WN_SUCCESS. Otherwise, it will return an error code. This may include 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. |
|
The attempt to make the connection was canceled by the user using a dialog box displayed by the provider. |
Remarks
If a provider displays a password dialog box because the specified credentials are insufficient and the CONNECT_INTERACTIVE flag is set, then the provider may not return an access-denied error code (one of ERROR_LOGON_FAILURE, WN_BAD_PASSWORD, WN_ACCESS_DENIED). The suggested behavior is for the provider to continue asking the user for valid credentials until the user either supplies them or presses a "cancel" button. If NPAddConnection3 is called to make the connection requested during the WNetConnectionDialog or WNetConnectionDialog1 function and an access-denied code is returned, the WNetConnectionDialog or WNetConnectionDialog1 function will, itself, display a password dialog box.
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 |