I'm am trying to write a RAS Component that lists the Available RAS
Connections on the current machine, I have got as far as
getting the Connections using the RasEnumEntry API
Getting the Entry Properties for Each entry using RASGetEntryProp erties
API
Getting the Dial Parameters using the RasGetEntryDial Params API
I am Getting unstuck when it comes to actually dial the Ras Connection. When
I actually Call the RASDIAL API I always Get Error 632 (Structure Size
Invalid) any Pointers that may be helpful to me would be appreciated.
Here is what I have :
*Ras Dial API Call*
<DllImport("Ras Api32.dll", CharSet:=CharSe t.Auto)> _
Public Function RasDial( _
ByRef lprasDialExtens ions As RASDIALEXTENSIO NS, _
ByVal lpszPhoneBook As String, _
ByRef lpRasDialParams As RASDIALPARAMS, _
ByVal dwNotifierType As Int32, _
ByVal hwndNotifier As System.Delegate , _
ByRef lphRasConn As IntPtr) As Int32
End Function
The threeStructures are Below:
<StructLayout(L ayoutKind.Seque ntial, CharSet:=CharSe t.Auto)> _
Public Structure RASDIALPARAMS
Public dwSize As Integer
<MarshalAs(Unma nagedType.ByVal TStr,
sizeconst:=CInt (RASFieldSizeCo nstants.RAS_Max EntryName + 1))> _
Public szEntryName As String
<MarshalAs(Unma nagedType.ByVal TStr,
sizeconst:=CInt (RASFieldSizeCo nstants.RAS_Max PhoneNumber + 1))> _
Public szPhoneNumber As String
<MarshalAs(Unma nagedType.ByVal TStr,
sizeconst:=CInt (RASFieldSizeCo nstants.RAS_Max CallbackNumber + 1))> _
Public szCallBackNumbe r As String
<MarshalAs(Unma nagedType.ByVal TStr,
sizeconst:=CInt (RASFieldSizeCo nstants.UNLEN + 1))> _
Public szUsername As String
<MarshalAs(Unma nagedType.ByVal TStr,
sizeconst:=CInt (RASFieldSizeCo nstants.PWLEN + 1))> _
Public szPassword As String
<MarshalAs(Unma nagedType.ByVal TStr,
sizeconst:=CInt (RASFieldSizeCo nstants.DNLEN + 1))> _
Public szDomain As String
#If OSVER > 4 Then
Public dwSubEntry As Integer
Public dwCallBackID As Integer
#End If
'RASDIALEXTENSI ONS
<StructLayout(L ayoutKind.Seque ntial, CharSet:=CharSe t.Auto)> _
Public Structure RASDIALEXTENSIO NS
Public dwSize As Integer
Public dwfOptions As Integer
Public hwndParent As Integer
Public Reserved As Integer
Public Reserved1 As Integer
Public RasEapINfo As RasEapINfo
End Structure
'RASEAPINFO
<StructLayout(L ayoutKind.Seque ntial, charset:=CharSe t.Auto)> _
Public Structure RASEAPINFO
Public dwSizeofEAPInfo As Int32
Public pbEapInfo As Int32
End Structure
Here is the Code so far >
Public Function Connect() As Boolean
Dim x As Integer 'Return from API Calls
Dim hconn As IntPtr 'Connection Handle
Dim bln As Boolean 'Password Stored
mParams = New RASDIALPARAMS
With mParams
.dwSize = Marshal.SizeOf( GetType(RASDIAL PARAMS))
.szEntryName = mEntryName
End With
x = RasGetEntryDial Params(mPhonebo ok, mParams, bln)
hconn = Nothing
x = RasDial(Nothing , Nothing, mParams, Nothing, Nothing, hconn)
End Function