Little Registry Cleaner/Common Tools/LittleSoftwareStats/MachineIdentifiers/VolumeInfoIdentifier.cs

(完整代码) 1KB

using System;
using System.Text;
using System.Runtime.InteropServices;

namespace LittleSoftwareStats.MachineIdentifiers
{
    public class VolumeInfoIdentifier : MachineIdentifierBase, IMachineIdentifier
    {
        [DllImport("kernel32.dll")]
        private static extern long GetVolumeInformation(string PathName, StringBuilder VolumeNameBuffer, UInt32 VolumeNameSize, ref UInt32 VolumeSerialNumber, ref UInt32 MaximumComponentLength, ref UInt32 FileSystemFlags, StringBuilder FileSystemNameBuffer, UInt32 FileSystemNameSize);

        protected override byte[] GetIdentifierHash()
        {
            string identifier = "NOTFOUND";

            if (Environment.OSVersion.Platform != PlatformID.MacOSX && Environment.OSVersion.Platform != PlatformID.Unix)
            {
                try
                {
                    uint serNum = 0;
                    uint maxCompLen = 0;
                    StringBuilder VolLabel = new StringBuilder(256);
                    UInt32 VolFlags = new UInt32();
                    StringBuilder FSName = new StringBuilder(256);
                    GetVolumeInformation(null, VolLabel, (UInt32)VolLabel.Capacity, ref serNum, ref maxCompLen, ref VolFlags, FSName, (UInt32)FSName.Capacity);
                    identifier = serNum.ToString();
                }
                catch { }
            }
            
            return base.ComputeHash(identifier);
        }
    }
}

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。