Page 1 of 1

wxGetenv() underMSW

Posted: Sat Oct 10, 2020 7:23 am
by raananb
I am trying to use wxDirTraverser on a folder in Users folder.

To avoid hard-coding, I need to get the user name. I tried using

Code: Select all

wxString user = wxGetenv("USER");
While the instruction above works fine in OSX, it returns en empty string under Windows 10, with wxWidgets-3.1.4 & Visual Studio 2019.

Using wxGetEnv("USER",&user) also return en empty string under Windows.

Any suggestions ?

Re: wxGetenv() underMSW

Posted: Sat Oct 10, 2020 7:40 am
by doublemax
https://docs.wxwidgets.org/trunk/group_ ... seros.html

Check wxGetHomeDir () and wxGetUserName ()

BTW:

Code: Select all

wxString user = wxGetenv("USERNAME"); 
should have worker under Windows.

Re: wxGetenv() underMSW

Posted: Sat Oct 10, 2020 8:08 am
by raananb
"USER" works under OSX, while Windows requires "USERNAME"...

Thanks.