?? 58.txt
字號:
如何獲取硬盤卷標、序列號和文件系統類型?
磁盤序列號在每次軟盤或硬盤格式化后都重新生成,并且不回重復。許多程序員用此加密。其實也可以修改該函數,可以得到磁盤卷標和文件系統類型信息。
聲明:
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 nFileSystemNameSize 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))
'文件系統類型 一般為 FAT
R = GetVolumeInformation(sRoot, strLabel, Len(strLabel), _
lSerialNum, 0, 0, strType, Len(strType))
GetSerialNumber = lSerialNum
'在 strLabel 中為 磁盤卷標
'在 strType 中為 文件系統類型
End Function
用法:
當驅動器不存在時,函數返回 0。如果是個非根目錄,也將返回 0:
lSerial = GetSerialNumber("c:\")
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -