• 软件测试技术
  • 软件测试博客
  • 软件测试视频
  • 开源软件测试技术
  • 软件测试论坛
  • 软件测试沙龙
  • 软件测试资料下载
  • 软件测试杂志
  • 软件测试人才招聘
    暂时没有公告

字号: | 推荐给好友 上一篇 | 下一篇

分辨率、卷标、序列号、分区表的读出

发布: 2007-5-25 09:19 | 作者: shawls | 来源: 互联网 | 查看: 54次 | 进入软件测试论坛讨论

领测软件测试网

 

Option Explicit

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

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 Sysflag 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 "驱动器文件系统 (FAT, 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

延伸阅读

文章来源于领测软件测试网 https://www.ltesting.net/