I write because I could not find any answers on the internet. I am writing a project in C# on WLANs (using managed C++). Considering a given interface (network card) connected to a network, there is a way to know how long the interface is connected to the network?
In other words, I would like to know the time that you see in the connection information in Windows 7 (trayicon -> Open Network and Sharing Center).
I hope I was clear and I apologize for my poor English.
May be you are looking for getiftable() function of windows. It is a winapi function that provides all the information related to a particular network interface
Here is a good example of it
Here is the explanation of the entire structure
According to msdn
dwLastChange
When connected, it will give you the time since it is so - i.e. in connected state.
Here is the declaration of this function in c#
You can use pinvoke.net for further help on declaration.
It seems like there is an easy way in .Net framework but not as expected
http://msdn.microsoft.com/en-us/library/system.net.networkinformation.operationalstatus.aspx
Check out the way they have implemented network status detection. My assumption is, you will have to record the time in your application since the status last changed.
I also practically tested the getifrow function and to my disappointment, it always returns zero on Win7, don't know about other platforms.