예제 #1
0
        public bool IsLegal(int pid, IRDPSRAPIApplication app)
        {
            var p = System.Diagnostics.Process.GetProcessById(pid);

            if (p == null)
            {
                return(false);
            }

            if ((p.ProcessName.ToLower() + ".exe") != Properties.Settings.Default.Application.ToLower())
            {
                return(false);
            }

            if (p.MainWindowHandle == IntPtr.Zero)
            {
                Console.WriteLine(DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss") + ":" + p.MainModule.ModuleName + ",这个程序没有发现窗口,将监控默认区域。");
                return(false);
            }

            if (Utils.IsMinimized(p.MainWindowHandle))
            {
                Utils.ShowWindow(p.MainWindowHandle, 1);
            }

            Rect r;

            Utils.GetWindowRect(p.MainWindowHandle, out r);
            this.SourceRect = r;
            this.SourceApps.Add(app);
            return(true);
        }
예제 #2
0
        private void _rdpSession_OnApplicationClose(object pApplication)
        {
            IRDPSRAPIApplication app = pApplication as IRDPSRAPIApplication;

            if (app == null)
            {
                return;
            }

            if (!string.IsNullOrWhiteSpace(Properties.Settings.Default.Application))
            {
                Console.WriteLine(DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss") + ":" + "ApplicationClose~" + app.Id + "," + app.Name);
                this.SourceApps.RemoveAll(m => m.Id == app.Id);
            }
        }
예제 #3
0
        private void _rdpSession_OnApplicationOpen(object pApplication)
        {
            IRDPSRAPIApplication app = pApplication as IRDPSRAPIApplication;

            if (app == null)
            {
                return;
            }

            Console.WriteLine("OnApplicationOpen:" + app.Id + "," + app.Name);
            if (!string.IsNullOrWhiteSpace(Properties.Settings.Default.Application))
            {
                if (string.IsNullOrWhiteSpace(app.Name) ||
                    app.Name?.ToLower() == Properties.Settings.Default.Application?.ToLower())
                {
                    if (!this.IsLegal(app.Id, app))
                    {
                        return;
                    }

                    this.SetDesktopSharedRect(this.SourceRect);
                }
            }
        }