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


C# ProcessHandle.GetExitTime方法代码示例

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


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

示例1: AddProcessItem

        private void AddProcessItem(
            ProcessHandle phandle,
            int pid,
            ref int totalCount, ref int hiddenCount, ref int terminatedCount,
            Func<int, bool> exists
            )
        {
            string fileName = phandle.GetImageFileName();

            if (fileName != null)
                fileName = FileUtils.GetFileName(fileName);

            if (pid == 0)
                pid = phandle.GetBasicInformation().UniqueProcessId.ToInt32();

            var item = listProcesses.Items.Add(new ListViewItem(new string[]
                    {
                        fileName,
                        pid.ToString()
                    }));

            DateTime exitTime = DateTime.FromFileTime(0);

            try { exitTime = phandle.GetExitTime(); }
            catch { }

            if (exitTime.ToFileTime() != 0)
            {
                item.BackColor = Color.DarkGray;
                item.ForeColor = Color.White;
                terminatedCount++;
            }
            else
            {
                totalCount++;

                if (!exists(pid))
                {
                    item.BackColor = Color.Red;
                    item.ForeColor = Color.White;
                    hiddenCount++;
                }
            }
        }
开发者ID:RoDaniel,项目名称:featurehouse,代码行数:44,代码来源:HiddenProcessesWindow.cs

示例2: AddProcessItem

        private void AddProcessItem(
            ProcessHandle phandle,
            int pid,
            ref int totalCount, ref int hiddenCount, ref int terminatedCount,
            Func<int, bool> exists
            )
        {
            string fileName = phandle.ImageFileName;

            if (!string.IsNullOrEmpty(fileName))
                fileName = FileUtils.GetFileName(fileName);

            if (pid == 0)
                pid = phandle.GetBasicInformation().UniqueProcessId.ToInt32();

            ListViewItem item = listProcesses.Items.Add(new ListViewItem(new string[]
            {
                fileName, 
                pid.ToString()
            }));

            // Check if the process has terminated. This is possible because 
            // a process can be terminated while its object is still being 
            // referenced.
            DateTime exitTime = DateTime.FromFileTime(0);

            try { exitTime = phandle.GetExitTime(); }
            catch { }

            if (exitTime.ToFileTime() != 0)
            {
                item.BackColor = Color.DarkGray;
                item.ForeColor = Color.White;
                terminatedCount++;
            }
            else
            {
                totalCount++;

                if (!exists(pid))
                {
                    item.BackColor = Color.Red;
                    item.ForeColor = Color.White;
                    hiddenCount++;
                }
            }
        }
开发者ID:john-peterson,项目名称:processhacker,代码行数:47,代码来源:HiddenProcessesWindow.cs


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