Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Many thanks to @Luke for the hint: Windows API functions to store credentials to and read them from Windows Vault are <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/aa375187%28v=vs.85%29.aspx" rel="noreferrer"><code>CredWrite()</code></a> and <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/aa374804%28v=vs.85%29.aspx" rel="noreferrer"><code>CredRead()</code></a>. Here is a code sample that may be compiled and run, that I used to confirm that these functions indeed do the expected thing:</p> <pre><code>#include &lt;windows.h&gt; #include &lt;wincred.h&gt; #include &lt;tchar.h&gt; #pragma hdrstop void main () { { //--- SAVE char* password = "brillant"; DWORD cbCreds = 1 + strlen(password); CREDENTIALW cred = {0}; cred.Type = CRED_TYPE_GENERIC; cred.TargetName = L"FOO/account"; cred.CredentialBlobSize = cbCreds; cred.CredentialBlob = (LPBYTE) password; cred.Persist = CRED_PERSIST_LOCAL_MACHINE; cred.UserName = L"paula"; BOOL ok = ::CredWriteW (&amp;cred, 0); wprintf (L"CredWrite() - errno %d\n", ok ? 0 : ::GetLastError()); if (!ok) exit(1); } { //--- RETRIEVE PCREDENTIALW pcred; BOOL ok = ::CredReadW (L"FOO/account", CRED_TYPE_GENERIC, 0, &amp;pcred); wprintf (L"CredRead() - errno %d\n", ok ? 0 : ::GetLastError()); if (!ok) exit(1); wprintf (L"Read username = '%s', password='%S' (%d bytes)\n", pcred-&gt;UserName, (char*)pcred-&gt;CredentialBlob, pcred-&gt;CredentialBlobSize); // must free memory allocated by CredRead()! ::CredFree (pcred); } } </code></pre> <p>A generic credential is stored in Windows Vault, as can be seen on the screenshot:</p> <p><img src="https://i.stack.imgur.com/udgcl.png" alt="A generic credential stored in Windows Vault"></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload