如果服务器被锁定 - 是否可以将密钥发送到子客户端窗口?
我的程序找到任何子窗口,如果一个由三部分组成的应用程序显示错误框,那么我想关闭它..并且当服务器未锁定时它工作正常。
代码:
[DllImport("user32", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
private extern static bool PostMessage(IntPtr hwnd, uint msg, IntPtr WParam, IntPtr lParam);
[DllImport("user32", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
private extern static bool BringWindowToTop(IntPtr hwnd);
public static bool FocusWindowAndSendEnter(IntPtr hWnd)
{
try
{ // hWnd = pointer to subwindow, like messagebox.
uint WM_KEYDOWN = 0x0100;
//Set focus
var res1 = BringWindowToTop(hWnd);
//Send enter_Key
var res2 = PostMessage(hWnd, WM_KEYDOWN, (IntPtr)Keys.Enter, IntPtr.Zero);
return (res1 == res2 == true);
}
catch (Exception ex)
{
Logger.LogException(MethodInfo.GetCurrentMethod().Name, ex);
}
return false;
}
如果服务器被锁定但正在运行,可以这样做吗?
My program, finds any subwindows, the case if an 3-part app shows an Error box, then i want to close it.. and it works fine, when the server not is locked.
Code:
[DllImport("user32", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
private extern static bool PostMessage(IntPtr hwnd, uint msg, IntPtr WParam, IntPtr lParam);
[DllImport("user32", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
private extern static bool BringWindowToTop(IntPtr hwnd);
public static bool FocusWindowAndSendEnter(IntPtr hWnd)
{
try
{ // hWnd = pointer to subwindow, like messagebox.
uint WM_KEYDOWN = 0x0100;
//Set focus
var res1 = BringWindowToTop(hWnd);
//Send enter_Key
var res2 = PostMessage(hWnd, WM_KEYDOWN, (IntPtr)Keys.Enter, IntPtr.Zero);
return (res1 == res2 == true);
}
catch (Exception ex)
{
Logger.LogException(MethodInfo.GetCurrentMethod().Name, ex);
}
return false;
}
Can this be done if the server is locked, but running?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当计算机被锁定时,出于安全目的,您能做的事情非常有限。我怀疑是否有办法解决这个问题,除非您阻止计算机被锁定,或者首先阻止消息框显示。
您试图用错误的方法解决问题。
了解如何处理该错误消息框,并采取措施防止这种情况发生。当电脑被锁定时,不要指望能做很多事情。
When a computer is locked, you are very limited in what you can do - for security purposes. I doubt there is a way around this unless you either stop the computer being locked, or stop the message box from showing up in the first place.
You're attempting to solve a problem in the wrong methods.
Find out what you can about that error message box and do what you can to prevent that happening. Don't expect to have much you can do when the PC is locked.