Exemplo n.º 1
0
        private string getFirmwareVersion(string deviceInstanceId)
        {
            var    biometricClassGuid = "53D29EF7-377C-4D14-864B-EB3A85769359";
            Guid   FPguid             = new Guid(biometricClassGuid);
            IntPtr h = SetupAPI.SetupDiGetClassDevs(
                ref FPguid,
                IntPtr.Zero,
                IntPtr.Zero,
                SetupAPI.DiGetClassFlags.DIGCF_PRESENT
                );

            if (h == (IntPtr)0)
            {
                return("");
            }
            SetupAPI.SP_DEVINFO_DATA dia = new SetupAPI.SP_DEVINFO_DATA();
            dia.cbSize = Marshal.SizeOf(dia);
            for (int i = 0; SetupAPI.SetupDiEnumDeviceInfo(h, i, ref dia); ++i)
            {
                UInt32        RequiredSize = 0;
                StringBuilder sb           = new StringBuilder(1024);
                if (!SetupAPI.SetupDiGetDeviceInstanceId(h, ref dia, sb, 1024, out RequiredSize))
                {
                    continue;
                }

                if (!deviceInstanceId.Equals(sb.ToString()))
                {
                    continue;
                }

                UInt32 RegType;
                if (!SetupAPI.SetupDiGetDeviceRegistryProperty(h, ref dia, SetupAPI.RegPropertyType.SPDRP_HARDWAREID, out RegType, sb, 1024, out RequiredSize))
                {
                    continue;
                }

                int pos = sb.ToString().IndexOf("REV_");
                if (pos <= 0)
                {
                    break;
                }
                pos += "REV_".Length;
                string s_toReturn = sb.ToString().Substring(pos, 4);

                SetupAPI.SetupDiDestroyDeviceInfoList(h);
                return(s_toReturn);
            }
            return("");
        }
Exemplo n.º 2
0
        private void updateCurNameFromIdentity()
        {
            StringBuilder name    = new StringBuilder();
            uint          cchName = (uint)name.Capacity;
            StringBuilder referencedDomainName    = new StringBuilder();
            uint          cchReferencedDomainName = (uint)referencedDomainName.Capacity;

            SetupAPI.SID_NAME_USE sidUse;
            // Sid for BUILTIN\Administrators
            byte[] Sid = new byte[_identity.AccountSidSize];
            _identity.AccountSid.GetBinaryForm(Sid, 0);
            if (!SetupAPI.LookupAccountSid(null, Sid, name, ref cchName, referencedDomainName, ref cchReferencedDomainName, out sidUse))
            {
                _name = "";
            }
            else
            {
                _name = name.ToString();
            }
        }