Hi Agraham,
I have another .net problem on GetSystemPowerStatusEx2. Maybe you can pin point out my mistakes if you manage to spot it. For some reasons, this is not working for me among so many others APIs.
//Sample code:
[DllImport("coredll.dll", EntryPoint = "GetSystemPowerStatusEx2", SetLastError = true)]
private static extern uint GetSystemPowerStatusEx2(_SYSTEM_POWER_STATUS_EX2 pSystemPowerStatusEx2,
uint dwLen,
bool fUpdate);
public bool MS_GetSystemPowerStatusEx2()
{
bool ret_value = false;
if (MSAPIWrapperStart == false)
{
return true;
}
if (GetSystemPowerStatusEx2(SystemPowerStatusEX2,
(uint)Marshal.SizeOf(typeof(_SYSTEM_POWER_STATUS_EX2)),
false) != 0)
{
ret_value = true;
}
return ret_value;
}
public struct _SYSTEM_POWER_STATUS_EX2
{
public byte ACLineStatus;
public byte BatteryFlag;
public byte BatteryLifePercent;
public byte Reserved1;
public uint BatteryLifeTime;
public uint BatteryFullLifeTime;
public byte Reserved2;
public byte BackupBatteryFlag;
public byte BackupBatteryLifePercent;
public byte Reserved3;
public uint BackupBatteryLifeTime;
public uint BackupBatteryFullLifeTime;
public uint BatteryVoltage;
public uint BatteryCurrent;
public uint BatteryAverageCurrent;
public uint BatteryAverageInterval;
public uint BatterymAHourConsumed;
public uint BatteryTemperature;
public uint BackupBatteryVoltage;
public byte BatteryChemistry;
[MarshalAs(UnmanagedType.ByValArray, SizeConst=128)]
public byte[] ExtraInfo;
}
private _SYSTEM_POWER_STATUS_EX2 SystemPowerStatusEX2;
SystemPowerStatusEX2 = new _SYSTEM_POWER_STATUS_EX2();
This time the result is giving me error 87.
I have another .net problem on GetSystemPowerStatusEx2. Maybe you can pin point out my mistakes if you manage to spot it. For some reasons, this is not working for me among so many others APIs.
//Sample code:
[DllImport("coredll.dll", EntryPoint = "GetSystemPowerStatusEx2", SetLastError = true)]
private static extern uint GetSystemPowerStatusEx2(_SYSTEM_POWER_STATUS_EX2 pSystemPowerStatusEx2,
uint dwLen,
bool fUpdate);
public bool MS_GetSystemPowerStatusEx2()
{
bool ret_value = false;
if (MSAPIWrapperStart == false)
{
return true;
}
if (GetSystemPowerStatusEx2(SystemPowerStatusEX2,
(uint)Marshal.SizeOf(typeof(_SYSTEM_POWER_STATUS_EX2)),
false) != 0)
{
ret_value = true;
}
return ret_value;
}
public struct _SYSTEM_POWER_STATUS_EX2
{
public byte ACLineStatus;
public byte BatteryFlag;
public byte BatteryLifePercent;
public byte Reserved1;
public uint BatteryLifeTime;
public uint BatteryFullLifeTime;
public byte Reserved2;
public byte BackupBatteryFlag;
public byte BackupBatteryLifePercent;
public byte Reserved3;
public uint BackupBatteryLifeTime;
public uint BackupBatteryFullLifeTime;
public uint BatteryVoltage;
public uint BatteryCurrent;
public uint BatteryAverageCurrent;
public uint BatteryAverageInterval;
public uint BatterymAHourConsumed;
public uint BatteryTemperature;
public uint BackupBatteryVoltage;
public byte BatteryChemistry;
[MarshalAs(UnmanagedType.ByValArray, SizeConst=128)]
public byte[] ExtraInfo;
}
private _SYSTEM_POWER_STATUS_EX2 SystemPowerStatusEX2;
SystemPowerStatusEX2 = new _SYSTEM_POWER_STATUS_EX2();
This time the result is giving me error 87.