나는 당신이 이러한 개별 기능을 사용하는 방법을 잘 모르겠지만, 여기에 다른 일을 확인하는 기능은 다음과 같습니다
//Get system RAM
private double GetSystemRam()
{
var searcher = new ManagementObjectSearcher("Select * From Win32_ComputerSystem");
double total_Ram_Bytes = 0;
foreach (ManagementObject Mobject in searcher.Get())
{
total_Ram_Bytes = (Convert.ToDouble(Mobject["TotalPhysicalMemory"]));
Console.WriteLine("RAM Size in Giga Bytes: {0}", total_Ram_Bytes/1073741824);
}
return total_Ram_Bytes;
}
//Get system processor speed
private int GetprocessorSpeed()
{
var searcher = new ManagementObjectSearcher("select MaxClockSpeed from Win32_Processor");
int processorSpeed = 0;
foreach (var item in searcher.Get())
{
processorSpeed = Convert.ToInt32(item["MaxClockSpeed"]);
Console.WriteLine("Processor Speed is(GHz):" + processorSpeed);
}
return processorSpeed;
}
//Get system maximum resolution
private void GetMaxResolution()
{
using (var searcher = new System.Management.ManagementObjectSearcher("SELECT * FROM CIM_VideoControllerResolution"))
{
var results = searcher.Get();
UInt32 maxHResolution = 0;
UInt32 maxVResolution = 0;
foreach (var item in results)
{
if ((UInt32)item["HorizontalResolution"] > maxHResolution)
maxHResolution = (UInt32)item["HorizontalResolution"];
if ((UInt32)item["VerticalResolution"] > maxVResolution)
maxVResolution = (UInt32)item["VerticalResolution"];
}
Console.WriteLine("Max Supported Resolution " + maxHResolution + "x" + maxVResolution);
}
}
//Check for availability of keyboard
private bool IsKeyboardAvailable()
{
bool isKeyboardAvailable = false;
var searcher = new ManagementObjectSearcher("select * from Win32_Keyboard");
List<string> keyBoardName = new List<string>();
foreach (var item in searcher.Get())
{
keyBoardName.Add(Convert.ToString(item["Name"]));
Console.WriteLine("KeyBoard name is :" + item["Name"]);
isKeyboardAvailable = true;
}
return isKeyboardAvailable;
}
//Check for availability of printer
private bool IsPrinterAvailable()
{
bool isPrinterAvailable = false;
var searcher = new ManagementObjectSearcher("Select * from Win32_Printer");
List<string> printerName = new List<string>();
foreach (var item in searcher.Get())
{
printerName.Add(item["Name"].ToString().ToLower());
Console.WriteLine("Printer name is :" + item["Name"]);
isPrinterAvailable = true;
}
return isPrinterAvailable;
}
//Check for availability of mouse
private bool IsMouseAvailable()
{
bool isMouseAvailable = false;
var searcher = new ManagementObjectSearcher("Select * from Win32_PointingDevice");
List<string> mouseType = new List<string>();
foreach (var item in searcher.Get())
{
mouseType.Add(item["Name"].ToString().ToLower());
Console.WriteLine("Mouse type is :" + item["Name"]);
isMouseAvailable = true;
}
return isMouseAvailable;
}
참고 : 값을 볼 수 있도록 난 그냥 Console.WriteLine을 사용하고 또한 LIST를 사용하면 원하는 경우 해당 항목을 더 사용할 수 있습니다.
How To Get Hardware Information (CPU ID, MainBoard Info, Hard Disk Serial, System Information , ...)
답장을 보내 주셔서 감사합니다. 내가 필요로하는 가장 중요한 것은 설치 전에 그것을 확인하는 방법입니다. – Civa
나중에 그게 임프 물건입니다, 나는 당신이 당신의 프로젝트에서 무엇을하는지 알지 못해서, 나는 단지 분리 된 기능을 만들었습니다. 당신을 돕기를 바랍니다. – Popeye
아마도 [custom prerequisite package] (http://msdn.microsoft.com/en-us/library/ms165429(v=80) .aspx)를 설치 프로그램에 추가 한 다음를 < InstallChecks> 요소를 사용하여 성능 테스트 용 사용자 지정 프로그램을 실행하십시오. (ClickOnce 부트 스트 래퍼 참조 (http://msdn.microsoft.com/en-us/library/ms229432(v=80) .aspx) –
Alexander