wxGetenv() underMSW Topic is solved

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
raananb
Super wx Problem Solver
Super wx Problem Solver
Posts: 430
Joined: Fri Oct 27, 2006 4:35 pm
Location: Paris, France
Contact:

wxGetenv() underMSW

Post by raananb » Sat Oct 10, 2020 7:23 am

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 ?

User avatar
doublemax
Moderator
Moderator
Posts: 15283
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: wxGetenv() underMSW

Post by doublemax » Sat Oct 10, 2020 7:40 am

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.
Use the source, Luke!

raananb
Super wx Problem Solver
Super wx Problem Solver
Posts: 430
Joined: Fri Oct 27, 2006 4:35 pm
Location: Paris, France
Contact:

Re: wxGetenv() underMSW

Post by raananb » Sat Oct 10, 2020 8:08 am

"USER" works under OSX, while Windows requires "USERNAME"...

Thanks.

Post Reply