Getting environment variables?

Lars Ivar Igesund larsivar at igesund.net
Sun Nov 23 12:21:38 PST 2008


torhu wrote:

> 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.

In tango this is available in tango.sys.win32.SpecialPath

-- 
Lars Ivar Igesund
blog at http://larsivi.net
DSource, #d.tango & #D: larsivi
Dancing the Tango


More information about the Digitalmars-d-learn mailing list