gpt4 book ai didi

vb6 - 如何使用 VB 6 读取硬盘卷序列号?

转载 作者:行者123 更新时间:2023-12-01 00:01:27 25 4
gpt4 key购买 nike

如何在不使用任何 ActiveX 控件或第三方插件的情况下使用 VB 6 读取硬盘卷序列号?

最佳答案

Private Declare Function GetVolumeInformation _
Lib "kernel32" Alias "GetVolumeInformationA" _
(ByVal lpRootPathName As String, _
ByVal pVolumeNameBuffer 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

Public Function GetSerialNumber( _
ByVal sDrive As String) As Long

If Len(sDrive) Then
If InStr(sDrive, "\\") = 1 Then
' Make sure we end in backslash for UNC
If Right$(sDrive, 1) <> "\" Then
sDrive = sDrive & "\"
End If
Else
' If not UNC, take first letter as drive
sDrive = Left$(sDrive, 1) & ":\"
End If
Else
' Else just use current drive
sDrive = vbNullString
End If

' Grab S/N -- Most params can be NULL
Call GetVolumeInformation( _
sDrive, vbNullString, 0, GetSerialNumber, _
ByVal 0&, ByVal 0&, vbNullString, 0)
End Function

调用:

Dim Drive As String
Drive = InputBox("Enter drive for checking SN")
MsgBox Hex$(GetSerialNumber(Drive))

来源:http://www.devx.com/tips/Tip/15908

关于vb6 - 如何使用 VB 6 读取硬盘卷序列号?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12099135/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com