PDA

View Full Version : Get Windows User name



Crispylx
3rd May 2011, 19:39
hi all,
Hopefully a simple one. I’m trying to set my open file dialog to open on the desktop. I’ve got it working on my computer (running windows 7) by specifying C:/Users/Owner/Desktop/.
After deploying the program on a machine running vista it seems this wont work and i need to specify the ‘Owner’ eg C:/Users/Eric/Desktop/.
Can anyone help me with a function to get this?
Yours in hope
Crispy

mcosta
3rd May 2011, 21:00
First of all; I don't know how Win7 and Win Vista works.

You can access to process Environment with
QProcessEnvironment::systemEnvironment() and then read the value of %HOME% environment variable with QProcessEnvironment::value()

ChrisW67
3rd May 2011, 23:38
QDesktopServices::storageLocation() with QDesktopServices::DesktopLocation.

Crispylx
4th May 2011, 07:16
Many thanks to both of you... and for your quick responses. I’m going to go with the QDesktopServices as it will be easier to drop into my existing code.

Thanks again