C#/Native: Reading HDD Serial Using SCSI PassThrough

放肆的年华 提交于 2019-12-02 03:12:35

Your code actually runs OK for me, i.e. it returns the same data as the other methods described in the referenced thread. The only change I had to make was from:

serial = Encoding.ASCII.GetString(result.Buffer, 0, result.Buffer.Length)
                       .Replace("\0", String.Empty)
                       .Trim();

To:

serial = Encoding.ASCII.GetString(result.Buffer, 0, result.Buffer.Length)
                       .Substring(IntPtr.Size)
                       .Replace("\0", String.Empty)
                       .Trim();
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!