public void Connect(String connectionName, String userName, String password) { var rdp = new RASDIALPARAMS(); rdp.dwSize = Marshal.SizeOf(rdp); rdp.szEntryName = connectionName; rdp.szUserName = userName; rdp.szPassword = password; UInt32 result = RasNativeMethods.RasDial(null, null, rdp, 0xFFFFFFFF, null, ref _connection); if (result != 0) { throw new RasException(result); } }
public static extern UInt32 RasDial([In] RASDIALEXTENSIONS lpRasDialExtensions, [In] String lpszPhonebook, [In] RASDIALPARAMS lpRasDialParams, uint dwNotifierType, Delegate lpvNotifier, ref IntPtr lphRasConn);