EdwardG has asked for the wisdom of the Perl Monks concerning the following question:
I was considering a reply to Need to determine state of mousepointer, thinking it would be easy, just a few trips to the right APIs, when lo - I got stuck calling GetCursorInfo (user32.dll).
use strict; use warnings; use Data::Dumper; use Win32::API; Win32::API::Struct->typedef( POINT => qw{ LONG x; LONG y; }); Win32::API::Struct->typedef( PCURSORINFO => qw{ DWORD cbSize; DWORD flags; HCURSOR hCursor; POINT ptScreenPos; }); my $pci = Win32::API::Struct->new('PCURSORINFO'); $pci->{cbSize} = $pci->sizeof(); Win32::API->Import("user32", "BOOL GetCursorInfo(PCURSORINFO pci)"); print Dumper($pci); # before, empty but for cbSize my $result = GetCursorInfo($pci) or die $^E; # DIES HERE, RESULTS BELO +W print Dumper($pci); # after, hopefully full of useful information
This dies upon calling GetCursorInfo because - as documented - the result is zero, and $^E (ie GetLastError) is telling me my parameter is incorrect -
The parameter is incorrect at getmouseshape.pl line 27, <DATA> line 16 +4.
And here is $pci before dying
$VAR1 = bless( { '__typedef__' => 'PCURSORINFO', 'ptScreenPos' => bless( { '__typedef__' => 'POINT', 'typedef' => [ [ 'x', 'l', 'LONG' ], [ 'y', 'l', 'LONG' ] ] }, 'Win32::API::Struct' ), 'cbSize' => 16, 'typedef' => [ [ 'cbSize', 'L', 'DWORD' ], [ 'flags', 'L', 'DWORD' ], [ 'hCursor', 'L', 'HCURSOR' ], [ 'ptScreenPos', '>', 'POINT' ] ] }, 'Win32::API::Struct' );
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Win32::API::Struct and GetCursorInfo with PCURSORINFO
by dfaure (Chaplain) on Jun 25, 2004 at 12:41 UTC | |
by bulk88 (Priest) on Oct 19, 2012 at 08:51 UTC | |
|
Re: Win32::API::Struct and GetCursorInfo with PCURSORINFO
by BrowserUk (Patriarch) on Jun 25, 2004 at 20:54 UTC | |
by Anonymous Monk on Jun 26, 2004 at 02:49 UTC |