各位大虾 请教一个获取电脑唯一标识的 C#的方法

zpfnfsa 2010-01-07 03:22:02
各位大虾 请教一个获取电脑唯一标识的 C#的方法

1.不能提取MAC地址
2.在网上找的 主板序列号 在神舟机器上无法读取 不知道是怎么回事
3.硬盘序列号 好多是提取的 硬盘类型 而不是 唯一标识 即 串口序列号


希望哪位大虾 发个可行的方法 出来
...全文
3472 31 打赏 收藏 转发到动态 举报
写回复
用AI写文章
31 条回复
切换为时间正序
请发表友善的回复…
发表回复
zchaoyangdun 2011-01-07
  • 打赏
  • 举报
回复
序列号合算
mendel 2010-01-10
  • 打赏
  • 举报
回复
[Quote=引用 23 楼 zpfnfsa 的回复:]
22楼的大侠 我添加了 using System.Management;

然后直接运行

MessageBox.Show(mo["SerialNumber"].ToString());报异常

未处理managementexception  找不到
详细信息如下:
未处理 System.Management.ManagementException
  Message="找不到 "
  Source="System.Management"
  StackTrace:
      在 System.Management.ManagementException.ThrowWithExtendedInfo(ManagementStatus errorCode)
      在 System.Management.PropertyData.RefreshPropertyInfo()
      在 System.Management.PropertyDataCollection.get_Item(String propertyName)
      在 System.Management.ManagementBaseObject.GetPropertyValue(String propertyName)
      在 System.Management.ManagementBaseObject.get_Item(String propertyName)
      在 WindowsApplication16.Form1.button2_Click(Object sender, EventArgs e) 位置 E:\project\WindowsApplication16\WindowsApplication16\Form1.cs:行号 26
      在 System.Windows.Forms.Control.OnClick(EventArgs e)
      在 System.Windows.Forms.Button.OnClick(EventArgs e)
      在 System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
      在 System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
      在 System.Windows.Forms.Control.WndProc(Message& m)
      在 System.Windows.Forms.ButtonBase.WndProc(Message& m)
      在 System.Windows.Forms.Button.WndProc(Message& m)
      在 System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
      在 System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
      在 System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
      在 System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
      在 System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
      在 System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
      在 System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
      在 System.Windows.Forms.Application.Run(Form mainForm)
      在 WindowsApplication16.Program.Main() 位置 E:\project\WindowsApplication16\WindowsApplication16\Program.cs:行号 17
      在 System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
      在 System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
      在 Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
      在 System.Threading.ThreadHelper.ThreadStart_Context(Object state)
      在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
      在 System.Threading.ThreadHelper.ThreadStart()


这是什么问题啊
[/Quote]

在引用里添加System.Management;
小范f-li.cn 2010-01-09
  • 打赏
  • 举报
回复
zhu_chuan_hang 2010-01-09
  • 打赏
  • 举报
回复
如果按楼主的意思,什么都可能被换掉的话,那还怎么保证唯一啊?
yingkk 2010-01-09
  • 打赏
  • 举报
回复
客户的计算机上什么硬件都是有可能换的,自然也没有绝对唯一的标示。现在很常用的方法是安装时候要序列号,当然序列号不能是永远固定不变的,每次当软件启动并且网络连接的时候,自动连上你的网络检查,有些序列号已经被你列进黑名单的,就提示非法,叫客户联系你们。被偷的给他们一个新的序列号就行。这是最正当方法了。
starj1 2010-01-09
  • 打赏
  • 举报
回复
大公司的话可以考虑推出加密狗,小公司只能将就着。
ouyangliping 2010-01-09
  • 打赏
  • 举报
回复
序列号是最好的方法,不可行的话,可以考虑记录系统硬件信息,包括CPU、硬盘、主板等等,只要其中一个信息符合就认为是这台电脑,毕竟你不能把电脑五脏六腑全换了还说是原来的电脑
ysz89757 2010-01-09
  • 打赏
  • 举报
回复
学习下
zhang_jun_long 2010-01-09
  • 打赏
  • 举报
回复
UP
zpfnfsa 2010-01-09
  • 打赏
  • 举报
回复
19楼的大侠
用序列号是个好办法 可以不用和硬件关联 每次联机都检查序列号是否合法
我要去问问项目经理能否改成这样
zpfnfsa 2010-01-09
  • 打赏
  • 举报
回复
给用户做的一个软件 因为用户不懂电脑 又经常换网卡地址
所以 系统可能重装
xr396464010 2010-01-09
  • 打赏
  • 举报
回复
up up up
zpfnfsa 2010-01-09
  • 打赏
  • 举报
回复
22楼的大侠 我添加了 using System.Management;

然后直接运行

MessageBox.Show(mo["SerialNumber"].ToString());报异常

未处理managementexception 找不到
详细信息如下:
未处理 System.Management.ManagementException
Message="找不到 "
Source="System.Management"
StackTrace:
在 System.Management.ManagementException.ThrowWithExtendedInfo(ManagementStatus errorCode)
在 System.Management.PropertyData.RefreshPropertyInfo()
在 System.Management.PropertyDataCollection.get_Item(String propertyName)
在 System.Management.ManagementBaseObject.GetPropertyValue(String propertyName)
在 System.Management.ManagementBaseObject.get_Item(String propertyName)
在 WindowsApplication16.Form1.button2_Click(Object sender, EventArgs e) 位置 E:\project\WindowsApplication16\WindowsApplication16\Form1.cs:行号 26
在 System.Windows.Forms.Control.OnClick(EventArgs e)
在 System.Windows.Forms.Button.OnClick(EventArgs e)
在 System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
在 System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
在 System.Windows.Forms.Control.WndProc(Message& m)
在 System.Windows.Forms.ButtonBase.WndProc(Message& m)
在 System.Windows.Forms.Button.WndProc(Message& m)
在 System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
在 System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
在 System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
在 System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
在 System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
在 System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
在 System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
在 System.Windows.Forms.Application.Run(Form mainForm)
在 WindowsApplication16.Program.Main() 位置 E:\project\WindowsApplication16\WindowsApplication16\Program.cs:行号 17
在 System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
在 System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
在 Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
在 System.Threading.ThreadHelper.ThreadStart_Context(Object state)
在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
在 System.Threading.ThreadHelper.ThreadStart()


这是什么问题啊
mendel 2010-01-09
  • 打赏
  • 举报
回复

private void button2_Click(object sender, EventArgs e)
{

ManagementClass mc = new ManagementClass("Win32_DiskDrive");
ManagementObjectCollection moc = mc.GetInstances();
foreach (ManagementObject mo in moc)
{
MessageBox.Show(mo["SerialNumber"].ToString());
}
ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT * FROM Win32_PhysicalMedia");
String strHardDiskID = null;
foreach (ManagementObject mo in searcher.Get())
{
strHardDiskID = mo["SerialNumber"].ToString().Trim();
break;
}
MessageBox.Show(strHardDiskID);

}


你看这里面两个哪个适合你
yinrongg 2010-01-08
  • 打赏
  • 举报
回复
电脑换了怎么办?
jin20000 2010-01-08
  • 打赏
  • 举报
回复
楼主,你为什么要这么做,具体是什么考虑,居然重装系统都不行
wbpmrck 2010-01-08
  • 打赏
  • 举报
回复
电脑就是若干部件的集合,你网卡、硬盘、主板都换的话,难不成让代码去获取主机箱的长相么??

这个问题本来就不是个问题,看用户什么东西可能不换的,就取那个唯一标识,否则就给客户发一个会员卡,这下不就唯一了
xr13417555629 2010-01-08
  • 打赏
  • 举报
回复
up
ytc666 2010-01-08
  • 打赏
  • 举报
回复
UP
bychgh 2010-01-08
  • 打赏
  • 举报
回复
帮顶
加载更多回复(11)
你想当“李逍遥”式的“大侠”吗? 这里无需计算机基础,无需编程经验,你也不必是计算机专业的在校大学生....只要爱好游戏,怀揣梦想! 有一定自主学习能力,跟着刘老师从“编程小白”修炼为游戏研发“大虾”吧!!!学习好Unity,其先决条件是一定要有稳固、扎实的编程基础!课程 《C# For Unity系列之入门篇》配套学习资料链接:http://pan.baidu.com/s/1gflxreN 密码:sou5;刘老师讲Unity学员群(2) 497429806一、热更新系列(技术含量:中高级):A:《lua热更新技术中级篇》https://edu.csdn.net/course/detail/27087B:《热更新框架设计之Xlua基础视频课程》https://edu.csdn.net/course/detail/27110C:《热更新框架设计之热更流程与热补丁技术》https://edu.csdn.net/course/detail/27118D:《热更新框架设计之客户端热更框架(上)》https://edu.csdn.net/course/detail/27132E:《热更新框架设计之客户端热更框架(中)》https://edu.csdn.net/course/detail/27135F:《热更新框架设计之客户端热更框架(下)》https://edu.csdn.net/course/detail/27136二:框架设计系列(技术含量:中级): A:《游戏UI界面框架设计系列视频课程》https://edu.csdn.net/course/detail/27142B:《Unity客户端框架设计PureMVC篇视频课程(上)》https://edu.csdn.net/course/detail/27172C:《Unity客户端框架设计PureMVC篇视频课程(下)》https://edu.csdn.net/course/detail/27173D:《AssetBundle框架设计_框架篇视频课程》https://edu.csdn.net/course/detail/27169三、Unity脚本从入门到精通(技术含量:初级)A:《C# For Unity系列之入门篇》https://edu.csdn.net/course/detail/4560B:《C# For Unity系列之基础篇》https://edu.csdn.net/course/detail/4595C: 《C# For Unity系列之中级篇》https://edu.csdn.net/course/detail/24422D:《C# For Unity系列之进阶篇》https://edu.csdn.net/course/detail/24465四、虚拟现实(VR)与增强现实(AR):(技术含量:初级)A:《虚拟现实之汽车仿真模拟系统 》https://edu.csdn.net/course/detail/26618五、Unity基础课程系列(技术含量:初级) A:《台球游戏与FlappyBirds—Unity快速入门系列视频课程(第1部)》 https://edu.csdn.net/course/detail/24643B:《太空射击与移动端发布技术-Unity快速入门系列视频课程(第2部)》https://edu.csdn.net/course/detail/24645 C:《Unity ECS(二) 小试牛刀》https://edu.csdn.net/course/detail/27096六、Unity ARPG课程(技术含量:初中级):A:《MMOARPG地下守护神_单机版实战视频课程(上部)》https://edu.csdn.net/course/detail/24965B:《MMOARPG地下守护神_单机版实战视频课程(中部)》https://edu.csdn.net/course/detail/24968C:《MMOARPG地下守护神_单机版实战视频课程(下部)》https://edu.csdn.net/course/detail/24979

110,537

社区成员

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

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

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