try

{

ConnectionOptions connection = new ConnectionOptions();

connection.Username = userNameBox.Text;

connection.Password = passwordBox.Text;

connection.Authority = "ntlmdomain:Finance123";

ManagementScope scope = new ManagementScope(

"\\dell417\root\CIMV2", connection);

scope.Connect();

ObjectQuery query= new ObjectQuery(

"SELECT * FROM Win32_CacheMemory");

ManagementObjectSearcher searcher =

new ManagementObjectSearcher(scope, query);

foreach (ManagementObject queryObj in searcher.Get())

{

Console.WriteLine("");

Console.WriteLine("Win32_CacheMemory instance");

Console.WriteLine("");

Console.WriteLine("Access: {0}", queryObj["Access"]);

if(queryObj["AdditionalErrorData"] == null)

Console.WriteLine("AdditionalErrorData: {0}", queryObj["AdditionalErrorData"]);

else

{

Byte[] arrAdditionalErrorData = (Byte[])(queryObj["AdditionalErrorData"]);

foreach (Byte arrValue in arrAdditionalErrorData)

{

Console.WriteLine("AdditionalErrorData: {0}", arrValue);

}

}

Console.WriteLine("Associativity: {0}", queryObj["Associativity"]);

Console.WriteLine("Availability: {0}", queryObj["Availability"]);

Console.WriteLine("BlockSize: {0}", queryObj["BlockSize"]);

Console.WriteLine("CacheSpeed: {0}", queryObj["CacheSpeed"]);

Console.WriteLine("CacheType: {0}", queryObj["CacheType"]);

Console.WriteLine("Caption: {0}", queryObj["Caption"]);

Console.WriteLine("ConfigManagerErrorCode: {0}", queryObj["ConfigManagerErrorCode"]);

Console.WriteLine("ConfigManagerUserConfig: {0}", queryObj["ConfigManagerUserConfig"]);

Console.WriteLine("CorrectableError: {0}", queryObj["CorrectableError"]);

Console.WriteLine("CreationClassName: {0}", queryObj["CreationClassName"]);

if(queryObj["CurrentSRAM"] == null)

Console.WriteLine("CurrentSRAM: {0}", queryObj["CurrentSRAM"]);

else

{

UInt16[] arrCurrentSRAM = (UInt16[])(queryObj["CurrentSRAM"]);

foreach (UInt16 arrValue in arrCurrentSRAM)

{

Console.WriteLine("CurrentSRAM: {0}", arrValue);

}

}

Console.WriteLine("Description: {0}", queryObj["Description"]);

Console.WriteLine("DeviceID: {0}", queryObj["DeviceID"]);

Console.WriteLine("EndingAddress: {0}", queryObj["EndingAddress"]);

Console.WriteLine("ErrorAccess: {0}", queryObj["ErrorAccess"]);

Console.WriteLine("ErrorAddress: {0}", queryObj["ErrorAddress"]);

Console.WriteLine("ErrorCleared: {0}", queryObj["ErrorCleared"]);

Console.WriteLine("ErrorCorrectType: {0}", queryObj["ErrorCorrectType"]);

if(queryObj["ErrorData"] == null)

Console.WriteLine("ErrorData: {0}", queryObj["ErrorData"]);

else

{

Byte[] arrErrorData = (Byte[])(queryObj["ErrorData"]);

foreach (Byte arrValue in arrErrorData)

{

Console.WriteLine("ErrorData: {0}", arrValue);

}

}

Console.WriteLine("ErrorDataOrder: {0}", queryObj["ErrorDataOrder"]);

Console.WriteLine("ErrorDescription: {0}", queryObj["ErrorDescription"]);

Console.WriteLine("ErrorInfo: {0}", queryObj["ErrorInfo"]);

Console.WriteLine("ErrorMethodology: {0}", queryObj["ErrorMethodology"]);

Console.WriteLine("ErrorResolution: {0}", queryObj["ErrorResolution"]);

Console.WriteLine("ErrorTime: {0}", queryObj["ErrorTime"]);

Console.WriteLine("ErrorTransferSize: {0}", queryObj["ErrorTransferSize"]);

Console.WriteLine("FlushTimer: {0}", queryObj["FlushTimer"]);

Console.WriteLine("InstallDate: {0}", queryObj["InstallDate"]);

Console.WriteLine("InstalledSize: {0}", queryObj["InstalledSize"]);

Console.WriteLine("LastErrorCode: {0}", queryObj["LastErrorCode"]);

Console.WriteLine("Level: {0}", queryObj["Level"]);

Console.WriteLine("LineSize: {0}", queryObj["LineSize"]);

Console.WriteLine("Location: {0}", queryObj["Location"]);

Console.WriteLine("MaxCacheSize: {0}", queryObj["MaxCacheSize"]);

Console.WriteLine("Name: {0}", queryObj["Name"]);

Console.WriteLine("NumberOfBlocks: {0}", queryObj["NumberOfBlocks"]);

Console.WriteLine("OtherErrorDescription: {0}", queryObj["OtherErrorDescription"]);

Console.WriteLine("PNPDeviceID: {0}", queryObj["PNPDeviceID"]);

if(queryObj["PowerManagementCapabilities"] == null)

Console.WriteLine("PowerManagementCapabilities: {0}", queryObj["PowerManagementCapabilities"]);

else

{

UInt16[] arrPowerManagementCapabilities = (UInt16[])(queryObj["PowerManagementCapabilities"]);

foreach (UInt16 arrValue in arrPowerManagementCapabilities)

{

Console.WriteLine("PowerManagementCapabilities: {0}", arrValue);

}

}

Console.WriteLine("PowerManagementSupported: {0}", queryObj["PowerManagementSupported"]);

Console.WriteLine("Purpose: {0}", queryObj["Purpose"]);

Console.WriteLine("ReadPolicy: {0}", queryObj["ReadPolicy"]);

Console.WriteLine("ReplacementPolicy: {0}", queryObj["ReplacementPolicy"]);

Console.WriteLine("StartingAddress: {0}", queryObj["StartingAddress"]);

Console.WriteLine("Status: {0}", queryObj["Status"]);

Console.WriteLine("StatusInfo: {0}", queryObj["StatusInfo"]);

if(queryObj["SupportedSRAM"] == null)

Console.WriteLine("SupportedSRAM: {0}", queryObj["SupportedSRAM"]);

else

{

UInt16[] arrSupportedSRAM = (UInt16[])(queryObj["SupportedSRAM"]);

foreach (UInt16 arrValue in arrSupportedSRAM)

{

Console.WriteLine("SupportedSRAM: {0}", arrValue);

}

}

Console.WriteLine("SystemCreationClassName: {0}", queryObj["SystemCreationClassName"]);

Console.WriteLine("SystemLevelAddress: {0}", queryObj["SystemLevelAddress"]);

Console.WriteLine("SystemName: {0}", queryObj["SystemName"]);

Console.WriteLine("WritePolicy: {0}", queryObj["WritePolicy"]);

}

Close();

}

catch(ManagementException err)

{

MessageBox.Show("An error occurred while querying for WMI data: " + err.Message);

}

catch(System.UnauthorizedAccessException unauthorizedErr)

{

MessageBox.Show("Connection error (user name or password might be incorrect): " + unauthorizedErr.Message);

}

Advertisements