Multiple-OS Header Access

Adam D. Ruppe destructionator at gmail.com
Wed Feb 12 09:40:00 PST 2014


On Wednesday, 12 February 2014 at 17:21:52 UTC, Malkierian wrote:
> not to mention C++ specific on Windows

They aren't really C++ specific, you can use them from a lot of 
languages, including C and D.

> So anyway, my question is, does D have the capability of 
> interfacing with Linux and Mac such that those functions are 
> accessible

Not those specific functions, since they are part of Windows. 
Similar functions on Linux would be... I think you'd have to read 
the /proc directory for directories with numeric names, then 
inside there, you can read a file called cmdline to get the 
process name (sort of, it is the command line used to launch it) 
and other stuff. The name of the directory is the process id.

To get the currently focused window on linux, you could do it by 
asking the X server. The functions XGetInputFocus or fetching the 
_NET_ACTIVE_WINDOW atom should give a usable window id. Tying 
window IDs to process IDs is a bit harder, you might be able to 
get it by looking for a _NET_WM_PID atom... which is opt-in by 
the application, I don't think the X server necessarily knows the 
pid of the owner (indeed, the owner might be running on a 
different computer anyway).

So yeah, kinda in depth low level stuff. I don't know if there's 
any library to help with this.

I have no idea about Mac (or even other unixes for that matter).

, and/or would I be better of working in C++ for this
> particular venture?

Linux is a pain in the ass to program for in any language... but 
if you can do it in C or C++, you can mostly just to the same 
thing in D. Might have to copy/paste function prototypes though.


More information about the Digitalmars-d-learn mailing list