G
Guest
When I instatiate the following class like so:
public static HardDrive theHD = new HardDrive();
in the program.cs, the program crashes to desktop for some users. Most have
no reported problem.
This is the class:
class HardDrive
{
public HardDrive()
{
ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT
* FROM Win32_DiskDrive");
if (searcher != null)
{
foreach (ManagementObject wmi_HD in searcher.Get())
{
Model = wmi_HD["Model"].ToString();
Type = wmi_HD["InterfaceType"].ToString();
break;
}
}
else
{
// Error
MessageBox.Show("Exiting: searcher == null.");
Application.Exit();
}
searcher = new ManagementObjectSearcher("SELECT * FROM
Win32_PhysicalMedia");
if (searcher != null)
{
foreach (ManagementObject wmi_HD in searcher.Get())
{
if (wmi_HD["SerialNumber"] == null)
SerialNo = "None";
else
SerialNo = wmi_HD["SerialNumber"].ToString();
break;
}
}
else
{
// Error
MessageBox.Show("Exiting: searcher2 == null.");
Application.Exit();
}
}
public string Model
{
get { return model; }
set { model = value; }
}
public string Type
{
get { return type; }
set { type = value; }
}
public string SerialNo
{
get { return serialNo; }
set { serialNo = value; }
}
private string model = null;
private string type = null;
private string serialNo = null;
}
anyone know why this might crash some users?
Patrick
public static HardDrive theHD = new HardDrive();
in the program.cs, the program crashes to desktop for some users. Most have
no reported problem.
This is the class:
class HardDrive
{
public HardDrive()
{
ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT
* FROM Win32_DiskDrive");
if (searcher != null)
{
foreach (ManagementObject wmi_HD in searcher.Get())
{
Model = wmi_HD["Model"].ToString();
Type = wmi_HD["InterfaceType"].ToString();
break;
}
}
else
{
// Error
MessageBox.Show("Exiting: searcher == null.");
Application.Exit();
}
searcher = new ManagementObjectSearcher("SELECT * FROM
Win32_PhysicalMedia");
if (searcher != null)
{
foreach (ManagementObject wmi_HD in searcher.Get())
{
if (wmi_HD["SerialNumber"] == null)
SerialNo = "None";
else
SerialNo = wmi_HD["SerialNumber"].ToString();
break;
}
}
else
{
// Error
MessageBox.Show("Exiting: searcher2 == null.");
Application.Exit();
}
}
public string Model
{
get { return model; }
set { model = value; }
}
public string Type
{
get { return type; }
set { type = value; }
}
public string SerialNo
{
get { return serialNo; }
set { serialNo = value; }
}
private string model = null;
private string type = null;
private string serialNo = null;
}
anyone know why this might crash some users?
Patrick