public static UInt16 GetOSAddressWidth() { try { SelectQuery query = new SelectQuery("select AddressWidth from Win32_Processor"); ManagementObjectSearcher searcher = new ManagementObjectSearcher(query); ManagementObjectCollection moCollection = searcher.Get(); foreach (ManagementObject mo in moCollection) { foreach (PropertyData property in mo.Properties) { if (property.Name.Equals("AddressWidth")) { return Convert.ToUInt16(property.Value); } } } throw new Exception("Didn't get expected query result from WMI."); } catch (Exception ex) { throw new Exception("Error occurs in WMI query.", ex.InnerException); } }
UInt16 os = GetOSAddressWidth(); string BarCode=""; if (os == 64) { RegistryKey rk = Registry.LocalMachine.OpenSubKey("Software\\Wow6432Node\\Clear"); BarCode = rk.GetValue("IsBarCodeWaterMark").ToString(); rk.Close(); } if (os == 32) { RegistryKey rk = Registry.LocalMachine.OpenSubKey("Software\\Clear"); BarCode = rk.GetValue("IsBarCodeWaterMark").ToString(); rk.Close(); }