Share via


StrongNameKeyGenEx Function

Generates a new public/private key pair with the specified key size, for strong name use.

BOOLEAN StrongNameKeyGenEx (
        [in]  LPCWSTR   wszKeyContainer,
        [in]  DWORD     dwFlags,
        [in]  DWORD     dwKeySize,
        [out] BYTE      **ppbKeyBlob,
        [out] ULONG     *pcbKeyBlob
);

Parameters

Parameter Description

wszKeyContainer

[in] The requested key container name. wszKeyContainer must be a non-empty string, or null to generate a temporary name.

dwFlags

[in] Specifies whether to leave the key registered. The following values are supported:

  • 0x00000000 - Used when wszKeyContainer is null to generate a temporary key container name.

  • 0x00000001 (SN_LEAVE_KEY) - Specifies that the key should be left registered.

dwKeySize

[in] The requested size of the key, in bits.

ppbKeyBlob

[out] The returned public/private key pair.

pcbKeyBlob

[out] The size, in bytes, of ppbKeyBlob.

Return Value

true on successful completion; otherwise, false.

Remarks

The .NET Framework versions 1.0 and 1.1 require a dwKeySize of 1024 bits to sign an assembly with a strong name; version 2.0 adds supports for 2048-bit keys.

After the key is retrieved, you should call the StrongNameFreeBuffer Function function to release the allocated memory.

If the StrongNameKeyGenEx function does not complete successfully, call the StrongNameErrorInfo Function function to retrieve the last generated error.

Requirements

Platforms: Windows 2000, Windows XP, Windows Server 2003 family

Header: StrongName.h

Library: Included as a resource in MsCorEE.dll

.NET Framework Version: 2.0, 1.1, 1.0

See Also

Reference

StrongNameKeyGen Function

Other Resources

Strong Naming Global Static Functions