public static void CreateEntry(string entryName, string url, RASDEVINFO device) { var props = new RASENTRY { dwSize = Marshal.SizeOf <RASENTRY>(), szAutodialDll = "", szAutodialFunc = "", szAreaCode = "", szCustomDialDll = "", szDeviceType = device.szDeviceType, szDeviceName = device.szDeviceName, dwType = (int)(RasEntryTypes.Vpn), //vpn dwEncryptionType = 1, // require dwFramingProtocol = (int)RasFramingProtocol.Ppp, dwfNetProtocols = (int)(RasNetProtocols.Ip | RasNetProtocols.Ipv6), //IP and IPv6 dwfOptions = (int)(RasEntryOptions.RemoteDefaultGateway | RasEntryOptions.ModemLights | RasEntryOptions.RequireEncrptedPw | RasEntryOptions.PreviewUserPw | RasEntryOptions.PreviewDomain | RasEntryOptions.ShowDialingProgress), szLocalPhoneNumber = url, szScript = "", dwVpnStrategy = 5, //SstpOnly szX25Address = "", szX25Facilities = "", szX25PadType = "", szX25UserData = "", dwfOptions2 = (int)(RasEntryOptions2.DoNotNegotiateMultilink | RasEntryOptions2.ReconnectIfDropped | RasEntryOptions2.UseTypicalSettings | RasEntryOptions2.IPv6RemoteDefaultGateway), szDnsSuffix = "", szPrerequisitePbk = "", szPrerequisiteEntry = "", dwRedialCount = 3000, dwRedialPause = 3, }; Checked("RasSetEntryProperties", VpnNative.RasSetEntryProperties(null, entryName, ref props, Marshal.SizeOf <RASENTRY>(), IntPtr.Zero, 0)); }
public static extern uint RasSetEntryProperties(string lpszPhonebook, string lpszEntry, ref RASENTRY lpRasEntry, int dwEntryInfoSize, IntPtr lpbDeviceInfo, int dwDeviceInfoSize);