Jump to content
View in the app

A better way to browse. Learn more.

Tuts 4 You

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

How to show the printed serial number of an external usb hard drive using c#

Featured Replies

Posted

I need to show the printed serial number of an external usb hard drive using c# .
I have found many sources in "github" but the returned serial number is not correct. the only program that gave me the correct serial number is "CrystalDiskInfo" which is open source but written in c ++ which I do not understand.

Here is an example with "CrystalDiskInfo" with the correct result:

hdd6.png.9220ddb01df52a87b64d8ad3a597e0b7.png

Thanks for help

  • Author
3 hours ago, kao said:

Thanks for the link , I have already used several sources but the serial number is still wrong and do not forget that it is an external Usb hard drive what can make things more complicated.

This is an image as a proof:

hdd_f.png.0827266685cbb51e7111db8c360d4fbc.png

 

24 minutes ago, ramzi2015 said:

do not forget that it is an external Usb hard drive

You never mentioned that. :) USB enclosures are tricky, some of them they report their own serial numbers and some - serial numbers of the actual hard disk.
My WD Book enclosure works fine with the code I suggested earlier.

 

Try running in command prompt:

wmic diskdrive get Name,Model,SerialNumber,Size,Status

If you don't see the correct information there, then C# application will not be able to get it without writing a lot of specific code (like Crystal Disk Info).

Edited by kao
sometimes -> some of them

  • Author
39 minutes ago, kao said:

You never mentioned that. :) USB enclosures are tricky, some of them they report their own serial numbers and some - serial numbers of the actual hard disk.
My WD Book enclosure works fine with the code I suggested earlier.

 

Try running in command prompt:


wmic diskdrive get Name,Model,SerialNumber,Size,Status

If you don't see the correct information there, then C# application will not be able to get it without writing a lot of specific code (like Crystal Disk Info).

No luck, the serial number is still incorrect with the "wmic" command.  I think things are more complicated than I thought. So, I will try to use a third party tool to get the correct result.

Thank you anyway

  • 3 years later...

ManagementObjectSearcher can't get the correct searial number,sometime.

To obtain the correct disk name and serial number, the best approach is to use CrystalDiskInfo(https://github.com/hiyohiyo/CrystalDiskInfo) . However, CrystalDiskInfois a Windows software written in C++. As a result, it cannot be directly used in one's own project. Therefore, I wrapped CrystalDiskInfo into a DLL. Now, other languages or Windows applications can also accurately distinguish the disk serial number with the help of CrystalDiskInfo. I have open-sourced this project on GitHub. If you are interested in it, you can check it out and use it.

https://github.com/ftyszyx/CrystalDiskInfo_dll_lib

Create an account or sign in to comment

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.