When available, use shfolder.dll to get special folder locations. This allows folders like the application data folder for all users to be used on Windows 95/98 when Internet Explorer 5 is installed.
git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@5195 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
parent
a87208a617
commit
5648dd2ace
2 changed files with 18 additions and 6 deletions
|
@ -16,6 +16,7 @@
|
|||
|
||||
#include "../Platform.h"
|
||||
#include <shellapi.h>
|
||||
#include <shfolder.h>
|
||||
#include "util.h"
|
||||
#include "state.h"
|
||||
#include "config.h"
|
||||
|
@ -626,6 +627,11 @@ char * NSISCALL GetNSISString(char *outbuf, int strtab)
|
|||
|
||||
int x = 2;
|
||||
|
||||
// Use SHGetFolderPath when shfolder.dll is available
|
||||
PFNSHGETFOLDERPATHA pSHGetFolderPath = 0;
|
||||
HMODULE hDLL = LoadLibrary("shfolder");
|
||||
if (hDLL) pSHGetFolderPath = (PFNSHGETFOLDERPATHA) myGetProcAddress(MGA_SHGetFolderPathA);
|
||||
|
||||
if (g_exec_flags.all_user_var)
|
||||
{
|
||||
x = 4;
|
||||
|
@ -651,15 +657,17 @@ char * NSISCALL GetNSISString(char *outbuf, int strtab)
|
|||
|
||||
while (x--)
|
||||
{
|
||||
if (pSHGetFolderPath) {
|
||||
if (!pSHGetFolderPath(g_hwnd, fldrs[x], NULL, SHGFP_TYPE_CURRENT, out)) break;
|
||||
}
|
||||
|
||||
if (!SHGetSpecialFolderLocation(g_hwnd, fldrs[x], &idl))
|
||||
{
|
||||
BOOL res = SHGetPathFromIDList(idl, out);
|
||||
CoTaskMemFree(idl);
|
||||
if (res)
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (res) break;
|
||||
}
|
||||
|
||||
*out=0;
|
||||
}
|
||||
|
||||
|
@ -673,6 +681,8 @@ char * NSISCALL GetNSISString(char *outbuf, int strtab)
|
|||
}
|
||||
}
|
||||
|
||||
if (hDLL) FreeLibrary(hDLL);
|
||||
|
||||
validate_filename(out);
|
||||
}
|
||||
else if (nVarIdx == NS_VAR_CODE)
|
||||
|
@ -896,7 +906,8 @@ struct MGA_FUNC MGA_FUNCS[] = {
|
|||
{"ADVAPI32", "LookupPrivilegeValueA"},
|
||||
{"ADVAPI32", "AdjustTokenPrivileges"},
|
||||
{"KERNEL32", "GetUserDefaultUILanguage"},
|
||||
{"SHLWAPI", "SHAutoComplete"}
|
||||
{"SHLWAPI", "SHAutoComplete"},
|
||||
{"SHFOLDER", "SHGetFolderPathA"}
|
||||
};
|
||||
|
||||
void * NSISCALL myGetProcAddress(const enum myGetProcAddressFunctions func)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue