'引用api获得硬盘序列号
网站建设哪家好,找成都创新互联公司!专注于网页设计、网站建设、微信开发、微信小程序定制开发、集团企业网站建设等服务项目。为回馈新老客户创新互联还提供了海西免费建站欢迎大家使用!
Private Declare Function MymachineC Lib "kernel32" Alias "GetVolumeInformationA" (ByVal lpRootPathName As String, ByVal lpVolumeNameBuffer As String, ByVal nVolumeNameSize As Long, lpVolumeSerialNumber As Long, lpMaximumComponentLength As Long, lpFileSystemFlags As Long, ByVal lpFileSystemNameBuffer As String, ByVal nFileSystemNameSize As Long) As Long
Private Sub Form_Load()
Dim AA, 硬盘序列号, Maxlen, Sysflag As Long: Dim VolName, FsysName As String
AA = MymachineC("c:\", VolName, 256, 硬盘序列号, Maxlen, Sysflag, FsysName, 256)
msgbox "C硬盘序列号-机器码啦-(16制): " Hex(硬盘序列号)
End Sub
很难达到你的要求的,VB好像是获取不到硬盘的物理序列号的,只能获取到某一个分区的序列号.不过可以调用其它的程序写的获取硬盘物理序列号的dll来获取,CPU的序列号我用的是wmi.VB本来对底层方面就不是很好
引用api获得硬盘序列号
Private Declare Function MymachineC Lib "kernel32" Alias "GetVolumeInformationA" (ByVal lpRootPathName As String, ByVal lpVolumeNameBuffer As String, ByVal nVolumeNameSize As Long, lpVolumeSerialNumber As Long, lpMaximumComponentLength As Long, lpFileSystemFlags As Long, ByVal lpFileSystemNameBuffer As String, ByVal nFileSystemNameSize As Long) As Long
Private Sub Form_Load()
Dim AA, 硬盘序列号, Maxlen, Sysflag As Long: Dim VolName, FsysName As String
AA = MymachineC("c:\", VolName, 256, 硬盘序列号, Maxlen, Sysflag, FsysName, 256)
msgbox "C硬盘序列号-机器码啦-(16制): " Hex(硬盘序列号)
End Sub
电脑没有机器码的,我们所说的机器码指对电脑的配件(如硬盘)型号按一定算法演算出的代码.通常不同软件演算出的机器码都是不一样的,下面三个函数分别得到本机IP,电脑名称,硬盤Id.(硬盤id可做机器码)Public Function GetIPAddress() As String'得到IPSTRComputer = "."
Set OBJWMIService = GetObject("winmgmts:" "{impersonationLevel=impersonate}!\\" STRComputer "\root\cimv2")Set IPConfigSet = OBJWMIService.ExecQuery("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled=TRUE") For Each IPConfig In IPConfigSet If Not IsNull(IPConfig.IPAddress) Then For i = LBound(IPConfig.IPAddress) To UBound(IPConfig.IPAddress) GetIPAddress = IPConfig.IPAddress(i) Next End IfNext
End Function
Public Function GetUserName() As String'得到电脑名称STRComputer = "."
Set OBJWMIService = GetObject("winmgmts:\\" STRComputer "\root\CIMV2")Set ColCSItems = OBJWMIService.ExecQuery("SELECT * From Win32_ComputerSystem")For Each OBJCSItem In ColCSItems GetUserName = OBJCSItem.UserNameNext
End Function
Public Function GetDiskID(Disk As String) As String'得到磁盤IDDim Flag As BooleanDim DiskID As String
Flag = FalseOn Error GoTo label
DiskID = Str(CreateObject("Scripting.FileSystemObject").GetDrive(Disk).SerialNumber)
Flag = Truelabel:If Flag Then GetDiskID = DiskIDElse GetDiskID = "" x = MsgBox("Function Parameter Like C " + Chr(10) + Chr(13) + "Please Check The Existence Of The " + Disk + " Disk", vbInformation + vbOKOnly, "Microsoft Excel 5.0")End If
End Function
新闻名称:读机器码vbnet 写机器码
URL分享:https://www.cdcxhl.com/article38/doejgsp.html
成都网站建设公司_创新互联,为您提供Google、云服务器、企业建站、外贸网站建设、移动网站建设、网站营销
声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联