use 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"; } }