Jump to content

[VB6] Como ver o numero de serie do disco?


David Pintassilgo
 Share

Recommended Posts

Em vb6 é assim, tem que adicionar uma referencia a SCRRUN.DLL incluída no Microsoft Scripting Runtime library.

Outra opção é chamar a função GetVolumeInformation da API.

    Public Function DevolveNumeroSerie(Optional ByVal LetraDrive As String) As Long
      
          Dim fso As Object, Drv As Object
          
          
          Set fso = CreateObject("Scripting.FileSystemObject")
          
          
          If LetraDrive <> "" Then
              Set Drv = fso.GetDrive(LetraDrive)
          Else
              Set Drv = fso.GetDrive(fso.GetDriveName(App.Path))
          End If
      
          With Drv
              If .IsReady Then
                  DriveSerial = Abs(.SerialNumber)
              Else    
                  DriveSerial = -1
              End If
          End With
          

          Set Drv = Nothing
          Set fso = Nothing
          
          DevolveNumeroSerie = DriveSerial
          
      End Function

"The Dark Side Clouds Everthing. Impossible To See The Future Is."My rig: Intel Core 2 Quad Q9450 | abit IP35P | 4G Kingston 800 Mhz | XFX GeForce 9800 GX2 1G ddr3 | 2X WD5000AAJS 500Gb Sata 2 | PSU 600W || Caixa El-Diablo | Creative XMod

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.