Click here to Skip to main content
15,885,641 members
Please Sign up or sign in to vote.
4.50/5 (2 votes)
See more:
How can I verify whether or not a VPN connection has been made?

I found a registry key showing the network name, but I'm not sure where I can check whether or not its connected.

C++
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\HomeGroup\NetworkLocations\Work


I want to check whether it's connected, so that I get an error message back much faster if there is no connection rather than waiting for a timeout.
Posted

You should be able to ping the network and see if the connection is established or not. Google search returns many results, one of them was this[^] and you can take a look at the .net RAS at http://dotras.codeplex.com/[^].
 
Share this answer
 
Comments
T2102 29-Apr-11 17:38pm    
Pinging is the same problem; there is a timeout involved. I run a spreadsheet that might have zero database calls to a remote server or could have hundreds. Checking this with a registry key or something similar is ideal since the timeout delay can be huge.
I think this all comes down to being able to access the remote server, so a timeout is unavoidable. Maybe you can try to access the server in a separate thread, so that it's not so noticeable?
 
Share this answer
 
v2
Comments
T2102 9-May-11 11:22am    
To know if the call is successful, I can use
<pre>return !system("ping network_DB");</pre>

However, this shows a dialog. I know how to use ShellExecuteEx and ShellExecute to execute the code above with a dialog hidden, but I am not sure how to check whether an error was encountered.

Do you know how I can do this without outputting the results to a file.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900