VB语言

本类阅读TOP10

·Visual Basic 安装程序的制作!!
·VB中使用EXCEL输出
·一个简单的MP3播放器
·VB程序实现WindowsXP效果的界面!!
·VB打造超酷个性化菜单(六)
·透明位图
·平铺与拉伸MDI窗口的背景图 ~!~
·对《VB程序实现WindowsXP效果的界面》一文的补遗
·从Windows资源管理器中拖动文件
·VB打造超酷个性化菜单(一)

分类导航
VC语言Delphi
VB语言ASP
PerlJava
Script数据库
其他语言游戏开发
文件格式网站制作
软件工程.NET开发
分辨率、卷标、序列号、分区表的读出

作者:未知 来源:月光软件站 加入时间:2005-2-28 月光软件站

 

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




相关文章

相关软件