[DllImport("kernel32.dll", PreserveSig = true, SetLastError = true, ExactSpelling = true)]
private static extern unsafe bool _IsWow64Process(void* hProcess, out bool wow64Process);
private static bool IsWow64Process(Process process)
{
if (process == null)
throw new ArgumentNullException("process");
if ((Environment.OSVersion.Version.Major == 5 && Environment.OSVersion.Version.Minor >= 1) || Environment.OSVersion.Version.Major >= 6)
unsafe
{
bool retVal;
if (_IsWow64Process(process.Handle.ToPointer(), out retVal))
return retVal;
}
return false;
}
public static string GetPointerSize(int processId)
{
using (Process p = Process.GetProcessById(processId))
if (IsWow64Process(p))
return 4;
switch (IntPtr.Size)
{
case 4:
return IsWow64Process(Process.GetCurrentProcess()) ? 8 : 4;
case 8:
return 8;
default:
throw new ApplicationException("Unknown pointer size");
}
}
26 November, 2010
Определение разрядности работающего процесса
Периодически тредуется код который сможет определить разрядность процесса по его id. Вот пример такого кода:
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment