解析度、卷標、序列號、分割槽表的讀出 (轉)

gugu99發表於2008-07-11
解析度、卷標、序列號、分割槽表的讀出 (轉)[@more@]

 

Option Explicit

Private Declare Function GetVolumeInformation Lib "kernel32.dll" Alias "GetVolumeInformationA" (ByVal lpPathName 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

Const FILE_VOLUME_IS_COMPRESSED = &H8000

Function GetSerialNumber(strDrive As String) As Long
Dim SerialNum As Long
Dim Res As Long
Dim Temp1 As String
Dim Temp2 As String
Temp1 = String$(255, Chr$(0))
Temp2 = String$(255, Chr$(0))
Res = GetVolumeInformation(strDrive, Temp1, Len(Temp1), SerialNum, 0, 0, Temp2, Len(Temp2))
MsgBox Temp1
MsgBox Temp2
MsgBox Hex(SerialNum)
GetSerialNumber = SerialNum
End Function

Public Sub GetVolInfo(ByVal path As String)
Dim aa As Long
Dim VolName As String
Dim fsysName As String
Dim VolSeri As Long, compress As Long
Dim Sylag As Long, Maxlen As Long
'初試化字串的長度
VolName = String(255, 0)
fsysName = String(255, 0)
aa = GetVolumeInformation(path, VolName, 256, VolSeri, Maxlen, _
Sysflag, fsysName, 256)
VolName = Left(VolName, InStr(1, VolName, Chr(0)) - 1)
fsysName = Left(fsysName, InStr(1, fsysName, Chr(0)) - 1)
compress = Sysflag And FILE_VOLUME_IS_COMPRESSED
If compress = 0 Then
MsgBox "未器"
Else
MsgBox "壓縮驅動器"
End If
MsgBox "驅動器卷標 :" + VolName
MsgBox "驅動器標號 : " + Hex(VolSeri)
MsgBox "驅動器 (, HPFS, or NTFS)" + fsysName
MsgBox "支援的檔名長度" + Str$(Maxlen)
End Sub

Private Sub Command1_Click()
MsgBox GetSerialNumber("C:")
End Sub


Private Sub Command2_Click()
Call GetVolInfo("C:")
End Sub

Private Sub Command3_Click()
Dim cr As String
Dim Twidth As Integer
Dim Theight As Integer
cr = Chr$(13) + Chr$(10)
Twidth% = Screen.Width Screen.TwipsPerPixelX
Theight% = Screen.Height Screen.TwipsPerPixelY
MsgBox "螢幕大小為" + cr + cr + Str$(Twidth%) + " x" + Str$(Theight%), 64, "Info"
End Sub


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/10748419/viewspace-1007112/,如需轉載,請註明出處,否則將追究法律責任。

相關文章