Eugenio Miró
Eugenio Miró

Reputation: 2428

Accessing TCP/IP routing information from a .NET application

I need to check if a TCP/IP route already exists from my application and add the route if it doesn't. Now I'm running the

route add <destination network ip address> MASK <mask> <gateway ip address>

with a Process.Start() and that's fine for me. However, as I'm elevating the route command with a "runas" verb, I need to check first if the route is already configured in order to avoid running the elevated command again.

Does anybody know how to get the TCP/IP routing information using .NET Framework? (I don't want to run route print with a Process.Start() and parse the output)

Thank you in advance!!

Upvotes: 3

Views: 1525

Answers (1)

Eric
Eric

Reputation: 19863

I think you have to rely on IpHlpApi.Dll

Here is a tutorial on how to use it with P/Invoke

Upvotes: 1

Related Questions