José Achig <jo*******@hotm ail.com> wrote in message
news:Or******** ******@TK2MSFTN GP11.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
"SystemAcco unt" 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 programmaticall y 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_wit h_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 "impersonab le" IPC mechanism (named pipes, RPC, etc) and "impersonat ion"
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_imperson ation.asp
For more details, I recommend Jeffrey Richter's book "Programmin g Server
Side Applications For Microsoft Windows 2000".
Regards,
Will