ImageVerifierCode 换一换
格式:DOCX , 页数:15 ,大小:219.39KB ,
资源ID:4520651      下载积分:2 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/4520651.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(如何得到硬盘序列号C#.docx)为本站会员(b****6)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

如何得到硬盘序列号C#.docx

1、如何得到硬盘序列号C#如何得到硬盘序列号C#部门: xxx 时间: xxx整理范文,仅供参考,可下载自行编辑硬盘序列号Serial Number)不等于卷标号来获取硬盘信息,而不需要写VXD或者DRIVER。这样这个问题就解决了,我对它进行了封装,大量使用了P/Invoke技术,一个完整的Library。支持Windows 98-2003。b5E2RGbCAP使用上很简单:HardDiskInfo hdd = AtapiDevice.GetHddInfo(0。 / 第一个硬盘p1EanqFDPwConsole.WriteLine(Module Number: 0, hdd.ModuleNumb

2、er。DXDiTa9E3dConsole.WriteLine(Serial Number: 0, hdd.SerialNumber。RTCrpUDGiTConsole.WriteLine(Firmware: 0, hdd.Firmware。Console.WriteLine(Capacity: 0 M, hdd.Capacity。5PCzVD7HxA下面是全部代码:using System。using System.Runtime.InteropServices。using System.Text。namespace Sunmast.HardwareSerializablepublic str

3、uct HardDiskInfo/ / 型号/ public string ModuleNumber。/ / 固件版本/ public string Firmware。/ / 序列号/ public string SerialNumber。/ / 容量,以M为单位/ public uint Capacity。#region Internal StructsStructLayout(LayoutKind.Sequential, Pack=1internal struct GetVersionOutParamspublic byte bVersion。public byte bRevision。p

4、ublic byte bReserved。public byte bIDEDeviceMap。public uint fCapabilities。MarshalAs(UnmanagedType.ByValArray, SizeConst=4public uint dwReserved。 / For future use.StructLayout(LayoutKind.Sequential, Pack=1internal struct IdeRegspublic byte bFeaturesReg。public byte bSectorCountReg。public byte bSectorNu

5、mberReg。public byte bCylLowReg。public byte bCylHighReg。public byte bDriveHeadReg。public byte bCommandReg。public byte bReserved。StructLayout(LayoutKind.Sequential, Pack=1internal struct SendCmdInParamspublic uint cBufferSize。public IdeRegs irDriveRegs。public byte bDriveNumber。MarshalAs(UnmanagedType.

6、ByValArray, SizeConst=3public byte bReserved。MarshalAs(UnmanagedType.ByValArray, SizeConst=4public uint dwReserved。public byte bBuffer。StructLayout(LayoutKind.Sequential, Pack=1internal struct DriverStatuspublic byte bDriverError。public byte bIDEStatus。MarshalAs(UnmanagedType.ByValArray, SizeConst=2

7、public byte bReserved。MarshalAs(UnmanagedType.ByValArray, SizeConst=2public uint dwReserved。StructLayout(LayoutKind.Sequential, Pack=1internal struct SendCmdOutParamspublic uint cBufferSize。public DriverStatus DriverStatus。public IdSector bBuffer。StructLayout(LayoutKind.Sequential, Pack=1, Size=512j

8、LBHrnAILginternal struct IdSectorpublic ushort wGenConfig。public ushort wNumCyls。public ushort wReserved。public ushort wNumHeads。public ushort wBytesPerTrack。public ushort wBytesPerSector。public ushort wSectorsPerTrack。MarshalAs(UnmanagedType.ByValArray, SizeConst=3public ushort wVendorUnique。Marsha

9、lAs(UnmanagedType.ByValArray, SizeConst=20xHAQX74J0Xpublic byte sSerialNumber。public ushort wBufferType。public ushort wBufferSize。public ushort wECCSize。MarshalAs(UnmanagedType.ByValArray, SizeConst=8public byte sFirmwareRev。MarshalAs(UnmanagedType.ByValArray, SizeConst=40LDAYtRyKfEpublic byte sMode

10、lNumber。public ushort wMoreVendorUnique。public ushort wDoubleWordIO。public ushort wCapabilities。public ushort wReserved1。public ushort wPIOTiming。public ushort wDMATiming。public ushort wBS。public ushort wNumCurrentCyls。public ushort wNumCurrentHeads。public ushort wNumCurrentSectorsPerTrack。public ui

11、nt ulCurrentSectorCapacity。public ushort wMultSectorStuff。public uint ulTotalAddressableSectors。public ushort wSingleWordDMA。public ushort wMultiWordDMA。MarshalAs(UnmanagedType.ByValArray, SizeConst=128Zzz6ZB2Ltkpublic byte bReserved。#endregion/ / ATAPI驱动器相关/ public class AtapiDevice#region DllImpor

12、tDllImport(kernel32.dll, SetLastError=truestatic extern int CloseHandle(IntPtr hObject。DllImport(kernel32.dll, SetLastError=truestatic extern IntPtr CreateFile(string lpFileName,uint dwDesiredAccess,uint dwShareMode,IntPtr lpSecurityAttributes,uint dwCreationDisposition,uint dwFlagsAndAttributes,Int

13、Ptr hTemplateFile。DllImport(kernel32.dllstatic extern int DeviceIoControl(IntPtr hDevice,uint dwIoControlCode,IntPtr lpInBuffer,uint nInBufferSize,ref GetVersionOutParams lpOutBuffer,uint nOutBufferSize,ref uint lpBytesReturned,Out IntPtr lpOverlapped。DllImport(kernel32.dllstatic extern int DeviceIo

14、Control(IntPtr hDevice,uint dwIoControlCode,ref SendCmdInParams lpInBuffer,uint nInBufferSize,ref SendCmdOutParams lpOutBuffer,uint nOutBufferSize,ref uint lpBytesReturned,Out IntPtr lpOverlapped。const uint DFP_GET_VERSION = 0x00074080。const uint DFP_SEND_DRIVE_COMMAND = 0x0007c084。const uint DFP_RE

15、CEIVE_DRIVE_DATA = 0x0007c088。const uint GENERIC_READ = 0x80000000。const uint GENERIC_WRITE = 0x40000000。const uint FILE_SHARE_READ = 0x00000001。const uint FILE_SHARE_WRITE = 0x00000002。const uint CREATE_NEW = 1。const uint OPEN_EXISTING = 3。#endregion#region GetHddInfo/ / 获得硬盘信息/ / 硬盘序号/ 硬盘信息/ / 参考l

16、u0的文章:http:/lu0s1.3322.org/App/2k1103.html/ by sunmast for everyone/ thanks lu0 for his great works/ 在Windows 98/ME中,S.M.A.R.T并不缺省安装,请将SMARTVSD.VXD拷贝到%SYSTEM%IOSUBSYS目录下。dvzfvkwMI1/ 在Windows 2000/2003下,需要Administrators组的权限。/ / / AtapiDevice.GetHddInfo(/ public static HardDiskInfo GetHddInfo(byte dri

17、veIndexrqyn14ZNXIswitch(Environment.OSVersion.Platformcase PlatformID.Win32Windows:return GetHddInfo9x(driveIndex。case PlatformID.Win32NT:return GetHddInfoNT(driveIndex。case PlatformID.Win32S:throw new NotSupportedException(Win32s is not supported.。EmxvxOtOcocase PlatformID.WinCE:throw new NotSuppor

18、tedException(WinCE is not supported.。SixE2yXPq5default:throw new NotSupportedException(Unknown Platform.。6ewMyirQFL#region GetHddInfo9xprivate static HardDiskInfo GetHddInfo9x(byte driveIndexkavU42VRUsGetVersionOutParams vers = new GetVersionOutParams(。y6v3ALoS89SendCmdInParams inParam = new SendCmd

19、InParams(。SendCmdOutParams outParam = new SendCmdOutParams(。M2ub6vSTnPuint bytesReturned = 0。IntPtr hDevice = CreateFile(.Smartvsd,0,0,IntPtr.Zero,CREATE_NEW,0,IntPtr.Zero。if (hDevice = IntPtr.Zerothrow new Exception(Open smartvsd.vxd failed.。if (0 = DeviceIoControl(hDevice,DFP_GET_VERSION,IntPtr.Ze

20、ro,0,ref vers,(uintMarshal.SizeOf(vers,ref bytesReturned,IntPtr.ZeroCloseHandle(hDevice。throw new Exception(DeviceIoControl failed:DFP_GET_VERSION。0YujCfmUCw/ If IDE identify command not supported, failsif (0 = (vers.fCapabilities & 1CloseHandle(hDevice。throw new Exception(Error: IDE identify comman

21、d not supported.。eUts8ZQVRdif (0 != (driveIndex & 1inParam.irDriveRegs.bDriveHeadReg = 0xb0。elseinParam.irDriveRegs.bDriveHeadReg = 0xa0。if (0 != (vers.fCapabilities & (16 driveIndexsQsAEJkW5T/ We dont detect a ATAPI device.CloseHandle(hDevice。throw new Exception(string.Format(Drive 0 is a ATAPI dev

22、ice, we dont detect it,driveIndex + 1。GMsIasNXkAelseinParam.irDriveRegs.bCommandReg = 0xec。inParam.bDriveNumber = driveIndex。inParam.irDriveRegs.bSectorCountReg = 1。inParam.irDriveRegs.bSectorNumberReg = 1。inParam.cBufferSize = 512。if (0 = DeviceIoControl(hDevice,DFP_RECEIVE_DRIVE_DATA,ref inParam,(

23、uintMarshal.SizeOf(inParam,ref outParam,(uintMarshal.SizeOf(outParam,ref bytesReturned,IntPtr.ZeroCloseHandle(hDevice。throw new Exception(DeviceIoControl failed: DFP_RECEIVE_DRIVE_DATA。TIrRGchYzgCloseHandle(hDevice。return GetHardDiskInfo(outParam.bBuffer。#endregion#region GetHddInfoNTprivate static

24、HardDiskInfo GetHddInfoNT(byte driveIndex7EqZcWLZNXGetVersionOutParams vers = new GetVersionOutParams(。lzq7IGf02ESendCmdInParams inParam = new SendCmdInParams(。SendCmdOutParams outParam = new SendCmdOutParams(。zvpgeqJ1hkuint bytesReturned = 0。/ We start in NT/Win2000IntPtr hDevice = CreateFile(strin

25、g.Format(.PhysicalDrive0,driveIndex,GENERIC_READ | GENERIC_WRITE,FILE_SHARE_READ | FILE_SHARE_WRITE,IntPtr.Zero,OPEN_EXISTING,0,IntPtr.Zero。if (hDevice = IntPtr.Zerothrow new Exception(CreateFile faild.。if (0 = DeviceIoControl(hDevice,DFP_GET_VERSION,IntPtr.Zero,0,ref vers,(uintMarshal.SizeOf(vers,r

26、ef bytesReturned,IntPtr.ZeroCloseHandle(hDevice。throw new Exception(string.Format(Drive 0 may not exists.,driveIndex + 1。NrpoJac3v1/ If IDE identify command not supported, failsif (0 = (vers.fCapabilities & 1CloseHandle(hDevice。throw new Exception(Error: IDE identify command not supported.。1nowfTG4K

27、I/ Identify the IDE drivesif (0 != (driveIndex & 1inParam.irDriveRegs.bDriveHeadReg = 0xb0。elseinParam.irDriveRegs.bDriveHeadReg=0xa0。if (0 != (vers.fCapabilities & (16 driveIndexfjnFLDa5Zo/ We dont detect a ATAPI device.CloseHandle(hDevice。throw new Exception(string.Format(Drive 0 is a ATAPI device

28、, we dont detect it.,driveIndex + 1。tfnNhnE6e5elseinParam.irDriveRegs.bCommandReg = 0xec。inParam.bDriveNumber = driveIndex。inParam.irDriveRegs.bSectorCountReg = 1。inParam.irDriveRegs.bSectorNumberReg = 1。inParam.cBufferSize = 512。if (0 = DeviceIoControl(hDevice,DFP_RECEIVE_DRIVE_DATA,ref inParam,(uintMarshal.SizeOf(inParam,ref outParam,(uintMarshal.SizeOf(outParam,ref bytesR

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1