[DllImport("coredll.dll", SetLastError=true)]
public static extern int RasGetConnectStatus(IntPtr hrasconn, ref RASCONNSTATUS lprasconnstatus);
const int RASCS_PAUSED = 0x1000;
const int RASCS_DONE = 0x2000;
const int RAS_MaxDeviceType = 16;
const int RAS_MaxDeviceName = 128;
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,
RASCS_Interactive = RASCS_PAUSED,
RASCS_RetryAuthentication,
RASCS_CallbackSetByCaller,
RASCS_PasswordExpired,
RASCS_Connected = RASCS_DONE,
RASCS_Disconnected
}
internal struct RASCONNSTATUS
{
public UInt32 dwSize;
public RASCONNSTATE rasconnstate;
public UInt32 dwError;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = RAS_MaxDeviceType + 1)]
public string szDeviceType;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = RAS_MaxDeviceName + 1)]
public string szDeviceName;
}
function info on msdn at http://msdn.microsoft.com/en-us/library/ms897100.aspx
public static RASCONNSTATUS GetConnectStatus(IntPtr hrasconn)
{
RASCONNSTATUS status = new RASCONNSTATUS();
status.dwSize = (UInt32)Marshal.SizeOf(status);
RasGetConnectStatus(hrasconn, ref status);
return status;
}