To register for an Internet.com membership to receive newsletters and white papers, use the Register button ABOVE.
To participate in the message forums BELOW, click here
VBForums  

VB Wire News
MSDN Subscribers: Download the VS 2010 Release Candidate
MSDN Subscribers: Download the VS 2010 Release Candidate
Sell Your Code and Make Money?
Creating your own Tetris game using VB.NET
Article :: Improving Software Economics, Part 4 of 7: Top 10 Principles of Iterative Software Management



Go Back   VBForums > Visual Basic > Visual Basic 6 and Earlier

Reply Post New Thread
 
Thread Tools Search this Thread Display Modes
Old Apr 23rd, 2007, 12:41 AM   #1
dr_aybyd
Addicted Member
 
Join Date: Nov 05
Posts: 201
dr_aybyd is an unknown quantity at this point (<10)
how to read/view serial number of USB Mass Storage

Hi, can you help on how can i view the serial number of my usb mass storage device plug in in my usb port..thanks!
dr_aybyd is offline   Reply With Quote
Old Apr 23rd, 2007, 10:59 AM   #2
mik706
Addicted Member
 
Join Date: Jul 02
Location: UK
Posts: 147
mik706 is an unknown quantity at this point (<10)
Re: how to read/view serial number of USB Mass Storage

You can use this to retreve the serial number of a drive you just need to pass it the root path as a string.
This does hopwever mean you need to workout what the root path of your usb drive is first.

Code:
Public Declare Function GetVolumeSerialNumber Lib "Kernel32.dll" 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

Public Function VolumeSerialNumber(ByVal RootPath As String) As String
    Dim VolLabel As String
    Dim VolSize As Long
    Dim Serial As Long
    Dim MaxLen As Long
    Dim Flags As Long
    Dim Name As String
    Dim NameSize As Long
    Dim S As String
    If GetVolumeSerialNumber(RootPath, VolLabel, VolSize, Serial, MaxLen, Flags, Name, NameSize) Then
        'Create an 8 character string
        S = Format(Hex(Serial), "00000000")
        'Adds the '-' between the first 4 characters and the last 4 characters
        VolumeSerialNumber = Left(S, 4) + "-" + Right(S, 4)
    Else
        'If the call to API function fails the function returns a zero serial number
        VolumeSerialNumber = "0000-0000"
    End If
End Function
usage:

Code:
Dim DiskNum As String

DiskNum = VolumeSerialNumber("C:\")
__________________
Mik706
mik706 is offline   Reply With Quote
Old Apr 23rd, 2007, 09:40 PM   #3
dr_aybyd
Addicted Member
 
Join Date: Nov 05
Posts: 201
dr_aybyd is an unknown quantity at this point (<10)
Re: how to read/view serial number of USB Mass Storage

thanks mik i got it now..
dr_aybyd is offline   Reply With Quote
Reply

Go Back   VBForums > Visual Basic > Visual Basic 6 and Earlier


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 12:20 PM.




To view more projects, click here

Acceptable Use Policy


The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.