Read soft hard disc serial number

Source: Internet
Author: User
Tags chr

Getting the serial number is the information to read the soft hard disc, which can be obtained by using the following function:

Public Declare Function getvolumeinformation Lib "kernel32.dll" Alias "Getvolumeinformationa" (ByVal lpRootPathName as St Ring, ByVal Lpvolumenamebuffer as String, ByVal nvolumenamesize as Integer, Lpvolumeserialnumber as Long, Lpmaximumcompone Ntlength as Long, lpfilesystemflags as Long, ByVal Lpfilesystemnamebuffer as String, ByVal nfilesystemnamesize as Long) as Long.

Now explain this function:

It is used to obtain a serial number, volume label, disk information (such as whether compression, etc.) the following example:

Set the custom function to call it first:

Function GetItNum(strDrv As String) As Long
Dim GetNum As Long
Dim Rs As Long
Dim Temp1 As String
Dim Temp2 As String
Temp1 = String$(255, Chr$(0))
Temp2 = String$(255, Chr$(0))
Rs = GetVolumeInformation(strDrv, Temp1, Len(Temp1), GetNum, 0, 0, Temp2, Len(Temp2))
MsgBox "卷标为:"+Temp1
MsgBox "序列号为:"+Hex(SerialNum)
End Function

Call Getitnum When you use it later ("Disk") on it!

This can be very smooth to control the mouse!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.