社区
C#
帖子详情
c# ManagementClass
一只鬼
2018-11-13 04:01:57
使用ManagementClass获取cup,硬盘等信息,极少电脑会出问题,但是还是碰到了,提示
System.IO.FileNotFoundException:
at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo)
为什么会报错呢?
...全文
269
3
打赏
收藏
c# ManagementClass
使用ManagementClass获取cup,硬盘等信息,极少电脑会出问题,但是还是碰到了,提示 System.IO.FileNotFoundException: at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo) 为什么会报错呢?
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
3 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
一只鬼
2018-11-21
打赏
举报
回复
引用 2 楼 sp1234 的回复:
贴出抛出异常的语句源代码,以及你的调试画面。
代码是这个 string cpuInfo = " "; using (ManagementClass cimobject = new ManagementClass("Win32_Processor")) { ManagementObjectCollection moc = cimobject.GetInstances(); foreach (ManagementObject mo in moc) { cpuInfo = mo.Properties["ProcessorId"].Value.ToString(); mo.Dispose(); } } 在我电脑上没报错,是在客户电脑上出现的,是.net framework弹出来的框
以专业开发人员为伍
2018-11-20
打赏
举报
回复
贴出抛出异常的语句源代码,以及你的调试画面。
一只鬼
2018-11-20
打赏
举报
回复
没人遇到过吗?好几天了
C#
中得到网卡号
C#
源代码
C#
中得到网卡号
C#
源代码 using System.
Mana
gem
en
t; //get the MAC address
Mana
gem
en
tCl
ass
mc=new
Mana
gem
en
tCl
ass
("Win32_NetworkAdapterConfiguration");
Mana
gem
en
tObjectCollection moc=mc.GetInstances(); string[] MacAddress=new string[2]; int ii=0; foreach(
Mana
gem
en
tObject mo in moc) { if((bool)mo["IP
En
abled"]==true) { MacAddress[ii]=mo["MacAddress"].ToString(); ii++; } mo.Dispose(); }
C#
系统硬件设备管理(监视,启用,禁用)源代码
C#
系统硬件设备管理(监视,启用,禁用)源代码!
C#
获取U盘ID序列号及U盘信息
获取U盘ID序列号 VS2005编译通过,源码源自CSDN。已经测试好用。 可以获得U盘名称,制造商ID号 版本号 U盘序列号及容量 Form1.cs using System; using System.Collections.G
en
eric; using System.Compon
en
tModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.IO; using System.
Mana
gem
en
t; namespace UDiskTest { public partial cl
ass
Form1 : Form { public Form1() { InitializeCompon
en
t(); } private void button2_Click(object s
en
der, Ev
en
tArgs e) { DriveInfo[] s = DriveInfo.GetDrives(); foreach (DriveInfo drive in s) { if (drive.DriveType == DriveType.Removable) { pf.Text = drive.Name.ToString(); break; } }
Mana
gem
en
tCl
ass
cimobject = new
Mana
gem
en
tCl
ass
("Win32_DiskDrive");
Mana
gem
en
tObjectCollection moc = cimobject.GetInstances(); foreach (
Mana
gem
en
tObject mo in moc) { if (mo.Properties["InterfaceType"].Value.ToString() == "USB") { try { //产品名称 Caption.Text = mo.Properties["Caption"].Value.ToString(); //总容量 Size.Text = mo.Properties["Size"].Value.ToString(); string[] info = mo.Properties["PNPDeviceID"].Value.ToString().Split('&'); string[] xx = info[3].Split('\\'); //序列号 MessageBox.Show("U盘序列号:" + xx[1]); PNPDeviceID.Text = xx[1]; xx = xx[0].Split('_'); //版本号 REV.Text = xx[1]; //制造商ID xx = info[1].Split('_'); VID.Text = xx[1]; } catch (Exception ex) { MessageBox.Show(ex.Message); } } } } } } 如果编译遇到问题是using System.
Mana
gem
en
t;无法找到引用找到, 项目(p)->添加引用(R)->找到.NET标签页 列表中下部位找到System.
Mana
gem
en
t 双击点确定
Win7 WMI报错
Win7事件查看器出现WMI错误,这是微软官方提供补丁。
C#
4种方式获取硬盘物理序列号
C#
4种方式获取硬盘物理序列号,不同方式针对不同环境下获取,windows7,8,10,2003,2008,2012,2016都测试可用
C#
111,125
社区成员
642,540
社区内容
发帖
与我相关
我的任务
C#
.NET技术 C#
复制链接
扫一扫
分享
社区描述
.NET技术 C#
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
让您成为最强悍的C#开发者
试试用AI创作助手写篇文章吧
+ 用AI写文章