$^E [the friendly interface to Win32::GetLastError()] often gets set to "overlapped I/O". You should only check $^E or GetLastError() very soon after a function that reports errors via it has failed. If UserGetGroups() didn't fail, or if it isn't documented that it makes error reasons available via $^E or GetLastError(), or if you didn't check $^E soon enough after the failure, then the value of $^E doesn't mean anything.

Checking the Win32API::Net documentation, I see they suggest using GetLastError(). Going further, I check the source code and see that the classic mistake of throwing away the error reason was made so I don't think they tested their assumption about the error reason being available from GetLastError(). The module needs to be patched to add a call to SetLastError() [for most of the XS functions] so that the documentation will be correct.

As things stand, the error reason returned by GetLastError() has nothing to do with UserGetGroups(), whether it failed recently or not.

The easiest way to get at the error reason would be to patch the module as I described and rebuild it, which requires that you get a C compiler. (Just another example of why XS code tends to suck and why one should try very hard to put less code in XS and more in Perl.)

Alternately, you could try working around it with Win32::API (rather awkwardly).

- tye        


In reply to Re: Win32API::Net UserGetGroups returns error code 997 (irrelevant) by tye
in thread Win32API::Net UserGetGroups returns error code 997 by ThorstenHirsch

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.