当前位置: 首页>>代码示例>>C#>>正文


C# ProcessHandle.WriteDump方法代码示例

本文整理汇总了C#中ProcessHandle.WriteDump方法的典型用法代码示例。如果您正苦于以下问题:C# ProcessHandle.WriteDump方法的具体用法?C# ProcessHandle.WriteDump怎么用?C# ProcessHandle.WriteDump使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ProcessHandle的用法示例。


在下文中一共展示了ProcessHandle.WriteDump方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: createDumpFileProcessMenuItem_Click

        private void createDumpFileProcessMenuItem_Click(object sender, EventArgs e)
        {
            SaveFileDialog sfd = new SaveFileDialog();

            sfd.Filter = "Dump Files (*.dmp)|*.dmp|All Files (*.*)|*.*";
            sfd.FileName =
                processP.Dictionary[processSelectedPid].Name +
                "_" +
                DateTime.Now.ToString("yyMMdd") +
                ".dmp";

            if (sfd.ShowDialog() == DialogResult.OK)
            {
                this.Cursor = Cursors.WaitCursor;

                try
                {
                    Exception exception = null;

                    ThreadStart dumpProcess = () =>
                        {
                            try
                            {
                                using (var phandle = new ProcessHandle(processSelectedPid,
                                    ProcessAccess.DupHandle | ProcessAccess.QueryInformation |
                                    ProcessAccess.SuspendResume | ProcessAccess.VmRead))
                                    phandle.WriteDump(sfd.FileName);
                            }
                            catch (Exception ex2)
                            {
                                exception = ex2;
                            }
                        };

                    if (OSVersion.HasTaskDialogs)
                    {
                        // Use a task dialog to display a fancy progress bar.
                        TaskDialog td = new TaskDialog();
                        Thread t = new Thread(dumpProcess);

                        td.AllowDialogCancellation = false;
                        td.Buttons = new TaskDialogButton[] { new TaskDialogButton((int)DialogResult.OK, "Close") };
                        td.WindowTitle = "Process Hacker";
                        td.MainInstruction = "Creating the dump file...";
                        td.ShowMarqueeProgressBar = true;
                        td.EnableHyperlinks = true;
                        td.CallbackTimer = true;
                        td.Callback = (taskDialog, args, userData) =>
                            {
                                if (args.Notification == TaskDialogNotification.Created)
                                {
                                    taskDialog.SetMarqueeProgressBar(true);
                                    taskDialog.SetProgressBarState(ProgressBarState.Normal);
                                    taskDialog.SetProgressBarMarquee(true, 100);
                                    taskDialog.EnableButton((int)DialogResult.OK, false);
                                }
                                else if (args.Notification == TaskDialogNotification.Timer)
                                {
                                    if (!t.IsAlive)
                                    {
                                        taskDialog.EnableButton((int)DialogResult.OK, true);
                                        taskDialog.SetProgressBarMarquee(false, 0);
                                        taskDialog.SetMarqueeProgressBar(false);

                                        if (exception == null)
                                        {
                                            taskDialog.SetMainInstruction("The dump file has been created.");
                                            taskDialog.SetContent(
                                                "The dump file has been saved at: <a href=\"file\">" + sfd.FileName + "</a>.");
                                        }
                                        else
                                        {
                                            taskDialog.UpdateMainIcon(TaskDialogIcon.Warning);
                                            taskDialog.SetMainInstruction("Unable to create the dump file.");
                                            taskDialog.SetContent(
                                                "The dump file could not be created: " + exception.Message
                                                );
                                        }
                                    }
                                }
                                else if (args.Notification == TaskDialogNotification.HyperlinkClicked)
                                {
                                    if (args.Hyperlink == "file")
                                        Utils.ShowFileInExplorer(sfd.FileName);

                                    return true;
                                }

                                return false;
                            };

                        t.Start();
                        td.Show(this);
                    }
                    else
                    {
                        // No task dialogs, do the thing on the GUI thread.
                        dumpProcess();

                        if (exception != null)
//.........这里部分代码省略.........
开发者ID:andyvand,项目名称:ProcessHacker,代码行数:101,代码来源:HackerWindow.cs


注:本文中的ProcessHandle.WriteDump方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。