I think if you found out the currently logged in user, you would get your result.
If there is no logged in user, then you're logged out.
I suppose if someone LOCKS the pc, then they are still logged in. Hmm. Maybe cycling through the running proccess (System.Diagnostics.Process.GetCurrentProcess()) and looking at the user names of running programs could be used as well.
For currently logged on user, I would take a look at:
-
System.Security.Principal.WindowsIdentity.GetCurrent()
-
and it's overloads to see what is correct usage.
There may in fact be a much easier solution, but I can't think of it right now.
I also found this:
http://www.thescripts.com/forum/thread536508.html