Results 1 to 8 of 8

Thread: Alert when a process opens a new connections

  1. #1

    Thread Starter
    Member
    Join Date
    Aug 2009
    Posts
    39

    Cool Alert when a process opens a new connections

    Hey there,

    I'm writing a program that notifies the user when process X.exe starts\receives a new TCP connection.

    Is the only way to issue a full 'netstat' and then select the entries relating to that specific application or is there a better way?

    Can someone give me some pointers?

    Thanks!

  2. #2
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    Re: Alert when a process opens a new connections

    Unless this X.exe has any APIs you can use to check such things then I'm fairly sure that netstat is the only option you have. I'd be interested to see if others have any better suggestions though.
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


  3. #3

    Thread Starter
    Member
    Join Date
    Aug 2009
    Posts
    39

    Re: Alert when a process opens a new connections

    What would the best way to do a netstat on vb .net be? I've been looking around but most of the information I found is from VB6 and mostly code... Those tutorials are certainly hard to find!

  4. #4
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    Re: Alert when a process opens a new connections

    You would call the netstat executable and then redirect the command window output to your vb.net program and read whatever information you need from it. I've never actually tried it but I know there are at least a couple of tutorials on how to do this on this forum alone. Just search for redirect console output or something like that and I'm sure you will find it.
    So then you can either read the info that netstat produces and extract the relevant bits in your program or you you can make it use the native 'find' functionality in command prompt to execute the netstat command and return only data that matches what you are looking for. Again, never had to do that so cant tell you exactly what to do but I know its possible. Personally I would much rather do it all through the vb program as you have more control and more powerful string searching functions.
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


  5. #5

    Thread Starter
    Member
    Join Date
    Aug 2009
    Posts
    39

    Re: Alert when a process opens a new connections

    Thanks for the quick reply Chris.

    Yes, I ment through the vb program. I called it 'netstat' as in short for 'the list of all active connections at a time'. Not really intending to run a cmd on the background and using it's output.

    So, to do this through vb code, I'd have to....? *wink*

  6. #6
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    Re: Alert when a process opens a new connections

    Well I think thats the only option you have. There might be some way to do it with unmanaged code (Windows APIs) but it would far more trouble than its worth if you ask me. The netstat / cmd window would be hidden, the user would not see anything, you just use it to execute the netstat.exe and then your program reads the output.
    Last edited by chris128; Sep 7th, 2009 at 07:52 AM. Reason: typo
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


  7. #7

    Thread Starter
    Member
    Join Date
    Aug 2009
    Posts
    39

    Re: Alert when a process opens a new connections

    There is a way; At least I believe I came across some source code for a VB6 version of it at some point during my research but the code was quite messy. I'll try to find it again and see if there's any benefit to it, otherwise netstat it is.

    Thanks for the help!

  8. #8
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    Re: Alert when a process opens a new connections

    No worries, if you do find a way to do it through managed code then post it up here as I'm sure it will come in handy for a lot of people and I would be interested to see how you can do it
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width