Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Interop / April 2004

Tip: Looking for answers? Try searching our database.

RasEnumConnections

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
James Hancock - 22 Apr 2004 17:20 GMT
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

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.