def _advapi32_load_key(key_object, key_info, container):
key_type = '<STR_LIT>' if isinstance(key_info, keys.PublicKeyInfo) else '<STR_LIT>'<EOL>algo = key_info.algorithm<EOL>if algo == '<STR_LIT>':<EOL><INDENT>provider = Advapi32Const.MS_ENH_RSA_AES_PROV<EOL><DEDENT>else:<EOL><INDENT>provider = Advapi32Const.MS_ENH_DSS_DH_PROV<EOL><DEDENT>context_handle = None<EOL>key_handle = None<EOL>try:<EOL><INDENT>context_handle = open_context_handle(provider, verify_only=key_type == '<STR_LIT>')<EOL>blob = _advapi32_create_blob(key_info, key_type, algo)<EOL>buffer_ = buffer_from_bytes(blob)<EOL>key_handle_pointer = new(advapi32, '<STR_LIT>')<EOL>res = advapi32.CryptImportKey(<EOL>context_handle,<EOL>buffer_,<EOL>len(blob),<EOL>null(),<EOL><NUM_LIT:0>,<EOL>key_handle_pointer<EOL>)<EOL>handle_error(res)<EOL>key_handle = unwrap(key_handle_pointer)<EOL>output = container(key_handle, key_object)<EOL>output.context_handle = context_handle<EOL>if algo == '<STR_LIT>':<EOL><INDENT>ex_blob = _advapi32_create_blob(key_info, key_type, algo, signing=False)<EOL>ex_buffer = buffer_from_bytes(ex_blob)<EOL>ex_key_handle_pointer = new(advapi32, '<STR_LIT>')<EOL>res = advapi32.CryptImportKey(<EOL>context_handle,<EOL>ex_buffer,<EOL>len(ex_blob),<EOL>null(),<EOL><NUM_LIT:0>,<EOL>ex_key_handle_pointer<EOL>)<EOL>handle_error(res)<EOL>output.ex_key_handle = unwrap(ex_key_handle_pointer)<EOL><DEDENT>return output<EOL><DEDENT>except (Exception):<EOL><INDENT>if key_handle:<EOL><INDENT>advapi32.CryptDestroyKey(key_handle)<EOL><DEDENT>if context_handle:<EOL><INDENT>close_context_handle(context_handle)<EOL><DEDENT>raise<EOL><DEDENT>
Loads a certificate, public key or private key into a Certificate,
PublicKey or PrivateKey object via CryptoAPI

:param key_object:
    An asn1crypto.x509.Certificate, asn1crypto.keys.PublicKeyInfo or
    asn1crypto.keys.PrivateKeyInfo object

:param key_info:
    An asn1crypto.keys.PublicKeyInfo or asn1crypto.keys.PrivateKeyInfo
    object

:param container:
    The class of the object to hold the key_handle

:raises:
    ValueError - when any of the parameters contain an invalid value
    TypeError - when any of the parameters are of the wrong type
    oscrypto.errors.AsymmetricKeyError - when the key is incompatible with the OS crypto library
    OSError - when an error is returned by the OS crypto library

:return:
    A PrivateKey, PublicKey or Certificate object, based on container