I have the following WinRT code which works fine to discover active VPN Profiles:
VpnManagementAgent vpn;
auto profiles = vpn.GetProfilesAsync().get();
wprintf(L"Found %d profiles\n", profiles.Size());
for (auto vp : profiles)
{
wprintf(L"Found profile %s\n", vp.ProfileName().c_str());
}
I would like to check the ConnectionStatus but this is not available on the IVpnProfile interface. I have tried adding the following to no avail as ConnectionStatus is available in the concrete VpnPlugInProfile and VpnNativeProfile classes:
VpnPlugInProfile pp = vp.as<VpnPlugInProfile>();
if (pp != nullptr)
wprintf(L"ConnectionStatus = %d\n", pp.ConnectionStatus());
This just give an Invalid Handle error.
Is there a way of getting ConnectionStatus from IVpnProfile?
IVpnProfile
- simply query fromWindows.Networking.Vpn.VpnNativeProfile
a new profile, assign to it your newly acquired profile name and then query for VpnNativeProfile2 which has aget_ConnectionStatus
. I have C code which do it and I tested it if someone is interested (reason I'm posting this as comment and not answer). The more complex task I am unable to perform is acquire the servers to which a connection is currently connected to. – Commissariatrasphone.pbk
file inside your%userprofile%\AppData\Local\Packages\%fullpackagename%\LocalState
. Because if you have so -IVpnProfile
can be queried forIVpnNativeProfile
. The program is designed clever and in case of missingrasphone.pbk
inside your app LocalState it'll only fill the profile name and forbid further queries to nativeprofile. God bless Microsoft. However I've found this with some heavy reverse - engineering - it would be helpful if instead there was a good documentation as well as good code. – Commissariat