11/2/2018 0 Comments Vb6 Get Serial NumberYou can get the serial number of your hard drive, floppy disk, or CD-ROM easily without any additional ActiveX component. Code Snippet Private Sub Command1_Click() Dim root As String Dim volume_name As String Dim serial_number As Long Dim max_component_length As Long Dim file_system_flags As Long Dim file_system_name As String Dim pos As Integer root = Text1.Text volume_name = Space$(1024) file_system_name = Space$(1024) If GetVolumeInformation(root, volume_name, _ Len(volume_name), serial_number, _ max_component_length, file_system_flags, _ file_system_name, Len(file_system_name)) = 0 _ Then MsgBox( 'Error getting volume information.' ) Exit Sub End If pos = InStr(volume_name, Chr$(0)) volume_name = Left$(volume_name, pos - 1) lblVolumeName.Caption = volume_name lblSerialNumber.Caption = Format$(serial_number) lblMaxComponentLength.Caption = _ Format$(max_component_length) pos = InStr(file_system_name, Chr$(0)) file_system_name = Left$(file_system_name, pos - 1) lblFileSystem.Caption = file_system_name lblFlags.Caption = '&&H' & Hex$(file_system_flags) End Sub. I am pasting the code of the class file opened by notepad here by --------------------------------------------------------------- VERSION 1.0 CLASS BEGIN MultiUse = -1 'True Persistable = 0 'NotPersistable DataBindingBehavior = 0 'vbNone DataSourceBehavior = 0 'vbNone MTSTransactionMode = 0 'NotAnMTSObject END Attribute VB_Name = 'HDSN' Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = True Attribute VB_PredeclaredId = False Attribute VB_Exposed = False Attribute VB_Ext_KEY = 'SavedWithClassBuilder6','Yes' Attribute VB_Ext_KEY = 'Top_Level','Yes' Option Explicit. (Evoluzione futura) End Select Select Case mvarPlatform Case 'WNT' ' Per Win NT/2000 apertura handle al drive fisico hdh = CreateFile(' & mvarCurrentDrive, _ GENERIC_READ + GENERIC_WRITE, FILE_SHARE_READ + FILE_SHARE_WRITE, _ 0, OPEN_EXISTING, 0, 0) Case 'W95', 'W98' ' Per Win 9X apertura handle al driver SMART ' (in WINDOWS SYSTEM da spostare in WINDOWS SYSTEM IOSUBSYS) ' che comunica con il driver IDE hdh = CreateFile(', _ 0, 0, 0, CREATE_NEW, 0, 0) Case Else ' Piattaforma non supportata (Win32S) Err.Raise 10002,, 'Illegal platform (only WNT, W98 or W95)' ' Altre piattaforme. Code Snippet Private Sub Command1_Click() Dim root As String Dim volume_name As String Dim serial_number As Long Dim max_component_length As Long Dim file_system_flags As Long Dim file_system_name As String Dim pos As Integer root = Text1.Text volume_name = Space$(1024) file_system_name = Space$(1024) If GetVolumeInformation(root, volume_name, _ Len(volume_name), serial_number, _ max_component_length, file_system_flags, _ file_system_name, Len(file_system_name)) = 0 _ Then MsgBox( 'Error getting volume information.' ) Exit Sub End If pos = InStr(volume_name, Chr$(0)) volume_name = Left$(volume_name, pos - 1) lblVolumeName.Caption = volume_name lblSerialNumber.Caption = Format$(serial_number) lblMaxComponentLength.Caption = _ Format$(max_component_length) pos = InStr(file_system_name, Chr$(0)) file_system_name = Left$(file_system_name, pos - 1) lblFileSystem.Caption = file_system_name lblFlags.Caption = '&&H' & Hex$(file_system_flags) End Sub. Hello everyone, i need your advise if i can get the Computer Serial number with using the Excel VBA. Hi Bruno, I am also interested in this topic. I also want to know how to retrieve using VB-6 the IDE header (hardware header of the HDD added by the manufacturer which includes serial number, model number, etc.) and the MAC address of the LAN adapter. Mr patil had asked about the manufacturer's serial number of the HDD. Your code is not the solution because it retrieves only the volume serial number inserted in the boot record by the Format command. Please review Mr patil's query and suggest the correct code. I am pasting the code of the class file opened by notepad here by --------------------------------------------------------------- VERSION 1.0 CLASS BEGIN MultiUse = -1 'True Persistable = 0 'NotPersistable DataBindingBehavior = 0 'vbNone DataSourceBehavior = 0 'vbNone MTSTransactionMode = 0 'NotAnMTSObject END Attribute VB_Name = 'HDSN' Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = True Attribute VB_PredeclaredId = False Attribute VB_Exposed = False Attribute VB_Ext_KEY = 'SavedWithClassBuilder6','Yes' Attribute VB_Ext_KEY = 'Top_Level','Yes' Option Explicit. (Evoluzione futura) End Select Select Case mvarPlatform Case 'WNT' ' Per Win NT/2000 apertura handle al drive fisico hdh = CreateFile(' & mvarCurrentDrive, _ GENERIC_READ + GENERIC_WRITE, FILE_SHARE_READ + FILE_SHARE_WRITE, _ 0, OPEN_EXISTING, 0, 0) Case 'W95', 'W98' ' Per Win 9X apertura handle al driver SMART ' (in WINDOWS SYSTEM da spostare in WINDOWS SYSTEM IOSUBSYS) ' che comunica con il driver IDE hdh = CreateFile(', _ 0, 0, 0, CREATE_NEW, 0, 0) Case Else ' Piattaforma non supportata (Win32S) Err.Raise 10002,, 'Illegal platform (only WNT, W98 or W95)' ' Altre piattaforme. Hi Guys, This code is great, even on Vista, after playing around a bit. The quick answer: either right-click the program and choose to run it as administrator, or try within softwaer to obtain administrative permissions. Otherwise, it won't work on vista. I played around for a while with this on a Windows Vista Business Edition machine.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |