Windows – detecting a VPN connection in Windows

cvpnwindows

Is there any way to detect if I am connected to a VPN using standard windows APIs in C?

Basically I have a client that has to sync with a server but only if the VPN is connected. This could be a standard windows VPN client or a Citrix.

Is RAS helpful here?

thank you, code is appreciated.

EDIT:
to make it clearer.

This is a client that will run on our customer's computer and they set the VPN and server however they want. So I wanted to know if windows keeps a setting somewhere that I can read via an API or registry or WMI or whatever that can tell me VPN: no or yes and if yes the info.

Best Answer

With the VPN I suspect you able to access resources that don't exists otherwise. So you could PING test a server on the VPN network. ICMP is the protocol for ping.

Here is some examples: http://www.alhem.net/project/ex10/index.html