共用方式為


CreateVPNConnection function

The CreateVPNConnection function creates a VPN connection.

Syntax

HRESULT WINAPI CreateVPNConnection(
  _In_     const HWND   hwndParent,
  _In_     const DWORD  dwWizardType,
  _In_     const DWORD  dwContextFlags,
  _In_     const DWORD  dwUserFlags,
  _In_     const HANDLE hUserContext,
  _In_opt_       LPWSTR pszCommandLine
);

Parameters

hwndParent [in]

Handle to the parent window that called this API.

This parameter is optional and can be set to NULL.

dwWizardType [in]

Specifies the style of the Get Connected wizard to be launched.

This parameter is optional and can be set to 0.

Value Meaning
0x00
Default style.

dwContextFlags [in]

A set of context flags that describes wizard behaviors.

This parameter is optional and can be set to 0.

Value Meaning
0x00
The wizard returns the results synchronously and blocks until this call is complete.
0x1
The wizard returns the results immediately and asynchronously via a Windows event.

dwUserFlags [in]

A set of user-defined application-specific flags. These flags are defined and interpreted by the calling application.

This parameter is optional and should be set to 0 by default.

hUserContext [in]

User context handle for the parent application thread.

This parameter is optional and should be set to NULL by default.

pszCommandLine [in, optional]

User command line parameters, if any.

This parameter is optional and can be set to NULL.

The following command-line options are supported:

Value Meaning
-HideFinishPage
Hide the Finish page of the Get Connected wizard.
-SkipInternetDetection
Do not display the Get Connected wizard page that shows whether or not the user has a working or active Internet connection.
-SkipExistingConnections
Do not display the Get Connected wizard page that shows a list of existing Internet connections. This command-line option is commonly used when creating additional Internet connections after one has been previously established, and to prevent novice users from creating a completely new connection each time they attempt to access the Internet.

Return value

If the method succeeds the return value is S_OK.

If the method fails, the return value is one of the standard error codes.

Remarks

Unlike GetVPNConnected, this function does not attempt to repair an existing connection to a VPN, but creates a new and separate connection entirely.

An import library containing the CreateVPNConnection function is not included in the Microsoft Windows Software Development Kit (SDK). Applications must use the GetModuleHandle and GetProcAddress functions to retrieve the function pointer from the corresponding DLL and call this function.

Requirements

Minimum supported client
Windows Vista [desktop apps only]
Minimum supported server
Windows Server 2008 [desktop apps only]
DLL
Connect.dll