Trying to use RAS

  • Thread starter Thread starter TJoker .NET
  • Start date Start date
T

TJoker .NET

Hi all.
I'm trying to programmatically connect to a remote network using dialup.
I've found the following code in C# from someone at MS.

http://groups.google.com/groups?selm=An87uzi#BHA.1532@cpmsftngxa08

I converted it to VB.NET using this utility:
http://csharpconverter.claritycon.com/Default.aspx

but the result code had some minor compilation errors. I think I fixed the
errors manually but when I try to connect using the code I get a runtime
error (immediately, without even trying to dial) and the app crashes. The
callback routine is invoked only once with the following parameters just
before the crash:
unMsg: 52429
rasconnstate: 0
dwError: 0

I have a valid dialup entry. Has anyone been through this ?
Here's the class I'm using:
------------------------------------------------------------------
Imports System
Imports System.Runtime.InteropServices

Namespace RAS

Public Class RasManager
Public Const RAS_MaxEntryName As Integer = 256
Public Const RAS_MaxPhoneNumber As Integer = 128
Public Const UNLEN As Integer = 256
Public Const PWLEN As Integer = 256
Public Const DNLEN As Integer = 15
Public Const MAX_PATH As Integer = 260
Public Const RAS_MaxDeviceType As Integer = 16
Public Const RAS_MaxCallbackNumber As Integer = RAS_MaxPhoneNumber


Delegate Sub Callback(ByVal unMsg As System.UInt32, ByVal
rasconnstate As Integer, ByVal dwError As Integer) 'ToDo: Unsigned Integers
not supported

<StructLayout(LayoutKind.Sequential, Pack:=4,
CharSet:=CharSet.Auto)> _
Public Structure RASDIALPARAMS
Public dwSize As Integer
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=RAS_MaxEntryName
+ 1)> _
Public szEntryName As String
<MarshalAs(UnmanagedType.ByValTStr,
SizeConst:=RAS_MaxPhoneNumber + 1)> _
Public szPhoneNumber As String
<MarshalAs(UnmanagedType.ByValTStr,
SizeConst:=RAS_MaxCallbackNumber + 1)> _
Public szCallbackNumber As String
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=UNLEN + 1)> _
Public szUserName As String
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=PWLEN + 1)> _
Public szPassword As String
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=DNLEN + 1)> _
Public szDomain As String
Public dwSubEntry As Integer
Public dwCallbackId As Integer
End Structure 'RASDIALPARAMS

'<DllImport("rasapi32.dll", CharSet:=CharSet.Auto)> _

Public Declare Auto Function RasDial Lib "rasapi32.dll" (ByVal
lpRasDialExtensions As Integer, ByVal lpszPhonebook As String, ByRef
lprasdialparams As RASDIALPARAMS, ByVal dwNotifierType As Integer, ByVal
lpvNotifier As Callback, ByRef lphRasConn As Integer) As Integer

Private RasDialPar As RASDIALPARAMS
Private Connection As Integer


Public Sub New()
Connection = 0
RasDialPar = New RASDIALPARAMS()
RasDialPar.dwSize = Marshal.SizeOf(RasDialPar)
End Sub 'New

#Region "Properties"

Public Property UserName() As String
Get
Return RasDialPar.szUserName
End Get
Set(ByVal Value As String)
RasDialPar.szUserName = Value
End Set
End Property


Public Property Password() As String
Get
Return RasDialPar.szPassword
End Get
Set(ByVal Value As String)
RasDialPar.szPassword = Value
End Set
End Property


Public Property EntryName() As String
Get
Return RasDialPar.szEntryName
End Get
Set(ByVal Value As String)
RasDialPar.szEntryName = Value
End Set
End Property
#End Region


Public Function Connect() As Integer
Dim rasDialFunc As New Callback(AddressOf
RasManager.RasDialFunc)
RasDialPar.szEntryName += ControlChars.NullChar
RasDialPar.szUserName += ControlChars.NullChar
RasDialPar.szPassword += ControlChars.NullChar
Dim result As Integer = RasDial(0, Nothing, RasDialPar, 0,
rasDialFunc, Connection)
Return result
End Function 'Connect


Public Shared Sub RasDialFunc(ByVal unMsg As System.UInt32, ByVal
rasconnstate As Integer, ByVal dwError As Integer) 'ToDo: Unsigned Integers
not supported
Debug.WriteLine("Callback function ----------------")
Debug.WriteLine(" unMsg: " & unMsg.ToString)
Debug.WriteLine(" rasconnstate: " & rasconnstate)
Debug.WriteLine(" dwError: " & dwError)
Debug.WriteLine("----------------------------------")
End Sub 'RasDialFunc

End Class 'RasManager
End Namespace 'RAS
-------------------------------------------------

The code calling it:
Dim myRas As New RAS.RasManager()
myRas.EntryName = "myentry"
myRas.UserName = "myuser"
myRas.Password = ""
Dim res As Integer = myRas.Connect().ToString()
Debug.WriteLine("result = " & res) 'prints 0

Thanks a lot

TJ!
 
Ok, after poking around and researching, I found the different pieces to do
what I needed and put them together.
What I needed was a way to fire an existing, pre-defined dialup connection,
passing it a user name and password. Then wait until the modem connects
(notified with events). Then also be able to hang up that specific
connection when needed.
Here's the code I put together (sample app and the RAS wrapper), enjoy.

TJ


-------------------- A test form -----------------------------

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.IO;

namespace TestRasDialup
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Button btnConnect;
private System.Windows.Forms.TextBox txtDebug;
private System.Windows.Forms.Button btnDisconnect;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.TextBox txtUser;
private System.Windows.Forms.TextBox txtPassword;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;

public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();

//
// TODO: Add any constructor code after InitializeComponent call
//
}

/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.btnConnect = new System.Windows.Forms.Button();
this.txtDebug = new System.Windows.Forms.TextBox();
this.btnDisconnect = new System.Windows.Forms.Button();
this.label1 = new System.Windows.Forms.Label();
this.txtUser = new System.Windows.Forms.TextBox();
this.txtPassword = new System.Windows.Forms.TextBox();
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// btnConnect
//
this.btnConnect.Location = new System.Drawing.Point(159, 8);
this.btnConnect.Name = "btnConnect";
this.btnConnect.Size = new System.Drawing.Size(71, 42);
this.btnConnect.TabIndex = 0;
this.btnConnect.Text = "Connect";
this.btnConnect.Click += new System.EventHandler(this.button1_Click);
//
// txtDebug
//
this.txtDebug.Anchor = (((System.Windows.Forms.AnchorStyles.Top |
System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right);
this.txtDebug.Font = new System.Drawing.Font("Courier New", 8.25F,
System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point,
((System.Byte)(0)));
this.txtDebug.Location = new System.Drawing.Point(4, 81);
this.txtDebug.Multiline = true;
this.txtDebug.Name = "txtDebug";
this.txtDebug.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
this.txtDebug.Size = new System.Drawing.Size(403, 357);
this.txtDebug.TabIndex = 1;
this.txtDebug.Text = "";
//
// btnDisconnect
//
this.btnDisconnect.Enabled = false;
this.btnDisconnect.Location = new System.Drawing.Point(237, 8);
this.btnDisconnect.Name = "btnDisconnect";
this.btnDisconnect.Size = new System.Drawing.Size(78, 42);
this.btnDisconnect.TabIndex = 2;
this.btnDisconnect.Text = "Disconnect";
this.btnDisconnect.Click += new System.EventHandler(this.button2_Click);
//
// label1
//
this.label1.Location = new System.Drawing.Point(6, 59);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(185, 18);
this.label1.TabIndex = 3;
this.label1.Text = "";
//
// txtUser
//
this.txtUser.Location = new System.Drawing.Point(64, 3);
this.txtUser.Name = "txtUser";
this.txtUser.Size = new System.Drawing.Size(88, 20);
this.txtUser.TabIndex = 4;
this.txtUser.Text = "DOMAIN\\loginid";
//
// txtPassword
//
this.txtPassword.Location = new System.Drawing.Point(63, 32);
this.txtPassword.Name = "txtPassword";
this.txtPassword.PasswordChar = '*';
this.txtPassword.Size = new System.Drawing.Size(91, 20);
this.txtPassword.TabIndex = 5;
this.txtPassword.Text = "password_here";
//
// label2
//
this.label2.Location = new System.Drawing.Point(6, 4);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(47, 23);
this.label2.TabIndex = 6;
this.label2.Text = "User";
//
// label3
//
this.label3.Location = new System.Drawing.Point(2, 31);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(59, 23);
this.label3.TabIndex = 7;
this.label3.Text = "Password";
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(416, 444);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.label3,
this.label2,
this.txtPassword,
this.txtUser,
this.label1,
this.btnDisconnect,
this.txtDebug,
this.btnConnect});
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false);

}
#endregion

public static Form1 CurrForm;

/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
CurrForm = new Form1();
Application.Run(CurrForm);
}

private Dialup.RASManager myRasMgr;
private EventHandler _rasConnectedHandler;
private EventHandler _rasDisconnectedHandler;
private Dialup.RasConnectionErrorEventHandler _rasConnectionErrorHandler;

private void button1_Click(object sender, System.EventArgs e)
{
//connect
btnConnect.Enabled = false;

myRasMgr = new Dialup.RASManager();
_rasConnectedHandler = new EventHandler(this.RAS_Connected);
_rasDisconnectedHandler = new EventHandler(this.RAS_Disconnected);
_rasConnectionErrorHandler = new
Dialup.RasConnectionErrorEventHandler(this.RAS_ConnectionError);

myRasMgr.RasConnected += _rasConnectedHandler;
myRasMgr.RasDisconnected += _rasDisconnectedHandler;
myRasMgr.RasConnectionError += _rasConnectionErrorHandler;

int res = myRasMgr.Connect("DialupConnName", txtUser.Text,
txtPassword.Text );
Form1.Debug("After connecting. Returned: " + res);

}

private void button2_Click(object sender, System.EventArgs e)
{
//diconnect

Form1.Debug("Try to disconnect. Are we connected?");
if(myRasMgr != null && myRasMgr.IsConnected)
{
Form1.Debug(" --> We are connected, disconnecting... ");
myRasMgr.Disconnect();
myRasMgr = null;
}

btnConnect.Enabled = true;
btnDisconnect.Enabled = false;
}

private void RAS_Connected(object sender, System.EventArgs e)
{
Form1.Debug(" --> EVENT: RAS_Connected");
btnConnect.Enabled = false;
btnDisconnect.Enabled = true;

}

private void RAS_Disconnected(object sender, System.EventArgs e)
{
Form1.Debug(" --> EVENT: RAS_Disconnected");
btnConnect.Enabled = true;
btnDisconnect.Enabled = false;

myRasMgr.RasConnected -= _rasConnectedHandler;
myRasMgr.RasDisconnected -= _rasDisconnectedHandler;
myRasMgr.RasConnectionError -= _rasConnectionErrorHandler;
myRasMgr = null;

}

private void RAS_ConnectionError(object sender,
Dialup.RasConnectionErrorEventArgs e)
{
Form1.Debug(" --> EVENT: RAS_ConnectionError, code: " + e.ErrorCode + ",
message: " + e.ErrorMessage);
myRasMgr.RasConnected -= _rasConnectedHandler;
myRasMgr.RasDisconnected -= _rasDisconnectedHandler;
myRasMgr.RasConnectionError -= _rasConnectionErrorHandler;
myRasMgr = null;

btnDisconnect.Enabled = (((Dialup.RASManager)sender).IsConnected);
btnConnect.Enabled = !btnDisconnect.Enabled;

}

public static void Debug(string msg)
{
CurrForm.txtDebug.AppendText(Environment.NewLine + msg);
System.Diagnostics.Debug.WriteLine(msg);

using(FileStream f = new FileStream(@"c:\temp\connection.log",
FileMode.Append, FileAccess.Write))
{
StreamWriter wr = new StreamWriter(f);
wr.WriteLine(DateTime.Now.ToLongTimeString() + " ---> " + msg);
wr.Close();
}
}


}
}


----------------------- Another File, the RAS support
classes ----------------------


using System;
using System.Runtime.InteropServices;
using System.Text;

namespace Dialup
{

public delegate void Callback(uint unMsg, int rasconnstate, int dwError);

[StructLayout(LayoutKind.Sequential, Pack=4, CharSet=CharSet.Auto)]
internal struct RASDIALPARAMS
{
public int dwSize;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst=RAS.RAS_MaxEntryName + 1)]
public string szEntryName;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst=RAS.RAS_MaxPhoneNumber +
1)]
public string szPhoneNumber;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst=RAS.RAS_MaxCallbackNumber+
1)]
public string szCallbackNumber;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst=RAS.UNLEN + 1)]
public string szUserName;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst=RAS.PWLEN + 1)]
public string szPassword;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst=RAS.DNLEN + 1)]
public string szDomain;
public int dwSubEntry;
public int dwCallbackId;
}

internal enum _RASCONNSTATE
{
RASCS_OpenPort = 0,
RASCS_PortOpened,
RASCS_ConnectDevice,
RASCS_DeviceConnected,
RASCS_AllDevicesConnected,
RASCS_Authenticate,
RASCS_AuthNotify,
RASCS_AuthRetry,
RASCS_AuthCallback,
RASCS_AuthChangePassword,
RASCS_AuthProject,
RASCS_AuthLinkSpeed,
RASCS_AuthAck,
RASCS_ReAuthenticate,
RASCS_Authenticated,
RASCS_PrepareForCallback,
RASCS_WaitForModemReset,
RASCS_WaitForCallback,
RASCS_Projected,

#if(WINVER4 || WINVER5 )
RASCS_StartAuthentication, // Windows 95 only
RASCS_CallbackComplete, // Windows 95 only
RASCS_LogonNetwork, // Windows 95 only
#endif
RASCS_SubEntryConnected,
RASCS_SubEntryDisconnected,

RASCS_Interactive = 0x1000,
RASCS_RetryAuthentication,
RASCS_CallbackSetByCaller,
RASCS_PasswordExpired,
#if (WINVER5)
RASCS_InvokeEapUI,
#endif

RASCS_Connected = 0x2000,
RASCS_Disconnected
}

internal enum RasFieldSizeConstants
{
RAS_MaxDeviceType =16,
RAS_MaxPhoneNumber =128,
RAS_MaxIpAddress =15,
RAS_MaxIpxAddress =21,
#if WINVER4
RAS_MaxEntryName =256,
RAS_MaxDeviceName =128,
RAS_MaxCallbackNumber =RAS_MaxPhoneNumber,
#else
RAS_MaxEntryName =20,
RAS_MaxDeviceName =32,
RAS_MaxCallbackNumber =48,
#endif

RAS_MaxAreaCode =10,
RAS_MaxPadType =32,
RAS_MaxX25Address =200,
RAS_MaxFacilities =200,
RAS_MaxUserData =200,
RAS_MaxReplyMessage =1024,
RAS_MaxDnsSuffix =256,
UNLEN =256,
PWLEN =256,
DNLEN =15
}


[StructLayout(LayoutKind.Sequential,CharSet=CharSet.Auto)]
public struct GUID
{
public uint Data1;
public ushort Data2;
public ushort Data3;
[MarshalAs(UnmanagedType.ByValArray,SizeConst=8)]
public byte[] Data4;
}

[StructLayout(LayoutKind.Sequential,CharSet=CharSet.Auto)]
internal struct RASCONN
{
public int dwSize;
public IntPtr hrasconn;

[MarshalAs(UnmanagedType.ByValTStr,SizeConst=(int)RasFieldSizeConstants.RAS_
MaxEntryName+1)]
public string szEntryName;

[MarshalAs(UnmanagedType.ByValTStr,SizeConst=(int)RasFieldSizeConstants.RAS_
MaxDeviceType+1)]
public string szDeviceType;

[MarshalAs(UnmanagedType.ByValTStr,SizeConst=(int)RasFieldSizeConstants.RAS_
MaxDeviceName+1)]
public string szDeviceName;
[MarshalAs(UnmanagedType.ByValTStr,SizeConst=260)]//MAX_PAPTH=260
public string szPhonebook;
public int dwSubEntry;
public GUID guidEntry;
#if (WINVER501)
int dwFlags;
public LUID luid;
#endif
}

[StructLayout(LayoutKind.Sequential,CharSet=CharSet.Auto)]
internal struct LUID
{
int LowPart;
int HighPart;
}


[StructLayout(LayoutKind.Sequential,CharSet=CharSet.Auto)]
public class RasStats
{
public int dwSize=Marshal.SizeOf(typeof(RasStats));
public int dwBytesXmited;
public int dwBytesRcved;
public int dwFramesXmited;
public int dwFramesRcved;
public int dwCrcErr;
public int dwTimeoutErr;
public int dwAlignmentErr;
public int dwHardwareOverrunErr;
public int dwFramingErr;
public int dwBufferOverrunErr;
public int dwCompressionRatioIn;
public int dwCompressionRatioOut;
public int dwBps;
public int dwConnectDuration;
}


public class RAS

{
public const int RAS_MaxEntryName = 256;
public const int RAS_MaxPhoneNumber = 128;
public const int UNLEN = 256;
public const int PWLEN = 256;
public const int DNLEN = 15;
public const int MAX_PATH = 260;
public const int RAS_MaxDeviceType = 16;
public const int RAS_MaxCallbackNumber = RAS_MaxPhoneNumber;

[DllImport("rasapi32.dll", CharSet=CharSet.Auto)]
internal static extern int RasDial (int lpRasDialExtensions,
string lpszPhonebook,
ref RASDIALPARAMS lprasdialparams, int dwNotifierType,
Callback lpvNotifier, ref IntPtr lphRasConn);

[DllImport("rassapi.dll", CharSet=CharSet.Auto)]
internal static extern int RasAdminGetErrorString (int ResourceId,
[MarshalAs(UnmanagedType.LPWStr,SizeConst=513)] ref string lpszString ,
int InBufSize);

[DllImport("mprapi.dll", CharSet=CharSet.Auto)]
internal static extern int MprAdminGetErrorString (int dwError ,
[MarshalAs(UnmanagedType.LPWStr,SizeConst=513)] ref string
lplpwsErrorString );

[DllImport("Rasapi32.dll", EntryPoint="RasEnumConnectionsA",
SetLastError=true)]
internal static extern int RasEnumConnections
(
ref RASCONN lprasconn, // buffer to receive connections data
ref int lpcb, // size in bytes of buffer
ref int lpcConnections // number of connections written to buffer
);


[DllImport("rasapi32.dll",CharSet=CharSet.Auto)]
public extern static uint RasHangUp(
IntPtr hrasconn // handle to the RAS connection to hang up
);

public RAS()
{

}


}

public sealed class RASManager
{
private bool m_connected;
private IntPtr m_ConnectedRasHandle;

public event RasConnectionErrorEventHandler RasConnectionError ;
public event EventHandler RasConnected ;
public event EventHandler RasDisconnected ;

public RASManager()
{
m_connected = true;

RASCONN lprasConn = new RASCONN();

lprasConn.dwSize = Marshal.SizeOf(typeof(RASCONN));
lprasConn.hrasconn = IntPtr.Zero;

int lpcb = 0;
int lpcConnections = 0;
int nRet = 0;
lpcb = Marshal.SizeOf(typeof(RASCONN));


nRet = RAS.RasEnumConnections(ref lprasConn, ref lpcb, ref
lpcConnections);


if(nRet != 0)
{
m_connected = false;
return;
}

if(lpcConnections > 0)
{
for (int i = 0; i < lpcConnections; i++)
{
RasStats stats = new RasStats();

m_ConnectedRasHandle = lprasConn.hrasconn;
//RAS.RasGetConnectionStatistics(lprasConn.hrasconn, stats);

if(lprasConn.szEntryName == "DialupConnName")
{
m_connected = true;
break;
}
}
}
else
{
m_connected = false;
}
}


public bool IsConnected
{
get
{
return m_connected;
}
}


public int Connect(string rasEntry, string userId, string password)
{
//connects to another network via dialup

RASDIALPARAMS par = new RASDIALPARAMS();
par.dwSize = Marshal.SizeOf(par);

Callback rasDialFunc = new Callback(this.RasDialFunc);
par.szEntryName += rasEntry + "\0";
par.szUserName += userId + "\0";
par.szPassword += password + "\0";
int result = RAS.RasDial(0, null, ref par, 0, rasDialFunc, ref
m_ConnectedRasHandle);
TestRasDialup.Form1.Debug("Connect(), Connection handle:" +
m_ConnectedRasHandle.ToString());
m_connected = false;//not connected yet... but in the process
return m_ConnectedRasHandle.ToInt32();
}

public void RasDialFunc(uint unMsg, int rasconnstate, int dwError)
{

_RASCONNSTATE state = (_RASCONNSTATE)rasconnstate;
switch(state)
{
case _RASCONNSTATE.RASCS_Connected:
m_connected = true;
OnRasConnected(EventArgs.Empty);
break;
case _RASCONNSTATE.RASCS_Disconnected:
m_connected = false;
OnRasDisconnected(EventArgs.Empty);
break;
}

//notify if something went wrong
if(dwError != 0)
OnRasConnectionError(new RasConnectionErrorEventArgs(dwError));

//debugging code
TestRasDialup.Form1.Debug("RasDialFunc ------------------");

TestRasDialup.Form1.Debug(" unMsg: " + unMsg);
TestRasDialup.Form1.Debug(" rasconnstate: " + rasconnstate);
TestRasDialup.Form1.Debug(" state: " + state.ToString());
TestRasDialup.Form1.Debug(" dwError: " + dwError);
if(dwError != 0)
TestRasDialup.Form1.Debug(" message: " +
RASManager.GetErrorMessage(dwError));

TestRasDialup.Form1.Debug("------------------------------");
}


public void Disconnect()
{
TestRasDialup.Form1.Debug("Disconnect(), Connection handle:" +
m_ConnectedRasHandle.ToString());
RAS.RasHangUp(m_ConnectedRasHandle);
OnRasDisconnected(EventArgs.Empty);
}

public static string GetErrorMessage(int errorCode)
{
string msg = null;
RAS.MprAdminGetErrorString(errorCode, ref msg);
return msg;
}

private void OnRasConnectionError(RasConnectionErrorEventArgs e)
{
if(this.RasConnectionError != null)
RasConnectionError(this, e);
}

private void OnRasConnected(EventArgs e)
{
if(this.RasConnected != null)
RasConnected(this, e);
}

private void OnRasDisconnected(EventArgs e)
{
if(this.RasDisconnected != null)
RasDisconnected(this, e);
}

}

#region Events

public class RasConnectionErrorEventArgs: EventArgs
{

private int _errorCode;
public int ErrorCode
{
get { return _errorCode; }
}

private string _errorMessage;
public string ErrorMessage
{
get { return _errorMessage; }
}

public RasConnectionErrorEventArgs(int errorCode)
{
_errorCode = errorCode;
_errorMessage = RASManager.GetErrorMessage(errorCode);
}
}

public delegate void RasConnectionErrorEventHandler(object sender,
RasConnectionErrorEventArgs e);




#endregion
}


************************************************************************
 
Back
Top