Newsgroup: it.comp.lang.visual-basic
Titolo: Seriale disco

La funzione sotto che io chiamo in questo modo:
numero= SerialeDisco("C:") funziona se il programma si trova su un disco
diverso da C: altrimenti mi restituisce zero! Cosa č che sbaglio?
Grazie
greg
----------------------------
Function SerialeDisco(disCo As String) As Long
Dim SerialNum As Long
Dim Result As Long
Dim Temp1 As String
Dim Temp2 As String
   Temp1 = String$(255, Chr$(0))
   Temp2 = String$(255, Chr$(0))
   Result = GetVolumeInformation(disCo, Temp1, Len(Temp1), SerialNum, 0, 0,
Temp2, Len(Temp2))
SerialeDisco = SerialNum
End Function
--
Greg

 diverso da C: altrimenti mi restituisce zero!
si neanche qui va'  questo esempio di AllApi  funziona (scaricalo se non lo hai)
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: KPD...@Allapi.net
    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
--
Fosco

 si neanche qui va'  questo esempio di AllApi  funziona (scaricalo se non lo hai)
http://www.mentalis.org/agnet/apiguide.shtml
http://www.allapi.net/agnet/appdown.shtml
--
Fosco

 "greg"
Stessa cosa col File System Object (*.vbs) :
Set oFSO = CreateObject("Scripting.FileSystemObject")
'sDriveName = oFSO.GetDriveName(sArg)
sDriveName="c:\"
With oFSO.GetDrive(sDriveName)
    Wscript.Echo "Total size of drive (KB):", .TotalSize / 1024
    Wscript.Echo "Available space (KB)    :", .AvailableSpace / 1024
    Wscript.Echo "Free space (KB)         :", .FreeSpace / 1024
    Wscript.Echo "Drive letter            :", .DriveLetter
    Wscript.Echo "UNC share name          :", .ShareName
    Wscript.Echo "Volume name             :", .VolumeName
    Wscript.Echo "Path                    :", .Path
    Wscript.Echo "Serial number           :", Hex(.SerialNumber)
     Wscript.Echo "Serial number           :", .SerialNumber
     Wscript.Echo "File system             :", .FileSystem
    Wscript.Echo "Drive ready             :", CBool(.IsReady)
    Select Case .DriveType
        Case 1: sType = "Removable"
        Case 2: sType = "Fixed"
        Case 3: sType = "Network"
        Case 4: sType = "CDROM"
        Case 5: sType = "RAM Disk"
        Case Else sType = "Unknown"
    End Select
    Wscript.Echo "Drive type              :", sType
End With
Set oFSO = Nothing
--
Fosco

 non lo hai)
Grazie Fosco, questo va bene
--
Greg