当前位置: 代码迷 >> ASP.NET >> 那位大哥可以提供一下读取物理硬盘序列号的activex解决思路
  详细解决方案

那位大哥可以提供一下读取物理硬盘序列号的activex解决思路

热度:3153   发布时间:2013-02-26 00:00:00.0
那位大哥可以提供一下读取物理硬盘序列号的activex
那位大哥可以提供一下读取物理硬盘序列号的activex
做了一个b/s系统,客户要求只有店里的电脑可以访问,偶想用个activex来读取硬盘序列号来比较.望高手能提供相关的例子(其它验证方式不考虑,因为服务器是租用的空间,没有任何权限);

------解决方案--------------------------------------------------------
1.建议楼主把权限验证方式改成windows验证,这样可以有效保证局域网内的安全性
2.使用IP地址识别来的更直观一点,用硬盘序列号太怪了点吧,还得先注册硬盘序列号,系统扩展也成问题

这里有读硬盘序列号的方汗
http://www.cnblogs.com/zhouyabo/archive/2006/07/04/442029
------解决方案--------------------------------------------------------
http://blog.csdn.net/fengzheng0306/archive/2006/04/28/694781.aspx
------解决方案--------------------------------------------------------
最近有篇文章刚好说道这个问题
http://community.csdn.net/Expert/topic/5409/5409478.xml?temp=.689831

应该可以帮到你
------解决方案--------------------------------------------------------
using System;
using System.Runtime.InteropServices;
using System.Management;
namespace Hardware
{
/// <summary>
/// Hardware_Mac 的摘要说明。
/// </summary>
public class HardwareInfo
{
//取机器名
public string GetHostName()
{
return System.Net.Dns.GetHostName();
}
//取CPU编号
public String GetCpuID()
{
try
{
ManagementClass mc = new ManagementClass( "Win32_Processor ");
ManagementObjectCollection moc = mc.GetInstances();

String strCpuID = null ;
foreach( ManagementObject mo in moc )
{
strCpuID = mo.Properties[ "ProcessorId "].Value.ToString();
break;
}
return strCpuID;
}
catch
{
return " ";
}
}//end method

//取第一块硬盘编号
public String GetHardDiskID()
{
try
{
ManagementObjectSearcher searcher = new ManagementObjectSearcher( "SELECT * FROM Win32_PhysicalMedia ");
String strHardDiskID = null ;
foreach(ManagementObject mo in searcher.Get())
{
strHardDiskID = mo[ "SerialNumber "].ToString().Trim();
break;
}
return strHardDiskID ;
}
catch
{
return " ";
}
}//end
public enum NCBCONST
{
NCBNAMSZ =16, /* absolute length of a net name */
MAX_LANA =254, /* lana 's in range 0 to MAX_LANA inclusive */
NCBENUM =0x37, /* NCB ENUMERATE LANA NUMBERS */
NRC_GOODRET =0x00, /* good return */
NCBRESET =0x32, /* NCB RESET */
NCBASTAT =0x33, /* NCB ADAPTER STATUS */
NUM_NAMEBUF =30, /* Number of NAME 's BUFFER */
}
[StructLayout(LayoutKind.Sequential)]
public struct ADAPTER_STATUS
{
[MarshalAs(UnmanagedType.ByValArray, SizeConst=6)]
public byte[] adapter_address;
public byte rev_major;
public byte reserved0;
public byte adapter_type;
public byte rev_minor;
public ushort duration;
public ushort frmr_recv;
public ushort frmr_xmit;
public ushort iframe_recv_err;
public ushort xmit_aborts;
public uint xmit_success;
public uint recv_success;
public ushort iframe_xmit_err;
public ushort recv_buff_unavail;
public ushort t1_timeouts;
public ushort ti_timeouts;
public uint reserved1;
public ushort free_ncbs;
public ushort max_cfg_ncbs;
  相关解决方案