Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Leggere il numero seriale con il visual basic

74 views
Skip to first unread message

Angelo Caputo

unread,
Feb 3, 2005, 8:44:17 AM2/3/05
to
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
(Toronto):

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

GbC|

unread,
Feb 3, 2005, 9:17:00 AM2/3/05
to
"Angelo Caputo" ha scritto...


> 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


Albe V°

unread,
Feb 3, 2005, 9:39:04 AM2/3/05
to
GbC| wrote:
> "Angelo Caputo" ha scritto...
>
>
>> 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...

E oltretutto non funziona ;-)

Alberto


--
E tutto mi sembrava andasse bene...


Wodka40°

unread,
Feb 3, 2005, 1:27:27 PM2/3/05
to
questo è quello che dice allAPI

'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


Ottomano Nicola

unread,
Feb 3, 2005, 4:45:41 PM2/3/05
to
"GbC|" <use...@gbcweb.com> ha scritto nel messaggio
news:wnqMd.14254$lB4.3...@twister1.libero.it
> "Angelo Caputo" ha scritto...
>
>
>> 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...

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

Fosco

unread,
Feb 5, 2005, 12:56:04 AM2/5/05
to
"Albe V°"

> E oltretutto non funziona ;-)

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


Albe V°

unread,
Feb 7, 2005, 3:00:51 AM2/7/05
to
Fosco wrote:
> "Albe V°"
>> E oltretutto non funziona ;-)
>
> questo si ..

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


0 new messages