|
-
Sep 5th, 2009, 11:43 PM
#1
Thread Starter
Member
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!
-
Sep 7th, 2009, 04:22 AM
#2
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.
-
Sep 7th, 2009, 07:33 AM
#3
Thread Starter
Member
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!
-
Sep 7th, 2009, 07:43 AM
#4
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.
-
Sep 7th, 2009, 07:46 AM
#5
Thread Starter
Member
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*
-
Sep 7th, 2009, 07:52 AM
#6
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
-
Sep 7th, 2009, 08:16 AM
#7
Thread Starter
Member
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!
-
Sep 7th, 2009, 08:29 AM
#8
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|