Get Drive Serial Number Vb Net

Active2 years, 2 months ago

How can I read the hard disk serial number for IDE and SATA drives in VB.NET?(I don't want the volume serial number).

Get

I actually tried with WMI just now and for my flash USB disk there was no serial number, apperently some USB flash drives do have them, some don't. Give this a shot: //import the System.Management namespace at the top in your 'using' statement.

This info should be gathered both for XP and Vista if possible without administrative rights.

dsolimano
7,6173 gold badges41 silver badges57 bronze badges
OrElseOrElse
3,37433 gold badges121 silver badges215 bronze badges

3 Answers

You can use WMI (Windows Management Instrumentation) like this:

Although, I've read about cases in which no serial number is returned using WMI. Another way to accomplish this would be through Platform Invocation Services (PInvoke).

This article includes a download in which the author implements CreateFile() and DeviceIoControl() to extract drive information through Interop services in VB .NET.

To use either of the above outlined methods you will need ADMIN rights, a utility which seems to circumvent this can be found here. If your feeling adventurous the C++/Win32 source code is available for you to peruse. (Check out the function 'ReadPhysicalDriveInNTWithZeroRights()')

PhaedrusPhaedrus
Bugs
4,1909 gold badges27 silver badges37 bronze badges
SatyabhanSatyabhan

Here is the code to get HDD Serial Number

Hope it Helps.

SMHasnainSMHasnain

Not the answer you're looking for? Browse other questions tagged vb.netserial-number or ask your own question.

Active4 years, 1 month ago

Is there a way to read USB device serial number and data in a text file in USB using visual studio 2005?

rahul
rahulrahul
156k44 gold badges208 silver badges250 bronze badges

3 Answers

Try this:

Get Drive Serial Number Vb Net

Here's the internals for the USBSerialNumber class:

Source: http://www.cfdan.com/posts/Retrieving_Non-Volatile_USB_Serial_Number_Using_C_Sharp.cfm

The MattThe Matt
5,1217 gold badges36 silver badges57 bronze badges

Serial Number Idm Gratis

Or, you can do it with much less code, here's the sample:

Drive Serial Number Look Up

xarizmatxarizmat

Vb Net Get Set

Matt answer is almost right, but you must pass drive letter without back slash in function:string serial = usb.getSerialNumberFromDriveLetter('f:');

mr_squallmr_squall

How To Find Hard Drive Serial Number

Not the answer you're looking for? Browse other questions tagged c#visual-studio-2005usb-drive or ask your own question.