473,406 Members | 2,281 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Enumerating windows from an NT service

Hi all,

The service I have written can not enumerate the current user's desktop
windows when running as a service.

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.

Is there a way to programmatically enumerate through the current desktop
windows when running as a service?

Also, How I can know the name of the user when he logged?

Thanks in advance

Nov 17 '05 #1
1 1736
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
Nov 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Brett Mostert | last post by:
Hi, I need to be able to Enumerate through Printer Drivers, ports, printers and so fourth. And even add printers, ports, and drivers and setup printers. Sofar i can do all of the following...
7
by: Rohan Ranade | last post by:
I am trying to implement a crawler in C# that scans all the shared folders in remote computers in a windows network. Are there classes in .NET to do this directly? Please help. Thank You. Rohan
1
by: José Achig | last post by:
Hi all, The service I have written can not enumerate the current user's desktop windows when running as a service. I read where one solution to this is to install the service with...
4
by: Brett Mostert | last post by:
Hi, I need to be able to Enumerate through Printer Drivers, ports, printers and so fourth. And even add printers, ports, and drivers and setup printers. Sofar i can do all of the following...
0
by: wifetalks | last post by:
I'm enumerating the computers in the domain to a listview control on my form, but how do I include the comments. Like what you would see in Windows Explorer when you browse the domain. On our...
1
by: Jay | last post by:
Hey There, I am trying to get a list of the open windows from a Windows Service. My initial code was written in a regular server and the window listing function EnumWindows worked fine, but when I...
5
by: Jay | last post by:
Hey There, I have this function that is called through EnumWindows: BOOL CALLBACK EnumOpenWindows(HWND hwnd, LPARAM lParam) { DWORD dwID; LPDWORD dwID2; LPDWORD currProcId;...
0
by: Simon Verona | last post by:
I have a problem on a specific pc... On the PC, in control panel Printers there are a few printers listed, including a printer that is a network share on another PC. I have some code that adds...
4
by: nagar | last post by:
On certain occasions I get COM exceptions errors when enumerating the Windows Explorer active windows Some customers reported the error System.OutOfMemoryException: Retrieving the COM class...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.