none
NM API - Recommended approach for a C# developer? (any C# example?) RRS feed

  • Question

  • Hi,

    If one is familiar with C# (but not C++) so I'm after advice re which approach I would be best taking here for direct usage of the NM API from a Windows application?  I would want to stick with C# for the bulk of the UI.

    Are there any real C# wrappers so to speak for the API?  I don't see any DLL's in the download.  So doesn't this mean (although there is a page in the help file on working with C# Managed code) that one really has to undertake the core interactions with the NM API via C++?  In which case you would effectively need to build one C++ project that calls the API and exposes your hopefully higher level methods via this assembly/DLL back to your UI C# project which would use PInvoke?  

    If there is a way to call the API directly via C# are there any good (complete) examples of this?   That is of C# code that doing captures within a C# application (i.e. no use of the Network Monitor UI itself)?

     

    thanks

     

    Thursday, July 15, 2010 2:55 AM

Answers

  • Hi,

    In the API directory of the installation of Network Monitor, we have a NetmonAPI.cs file.  This is a PInvoke wrapper for C# which will let you call the Netmon API directly from C#.  There's a few caveats to using it such as keeping handles around, closing handles, and some buffer managment, but we do have samples of this.

    The best place to look at getting started is the Top Users Expert and the Expert SDK.  You can also see the very very bottom of this thread with an example from me on doing a live capture in C#: http://nmparsers.codeplex.com/Thread/View.aspx?ThreadId=54919.

    Hope that gives you a good start.  Keep us posted if you have more questions, we're happy to help.


    Michael Hawker | Program Manager | Network Monitor
    • Marked as answer by callagga Friday, July 16, 2010 10:21 PM
    Thursday, July 15, 2010 5:28 PM
    Moderator