I'm having problems using RasEnumConnections.
[DllImport("rasapi32.dll", CharSet=CharSet.Auto)]
public static extern int RasEnumConnections(ref RASCONN[] Connections, ref
int dwSize, out int TotalConnections);
[StructLayout(LayoutKind.Sequential, Pack=4, CharSet=CharSet.Auto)]
public struct RASCONN {
public int dwSize;
public IntPtr hrasconn;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst=RAS_MaxEntryName + 1)]
public string szEntryName;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst=RAS_MaxDeviceType + 1)]
public string szDeviceType;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst=RAS_MaxDeviceName + 1)]
public string szDeviceName;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst=MAX_PATH)]
public string szPhonebook;
public int dwSubEntry;
public Guid guidEntry;
public int dwSessionId;
public int dwFlags;
public Guid luid;
}
That's how I have it all defined.
RASCONN[] rascon = new RASCONN[]{};
int dwSize = Marshal.SizeOf(typeof(RASCONN));
int TotalConnections;
int Result = RasEnumConnections(ref rascon, ref dwSize, out
TotalConnections);
But I'm getting an "Invalid size" message (the result) when I call it as I
do immediately above.
Anyone have any idea what I'm doing wrong?
Thanks!
James Hancock
Adam Tibi - 29 Apr 2004 19:30 GMT
Hi James and sorry for late reply, I hope it is not too late
You did not specify [In(), Out()] for the RASCONN[] argument.
This is the API prototype in VB.NET
<DllImport("RASAPI32")> _
Friend Shared Function RasEnumConnections(<[In](), Out()> ByVal lpRasCon()
As RASCONN, ByRef lpcb As Integer, ByRef lpcConnections As Integer) As
Integer
End Function
This is tested and working :)
> I'm having problems using RasEnumConnections.
>
[quoted text clipped - 36 lines]
> Thanks!
> James Hancock
James Hancock - 30 Apr 2004 21:21 GMT
Great! Thanks!
> Hi James and sorry for late reply, I hope it is not too late
>
[quoted text clipped - 52 lines]
>> Thanks!
>> James Hancock