I'm having an odd problem with Win32::API, but I don't believe it's a bug in the module, but rather something that I've missed.
The problem is that the code below runs fine by itself, but when I put it in a module which I use from my main script I get the following error:
It seems to me that the problem might be related to namespacing or perhaps some obscure scoping rule - please enlighten me as to what I've overlooked here. I've tried changing the return type to INT and BYTE with the same result.Win32::API::parse_prototype: WARNING unknown output parameter type 'BO +OL' at C:/Perl/site/lib/Win32/API.pm line 273.
Updateduse strict; use warnings; use Win32::API; Win32::API::Struct->typedef(SYSTEM_POWER_STATUS => qw ( BYTE ACLineStatus; BYTE BatteryFlag; BYTE BatteryLifePercent; BYTE Reserved1; DWORD BatteryLifeTime; DWORD BatteryFullLifeTime; )); my $bar = Win32::API->new('kernel32','BOOL GetSystemPowerStatus(SYSTEM +_POWER_STATUS status)'); my $foo = Win32::API::Struct->new('SYSTEM_POWER_STATUS'); $bar->Call($foo); foreach (qw( ACLineStatus BatteryFlag BatteryLifePercent Reserved1 + BatteryLifeTime BatteryFullLifeTime)) { print "$_: $foo->{$_}\n"; } }
Another update
Okay, I found a way to make it work/not work.
It turns out that for the package to work, the datastructure as well as the function (basically all the code I posted) needs to be written inside the function that I call in the package...I'd like to know why this is the case, though :-p
In reply to Win32::API missing types by Nemurenai
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |