CredProtectW function (wincred.h)
The CredProtect function encrypts the specified credentials so that only the current security context can decrypt them.
Syntax
BOOL CredProtectW(
[in] BOOL fAsSelf,
[in] LPWSTR pszCredentials,
[in] DWORD cchCredentials,
[out] LPWSTR pszProtectedCredentials,
[in, out] DWORD *pcchMaxChars,
[out] CRED_PROTECTION_TYPE *ProtectionType
);
Parameters
[in] fAsSelf
Set to TRUE to specify that the credentials are encrypted in the security context of the current process. Set to FALSE to specify that credentials are encrypted in the security context of the calling thread security context.
[in] pszCredentials
A pointer to a string that specifies the credentials to encrypt. The function encrypts the number of characters provided in the cchCredentials parameter.
[in] cchCredentials
The size, in characters, of the pszCredentials buffer.
[out] pszProtectedCredentials
A pointer to a string that, on output, receives the encrypted credentials.
[in, out] pcchMaxChars
The size, in characters of the pszProtectedCredentials buffer. On output, if the pszProtectedCredentials is not of sufficient size to receive the encrypted credentials, this parameter specifies the required size, in characters, of the pszProtectedCredentials buffer.
[out] ProtectionType
A pointer to a CRED_PROTECTION_TYPE enumeration type that, on output, specifies the type of protection provided.
Return value
TRUE if the function succeeds; otherwise, FALSE.
For extended error information, call the GetLastError function.
Remarks
Note that the output of the CredProtect function is not integrity protected, so if the output is modified, the CredUnprotect function is not updated and may produce incorrect results.
Note
The wincred.h header defines CredProtect as an alias which automatically selects the ANSI or Unicode version of this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions for Function Prototypes.
Requirements
Requirement | Value |
---|---|
Minimum supported client | Windows Vista [desktop apps only] |
Minimum supported server | Windows Server 2008 [desktop apps only] |
Target Platform | Windows |
Header | wincred.h |
Library | Advapi32.lib |
DLL | Advapi32.dll |