Вопрос
Как программно узнать имя CD-ROM'а?
Ответ
Private Declare Function GetVolumeInformation Lib "Kernel32" Alias
"GetVolumeInformationA" (ByVal lpRootPathName As String, ByVal lpVolumeNameBuffer As
String, ByVal nVolumeNameSize As Long, lpVolumeSerialNumber As Long,
lpMaximumComponentLength As Long, lpFileSystemFlags As Long, ByVal
lpFileSystemNameBuffer As String, ByVal nFileSystemNameSize As Long) As Long
Private Sub Form_Load()
'KPD-Team 1998
'URL: http://www.allapi.net/
'E-Mail: KPDTeam@Allapi.net
Dim Serial As Long, VName As String, FSName As String
Const CD_ROM As String = "C:\"
'Create buffers
VName = String$(255, Chr$(0))
FSName = String$(255, Chr$(0))
'Get the volume information
GetVolumeInformation CD_ROM, VName, 255, Serial, 0, 0, FSName, 255
'Strip the extra chr$(0)'s
VName = Left$(VName, InStr(1, VName, Chr$(0)) — 1)
FSName = Left$(FSName, InStr(1, FSName, Chr$(0)) — 1)
MsgBox "The Volume name of C:\ is '" + VName + "', the File system name of C:\
is '" + FSName + "' and the serial number of C:\ is '" + Trim(Str$(Serial)) + "'",
vbInformation + vbOKOnly, App.Title
End Sub
'VName — это и есть метка.Остальное если не надо можно поудалять.
Хвастунов Михаил
Copyright 2000-2004 Сообщество Чайников
Контактная информация