- 积分
- 15190
- 明经币
- 个
- 注册时间
- 2003-9-13
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
发表于 2003-12-16 18:57:00
|
显示全部楼层
Private Declare Function GetVolumeInformation Lib "kernel32.dll" Alias _
"GetVolumeInformationA" (ByVal lpRootPathName As String, ByVal _
lpVolumeNameBuffer As String, ByVal nVolumeNameSize As Integer, _
lpVolumeSerialNumber As Long, lpMaximumComponentLength As Long, _
lpFileSystemFlags As Long, ByVal lpFilesyStemNameBuffer As String, _
ByVal nFilesSystemNameSize As Long) As Long
Function GetSerialNumber(sRoot As String) As Long
Dim lSerialNum As Long
Dim R As Long
Dim strLabel As String, strType As String
strLabel = String$(255, Chr$(0))
strType = String$(255, Chr$(0))
R = GetVolumeInformation(sRoot, strLabel, Len(strLabel), _
lSerialNum, 0, 0, strType, Len(strType))
GetSerialNumber = lSerialNum
End Function
用法:lserial = GetSerialNumber("c:\")
lserial = GetSerialNumber("d:\")
lserial = GetSerialNumber("e:\")
如果驱动器不存在,则返回0。
本程序还可得到:磁盘卷标(strLabel),文件系统类型(strType)。 |
|