Hi,
Not really sure if this will work but maybe you could use the
win32_operatingsystems numberofusers property. Add a reference to
system.management
Dim moReturn As Management.ManagementObjectCollection
Dim moSearch As Management.ManagementObjectSearcher
Dim mo As Management.ManagementObject
moSearch = New Management.ManagementObjectSearcher("Select * from
Win32_OperatingSystem")
moReturn = moSearch.Get
For Each mo In moReturn
Try
Trace.WriteLine(mo("NumberOfUsers").ToString)
Catch ex As System.Exception
Trace.WriteLine(ex.ToString)
End Try
Next
http://msdn.microsoft.com/library/de...tingsystem.asp
Ken
-----------------
"Jarod_24" <ja******@hotmail.com> wrote in message
news:43**********************@titian.nntpserver.co m...
Im writing a power saving service that runs on a computer and i need to
see if a user is logged in on the machine that the service itself is
installed on.
No active directory. Basically, if there is a user logged in, the service
will for example do a Hibernate, but if there is no user logged in, then
it will to a Shutdown.
Im using VS2003.
"Ken Tucker [MVP]" <Ke**********@discussions.microsoft.com> wrote in
message news:88**********************************@microsof t.com... Hi,
Are you looking to see who the machine is logged in as or if a
user is logged into your active directory? What version of vb are you
using?
Ken
---------------------
"Jarod_24" wrote:
How do a windows-service detect whether a user is logged or not on a
computer?
So far i've found nothing in the windows api or any code examples that
will allow me to figure this out.
The solution i have today is to use Diagnostics.Process.GetProcesses and
then iterate through the array i get and look for
explorer.exe
Explorer.exe is not loaded when a user is logged out of a computer.
I found this on winlogon states:
http://msdn.microsoft.com/library/de...gon_states.asp
but i cant see any api methods that will return the state that winlogon
is actually in...
the only solution getting close to this issue i found at
http://weblogs.asp.net/ralfw/archive.../04/47388.aspx but that
dosent
work.