I am trying to use Win32::API to access advapi32.dll CredRead API, I have little experience with how to interact with Windows DLL’s, pointers, etc and way out of my depth here.

The error I am getting is “Win32::API a function was called with the wrong prototype and caused a C stack inconsistency”, code is below.

The CredRead is used to access the Windows version of Keepass, it is the Windows Credentials Manager.

Here is the code I have, can someone please assist me. Thank You
use strict; use Win32; use Win32::API; # public enum CRED_TYPE : int # { # GENERIC = 1, # DOMAIN_PASSWORD = 2, # DOMAIN_CERTIFICATE = 3, # DOMAIN_VISIBLE_PASSWORD = 4, # MAXIMUM = 5 # } my $CredRead = new Win32::API('advapi32.dll', 'CredRead', [qw(P P)], 'N') or die "Find CredRead: $^E"; my $strTarget = "testUser"; #I created user testUser via Control Panel > Credential Manager $CredRead->Call($strTarget,1) or die "CredRead->Call: $^E";

Reference URL's:-
https://msdn.microsoft.com/en-us/library/windows/desktop/aa374804(v=vs.85).aspx
http://www.pinvoke.net/default.aspx/advapi32/CredRead%20.html
http://stackoverflow.com/questions/32548714/how-to-store-and-retrieve-credentials-on-windows-using-c-sharp?rq=1


In reply to Stuck trying to use Win32::API by newbieperlperson

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.