in reply to Windows Device Tree

If an API call is failing, then you should print the value returned by GetLastError(), this will usually give you an error code that will sometimes help you identify why the API is failing.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

Replies are listed 'Best First'.
Re^2: Windows Device Tree ($^E)
by tye (Sage) on Aug 28, 2006 at 17:16 UTC

    $^E is easier to use than Win32::GetLastError().

    - tye        

      I've never been 100% sure whether referencing $^E, (which I always use myself), is effectively a synchronous call to GetLastError(), or whether it ($^E) only get's set if the XS code arranges to do so? Hence my reluctance to recommend $^E to others directly.


      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.

        The "get magic" on $^E is simply GetLastError() along with building a string out of the number returned.

        But there is a problem with XS modules not arranging for $^E to be set, but that is because several XS modules use API(s) that return a failure code and the XS code fails to call SetLastError(), which means that calling Win32::GetLastError() doesn't get around such problems anyway.

        - tye        

Re^2: Windows Device Tree
by jschollen (Beadle) on Aug 29, 2006 at 09:48 UTC
    Great idea.
    When I use Win32::GetLastError I receive error value 1784 which means ERROR_INVALID_USER_BUFFER: The supplied user buffer is not valid for the requested operation

    I guess that means that I did not define my structures correctly.

    Can someone guide me? (all help is much appreciated).

    The structures I found on MSDN are: The once I found in CommCtrl.h are:

    Update:
    I think I found the sollution to my problem.
    The structures should be defined as:

    And the sizes of the of the structures should not be defined with length() but with sizeof():

    I do get some warnings about uninitialized values, but that can be sorted out.