C# 从 Windows 服务检查系统是否为 64 位
C# Check if system is 64bit from Windows Service
我创建了一个 windows 服务来检查系统是 64 位还是 32 位,检查后从我的服务器下载适当的文件。但是我现在的代码不起作用。
我正在使用
int system = IntPtr.Size;
if (system == 4)
{
//the system is 32 bit
WebClient webClient = new WebClient();
webClient.DownloadFile("http://www.myserver.com/updates/dll/bin.dll", "C:\bin.dll");
}
if (system == 8)
{
//the system is 64bit
WebClient webClient = new WebClient();
webClient.DownloadFile("http://www.myserver.com/updates/dll/64/bin.dll", "C:\bin.dll");
}
您可以使用 System.Environment.Is64BitOperatingSystem 属性 检查您的操作系统版本是否为 x64,而不是检查指针大小。
不要使用 IntPtr.Size,而是使用内置函数。 MSDN 说 https://msdn.microsoft.com/en-us/library/system.environment.is64bitoperatingsystem(VS.100).aspx
可以通过Environment
调用
我创建了一个 windows 服务来检查系统是 64 位还是 32 位,检查后从我的服务器下载适当的文件。但是我现在的代码不起作用。
我正在使用
int system = IntPtr.Size;
if (system == 4)
{
//the system is 32 bit
WebClient webClient = new WebClient();
webClient.DownloadFile("http://www.myserver.com/updates/dll/bin.dll", "C:\bin.dll");
}
if (system == 8)
{
//the system is 64bit
WebClient webClient = new WebClient();
webClient.DownloadFile("http://www.myserver.com/updates/dll/64/bin.dll", "C:\bin.dll");
}
您可以使用 System.Environment.Is64BitOperatingSystem 属性 检查您的操作系统版本是否为 x64,而不是检查指针大小。
不要使用 IntPtr.Size,而是使用内置函数。 MSDN 说 https://msdn.microsoft.com/en-us/library/system.environment.is64bitoperatingsystem(VS.100).aspx 可以通过Environment
调用