VB怎么获取磁盘分区号

VB怎么获取磁盘分区号,第1张

:Private Declare Function GetLogicalDriveStrings Lib "kernel32" Alias "GetLogicalDriveStringsA" (ByVal nBufferLength As Long, ByVal lpBuffer As String) As Long Private Declare Function GetDriveType Lib "kernel32" Alias "GetDrive

你可以调用vb的内部控件CommonDialog 60。

在工具箱里单击右键,选部件,再选microsoft common dialog control 60

就会出现这个控件。

然后你就可以运用了。

Option Explicit

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)

Const MAX_FILENAME_LEN = 256

Private Sub Form_Load()

Dim RetVal As Long

Dim str As String MAX_FILENAME_LEN

Dim str2 As String MAX_FILENAME_LEN

Dim A As Long

Dim B As Long

MeShow

Call GetVolumeInformation("C:\", str, MAX_FILENAME_LEN, RetVal, A, B, str2, MAX_FILENAME_LEN)

Text1 = RetVal

End Sub

Private Declare Function GetVolumeInformation _

Lib "kernel32" Alias "GetVolumeInformationA" _

(ByVal lpRootPathName As String, _

ByVal lpszVolumeNameBuffer As String, _

ByVal lVolumeNameSize As Long, _

lpVolumeSerialNumber As Long, _

lpMaximumComponentLength As Long, _

lpFileSystemFlags As Long, _

ByVal lpszFileSystemNameBuffer As String, _

ByVal nFileSystemNameSize As Long) As Long

Public Function GetVolumeSerialNumber(ByVal RootPath As String) As String

Dim lpszVolumeNameBuffer As String

Dim lpszFileSystemNameBuffer As String

Dim lVolumeNameSize As Long

Dim lpVolumeSerialNumber As Long

Dim lpMaximumComponentLength As Long

Dim lpFileSystemFlags As Long

Dim nFileSystemNameSize As Long

Dim lRetVal As Long

lpVolumeSerialNumber = 0

lpMaximumComponentLength = 0

lpFileSystemFlags = 0

lpszVolumeNameBuffer = Space$(255)

lpszFileSystemNameBuffer = Space(255)

lVolumeNameSize = Len(lpszVolumeNameBuffer)

nFileSystemNameSize = Len(lpszFileSystemNameBuffer)

lRetVal = GetVolumeInformation(RootPath, _

lpszVolumeNameBuffer, _

lVolumeNameSize, _

lpVolumeSerialNumber, _

lpMaximumComponentLength, _

lpFileSystemFlags, _

lpszFileSystemNameBuffer, _

nFileSystemNameSize)

GetVolumeSerialNumber = Hex$(lpVolumeSerialNumber)

End Function

Private Sub Command1_Click()

Dim sRetVal As String

sRetVal = GetVolumeSerialNumber("C:\")

MsgBox "VolumeSerialNumber is: " & sRetVal

End Sub

只需在窗体建一个COMMAND1。

以上就是关于VB怎么获取磁盘区号全部的内容,包括:VB怎么获取磁盘分区号、在VB中调用本地磁盘、vb 获取硬盘序列号序列号等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/10083228.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-05
下一篇 2023-05-05

发表评论

登录后才能评论

评论列表(0条)

保存