473,804 Members | 2,225 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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
"SystemAcco unt" rights and "Allow service to interact with desktop" but I
know it leaves the system vulnerable to maliciousness.

Is there a way to programmaticall y 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 1749
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
Nov 17 '05 #2

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

Similar topics

0
1350
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 except anything to do with drivers. I have added a reference to the PRNADMIN.DLL from MS Windows 2003 Tool Kit into my project to do all of the above, but when i try to enumerate printers i received the following error....
7
3170
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
1541
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 "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
4
6999
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 except anything to do with drivers. I have added a reference to the PRNADMIN.DLL from MS Windows 2003 Tool Kit into my project to do all of the above, but when i try to enumerate printers i received the following error....
0
951
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 domain, the computer names are insignificant (Dell service tag), so we include the user's name in the comments (computer description). Using WinXP, the explorer displays this comment when viewing in Tiles or Details view. How do I get this...
1
1137
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 ported my code over to the service, then it stopped working. I saw that this is due to a service running on a different "non-interactive" dekstop than a regular user desktop. How would I get a service to just get the window handles of the...
5
1351
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; FILE* fp; struct _HwndProcStruct* locHPStruct;
0
1381
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 these printers to a combobox so that the user can pick a printer, this code is : ====================================== Dim pkInstalledPrinters As String ' Find all printers installed
4
2843
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 factory for component with CLSID {9BA05972-F6A8-11CF-A442-00A0C90A8F39} failed due to the following error: 8007000e. Here's the code I use to retrieve the list of IE windows. Are there better solutions that prevent the exceptions?
0
9715
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10603
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10353
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10099
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9176
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6869
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5675
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4314
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3836
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.