PDA

View Full Version : Absolute Path to users "Program Files" on Windows



MisterIKS
5th June 2010, 09:25
Hey everybody,

I guess there's an easy solution, but google and me together were just not able to figure it out. How can I get the full path to users Program Files, usually "C:\Program Files\"?

I tried SHGetFolderPath, but it returned a TCHAR wich produced about 200 japanese looking characters behind the program-files-path wich was actually right, but not usable it this way.

Any suggestions? Thanks,

MisterIKS

tbscope
5th June 2010, 09:29
Try the "PROGRAMFILES" environment variable

MisterIKS
5th June 2010, 09:35
That's what I read everywhere, but how can I do that with Qt? Do you mean getenv() ? How can I convert the return value to QString, thats my biggest problem using windows-functions.

tbscope
5th June 2010, 09:41
Try

QString programFilesPath(getenv("PROGRAMFILES"));

MisterIKS
5th June 2010, 09:45
Wow, amazing ;-) That works fine, thanks a lot!

wysota
5th June 2010, 09:58
How about using QDesktopServices::storageLocation() with QDesktopServices::ApplicationsLocation?

MisterIKS
5th June 2010, 10:40
That's acually not the C:\Program Files Directory, but yet a nice hint to a function I didn't know.
Thanks for that!