Private Sub Form_Load()
Dim SerialeDrive
Dim fso As Object, Drv As Object
'Crea FileSystemObject object
Set fso = CreateObject("Scripting.FileSystemObject")
'Assegna letter del disco se non specificato
If DriveLetter <> "" Then
Set Drv = fso.GetDrive(DriveLetter)
Else
Set Drv = fso.GetDrive(fso.GetDriveName(App.Path))
End If
With Drv
If .IsReady Then
DriveSerial = Abs(.SerialNumber)
Else '"Disco non č pronto!"
SerialeDrive = -1
End If
End With
'Pulisci
Set Drv = Nothing
Set fso = Nothing
MsgBox " Numero seriale di questo disco " & Left(App.Path,
1) & ": " & SerialeDrive
End
End Sub
> Questo č il piu semplice script per leggere il numero seriale del
> disco (funziona con VB5 e VB6), mi č stato dato dal mio amico Dr. Wrya
[CUT]
Si, ma con il FSO...
-> GbC|
www.gbcweb.com
E oltretutto non funziona ;-)
Alberto
--
E tutto mi sembrava andasse bene...
'Example by Alexey (alexey...@rambler.ru)
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 Const MAX_FILENAME_LEN = 256
Public Function DriveSerial(ByVal sDrv As String) As Long
Dim RetVal As Long
Dim str As String * MAX_FILENAME_LEN
Dim str2 As String * MAX_FILENAME_LEN
Dim a As Long
Dim b As Long
Call GetVolumeInformation(sDrv & ":\", str, MAX_FILENAME_LEN, RetVal, a,
b, str2, MAX_FILENAME_LEN)
DriveSerial = RetVal
End Function
Private Sub Form_Load()
MsgBox "Serial of drive C is " & DriveSerial("C")
End Sub
se imposti il seriale
E che di solito fa incazzare il Norton Antivirus... :-(
bye
--
"Seminate Linux, che Windows si pianta da sè...." (Antico Adagio)
Gestione Ottica - Gestionale per Ottici e Programmi Gratuiti su:
http://www.nicolaottomano.it
Sinapsi Antispam. Antispam Gratuito.
http://www.sinapsi-antispam.tk
http://www.nicolaottomano.it/sinapsi.htm
email spamtrap: spam...@nicolaottomano.it
questo si .. e mi pare che l'abbia postato proprio
qui qualcuno tempo fa' ,non ricordo chi pero' :- (( :
' *.vbs
Set fso = CreateObject("Scripting.FileSystemObject")
Set d = fso.GetDrive(fso.GetDriveName(fso.GetAbsolutePathName(drvpath)))
s = "Unità " & d.DriveLetter & ": - " & t
s = s & vbCrLf & "SN: " & d.SerialNumber
GetSN= s
MsgBox s
'''''''''''''''''Originale x Visual Basic
1) Ricavare il numero seriale dell'Hard-Disk (metodo senza API):
Private Sub Form_Load()
MsgBox GetSN(drvpath)
End Sub
Private Function GetSN(drvpath) As String
Dim fso As Object, d As Object, s As String
Set fso = CreateObject("Scripting.FileSystemObject")
Set d = fso.GetDrive(fso.GetDriveName(fso.GetAbsolutePathName(drvpath)))
s = "Unità " & d.DriveLetter & ": - " & t
s = s & vbCrLf & "SN: " & d.SerialNumber
GetSN = s
End Function
--
Fosco
Beh, quello che hai postato non funziona.
Ma, a parte la variabile non dichiarata che č facile da risolvere, resta il
punto sollevato correttamente da GBC, ossia che si utilizza il FSO, e quindi
non va su tutti i sistemi (quasi, ma non tutti).
Ciao
Alberto