コード例 #1
0
ファイル: Program.cs プロジェクト: xjqhhh/KrkrExtract
        static void Main()
        {
            SetProcessDPIAware();
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            if (CheckMutex())
            {
                MessageBox.Show("Waiting for another task...", "KrkrExtract", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Environment.Exit(-1);
            }


            var args = Environment.GetCommandLineArgs();

            if (args.Length >= 2)
            {
                string ProgramName = args[1];
                if (KrkrExtract.CreateProcessInternalWithDll(ProgramName, KrkrMode.NORMAL) == NativeHelper.INVALID_HANDLE_VALUE)
                {
                    MessageBox.Show("Failed to launch executable...", "KrkrExtract", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Environment.Exit(-1);
                }

                UILoader.LoadUIAndRun();
            }
            else
            {
                Application.Run(new KrkrExtract());
                UILoader.LoadUIAndRun();
            }
        }
コード例 #2
0
        private void KrkrExtract_DragDrop(object sender, DragEventArgs e)
        {
            string[] FileList = (string[])e.Data.GetData(DataFormats.FileDrop, false);
            if (FileList.Length > 1)
            {
                MessageBox.Show("DrapDrop only accept one file", "KrkrExtract", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            string ProgramName = FileList[0];

            if (ProgramName.ToLower().EndsWith(".lnk"))
            {
                ProgramName = GetShortcutTargetFile(ProgramName);
                if (string.IsNullOrEmpty(ProgramName))
                {
                    MessageBox.Show("Couldn't resolve symbolic link", "KrkrExtract", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }

            if (!ProgramName.ToLower().EndsWith(".exe"))
            {
                MessageBox.Show("Only *.exe (PE files) are supported", "KrkrExtract", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            IntPtr RemoteProcess = CreateProcessInternalWithDll(ProgramName, m_Mode);

            if (RemoteProcess == NativeHelper.INVALID_HANDLE_VALUE)
            {
                MessageBox.Show("Failed to launch executable...", "KrkrExtract", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                this.Hide();
                UILoader.LoadUIAndRun();
                this.Close();
                Environment.Exit(0);
            }
        }