大橙子网站建设,新征程启航

为企业提供网站建设、域名注册、服务器等服务

vb.net硬盘号 vb读取硬盘序列号

请问为什么我公司的vb.net源码到了我的电脑上运行就会显示好多未声明啊?

用API 函数GetVolumeInformation得到的不是硬盘的序列号!!!

公司主营业务:网站制作、成都做网站、移动网站开发等业务。帮助企业客户真正实现互联网宣传,提高企业的竞争能力。成都创新互联是一支青春激扬、勤奋敬业、活力青春激扬、勤奋敬业、活力澎湃、和谐高效的团队。公司秉承以“开放、自由、严谨、自律”为核心的企业文化,感谢他们对我们的高要求,感谢他们从不同领域给我们带来的挑战,让我们激情的团队有机会用头脑与智慧不断的给客户带来惊喜。成都创新互联推出襄州免费做网站回馈大家。

BOOL GetVolumeInformation(

LPCTSTR lpRootPathName,

LPTSTR lpVolumeNameBuffer,

DWORD nVolumeNameSize,

LPDWORD lpVolumeSerialNumber,

LPDWORD lpMaximumComponentLength,

LPDWORD lpFileSystemFlags,

LPTSTR lpFileSystemNameBuffer,

DWORD nFileSystemNameSize

);

看看英文啊:VolumeSerialNumber!得到的只是卷区序列号!

硬盘的序列号应该是

Drive Model Number________________: WDC WD400EB-00CPF0

Drive Serial Number_______________: WD-WCAATF083586

Drive Controller Revision Number__: 06.04G06

Controller Buffer Size on Drive___: 2097152 bytes

Drive Type________________________: Fixed

Drive Size________________________: 40020664320 bytes

中:

Drive Serial Number_______________: WD-WCAATF083586 这才是硬盘Serial Number!!!!

这个号是不会因为你格式化硬盘而改动,也不是网上流传的修改工具能改的,(其实网上流传的修改工具的也不过是卷区号而已!)

建议用 DiskID.dll或DiskID32.dll来获取

用diskid.dll和disk32.dll获得硬盘序列号

1.调用diskid.dll实现:

Option Explicit

Private Declare Function IsWinNT Lib "DiskID.DLL" () As Long

Private Declare Function ReadPhysicalDrive9X Lib "DiskID.DLL" (driveID As Long, buffer As Long, bufLen As Long) As Long

Private Declare Function ReadPhysicalDriveInNT Lib "DiskID.DLL" (driveID As Long, buffer As Long, bufLen As Long) As Long

Private Type DRIVER_INFO_OK

ModalNumber(39) As Byte

SerialNumber(19) As Byte

ControlNum(7) As Byte

DriveType As Long

Cylinders As Long

Heads As Long

Sectors As Long

End Type

Private Sub Command1_Click()

Dim x As DRIVER_INFO_OK

Dim i As Long

If IsWinNT = 1 Then

i = ReadPhysicalDriveInNT(ByVal 0, ByVal VarPtr(x), ByVal 256)

Else

i = ReadPhysicalDrive9X(ByVal 0, ByVal VarPtr(x), ByVal 256)

End If

Dim s As String

s = StrConv(x.ModalNumber, vbUnicode)

s = Left(s, InStr(1, s, Chr(0)) - 1)

MsgBox "硬件厂商代码为:" + s

s = StrConv(x.SerialNumber, vbUnicode)

s = Left(s, InStr(1, s, Chr(0)) - 1)

MsgBox "硬盘序列号为:" + s

End Sub

2.调用diskid32.dll实现:

Option Explicit

Private Declare Function DiskID32 Lib "DiskID32.DLL" (ByRef DiskModel As Byte, ByRef DiskID As Byte) As Long

Private Sub Command1_Click()

Dim DiskModel(31) As Byte, DiskID(31) As Byte, i As Integer, Model As String, ID As String

If DiskID32(DiskModel(0), DiskID(0)) 1 Then

MsgBox "get diskid32 err"

Exit Sub

End If

For i = 0 To 31

If Chr(DiskModel(i)) Chr(0) Then

Model = Model Chr(DiskModel(i))

End If

If Chr(DiskID(i)) Chr(0) Then

ID = ID Chr(DiskID(i))

End If

Next

MsgBox "硬件产生代码为:" + Model

MsgBox "硬盘序列号为:" + ID

End Sub

说明:diskid.dll可从下载

diskid32.dll可从下载

VS2010中怎么获取cpu或者硬盘序列号。用vb.net。想编一个注册码的软件

Private Function 硬盘序列号() As String

Try

Dim myInfo As Microsoft.Win32.RegistryKey = My.Computer.Registry.LocalMachine.OpenSubKey("HARDWARE\DEVICEMAP\Scsi\Scsi Port 0\Scsi Bus 1\Target Id 0\Logical Unit Id 0")

硬盘序列号 = Trim(myInfo.GetValue("SerialNumber"))

Catch

Try

Dim myInfo As Microsoft.Win32.RegistryKey = My.Computer.Registry.LocalMachine.OpenSubKey("HARDWARE\DEVICEMAP\Scsi\Scsi Port 1\Scsi Bus 1\Target Id 0\Logical Unit Id 0")

硬盘序列号 = Trim(myInfo.GetValue("SerialNumber"))

Catch

硬盘序列号 = ""

End Try

End Try

End Function

只在我的电脑上试过,你试下

VB.NET获取硬盘信息的几种方法

strResult += 磁盘类型: System.Convert.ToInt16(disk(DriveType).ToString())End IfMsgBox(strResult)NextEnd Sub总结:在VB.NET中,用API函数可以获取硬盘信息。原来熟悉API函数VB6程序员,可以对API函数声明进行适当的更改后,进行调用。利用FSO(文件系统对象)的Scrrun.DLL,也可以获得磁盘信息。在.net Framwork中,利用WMI可以获取更多的关于机器硬件的详细信息(参考System.Management命名空间)。

win7下vb.net 如何获取硬盘序列号

Private Function 硬盘序列号() As String

Try

Dim myInfo As Microsoft.Win32.RegistryKey = My.Computer.Registry.LocalMachine.OpenSubKey("HARDWARE\DEVICEMAP\Scsi\Scsi Port 0\Scsi Bus 1\Target Id 0\Logical Unit Id 0")

硬盘序列号 = Trim(myInfo.GetValue("SerialNumber"))

Catch

Try

Dim myInfo As Microsoft.Win32.RegistryKey = My.Computer.Registry.LocalMachine.OpenSubKey("HARDWARE\DEVICEMAP\Scsi\Scsi Port 1\Scsi Bus 1\Target Id 0\Logical Unit Id 0")

硬盘序列号 = Trim(myInfo.GetValue("SerialNumber"))

Catch

硬盘序列号 = ""

End Try

End Try

End Function

试下,如果返回为空,则表示失败。

在本机win8win8.1有效,不过好像在有些机器上没用。


本文名称:vb.net硬盘号 vb读取硬盘序列号
新闻来源:http://dzwzjz.com/article/doocsjc.html
在线咨询
服务热线
服务热线:028-86922220
TOP