Reputation: 2428
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
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