Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Volume Serial Number

Status
Not open for further replies.

victoryhighway2

Programmer
Jul 18, 2005
42
US
Hello group,
Is there a method of reading and/or changing a disk's volume serial number in visual basic code?

If so, how would I be able to do it?

Thanks,
Geoffrey
 
Check out this thread: thread222-845977

I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson
 
Hi jebenson,
I looked at that thread at it's not exactly what I'm looking for. I am using a USB flash drive to provide application security and I would like to use the OS level (FAT? Boot sector?) Volume Serial Number.

I've been looking around the 'net for information about this and I found a way that we can read this via Visual Basic code:

Code:
Public Declare Function GetVolumeSerialNumber Lib "kernel32" Alias "GetVolumeInformationA" (ByVal lpRootPathName As String, ByVal lpVolumeNameBuffer As Long, ByVal nVolumeNameSize As Long, lpVolumeSerialNumber As Long, ByVal lpMaximumComponentLength As Long, ByVal lpFileSystemFlags As Long, ByVal lpFileSystemNameBuffer As Long, ByVal nFileSystemNameSize As Long) As Long

Public Function VolumeSerial(DriveLetter) As Long
    Dim Serial As Long
    Call GetVolumeSerialNumber(UCase(DriveLetter) & ":\", 0&, 0&, Serial, 0&, 0&, 0&, 0&)
    VolumeSerial = Serial
End Function

On the other side, I have found a site with some C code for changing the serial number:

I just don't know if there is a way to do this with VB code.

Any advice?

Regards,
Geoffrey
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top