How to get Laptop battery level

H. S. Teoh hsteoh at quickfur.ath.cx
Mon Feb 22 21:20:40 UTC 2021


On Mon, Feb 22, 2021 at 08:59:01PM +0000, Greatsam4sure via Digitalmars-d-learn wrote:
> Dlang is a system programming language. How do I access the battery
> level of my system using code in dlang? I will appreciate vide sample

There is no universal API for this.  It depends on which OS you're
using.  For that, you need to consult your OS's documentation. Most
likely there will be some kind of C API or system library that could
give you this information.

D can't possibly provide a universal API for something like this because
it varies too widely -- some platforms do not have any meaningful
notion of "battery level", whereas other systems may well have multiple
"battery levels" and it would be ambiguous which one is meant.  If you
want to do systems programming you have to know the system you're
programming, and be prepared to call OS APIs yourself.


T

-- 
The irony is that Bill Gates claims to be making a stable operating system and Linus Torvalds claims to be trying to take over the world. -- Anonymous


More information about the Digitalmars-d-learn mailing list