PDA

View Full Version : Come leggere il codice driveC:, con VB6


visodont
06-09-2003, 17:47
Come è possibile leggere con il VB6, il numero di serie del disco Rigido C: o di altri dischi ?

Grazie,
Visodont

bsummer
06-09-2003, 18:25
Oggetto Drive, proprietà SerialNumber.

Aloha!

matpez
06-09-2003, 19:02
Oppure se per caso nn ti va di utilizzare un controllo perchè ti serve solo per te e nn vuoi occupare la form inutilmente ecco qua il codice:

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: [email protected]
Dim Serial As Long, VName As String, FSName As String
'Create buffers
VName = String$(255, Chr$(0))
FSName = String$(255, Chr$(0))
'Get the volume information
GetVolumeInformation "C:\", 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

bsummer
06-09-2003, 19:11
Se non vogliamo occupare spazio sul form, io la vedo + semplice così :


Dim fs, d, s
Set fs = CreateObject("Scripting.FileSystemObject")
Set d = fs.GetDrive("c")
s = "Numero Seriale :" & d.SerialNumber
MsgBox s



;)

Aloha!

visodont
07-09-2003, 16:09
Grazie, proverò !
Asta la vista,
Visodont