Possible en double:
How to detect Windows 64 bit platform with .net?32 ou 64 bit machine
J'utilise ce contrôle de code ti si la machine est de 64 ou 32 bits:
public static string GetOSBit()
{
bool is64bit = Is64Bit();
if (is64bit)
return "64 bit";
else
return "32 bit";
}
[DllImport("kernel32.dll", SetLastError = true, CallingConvention = CallingConvention.Winapi)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool IsWow64Process([In] IntPtr hProcess, [Out] out bool lpSystemInfo);
public static bool Is64Bit()
{
bool retVal;
IsWow64Process(Process.GetCurrentProcess().Handle, out retVal);
return retVal;
}
J'ai une machine 32 bits et ça marche bien pour moi. Il renvoie "32 bits". Mon ami a cependant aussi une machine 32 bits, mais a installé la machine virtuelle qui est 64 bits. Le code ci-dessus renvoie "32 bits" pour sa machine virtuelle, bien que ce soit 64 bits. Je travaille en C#, .Net 2.0.
Comme le suggère l'API, cela décrit un processus, pas la machine – sehe