Finding serial number of USB drive without WMI

前端 未结 2 1001
抹茶落季
抹茶落季 2021-01-21 13:48

How do we find the serial number of a USB drive without using WMI in c#?

Thanks

相关标签:
2条回答
  • 2021-01-21 14:37

    The following link looks like a good place to start if you can use WMI. Volatile USB Serial Number Using C#.

    You could implement a WMI soloution as this looks like it is pretty simple code and has been fairly extensivly tested. If you get a WMI error you could gracefully fall into another implementation using non WMI calls.

    To get the serial number without using WMI I would recommend that you look at the microsoft scripting runtime. You can add this to your project references from the COM tab.

    0 讨论(0)
  • 2021-01-21 14:46

    I don't think that C# has any native APIs for that sort of thing, but this blog post suggests a way to do it with interop. Code is in VB.net, but it shouldn't be too hard to translate into c# Hope that helps.

    0 讨论(0)
提交回复
热议问题