Linux:
$ sudo smartctl -a /dev/sda
In "Programming > General"? ;-)
I think you mean "please explain how that helps me get it under program control."
The canonical answer would be that the source of that utility will be available, and in practice it is likely to be a thin wrapper around something in /proc or /sys. However you might also find that it interfaces to the /dev/sda "device driver" (i.e. in the current context a kernel module) via an ioctl call, and my experience with these is that you can find yourself in very deep water due to data structure packing peculiarities etc.
Poking around on Debian suggests that the libatasmart4 package is relevant, but I've not gone any deeper looking at the API. My suggestion would be at least to start off with a "quick and dirty" solution parsing the output of some of the dedicated utilities, particularly since some of them appear to be oriented towards Munin etc. so are designed for that sort of thing.
Sorry I can't help on Windows, haven't really touched it for decades.
MarkMLl