Hello,
I have been trying to get this to work for a while now and just to new to fully understand what is the problem.
I'm using a OS class, that I found on the internet.
Code:
static public SoftwareArchitecture ProgramBits
{
get
{
SoftwareArchitecture pbits = SoftwareArchitecture.Unknown;
System.Collections.IDictionary test = Environment.GetEnvironmentVariables();
switch (IntPtr.Size * 8)
{
case 64:
pbits = SoftwareArchitecture.Bit64;
break;
case 32:
pbits = SoftwareArchitecture.Bit32;
break;
default:
pbits = SoftwareArchitecture.Unknown;
break;
}
return pbits;
What I do not understand is what I need to do to make this If else statement work with this above code.
Code:
private void button2_Click(object sender, EventArgs e)
{
if (OSVersionInfo.OSBits == 64)
{
MessageBox.Show("OS is x64 Bit");
}
else if (OSVersionInfo.OSBits == 32)
{
MessageBox.Show("OS is x86 Bit");
}
else
{
//return 2;
}
}
This is the error message that I get when I use 64 and 32.
When I Debug, this is the error message that I get "Error 1 Operator '==' cannot be applied to operands of type 'JCS.OSVersionInfo.SoftwareArchitecture' and 'int' D:\OSVersionInfo\OSVersionInfo\Form1.cs 45 17 OSVersionInfo
"
This is the error message that I get when I switch it to Bit64 and Bit32
Error 1 The name 'Bit64' does not exist in the current context D:\OSVersionInfo\OSVersionInfo\Form1.cs 45 41 OSVersionInfo
Any help to learn what I'm doing wrong would be great.
Thanks,
-Mike