0
我在做一點計算機信息工具。現在我正在做用戶帳戶。我用可用用戶填充組合框。Win32_Account類奇怪的行爲
ManagementObjectSearcher mosAccounts = new ManagementObjectSearcher("SELECT * FROM Win32_Account");
foreach (ManagementObject moUA in mosAccounts.Get())
{
comboBox4.Items.Add(moUA["Name"].ToString());
}
然後我展示他們:
private void comboBox4_SelectedIndexChanged(object sender, EventArgs e)
{
ManagementObjectSearcher mosAccounts = new ManagementObjectSearcher("SELECT * FROM Win32_Account");
foreach (ManagementObject moUA in mosAccounts.Get())
{
lblDescriptionUA.Text = "Description: " + moUA["Description"].ToString();
if (moUA["Domain"] != null)
{
lblDomain.Text = "Domain: " + moUA["Domain"].ToString();
}
else
lblDomain.Text = "Domain: Not Available";
if (moUA["InstallDate"] != null)
{
lblInstallDateUA.Text = "Install Date: " + moUA["InstallDate"].ToString();
}
else
lblInstallDateUA.Text = "Install Date: Not Available";
lblLocalAccount.Text = "Local Account: " + moUA["LocalAccount"].ToString();
if (moUA["SID"] != null)
{
lblSID.Text = "SID: " + moUA["SID"].ToString();
}
else
lblSID.Text = "SID: Not Available";
if (moUA["SIDType"] != null)
{
lblSIDType.Text = "SID Type: " + moUA["SIDType"];
}
else
lblSIDType.Text = "SID Type: Not Available";
if (moUA["Status"] != null)
{
lblStatusUA.Text = "Status: " + moUA["Status"].ToString();
}
else
lblStatusUA.Text = "Status: Not Available";
}
}
但每次我從下拉框中選擇一個用戶,標籤要瘋了,表現出這麼多的信息,切換它。這就像他們正在顯示關於所有用戶的信息。有什麼我失蹤?
附加信息:我在工作。有很多域用戶。組合框向他們展示了他們。因爲所有的域用戶都是Mybe。我做了一個選項,只顯示本地用戶,但與此相同的問題。