Serial number of Hard Disk or Hard Drive

前端 未结 5 2019
滥情空心
滥情空心 2020-12-14 12:30

At first it may seems it is very easy question and some body may be trying to give me advice to try Google, it may be so. But for me it is very hard I have try Google, Stack

5条回答
  •  清歌不尽
    2020-12-14 13:10

    The best way I found is:

    1. Download the .dll from here

    2. Add the .dll to your project

    3. Add this code:

      [DllImportAttribute("HardwareIDExtractorC.dll")]
      public static extern String GetIDESerialNumber(byte DriveNumber);

    4. Call the hard disk ID from where you need it:

      GetIDESerialNumber(0).Replace(" ", string.Empty);

    Note: Go to the properties of the dll in explorer and set Build Action to Embedded Resource.

提交回复
热议问题