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 / December 2004

Tip: Looking for answers? Try searching our database.

MprAdminInterfaceEnum

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Juan Ignacio Gelos - 30 Nov 2004 14:27 GMT
Hi,

   Trying to enumerate interfaces on RRAS.
   Bellow is what I have so far. The MprAdminInterfaceEnum has an
lplpbBuffer out parameter which is a buffer that will contain an array of
MPR_INTERFACE_0's.
   I want to access the wszInterfaceName for each interface. How should I
marshal this parameter?

Thanks,
Juan

/// <summary>
 /// The MprAdminInterfaceEnum function enumerates all the interfaces on a
specified server.
 /// </summary>
 /// <param name="hMprServer">[in] Handle to the router on which to execute
this call. Obtain this handle by calling MprAdminServerConnect.</param>
 /// <param name="dwLevel">[in] Specifies the level of information passed
in lpBuffer. Must be zero.</param>
 /// <param name="lplpbBuffer">[out] Pointer to a pointer variable that
points to an array of MPR_INTERFACE_0 structures on successful return. This
memory must be freed by a call to the MprAdminBufferFree function.</param>
 /// <param name="dwPrefMaxLen">[in] Specifies the preferred maximum length
of returned data (in 8-bit bytes). If this parameter is -1, the buffer
returned is large enough to hold all available information. </param>
 /// <param name="lpdwEntriesRead">[out] Pointer to a DWORD variable. This
variable receives the total number of interfaces that were enumerated from
the current position in the enumeration.</param>
 /// <param name="lpdwTotalEntries">[out] Pointer to a DWORD variable. This
variable receives the total number of interfaces that could have been
enumerated from the current resume position.</param>
 /// <param name="lpdwResumeHandle">[in] Pointer to a DWORD variable. This
variable specifies a resume handle that can be used to continue the
enumeration. The handle should be zero on the first call, and left unchanged
on subsequent calls. If the return code is ERROR_MORE_DATA then the call can
be re-issued using the handle to retrieve more data. If on return, the
handle is NULL, the enumeration cannot be continued. For other types of
error returns, this handle is invalid.
 /// This parameter is optional. If the calling application specifies NULL
for this parameter, the function does not return a resume handle.</param>
 /// <returns></returns>
 /// <remarks><code>
 /// DWORD APIENTRY
 /// MprAdminInterfaceEnum(
 ///     IN      MPR_SERVER_HANDLE       hMprServer,
 ///     IN      DWORD                   dwLevel,
 ///     OUT     LPBYTE *                lplpbBuffer,
 ///     IN      DWORD                   dwPrefMaxLen,
 ///     OUT     LPDWORD                 lpdwEntriesRead,
 ///     OUT     LPDWORD                 lpdwTotalEntries,
 ///     IN      LPDWORD                 lpdwResumeHandle        OPTIONAL
 /// );
 /// </code></remarks>
 [DllImport("Mprapi.dll", CharSet = CharSet.Ansi)]
 public static extern int MprAdminInterfaceEnum(
  IntPtr hMprServer,
  [MarshalAs(UnmanagedType.U4)]
     int dwLevel,

     ref MPR_INTERFACE_0[] lplpbBuffer,
     int dwPrefMaxLen,
  ref int lpdwEntriesRead,
  ref int lpdwTotalEntries,
  ref int lpdwResumeHandle
  );

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
public struct MPR_INTERFACE_0
{
 [MarshalAs(UnmanagedType.ByValTStr, SizeConst =
MprApi.MAX_INTERFACE_NAME_LEN+1)]
 public string wszInterfaceName;
 public IntPtr hInterface;
 public bool fEnabled;
 public ROUTER_INTERFACE_TYPE dwIfType;
 public ROUTER_CONNECTION_STATE dwConnectionState;
 public UnreachabilityReasons fUnReachabilityReasons;
 public int dwLastError;
}
Juan Ignacio Gelos - 01 Dec 2004 07:54 GMT
Found the answer here:
http://www.dotnetinterop.com/faq/?q=CalleeAllocatedStructArray

Regards,
Juan

> Hi,
>
[quoted text clipped - 76 lines]
>   public int dwLastError;
>  }
Juan Ignacio Gelos - 01 Dec 2004 07:56 GMT
Also, in case anyone else is looking for info on MprAdmin, it uses
Unicode... so all the DllImport's should use CharSet = CharSet.Unicode

> Hi,
>
[quoted text clipped - 76 lines]
>   public int dwLastError;
>  }

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.