VB取磁盘序列号卷标和文件系统类型
声明: PrivateDeclareFunctionGetVolumeInformationLib"kernel32.dll"Alias"GetVolumeInformationA"(ByVallpRootPathNameAsString,ByVallpVolumeNameBufferAsString,ByValnVolumeNameSizeAsInteger,lpVolumeSerialNumberAsLong,lpMaximumComponentLengthAs
声明:
PrivateDeclareFunctionGetVolumeInformationLib"kernel32.dll"Alias"GetVolumeInformationA"(ByVallpRootPathNameAsString,ByVallpVolumeNameBufferAsString,ByValnVolumeNameSizeAsInteger,lpVolumeSerialNumberAsLong,lpMaximumComponentLengthAsLong,lpFileSystemFlagsAsLong,ByVallpFileSystemNameBufferAsString,ByValnFileSystemNameSizeAsLong)AsLong
代码:
FunctionGetSerialNumber(sRootAsString)AsLong
DimlSerialNumAsLong
DimRAsLong
DimsTemp1AsString,sTemp2AsString
strLabel=String$(255,Chr$(0))
注释:磁盘卷标
strType=String$(255,Chr$(0))
注释:文件系统类型一般为FAT
R=GetVolumeInformation(sRoot,strLabel,Len(strLabel),lSerialNum,0,0,strType,Len(strType))
GetSerialNumber=lSerialNum
注释:在strLabel中为磁盘卷标
注释:在strType中为文件系统类型
EndFunction
用法:
当驱动器不存在时,函数返回0。如果是个非根目录,也将返回0:
lSerial=GetSerialNumber("c:")->
PrivateDeclareFunctionGetVolumeInformationLib"kernel32.dll"Alias"GetVolumeInformationA"(ByVallpRootPathNameAsString,ByVallpVolumeNameBufferAsString,ByValnVolumeNameSizeAsInteger,lpVolumeSerialNumberAsLong,lpMaximumComponentLengthAsLong,lpFileSystemFlagsAsLong,ByVallpFileSystemNameBufferAsString,ByValnFileSystemNameSizeAsLong)AsLong
代码:
FunctionGetSerialNumber(sRootAsString)AsLong
DimlSerialNumAsLong
DimRAsLong
DimsTemp1AsString,sTemp2AsString
strLabel=String$(255,Chr$(0))
注释:磁盘卷标
strType=String$(255,Chr$(0))
注释:文件系统类型一般为FAT
R=GetVolumeInformation(sRoot,strLabel,Len(strLabel),lSerialNum,0,0,strType,Len(strType))
GetSerialNumber=lSerialNum
注释:在strLabel中为磁盘卷标
注释:在strType中为文件系统类型
EndFunction
用法:
当驱动器不存在时,函数返回0。如果是个非根目录,也将返回0:
lSerial=GetSerialNumber("c:")->
- 上一篇:用VB获得大容量硬盘信息
- 下一篇:教你在CoolBar中显示指定的图片
精彩图集
精彩文章