资源预览内容
第1页 / 共9页
第2页 / 共9页
第3页 / 共9页
第4页 / 共9页
第5页 / 共9页
第6页 / 共9页
第7页 / 共9页
第8页 / 共9页
第9页 / 共9页
亲,该文档总共9页全部预览完了,如果喜欢就下载吧!
资源描述
硬盘序列号获取的实际操作硬盘序列号获取的实际操作硬盘序列号获取的实际操作2010-03-04 14:54 来源:watchstor.com 我要评论(0)摘要:要获取硬盘序列号,需要访问注册表实际操作如下,建立一个新的窗体,在上面添加一个标签abel1,一个按钮command1,实现:按下按钮,在标签上显示硬盘序列号。 标签:硬盘序列号 硬盘序列号是基本常识,然后我就学习及深入的研究硬盘序列号,在这里和大家一起探讨硬盘序列号的使用方法,希望对大家有用。要获取硬盘序列号,需要访问注册表实际操作如下,建立一个新的窗体,在上面添加一个标签 Label1,一个按钮 command1,实现:按下按钮,在标签上显示硬盘序列号代码:Imports systemImports Microsoft.Win32Imports system.DiagnosticsImports system.Windows.Forms以上创建命名空间Private Command1_Click(ByVal sender As System.Object,_ByVal e As System.EventArgs) Handles Command1.ClickDim myDec As RegistryKeyDim myScsi As RegistryKeyDim myPort As RegistryKeyDim myBus As RegistryKeyDim myHd As RegistryKeyDim myInfo As RegistryKeyDim myHW As RegistryKeyDim myLM As RegistryKey定义获取硬盘序列号的节点myLM=Registry.LocalMachinemyHW=myLM.OpenSubKey(“HARDWARE“)myDec=myHW.OpenSubKey(“DEVICEMAP“)myScsi=myDec.OpenSubKey(“Scsi“)myPort=myScsi.OpenSubKey(“Scsi Port 1“)myBus=myPort.OpenSubKey(“Scsi Bus 0“)myHd=myBus.OpenSubKey(“Target Id 0“)myInfo=myHd.OpenSubKey(“Logical Unit Id 0“)获取硬盘序列号Me.Label1.Text=myInfo.GetValue(“Identifier“)在标签上显示出来以上介绍硬盘序列号如何获取。如何获得硬盘序列号Delphi 如何获得硬盘序列号文章来自: 好喜爱学习网(http:/www.haoxiai.net) 网址:http:/www.haoxiai.net/bianchengyuyan/Delphi/14220.html摘 要:以下代码获得指定硬盘的序列号,并以字符串的形式返回关键字:硬盘 序列号 获取 类 别:API usesSysUtils, Windows;function Get_DiskSerialNo(DriveID : char) : string;varVolumeSerialNumber : DWORD;MaximumComponentLength : DWORD;FileSystemFlags : DWORD;beginresult := ;tryGetVolumeInformation(PChar(DriveID + :),nil, 0, VolumeSerialNumber,MaximumComponentLength, FileSystemFlags,nil, 0);result := IntToHex(HiWord(VolumeSerialNumber), 4) +- + IntToHex(LoWord(VolumeSerialNumber), 4);exceptend;end;C#获取硬盘序列号注册 Alixixi 会员,创建你的 WEB 开发资料库,马上注册!using System;using System.Runtime.InteropServices;namespace ArLi.CommonPrj #region how use this?/*string sVol = getvol.GetVolOf(“C“);*/#endregionpublic class getvolDllImport(“kernel32.dll“)private static extern int GetVolumeInformation(string lpRootPathName,string lpVolumeNameBuffer,int nVolumeNameSize,ref int lpVolumeSerialNumber,int lpMaximumComponentLength,int lpFileSystemFlags,string lpFileSystemNameBuffer,int nFileSystemNameSize);public static string GetVolOf(string drvID)const int MAX_FILENAME_LEN = 256;int retVal = 0;int a =0;int b =0;string str1 = null;string str2 = null;int i = GetVolumeInformation(drvID + “:“,str1,MAX_FILENAME_LEN,ref retVal,a,b,str2,MAX_FILENAME_LEN);return retVal.ToString(“x“);delphi 的代码type MIDPtr = MIDRec; MIDRec = Record InfoLevel: word; SerialNum: LongInt; VolLabel: Packed Array 0.10 of Char; FileSysType: Packed Array 0.7 of Char; end; function GetDriveSerialNum(MID: MIDPtr; drive: Word): Boolean; assembler; asm push DS Just for safety, I dont think its really needed mov ax,440Dh Function Get Media ID mov bx,drive drive no (0-Default, 1-A .) mov cx,0866h category and minor code lds dx,MID Load pointeraddr. call DOS3Call Supposed to be faster than INT 21H jc err mov al,1 No carry so return TRUE jmp ok err: mov al,0 Carry set so return FALSE ok: pop DS Restore DS, were not supposed to change it end; procedure TForm1.NrBtnClick(Sender: TObject); var 用 diskid.dll 和 disk32.dll 获得硬盘序列号-vb 教程点击: 发布日期:2007-4-19 15:35:00 进入论坛sp; 今天夜里两点,还没有入睡,就把取得序列号的代码简单写了一下,没有分别在不同的系统上调试,只在 win2000 下调试通过,如果有问题的话,请告诉我,我再修改1.调用 diskid.dll 实现:Option ExplicitPrivate Declare Function IsWinNT Lib “DiskID.DLL“ () As LongPrivate Declare Function ReadPhysicalDrive9X Lib “DiskID.DLL“ (driveID As Long, buffer As Long, bufLen As Long) As LongPrivate Declare Function ReadPhysicalDriveInNT Lib “DiskID.DLL“ (driveID As Long, buffer As Long, bufLen As Long) As LongPrivate Type DRIVER_INFO_OKModalNumber(39) As ByteSerialNumber(19) As ByteControlNum(7) As ByteDriveType As LongCylinders As LongHeads As LongSectors As LongEnd TypePrivate Sub Command1_Click()Dim x As DRIVER_INFO_OKDim i As LongIf IsWinNT = 1 Theni = ReadPhysicalDriveInNT(ByVal 0, ByVal VarPtr(x), ByVal 256)Elsei = ReadPhysicalDrive9X(ByVal 0, ByVal VarPtr(x), ByVal 256)End IfDim s As Strings = StrConv(x.ModalNumber, vbUnicode)s = Left(s, InStr(1, s, Chr(0) - 1)MsgBox “硬件厂商代码为:“ + ss = StrConv(x.SerialNumber, vbUnicode)s = Left(s, InStr(1, s, Chr(0) - 1)MsgBox “硬盘序列号为:“ + sEnd Sub2.调用 diskid32.dll 实现:Option ExplicitPrivate Declare Function DiskID32 Lib “DiskID32.DLL“ (ByRef DiskModel As Byte, ByRef DiskID As Byte) As LongPrivate Sub Command1_Click()Dim DiskModel(31) As Byte, DiskID(31) As Byte, i As Integer, Model As String, ID As StringIf DiskID32(DiskModel(0), DiskID(0) Chr(0) ThenModel = Model & Chr(DiskModel(i)End IfIf Chr(DiskID(i) Chr(0) ThenID = ID & Chr(D
网站客服QQ:2055934822
金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号