José Achig <jo*******@hotmail.com> wrote in message
news:Or**************@TK2MSFTNGP11.phx.gbl...
The service I have written can not enumerate the current user's desktop
windows when running as a service.
In general services run on an invisible, non-interactive desktop which is
different from the one with which you (and your user) are familiar.
I read where one solution to this is to install the service with
"SystemAccount" rights and "Allow service to interact with desktop" but I
know it leaves the system vulnerable to maliciousness.
Right. That's a bad idea.
Is there a way to programmatically enumerate through the current desktop
windows when running as a service?
Take a look here:
http://msdn.microsoft.com/library/de...us/dllproc/bas
e/interacting_with_the_user_in_a_service.asp
Also, How I can know the name of the user when he logged?
GetUserName() returns the name of the security principal associated with the
current thread. In an application, that's what you want. In a service, it
usually is not. Often services that need to know who their clients are use
an "impersonable" IPC mechanism (named pipes, RPC, etc) and "impersonation"
so that the server service can "assume the identity" of the client
application. You can start reading about that here:
http://msdn.microsoft.com/library/de...us/security/se
curity/client_impersonation.asp
For more details, I recommend Jeffrey Richter's book "Programming Server
Side Applications For Microsoft Windows 2000".
Regards,
Will