C#获得主板序列号、

I_Love_Soft 2002-08-16 02:52:56
如上
...全文
179 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
wywhsjf 2002-08-22
  • 打赏
  • 举报
回复
不知道dos下用c语言编程怎么获得主板序列号?
SessionEnum 2002-08-16
  • 打赏
  • 举报
回复
private void Init()
{
TreeNode myNode,myChildNode,mySubNode;
string []myClassName = new String[]{"Cooling device classes ","Input device classes","Mass storage classes ","Motherboard, controller, and port classes","Networking device classes","Power classes","Printing classes","Telephony classes","Video and monitor classes"};
string [][]myWmiClass = {
new string[]{"Win32_Fan","Win32_HeatPipe","Win32_Refrigeration","Win32_TemperatureProbe"},
new string[]{"Win32_Keyboard","Win32_PointingDevice"},
new string[]{"Win32_CDROMDrive","Win32_DiskDrive","Win32_FloppyDrive","Win32_LogicalDisk","Win32_TapeDrive"},
new string[]{"Win32_1394Controller","Win32_1394ControllerDevice","Win32_AllocatedResource","Win32_AssociatedProcessorMemory","Win32_BaseBoard","Win32_BIOS","Win32_Bus","Win32_CacheMemory","Win32_DeviceBus","Win32_DeviceMemoryAddress","Win32_DeviceSettings","Win32_DMAChannel","Win32_FloppyController","Win32_IDEController","Win32_IDEControllerDevice","Win32_InfraredDevice","Win32_IRQResource","Win32_MemoryArray","Win32_MemoryArrayLocation","Win32_MemoryDevice","Win32_MemoryDeviceArray","Win32_MemoryDeviceLocation","Win32_MotherboardDevice","Win32_OnBoardDevice","Win32_ParallelPort","Win32_PCMCIAController","Win32_PhysicalMemory","Win32_PhysicalMemoryArray","Win32_PhysicalMemoryLocation","Win32_PNPAllocatedResource","Win32_PNPDevice","Win32_PNPEntity","Win32_PortConnector","Win32_PortResource","Win32_Processor","Win32_SCSIController","Win32_SCSIControllerDevice","Win32_SerialPort","Win32_SerialPortConfiguration","Win32_SerialPortSetting","Win32_SMBIOSMemory","Win32_SoundDevice","Win32_SystemBIOS","Win32_SystemDriverPNPEntity","Win32_SystemEnclosure","Win32_SystemMemoryResource","Win32_SystemSlot","Win32_USBController","Win32_USBControllerDevice"},
new string[]{"Win32_NetworkAdapter","Win32_NetworkAdapterConfiguration","Win32_NetworkAdapterSetting"},
new string[]{"Win32_AssociatedBattery","Win32_Battery","Win32_CurrentProbe","Win32_PortableBattery","Win32_PowerManagementEvent","Win32_UninterruptiblePowerSupply","Win32_VoltageProbe"},
new string[]{"Win32_DriverForDevice","Win32_Printer","Win32_PrinterConfiguration","Win32_PrinterController","Win32_PrinterDriver","Win32_PrinterDriverDll","Win32_PrinterSetting","Win32_PrintJob","Win32_TCPIPPort"},
new string[]{"Win32_POTSModem","Win32_POTSModemToSerialPort"},
new string[]{"Win32_DesktopMonitor","Win32_DisplayConfiguration","Win32_DisplayControllerConfiguration","Win32_VideoConfiguration","Win32_VideoController","Win32_VideoSettings"}
};
sbStatus.Panels[0].Width = Width / 4;
sbStatus.Panels[1].Width = Width * 3 / 4;
tvInfoList.Width = sbStatus.Panels[0].Width;

myNode = tvInfoList.Nodes.Add("Windows Management Instrumentation(WMI)");
myNode.Tag = "";

for(int i=0;i<myClassName.Length;i++)
{
myChildNode = myNode.Nodes.Add(myClassName[i]);
myChildNode.Tag = "";
foreach(string myClass in myWmiClass[i])
{
mySubNode = myChildNode.Nodes.Add(myClass);
mySubNode.Tag = myClass;
}
}

}
private void RefreshInfo(string sInfoName)
{
if(sInfoName=="")return;

// Build a query for enumeration of Win32_BaseBoard instances
SelectQuery query = new SelectQuery(sInfoName);
ListViewItem myItem;
object myValue;

// Instantiate an object searcher with this query
try
{
ManagementObjectSearcher searcher = new ManagementObjectSearcher(query);
ManagementObjectCollection myCollection = searcher.Get();

// lvInfoList.Enabled = false;
//No preformance raising?!
// lvInfoList.Visible = false;
lvInfoList.Items.Clear();

foreach(ManagementObject myMgmtObj in myCollection)
{
foreach(PropertyData Property in myMgmtObj.Properties)
{
myItem = lvInfoList.Items.Add(Property.Name.ToString());
myValue = Property.Value;
if(myValue==null)
{
myItem.SubItems.Add("");
}
else
{
myItem.SubItems.Add(myValue.ToString());
}
}
}
}
catch{}
}
private void MainForm_Load(object sender, System.EventArgs e)
{
Init();
}

private void tvInfoList_AfterSelect(object sender, System.Windows.Forms.TreeViewEventArgs e)
{
sbStatus.Panels[0].Text = "正在读取数据...";
RefreshInfo(e.Node.Tag.ToString());
sbStatus.Panels[0].Text = "就绪";
}

110,536

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧