Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SHGetFolderPath is Deprecated #4

Open
Zardoz89 opened this issue Jul 22, 2015 · 5 comments
Open

SHGetFolderPath is Deprecated #4

Zardoz89 opened this issue Jul 22, 2015 · 5 comments

Comments

@Zardoz89
Copy link

This function is deprecated. On Windows Vista/7/8/10, should be SHGetKnownFolderPath

https://msdn.microsoft.com/en-us/library/windows/desktop/bb762181(v=vs.85).aspx

@Malvineous
Copy link
Owner

Any chance you can submit a patch? I don't do much development under Windows so not terribly familiar with it.

@Zardoz89
Copy link
Author

I don't do much development under Windows.

Same problem, but I can try it. Also, I noticed that on Visual Studio 2013 give errors about using deprecated functions (strcat instead of strcat_s)

EDIT :
I also read that on Visual Studio, WINVER macro it's set with the desried windows version target, so could conditionally setup to use SHGetKnownFolderPath if is Windows Vista/7/8/10 or SHGetFolderPath on XP, if the effort for XP support is desirable

@Zardoz89
Copy link
Author

Also, I'm trying to write a function to get the path to a resource/assests files. ie :
get_program_resource_folder(out, MAX_PATH, "MyApp", "assets/img/smile.png);

Would return :

  • /usr/share/MyApp/assets/img/smile.png -> on linux/bsd
  • c:\Program Files\MyApp\assets\img\smile.png -> on windows

Also, would try some fallback locations before falling :

  • Linux :
    1. Relative to execution path
    2. /usr/local/share/AppName/
    3. /usr/share/AppName/
    4. /opt/AppName/
    5. Relative to program binary location
  • Windows :
    1. Relative to execution path
    2. %Program_Files%/AppName/
    3. Relative to program binary location

I don't have Mac or a OSX virtual machine, so I not have clue about these path on OSX, but I would guess that would extend the same paths that a BSD/Linux machine would use.

@Malvineous
Copy link
Owner

A resource folder is a very difficult problem, because it can change depending on how the application was installed.

Under Linux, it could be /usr/local/share/MyApp/ or /usr/share/MyApp/ depending on the prefix used during compilation/installation. Often users of my own programs choose to install them into /home/user/myapp/ so then the path would be /home/user/myapp/share/MyApp/ which means searching a list of paths won't work under Linux. You'd have to capture the path somehow during the compilation process, which is different depending on the build system in use.

Under Windows it can be %ProgramFiles% but only if the user installed the app into the default path (what if they chose to install it into D:\Apps for disk-space reasons?) Again you'd either have to capture it in the install process, or just use a path relative to the .exe because everything is probably in the same folder anyway there. This assumes you put your .exe files in the root of the install path, if you put them in a "bin" folder then it won't work.

Under Mac I think it goes into something like /Library/Application Support/ so perhaps that could be hard-coded, but you'd also want to use the same process as Linux in case of users installing it into their home directory also.

Difficult problem!

@Zardoz89
Copy link
Author

Zardoz89 commented Sep 7, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants