如何在默认桌面和Winlogon桌面之间切换过程? [英] How to Switch a Process between Default Desktop and Winlogon Desktop?

查看:546
本文介绍了如何在默认桌面和Winlogon桌面之间切换过程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我正在编写远程桌面应用程序,例如 TeamViewer

strong>在Windows 7(x64)和Windows 8(x64)上的C ++中。



1。什么让我卡住了



我使用SendInput()实现了鼠标输入和键盘输入。我发现SendInput()工作完美,当进程运行在winsta0 \desktop下。



如果我在winsta0 \winlogon下运行进程,SendInput()不能在winsta0下工作\default。



2。我尝试了



我尝试过使用SetThreadDesktop()将进程从winsta0 \desktop切换到winsta0 \winlogon,但出现错误170:请求的资源正在使用,我困扰了。



3。我想知道



我注意到TeamViewer有一个名为TeamViewer_Desktop.exe的进程,可以在Winlogon,Default和Screensaver下控制鼠标和键盘。它是如何做到的?



如果你有任何想法,请告诉我。非常感谢。非常感谢您能提供代码帮助我理解如何解决我的问题。



编辑1:
我想了解的是如何让我的应用在默认桌面和Winlogon桌面之间切换。因此,我可以在安全桌面上控制鼠标和键盘,而不创建在winlogon.exe下运行的另一个进程。

解决方案

SetThreadDesktop 是正确的。该错误告诉您,在当前桌面上有一些资源打开,例如窗口,并阻止您切换。如果你试图生产一个最小的测试用例(因为你在这里提出问题时打算做的)。你会发现。



你的程序,直到你发现阻止你切换桌面的块。一些Windows API是讨厌的,阻止您切换桌面,所以需要在专用线程中调用。


My English is not good, but I will try my best to describe the problem clearly.

I am writing a remote desktop app like TeamViewer in C++ on Windows 7 (x64) and Windows 8 (x64).

1. What made me stuck

I have implemented the mouse input and keyboard input by using SendInput(). I found SendInput() worked perfectly when the process ran under winsta0\desktop. But after user locked computer or screensaver launched, it didn’t work.

If I run the process under winsta0\winlogon, SendInput() doesn’t work under winsta0\default.

2. What I have tried

I have tried using SetThreadDesktop() to switch the process from winsta0\desktop to winsta0\winlogon but got error 170: "The requested resource is in use" and I stucked.

3. What I want to know

I noticed that TeamViewer has a process named TeamViewer_Desktop.exe which can control mouse and keyboard under Winlogon, Default and Screensaver. How does it do it?

If you have any idea, please tell me. Thanks so much. And I’m very appreciate if you can provide the code to help me understand how to solve my question.

Edit 1: What I want to know is how can I make my app switch between Default Desktop and Winlogon Desktop. So I can control mouse and keyboard on Secured Desktop without creating another process ran under winlogon.exe.

解决方案

You did the right thing: SetThreadDesktop is correct. The error is telling you that you have some resources open on the current desktop though, such as a window, and that prevents you from switching. If you had tried to produce a minimal test-case (as you are meant to do when asking questions here!) you would have found that out.

Cut out parts of your program until you find the chunk that's preventing you switching desktop. Some Windows APIs are nasty and prevent you switching desktop, so need to be called in a dedicated thread.

这篇关于如何在默认桌面和Winlogon桌面之间切换过程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆