Last active
February 26, 2021 03:38
-
-
Save saostad/0da32d31dbfa2e2b81716eba4dbbb03b to your computer and use it in GitHub Desktop.
read_from_windows_credential_manager.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Windows.h> | |
#include <WinCred.h> | |
#include <iostream> | |
using namespace std; | |
main() | |
{ | |
PCREDENTIALA cred; | |
LPCSTR cred_name = "test_cred"; | |
const bool result = ::CredReadA(cred_name, 1, 0, &cred); | |
auto blobSize = cred->CredentialBlobSize; | |
if (result) | |
{ | |
wchar_t const *const passwordOut = (wchar_t const *const)cred->CredentialBlob; | |
cout << cred->UserName << endl; | |
wcout << passwordOut << endl; | |
} | |
else | |
{ | |
wcout << GetLastError(); | |
} | |
::CredFree(cred); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment