|
-
May 30th, 2009, 01:13 PM
#1
Thread Starter
Lively Member
[RESOLVED] serial number of pen drive
hello..
somebody can helpme about get the serial number of pen drive ( not volume information).
thanks all...
-
May 31st, 2009, 05:01 PM
#2
Re: serial number of pen drive
here is some code to get serial number, if you have more than 1 usb drive you will need to make an array or simething, as obviously this will only get the serial number of the last usb drive
vb Code:
strComputer = "." Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2") Set colitems = objWMIService.ExecQuery("SELECT * FROM Win32_DiskDrive", , 48) For Each objitem In colitems If objitem.interfacetype = "USB" Then sernum = objitem.pnpdeviceid Next sernum = Mid(sernum, InStrRev(sernum, "\") + 1) sernum = Left(sernum, InStr(sernum, "&") - 1)
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Jul 21st, 2009, 10:57 AM
#3
New Member
Re: serial number of pen drive
READ USB serial number with VB.
You are just too good Man. I looked high and dry on the net for this code but none came even close enough. If u cud make it detect all usb drives and their serial numbers in a list,you've got a winner.
Anyway, i bow to the master.
Last edited by Laserfinder; Jul 21st, 2009 at 11:01 AM.
-
Feb 25th, 2010, 12:19 PM
#4
New Member
Re: serial number of pen drive
The code is nice and it works. But new Pen Drive does not have Serial No. Old Transcend have serial No. But now dont have it. Is there any chance to make a serial No by our own for the pen drive or is there any pen drive with Serial No in Market.
Thanks in advance
Thiyagu
-
May 31st, 2009, 07:41 PM
#5
Thread Starter
Lively Member
Re: serial number of pen drive
can you post some complete example?
its because i dont know how to use that sample...
thanks..
-
Jun 1st, 2009, 05:51 AM
#6
Re: serial number of pen drive
that is complete, put command button, with the above code for click event, the serial number is in the variable sernum
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Jun 1st, 2009, 03:25 PM
#7
Thread Starter
Lively Member
Re: serial number of pen drive
thanks that works
-
Jul 22nd, 2009, 10:18 PM
#8
Re: [RESOLVED] serial number of pen drive
the code does return all usb drives, just as it stands it only retains the last one, just add each to a listbox or an array to work with
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Jan 5th, 2010, 06:55 AM
#9
Junior Member
Re: [RESOLVED] serial number of pen drive
westconn1, your code is fantastic! Thank you.
-
Feb 25th, 2010, 03:09 PM
#10
Re: [RESOLVED] serial number of pen drive
ask before you buy, as they are now so cheap, maybe the manufacturer don't bother with serial number any more, i think all mine have, but i have not bought any new for a while
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|