using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Threading;
namespace ProcessList
{
class Program
{
public static bool Is64Bit(Process process)
{
if (!Environment.Is64BitOperatingSystem)
return false;
// if this method is not available in your version of .NET, use GetNativeSystemInfo via P/Invoke instead
bool isWow64;
try
{
if (!IsWow64Process(process.Handle, out isWow64))
throw new Win32Exception();
}
catch (Exception)
{
return true;
}
return !isWow64;
}
static void Main(string[] args)
{
Console.BufferHeight = 10000;
Process[] prc = Process.GetProcesses();
foreach (Process theprocess in prc)
{
Console.WriteLine($"PROCESS: {theprocess.ProcessName} #{theprocess.Id}");
if (!Is64Bit(theprocess))
foreach (ProcessModule item in theprocess.Modules)
Console.WriteLine($"\t {item.ModuleName}");
}
Console.ReadLine();
}
[DllImport("kernel32.dll", SetLastError = true, CallingConvention = CallingConvention.Winapi)]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool IsWow64Process([In] IntPtr process, [Out] out bool wow64Process);
}
}