Getting environment variables?

torhu no at spam.invalid
Sun Nov 23 12:06:32 PST 2008


Christopher Wright wrote:
> Hey all,
> 
> How do I get environment variables in a D program? I specifically want 
> the path to a user's home folder.
> 
> Ta muchly.

I think the 'correct' way on Windows is to use SHGetSpecialFolderPathA.

Something like this:

char[MAX_PATH] buf;
SHGetSpecialFolderPathA(null, buf.ptr, CSIDL_PERSONAL, false);
char[] dir = toString(buf.ptr);

or CSIDL_APPDATA, etc.


More information about the Digitalmars-d-learn mailing list