예제 #1
0
        private void ThreadProcSafe()
        {
            Console.WriteLine("tick");
            IntPtr logOffHandle = FindWindow(null, Resources.TargetWindowTitle);
            if (logOffHandle == IntPtr.Zero)
            {
                /*StringBuilder sb = new StringBuilder(256);
                foregroundHandler = GetForegroundWindow();
                GetWindowText(foregroundHandler, sb, sb.Capacity);

                String title = sb.ToString();
                sb.Clear();
                GetClassName(foregroundHandler, sb, sb.Capacity);
                String className = sb.ToString();

                if (className.Equals("Shell_TrayWnd"))
                {
                    //LockWorkStation();
                    //ShowWindow(foregroundHandler, 0);
                    //Developex.ScreenLocker.ShowSystemModalDialog("Never Log off", this);
                    //this.AppendText(String.Format("\"log off\" window is not found {0} <------------>   HWND:{1}, title: {2}, className: {3}", DateTime.Now, foregroundHandler, title, className));
                }
                //if (className.Equals("DV2ControlHost"))
                //{
                //    ShowWindow(foregroundHandler, 0);
                //}
                this.AppendText(String.Format("\"log off\" window is not found {0} <------------>   HWND:{1}, title: {2}, className: {3}", DateTime.Now, foregroundHandler, title, className));
                //ShowWindow(FindWindow("Shell_TrayWnd", null), 5);
                //this.ShowDialog();
                 */
            }
            else
            {
                WINDOWINFO winInfo = new WINDOWINFO();
                GetWindowInfo(logOffHandle, out winInfo);

                this.AppendText(String.Format("Prevented from logging off {0} times at {1}", (++times), DateTime.Now));
                this.AppendText(String.Format("dwExStyle: {0}, dwStyle: {1}, atomWindowType: {2}", winInfo.dwExStyle, winInfo.dwStyle, winInfo.atomWindowType));
                SendKeys.SendWait("{ENTER}");
            }
        }
예제 #2
0
 public static extern bool GetWindowInfo(IntPtr hWnd, out WINDOWINFO pwi);
예제 #3
0
 public static extern bool GetWindowInfo(IntPtr hWnd, out WINDOWINFO pwi);