RASDIALPARAMS - diff size expected between GetRasEntryDialParams and RasDial ??

G

Guest

Hi

I have a app which needs to make an internet connection - I'm using the RAS API to do this..

I have the RasEnumEntries working ok - finds the entry I need and also the RasGetEntryDialParams - retrieve the data for the entry I want to dial - BUT when I pass this structure to RasDial I get a 632 error (structure is incorrect size)...
It's got me stumped - why do they expect different sizes of the same structure ??

Any help appreciated - TIA .. Ke

Dec'

Public Const RAS_MaxEntryName As Int32 = 25
Public Const RAS_MaxPhoneNumber As Int32 = 12
Public Const RAS_MaxCallbackNumber As Int32 = 12
Public Const RAS_MaxUserName As Int32 = 25
Public Const RAS_MaxPassword As Int32 = 25
Public Const RAS_MaxDomain As Int32 = 1
Public Const MAX_PATH As Int32 = 26

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure RASDIALPARAM
Public Size As Int3
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=RAS_MaxEntryName + 1)> Public EntryName As Strin
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=RAS_MaxPhoneNumber + 1)> Public PhoneNumber As Strin
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=RAS_MaxCallbackNumber + 1)> Public CallBackNumber As Strin
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=RAS_MaxUserName + 1)> Public UserName As Strin
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=RAS_MaxPassword + 1)> Public Password As Strin
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=RAS_MaxDomain + 1)> Public Domain As Strin
Public SubEntry As Int3
Public CallBackID As Int3
End Structur

Public Declare Auto Function RasGetEntryDialParams Lib "rasapi32.dll" (
ByVal PhoneBook As String,
ByRef DialParams As RASDIALPARAMS,
ByRef Password As Int32) As Int3

Public Declare Auto Function RasDial Lib "rasapi32.dll" (
ByRef RasDialExtensions As Int32,
ByVal PhoneBook As String,
ByRef DialParams As RASDIALPARAMS,
ByVal NotifierType As Int32,
ByRef Notifier As Int32,
ByRef hRasConnection As Int32) As Int3

Code..

Private Function GetRasDialParams(ByVal EntryName As String) As Boolea

Dim params As New RASDIALPARAM
Dim rtn As Int32, bResult As Boolean = Fals
params.Size = Marshal.SizeOf(params
params.EntryName = EntryNam
Dim bFlag As Int3
Tr
rtn = RasGetEntryDialParams(vbNullString, params, bFlag
If rtn = 0 The
MsgBox(RasDial(Nothing, vbNullString, params, 0, Nothing, hRASHandle)) ' returns 632 for some reason..
bResult = Tru
End I
Catch ex As Exceptio
MsgBox(ex.ToString
End Tr

Return bResul

End Function
 
M

Mattias Sjögren

Ken,
It's got me stumped - why do they expect different sizes of the same structure ???

I don't think the problem is with the RASDIALPARAMS struct here
(except that you should change its CharSet to Auto), but with the
other parameters. Try to change your declaration to

Public Declare Auto Function RasDial Lib "rasapi32.dll" ( _
ByVal RasDialExtensions As IntPtr, _
ByVal PhoneBook As String, _
ByRef DialParams As RASDIALPARAMS, _
ByVal NotifierType As Int32, _
ByVal Notifier As IntPtr, _
ByRef hRasConnection As IntPtr) As Int32



Mattias
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top