473,548 Members | 2,593 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Finding currently visible desktop

How can I find the currently visible desktop? By calling EnumWindowStati ons
and EnumDesktops I get a list of all available desktops. But is there a way
to figure out which one of them is currently visible?

I've tried to find the visible desktop by comparing the desktop handle,
returned by the OpenDesktop function, to the desktop handle received by
calling OpenInputDeskto p. The result is that the default desktop is always
the one currently receiving user input.
But by using the default desktop my window always shows up at the desktop of
the first user logged on to the system after reboot. No matter if this
desktop is currently visible or not!

As a second attempt I've called GetUserObjectIn formation for each desktop
and checked the visible flag. But the result is there is no visible desktop
at all !?

What am I doing wrong? Or what is the right way to search for the currently
visible desktop?
Sep 6 '06 #1
15 3014
Take a look at this blog entry, which explains why there is no "currentyl
visible desktop"

http://blogs.msdn.com/oldnewthing/ar...22/712677.aspx

--
SvenC

"Mephisto18 7" <Me*********@di scussions.micro soft.comwrote in message
news:40******** *************** ***********@mic rosoft.com...
How can I find the currently visible desktop? By calling
EnumWindowStati ons
and EnumDesktops I get a list of all available desktops. But is there a
way
to figure out which one of them is currently visible?

I've tried to find the visible desktop by comparing the desktop handle,
returned by the OpenDesktop function, to the desktop handle received by
calling OpenInputDeskto p. The result is that the default desktop is always
the one currently receiving user input.
But by using the default desktop my window always shows up at the desktop
of
the first user logged on to the system after reboot. No matter if this
desktop is currently visible or not!

As a second attempt I've called GetUserObjectIn formation for each desktop
and checked the visible flag. But the result is there is no visible
desktop
at all !?

What am I doing wrong? Or what is the right way to search for the
currently
visible desktop?

Sep 6 '06 #2
Okay, let me rephrase my question more precisely:
I want the desktop currently visible at the display connected directly to
the computer. No remote or inactive desktops. And if there's more then one,
fine, which one of them are visible?
The main thing is: I need to find the desktop which currently has full
access to the graphic adapters hardware acceleration.

"SvenC" wrote:
Take a look at this blog entry, which explains why there is no "currentyl
visible desktop"

http://blogs.msdn.com/oldnewthing/ar...22/712677.aspx

--
SvenC

"Mephisto18 7" <Me*********@di scussions.micro soft.comwrote in message
news:40******** *************** ***********@mic rosoft.com...
How can I find the currently visible desktop? By calling
EnumWindowStati ons
and EnumDesktops I get a list of all available desktops. But is there a
way
to figure out which one of them is currently visible?

I've tried to find the visible desktop by comparing the desktop handle,
returned by the OpenDesktop function, to the desktop handle received by
calling OpenInputDeskto p. The result is that the default desktop is always
the one currently receiving user input.
But by using the default desktop my window always shows up at the desktop
of
the first user logged on to the system after reboot. No matter if this
desktop is currently visible or not!

As a second attempt I've called GetUserObjectIn formation for each desktop
and checked the visible flag. But the result is there is no visible
desktop
at all !?

What am I doing wrong? Or what is the right way to search for the
currently
visible desktop?


Sep 6 '06 #3
Hi,

"Mephisto18 7" <Me*********@di scussions.micro soft.comwrote in message
news:04******** *************** ***********@mic rosoft.com...
Okay, let me rephrase my question more precisely:
I want the desktop currently visible at the display connected directly to
the computer. No remote or inactive desktops. And if there's more then
one,
fine, which one of them are visible?
The main thing is: I need to find the desktop which currently has full
access to the graphic adapters hardware acceleration.
hmm - can a desktop have full access to a GPU or parts of a GPU, sorry don't
know.

--
SvenC
"SvenC" wrote:
>Take a look at this blog entry, which explains why there is no "currentyl
visible desktop"

http://blogs.msdn.com/oldnewthing/ar...22/712677.aspx

--
SvenC

"Mephisto187 " <Me*********@di scussions.micro soft.comwrote in message
news:40******* *************** ************@mi crosoft.com...
How can I find the currently visible desktop? By calling
EnumWindowStati ons
and EnumDesktops I get a list of all available desktops. But is there a
way
to figure out which one of them is currently visible?

I've tried to find the visible desktop by comparing the desktop handle,
returned by the OpenDesktop function, to the desktop handle received by
calling OpenInputDeskto p. The result is that the default desktop is
always
the one currently receiving user input.
But by using the default desktop my window always shows up at the
desktop
of
the first user logged on to the system after reboot. No matter if this
desktop is currently visible or not!

As a second attempt I've called GetUserObjectIn formation for each
desktop
and checked the visible flag. But the result is there is no visible
desktop
at all !?

What am I doing wrong? Or what is the right way to search for the
currently
visible desktop?



Sep 6 '06 #4
The problem is. On remote desktops there is only software rendering
available. And on invisible desktops the graphic driver is not performing any
rendering at all because there is no visible window.
So I need to get access to a visible desktop in order to get access to the
graphical hardware

"SvenC" wrote:
Hi,

"Mephisto18 7" <Me*********@di scussions.micro soft.comwrote in message
news:04******** *************** ***********@mic rosoft.com...
Okay, let me rephrase my question more precisely:
I want the desktop currently visible at the display connected directly to
the computer. No remote or inactive desktops. And if there's more then
one,
fine, which one of them are visible?
The main thing is: I need to find the desktop which currently has full
access to the graphic adapters hardware acceleration.

hmm - can a desktop have full access to a GPU or parts of a GPU, sorry don't
know.

--
SvenC
"SvenC" wrote:
Take a look at this blog entry, which explains why there is no "currentyl
visible desktop"

http://blogs.msdn.com/oldnewthing/ar...22/712677.aspx

--
SvenC

"Mephisto18 7" <Me*********@di scussions.micro soft.comwrote in message
news:40******** *************** ***********@mic rosoft.com...
How can I find the currently visible desktop? By calling
EnumWindowStati ons
and EnumDesktops I get a list of all available desktops. But is there a
way
to figure out which one of them is currently visible?

I've tried to find the visible desktop by comparing the desktop handle,
returned by the OpenDesktop function, to the desktop handle received by
calling OpenInputDeskto p. The result is that the default desktop is
always
the one currently receiving user input.
But by using the default desktop my window always shows up at the
desktop
of
the first user logged on to the system after reboot. No matter if this
desktop is currently visible or not!

As a second attempt I've called GetUserObjectIn formation for each
desktop
and checked the visible flag. But the result is there is no visible
desktop
at all !?

What am I doing wrong? Or what is the right way to search for the
currently
visible desktop?


Sep 6 '06 #5
"Mephisto18 7" <Me*********@di scussions.micro soft.comwrote in message
news:40******** *************** ***********@mic rosoft.com...
How can I find the currently visible desktop? By calling
EnumWindowStati ons
and EnumDesktops I get a list of all available desktops. But is there a
way
to figure out which one of them is currently visible?
If you have an hwnd that is on the desktop you are looking for, you can do a
GetWindowThread ProcessId() to get the thread id of it, then use
GetThreadDeskto p() to get an HDESK of that thread.

-- David
http://www.dcsoft.com
Sep 6 '06 #6
The problem is. On remote desktops there is only software rendering
available. And on invisible desktops the graphic driver is not performing
any
rendering at all because there is no visible window.
So I need to get access to a visible desktop in order to get access to the
graphical hardware
But that is never going to work reliably.
If the Logon desktop is visible (for example, when you log on (duh) or
change your password) you can not get access to it.
Or if the visible desktop belongs to the administrator, I think you are also
out of luck.

There is a number of cases where you are not allowed access to the visible
desktop out of concern for security.
But if your desktop is not visible, it shouldn't matter if your stuff is
drawn or not.
What is is that you are trying to do?

--

Kind regards,
Bruno van Dooren
br************* *********@hotma il.com
Remove only "_nos_pam"
Sep 6 '06 #7
>How can I find the currently visible desktop? By calling
>EnumWindowStat ions
and EnumDesktops I get a list of all available desktops. But is there a
way
to figure out which one of them is currently visible?

If you have an hwnd that is on the desktop you are looking for, you can do
a GetWindowThread ProcessId() to get the thread id of it, then use
GetThreadDeskto p() to get an HDESK of that thread.
Since he doesn't know which desktop is visible, he probably wouldn't know
which windows are visible either.
And of course, you cannot get access to the logon desktop - and possible
other desktops as well- for security reasons.

--

Kind regards,
Bruno van Dooren
br************* *********@hotma il.com
Remove only "_nos_pam"
Sep 6 '06 #8
Pretty smart, unfortunately I don't have such a handle.

"David Ching" wrote:
"Mephisto18 7" <Me*********@di scussions.micro soft.comwrote in message
news:40******** *************** ***********@mic rosoft.com...
How can I find the currently visible desktop? By calling
EnumWindowStati ons
and EnumDesktops I get a list of all available desktops. But is there a
way
to figure out which one of them is currently visible?

If you have an hwnd that is on the desktop you are looking for, you can do a
GetWindowThread ProcessId() to get the thread id of it, then use
GetThreadDeskto p() to get an HDESK of that thread.

-- David
http://www.dcsoft.com
Sep 6 '06 #9
Actually, I've already managed to open a window on the administrators desktop
from within my remote desktop.
What I'm doing is the graphical component for a benchmarking tool designed
to be used in hospitals for unattended system checks.
If the window is not visible the graphic driver is so clever that he is not
performing real rendering any more. At least the framerate reaches
astronomical values.

"Bruno van Dooren [MVP VC++]" wrote:
The problem is. On remote desktops there is only software rendering
available. And on invisible desktops the graphic driver is not performing
any
rendering at all because there is no visible window.
So I need to get access to a visible desktop in order to get access to the
graphical hardware

But that is never going to work reliably.
If the Logon desktop is visible (for example, when you log on (duh) or
change your password) you can not get access to it.
Or if the visible desktop belongs to the administrator, I think you are also
out of luck.

There is a number of cases where you are not allowed access to the visible
desktop out of concern for security.
But if your desktop is not visible, it shouldn't matter if your stuff is
drawn or not.
What is is that you are trying to do?

--

Kind regards,
Bruno van Dooren
br************* *********@hotma il.com
Remove only "_nos_pam"
Sep 6 '06 #10

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

Similar topics

1
1787
by: Mike Turco | last post by:
How do I go about finding the location of the desktop, temp folder, program files folder, my documents, etc. For example, say that I want to programmatically export a table to a file on the desktop. How do I find the folder? Thanks, Mike
5
11538
by: Dan Pavel | last post by:
Hi, I am starting a new process (Notepad) on a remote machine but it is not visible. When I start it on my machine it is visible. What I am doing wrong ? private void run_notepad(string machina) { ManagementOperationObserver observer = new ManagementOperationObserver(); completionHandler.MyHandler completionHandlerObj = new...
7
1578
by: Richard | last post by:
If the grid is dragged off the screen and back on the data is visible. Tried a dg.refresh() and Inactivate(). Can I do this by overriding custom base class OnPaint that my form inherits from? I don't thin it is the backcolor or something like that because the error does not occur on everyone's workstation. Could be it be the video card or tied...
3
1367
by: simonc | last post by:
I am writing a program that runs doing a repetitive task for several minutes. When I start it calculating the program's form only stays visible as long as it is the top window on the desktop. As soon as I put another window on top of the form I can't get back to the form. If I minimise everything else on the desktop I still can't seen the...
4
22073
by: Ahmed Perlom | last post by:
Hi all, How can I know if the session ID that a certain process is running on is actually the active session that he consol is connected to. I can get the session id of a process by
4
2376
by: Abhishek | last post by:
Hi All, how do I find the handle of a child window and get a screenshot of that in a hbitmap at present i tried the below method but am getting the screenshot of the desktop. the Egyptian Addiction is the name of the game and the mozillacontentwindowclass is the handle i need who's window i want to capture int nScreenWidth = 300; int...
6
2606
by: Lee | last post by:
how can i do this? I have a form, which i do not want to keep on top of all others (TopMost), yet i dont want it dissapearing when the "show desktop" button is pressed. Now i know that the show desktop button doesn't minimise all forms, it sets the desktop to be topmost. so i presume it will mean capturing the "show desktop" event...
0
1173
by: Mani | last post by:
Hi All, I have a terminal server running in Windows 2000. I have an MFC application "A.exe" developed in VC++ 2005, which runs in this machine. This application shows a tray icon in the task bar when minimized. At this point, I connect to this server using remote desktop. In the remote desktop session, I am not able to see this...
1
1214
by: Ganesh | last post by:
Dear Experts, I have an application that has several graphical components on it. The state of these components is decided by some data which is available in some data store. The graphical components periodically go to the data base to see if the data has changed and accordingly change their display state. Now its wasteful for my application...
0
7512
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...
0
7707
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. ...
0
7951
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...
0
7803
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...
0
5082
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...
0
3495
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1926
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
1
1051
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
751
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.