Getting environment variables?

novice2 sorry at noem.ail
Sun Nov 23 03:03:02 PST 2008


>     homeDrive = toString(getenv("HOMEDRIVE")).dup;
>     homePath = toString(getenv("HOMEPATH")).dup;

don't forget, that D char[] is utf8 and windows char* is 8-bit chars, not utf8.
so you should import std.windows.charset and use toMBSz() as D->WindowsAPI and fromMBSz as WindowsAPI->D string converter. for example:
homeDrive = fromMBSz(getenv("HOMEDRIVE")).dup;


More information about the Digitalmars-d-learn mailing list