Vb6 Get Serial Number

Code SnippetPrivate Sub Command1ClickDim root As StringDim volumename As StringDim serialnumber As LongDim maxcomponentlength As LongDim filesystemflags As LongDim filesystemname As StringDim pos As Integerroot = Text1.Textvolumename = Space$(1024)filesystemname = Space$(1024)If GetVolumeInformation(root, volumename, Len(volumename), serialnumber, maxcomponentlength, filesystemflags, filesystemname, Len(filesystemname)) = 0 ThenMsgBox( 'Error getting volume information.' )Exit SubEnd Ifpos = InStr(volumename, Chr$(0))volumename = Left$(volumename, pos - 1)lblVolumeName.Caption = volumenamelblSerialNumber.Caption = Format$(serialnumber)lblMaxComponentLength.Caption = Format$(maxcomponentlength)pos = InStr(filesystemname, Chr$(0))filesystemname = Left$(filesystemname, pos - 1)lblFileSystem.Caption = filesystemnamelblFlags.Caption = '&&H' & Hex$(filesystemflags)End Sub. I am pasting the code of the class file opened by notepad here by-VERSION 1.0 CLASSBEGINMultiUse = -1 'TruePersistable = 0 'NotPersistableDataBindingBehavior = 0 'vbNoneDataSourceBehavior = 0 'vbNoneMTSTransactionMode = 0 'NotAnMTSObjectENDAttribute VBName = 'HDSN'Attribute VBGlobalNameSpace = FalseAttribute VBCreatable = TrueAttribute VBPredeclaredId = FalseAttribute VBExposed = FalseAttribute VBExtKEY = 'SavedWithClassBuilder6','Yes'Attribute VBExtKEY = 'TopLevel','Yes'Option Explicit. (Evoluzione futura)End SelectSelect Case mvarPlatformCase 'WNT' Per Win NT/2000 apertura handle al drive fisicohdh = CreateFile(' & mvarCurrentDrive, GENERICREAD + GENERICWRITE, FILESHAREREAD + FILESHAREWRITE, 0, OPENEXISTING, 0, 0)Case 'W95', 'W98' Per Win 9X apertura handle al driver SMART' (in WINDOWSSYSTEM da spostare in WINDOWSSYSTEMIOSUBSYS)' che comunica con il driver IDEhdh = CreateFile(', 0, 0, 0, CREATENEW, 0, 0)Case Else' Piattaforma non supportata (Win32S)Err.Raise 10002, 'Illegal platform (only WNT, W98 or W95)' ' Altre piattaforme. Code SnippetPrivate Sub Command1ClickDim root As StringDim volumename As StringDim serialnumber As LongDim maxcomponentlength As LongDim filesystemflags As LongDim filesystemname As StringDim pos As Integerroot = Text1.Textvolumename = Space$(1024)filesystemname = Space$(1024)If GetVolumeInformation(root, volumename, Len(volumename), serialnumber, maxcomponentlength, filesystemflags, filesystemname, Len(filesystemname)) = 0 ThenMsgBox( 'Error getting volume information.' )Exit SubEnd Ifpos = InStr(volumename, Chr$(0))volumename = Left$(volumename, pos - 1)lblVolumeName.Caption = volumenamelblSerialNumber.Caption = Format$(serialnumber)lblMaxComponentLength.Caption = Format$(maxcomponentlength)pos = InStr(filesystemname, Chr$(0))filesystemname = Left$(filesystemname, pos - 1)lblFileSystem.Caption = filesystemnamelblFlags.Caption = '&&H' & Hex$(filesystemflags)End Sub.

Get Desktop Serial Number

Vb6 get hard drive serial number

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. Please help.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 CLASSBEGINMultiUse = -1 'TruePersistable = 0 'NotPersistableDataBindingBehavior = 0 'vbNoneDataSourceBehavior = 0 'vbNoneMTSTransactionMode = 0 'NotAnMTSObjectENDAttribute VBName = 'HDSN'Attribute VBGlobalNameSpace = FalseAttribute VBCreatable = TrueAttribute VBPredeclaredId = FalseAttribute VBExposed = FalseAttribute VBExtKEY = 'SavedWithClassBuilder6','Yes'Attribute VBExtKEY = 'TopLevel','Yes'Option Explicit.

(Evoluzione futura)End SelectSelect Case mvarPlatformCase 'WNT' Per Win NT/2000 apertura handle al drive fisicohdh = CreateFile(' & mvarCurrentDrive, GENERICREAD + GENERICWRITE, FILESHAREREAD + FILESHAREWRITE, 0, OPENEXISTING, 0, 0)Case 'W95', 'W98' Per Win 9X apertura handle al driver SMART' (in WINDOWSSYSTEM da spostare in WINDOWSSYSTEMIOSUBSYS)' che comunica con il driver IDEhdh = CreateFile(', 0, 0, 0, CREATENEW, 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. It seemed to be the best way out of any code I found to get a hard drive serial number with any other operating system, but Vista just wasn't working. After dissecting it a little bit, I looked into the CreateFile function that is used to get a handle of the hard drive. See this page for more information:. There is a statement on this page that says, 'The caller must have administrative privileges.'

So I tried right-clicking my app, and this time it got what I needed! Now I'll just need to research a way through the User Account Control permissions for Vista. HelloI put this code in a module but it just turns to red text.codeVERSION 1.0 CLASSBEGINMultiUse = -1 'TruePersistable = 0 'NotPersistableDataBindingBehavior = 0 'vbNoneDataSourceBehavior = 0 'vbNoneMTSTransactionMode = 0 'NotAnMTSObjectENDAttribute VBName = 'HDSN'Attribute VBGlobalNameSpace = FalseAttribute VBCreatable = TrueAttribute VBPredeclaredId = FalseAttribute VBExposed = FalseAttribute VBExtKEY = 'SavedWithClassBuilder6','Yes'Attribute VBExtKEY = 'TopLevel','Yes'Option Explicit/codeis there a difference of putting it in a module vs a class module?

Raj, This requires Admin Previlleges and will not work in user login mode.