CredProtect function
Applies to: desktop apps only
The CredProtect function encrypts the specified credentials so that only the current security context can decrypt them.
Syntax
BOOL WINAPI CredProtect( __in BOOL fAsSelf, __in LPTSTR pszCredentials, __in DWORD cchCredentials, __out LPTSTR pszProtectedCredentials, __inout DWORD *pcchMaxChars, __out CRED_PROTECTION_TYPE *ProtectionType );
Parameters
- fAsSelf [in]
-
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.
- pszCredentials [in]
-
A pointer to a null-terminated string that specifies the credentials to encrypt.
- cchCredentials [in]
-
The size, in characters, of the pszCredentials buffer. This value must include the NULL terminating character.
- pszProtectedCredentials [out]
-
A pointer to a null-terminated string that, on output, receives the encrypted credentials.
- pcchMaxChars [in, out]
-
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.
- ProtectionType [out]
-
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.
Requirements
|
Minimum supported client | Windows Vista |
|---|---|
|
Minimum supported server | Windows Server 2008 |
|
Header |
|
|
Library |
|
|
DLL |
|
|
Unicode and ANSI names | CredProtectW (Unicode) and CredProtectA (ANSI) |
Send comments about this topic to Microsoft
Build date: 3/13/2012