To extract data from a windows function I made the following function:
if System.IsFunctionAvailable("GetSystemPowerStatus","Kernel32.dll") then
Soft Declare Function SystemPowerStatus lib "Kernel32.dll" Alias "GetSystemPowerStatus" (ByRef Result As Ptr) as boolean
Var Result as Ptr
Var MB as new MemoryBlock(8)
if SystemPowerStatus(Result) then
'Pointer to memoryblock
MB = Result
'With these lines the app shuts down
Var ACLineStatus as byte = mb.UInt8Value(0)
Var BatteryStatus as byte = mb.UInt8Value(1)
Var BatteryPercentage as byte = mb.UInt8Value(2)
Var BatteryPowerSavingStatus as byte = mb.UInt8Value(3)
Var BatteryLifeTime as UInt16 = mb.UInt16Value(4)
Var BatteryTotalLifeTime as Uint16 = mb.UInt16Value(6)
end if
end if
This doesn’t work and it closes my program without any error
Where am I going wrong?
7 posts - 5 participants