Example #1
0
        public Main()
        {
            InitializeComponent();

            this.Icon = Properties.Resources.icon;

            this.AllowDrop = true;
            this.DragEnter += delegate(object sender, DragEventArgs e)
            {
                if (e.Data.GetDataPresent(DataFormats.FileDrop))
                {
                    e.Effect = DragDropEffects.Copy;

                    LoadFile(((string[])e.Data.GetData(DataFormats.FileDrop))[0], true);
                }
            };
            this.DragLeave += delegate { UnloadFile(); };
            this.DragDrop += delegate(object sender, DragEventArgs e)
            {
                LoadFile(((string[])e.Data.GetData(DataFormats.FileDrop))[0]);
            };

            bg.DoWork += delegate
            {
                IntPtr hProc = IntPtr.Zero;

                WinAPI.STARTUPINFO si = new WinAPI.STARTUPINFO();
                WinAPI.PROCESS_INFORMATION pi = new WinAPI.PROCESS_INFORMATION();
                WinAPI.CreateProcess(null, String.Format("\"{0}\" \"{1}\"", Program.location + "\\SecureDesktop.exe", fileloc), IntPtr.Zero, IntPtr.Zero, false, WinAPI.CREATE_NO_WINDOW, IntPtr.Zero, null, ref si, out pi);
                hProc = pi.hProcess;
                //if (!this.IsDisposed) this.Invoke((Action)delegate { this.Close(); });
                try
                {
                    uint code;
                    while (!this.IsDisposed)
                    {
                        Thread.Sleep(500);
                        if (!WinAPI.GetExitCodeProcess(hProc, out code) || code != 259) { break; }
                    }
                }
                catch { }
            };
            bg.RunWorkerCompleted += delegate
            {
                btnRun.Enabled = true;
                stop.Stop();

                labelTime.Text = String.Format("Secure Desktop ran for {0:0}m{1:0}s", stop.Elapsed.TotalMinutes, stop.Elapsed.Seconds);
            };

            labelFile.SizeChanged += delegate
            {
                if (labelFile.Width < 260) this.Width = 428;
                else
                    this.Width = labelFile.Width + 168;
            };
        }
Example #2
0
        public Main()
        {
            InitializeComponent();

            this.Icon = Properties.Resources.icon;

            this.AllowDrop  = true;
            this.DragEnter += delegate(object sender, DragEventArgs e)
            {
                if (e.Data.GetDataPresent(DataFormats.FileDrop))
                {
                    e.Effect = DragDropEffects.Copy;

                    LoadFile(((string[])e.Data.GetData(DataFormats.FileDrop))[0], true);
                }
            };
            this.DragLeave += delegate { UnloadFile(); };
            this.DragDrop  += delegate(object sender, DragEventArgs e)
            {
                LoadFile(((string[])e.Data.GetData(DataFormats.FileDrop))[0]);
            };

            bg.DoWork += delegate
            {
                IntPtr hProc = IntPtr.Zero;

                WinAPI.STARTUPINFO         si = new WinAPI.STARTUPINFO();
                WinAPI.PROCESS_INFORMATION pi = new WinAPI.PROCESS_INFORMATION();
                WinAPI.CreateProcess(null, String.Format("\"{0}\" \"{1}\"", Program.location + "\\SecureDesktop.exe", fileloc), IntPtr.Zero, IntPtr.Zero, false, WinAPI.CREATE_NO_WINDOW, IntPtr.Zero, null, ref si, out pi);
                hProc = pi.hProcess;
                //if (!this.IsDisposed) this.Invoke((Action)delegate { this.Close(); });
                try
                {
                    uint code;
                    while (!this.IsDisposed)
                    {
                        Thread.Sleep(500);
                        if (!WinAPI.GetExitCodeProcess(hProc, out code) || code != 259)
                        {
                            break;
                        }
                    }
                }
                catch { }
            };
            bg.RunWorkerCompleted += delegate
            {
                btnRun.Enabled = true;
                stop.Stop();

                labelTime.Text = String.Format("Secure Desktop ran for {0:0}m{1:0}s", stop.Elapsed.TotalMinutes, stop.Elapsed.Seconds);
            };
        }