2024年3月14日发(作者:)
C#判断当前系统是32位还是64位
C#判断当前系统是32位还是64位
// The initial C# code for the plain WMI query was generated by WMI Code Generator, Version
5.00, /
using System;
using ment;
using c;
namespace Win32_Processor_Query
public class WMIQuery
public static int Main(string[] args)
string fullpath = mandLineArgs().GetValue(0).ToString();
string[] program = (‘’);
string exename = program[erBound(0)];
exename = ing(0, f(‘.’));
if ( 0)
andardError();
ine();
ine(exename + , Version 1.00
ine( Detect if running in a 32-bit or 64-bit OS
ine();
ine( Usage: + r() + [ computername ]
ine();
ine( Where: computername is the (optional) name of a remote computer
ine( (default if not specified: local computer)
ine();
ine( Note: Return value ( ErrorLevel ) 32 or 64 equals OS value
ine();
ine( Written by Rob van der Woude
ine(
andardOutput();
return 1;
string wmins = rootCIMV2
if ( == 1)
wmins = + args[0] + + wmins;
UInt16 addresswidth = 0;
ManagementObjectSearcher searcher = new ManagementObjectSearcher(wmins, SELECT *
FROM Win32_Processor
foreach (ManagementObject queryObj in ())
addresswidth = (UInt16) (queryObj[ AddressWidth ]);
ine( Windows : {0}-bit , addresswidth);
ine( Processor : {0}-bit , queryObj[ DataWidth ]);
return addresswidth;
catch (Exception e)
andardError();
ine( Error: + e);
ine();
ine( For detailed help, run: + exename + /?
andardOutput();
return 1;
}


发布评论