-2
我有一些问题(c#)。使用c获取系统信息#
我可以检索从Win32的踢脚线一些主板的信息,但是当我想型号 但累积的错误。
我们如何获得Windows上安装的软件列表(如xp)。
我们如何获得Windows上安装的外围设备列表(包括详细信息)(如扫描仪,网络摄像头)。
如何获得总数直接数量的公羊(刚)。
我有一些问题(c#)。使用c获取系统信息#
我可以检索从Win32的踢脚线一些主板的信息,但是当我想型号 但累积的错误。
我们如何获得Windows上安装的软件列表(如xp)。
我们如何获得Windows上安装的外围设备列表(包括详细信息)(如扫描仪,网络摄像头)。
如何获得总数直接数量的公羊(刚)。
使用WMI(我怀疑你已经在使用它):
型号为空白。尝试Manufacturer
属性。同时获取Product
属性以获取模型。
安装的软件:获取Win32_Product
类。
尝试Win32_PnPSignedDriver
类并重复遍历。
使用Win32_ComputerSystem
类和得到TotalPhysicalMemory
财产。
获取WMIEXPLORER并与之一起玩。LINK
样品为C#:
如果您需要连接到使用证书的远程计算机(strUserName中和strPassword变量):
private ManagementScope CreateNewManagementScope(string server)
{
string serverString = @"\\" + server + @"\root\cimv2";
ManagementScope scope = new ManagementScope(serverString);
if (!chkUseCurrentUser.Checked)
{
ConnectionOptions options = new ConnectionOptions
{
Username = strUsername,
Password = strPassword,
Impersonation = ImpersonationLevel.Impersonate,
Authentication = AuthenticationLevel.PacketPrivacy
};
scope.Options = options;
}
return scope;
}
获取服务:
private void GetServicesForComputer(string computerName)
{
ManagementScope scope = CreateNewManagementScope(computerName);
SelectQuery query = new SelectQuery("select * from Win32_Service");
try
{
using (ManagementObjectSearcher searcher = new ManagementObjectSearcher(scope, query))
{
ManagementObjectCollection services = searcher.Get();
List<string> serviceNames =
(from ManagementObject service in services select service["Caption"].ToString()).ToList();
lstServices.DataSource = serviceNames;
}
}
catch (Exception exception)
{
lstServices.DataSource = null;
lstServices.Items.Clear();
lblErrors.Text = exception.Message;
Console.WriteLine(Resources.MainForm_GetServicesForServer_Error__ + exception.Message);
}
}
从wmiexplorer一些屏幕:
你可以找到所有这些问题的答案已经在SO。 – 2014-11-02 08:29:49
虽然我回答了你应该让你的问题更清楚你确实使用了WMI并提供了一个代码示例。 – e4rthdog 2014-11-02 08:57:30
我发现第一个问题的答案 - “模型是空白的”-tnx到e4rthdog – 2014-11-02 10:56:07