예제 #1
0
        void initializeLocal(String oid, OidGroupEnum group)
        {
            IntPtr ptr, oidptr;

            if (searchBy.ToLower() == "byvalue")
            {
                oidptr = Marshal.StringToHGlobalAnsi(oid);
                ptr    = Crypt32.CryptFindOIDInfo(Wincrypt.CRYPT_OID_INFO_OID_KEY, oidptr, (UInt32)group);
            }
            else
            {
                oidptr = Marshal.StringToHGlobalUni(oid);
                ptr    = Crypt32.CryptFindOIDInfo(Wincrypt.CRYPT_OID_INFO_NAME_KEY, oidptr, (UInt32)group);
            }
            if (ptr.Equals(IntPtr.Zero))
            {
                return;
            }
            if (_cng)
            {
                Wincrypt.CRYPT_OID_INFO OidInfo = (Wincrypt.CRYPT_OID_INFO)Marshal.PtrToStructure(ptr, typeof(Wincrypt.CRYPT_OID_INFO));
                FriendlyName = OidInfo.pwszName;
                Value        = OidInfo.pszOID;
                OidGroup     = (OidGroupEnum)OidInfo.dwGroupId;
            }
            else
            {
                Wincrypt.CRYPT_OID_INFO_Win2k3 OidInfo = (Wincrypt.CRYPT_OID_INFO_Win2k3)Marshal.PtrToStructure(ptr, typeof(Wincrypt.CRYPT_OID_INFO_Win2k3));
                FriendlyName = OidInfo.pwszName;
                Value        = OidInfo.pszOID;
                OidGroup     = (OidGroupEnum)OidInfo.dwGroupId;
            }
            Marshal.FreeHGlobal(oidptr);
        }