Hello world. In this tutorial I am sharing to you a sample code in Visual Basic.Net to retrieve a hard drive's serial number.
We will be using a DLL I created named Hardware.dll. To use it just add it as reference to your project and import it using the following:
Imports Hardware.DriverUtility
Now let us use the dll in our .NET Program. Using Visual Studio. Create a console application and paste the following code.
Imports Hardware.DriverUtility Module TestDriveSerial Sub Main() Console.WriteLine("Long Serial Number: " & SerialNumber()) Console.WriteLine("Hex Serial Number: " & Hex(SerialNumber())) Console.ReadKey() End Sub End Module
The function SerialNumber() returns a Long data type. If the driver is not ready it returns -1 value.
You may download the DLL and sample project above. Please don't hesitate to comment below.
You're awesome!
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.