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 "../Platform.h"
|
||||||
#include <shellapi.h>
|
#include <shellapi.h>
|
||||||
|
#include <shfolder.h>
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "state.h"
|
#include "state.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
@ -626,6 +627,11 @@ char * NSISCALL GetNSISString(char *outbuf, int strtab)
|
||||||
|
|
||||||
int x = 2;
|
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)
|
if (g_exec_flags.all_user_var)
|
||||||
{
|
{
|
||||||
x = 4;
|
x = 4;
|
||||||
|
@ -651,15 +657,17 @@ char * NSISCALL GetNSISString(char *outbuf, int strtab)
|
||||||
|
|
||||||
while (x--)
|
while (x--)
|
||||||
{
|
{
|
||||||
|
if (pSHGetFolderPath) {
|
||||||
|
if (!pSHGetFolderPath(g_hwnd, fldrs[x], NULL, SHGFP_TYPE_CURRENT, out)) break;
|
||||||
|
}
|
||||||
|
|
||||||
if (!SHGetSpecialFolderLocation(g_hwnd, fldrs[x], &idl))
|
if (!SHGetSpecialFolderLocation(g_hwnd, fldrs[x], &idl))
|
||||||
{
|
{
|
||||||
BOOL res = SHGetPathFromIDList(idl, out);
|
BOOL res = SHGetPathFromIDList(idl, out);
|
||||||
CoTaskMemFree(idl);
|
CoTaskMemFree(idl);
|
||||||
if (res)
|
if (res) break;
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
*out=0;
|
*out=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -673,6 +681,8 @@ char * NSISCALL GetNSISString(char *outbuf, int strtab)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (hDLL) FreeLibrary(hDLL);
|
||||||
|
|
||||||
validate_filename(out);
|
validate_filename(out);
|
||||||
}
|
}
|
||||||
else if (nVarIdx == NS_VAR_CODE)
|
else if (nVarIdx == NS_VAR_CODE)
|
||||||
|
@ -896,7 +906,8 @@ struct MGA_FUNC MGA_FUNCS[] = {
|
||||||
{"ADVAPI32", "LookupPrivilegeValueA"},
|
{"ADVAPI32", "LookupPrivilegeValueA"},
|
||||||
{"ADVAPI32", "AdjustTokenPrivileges"},
|
{"ADVAPI32", "AdjustTokenPrivileges"},
|
||||||
{"KERNEL32", "GetUserDefaultUILanguage"},
|
{"KERNEL32", "GetUserDefaultUILanguage"},
|
||||||
{"SHLWAPI", "SHAutoComplete"}
|
{"SHLWAPI", "SHAutoComplete"},
|
||||||
|
{"SHFOLDER", "SHGetFolderPathA"}
|
||||||
};
|
};
|
||||||
|
|
||||||
void * NSISCALL myGetProcAddress(const enum myGetProcAddressFunctions func)
|
void * NSISCALL myGetProcAddress(const enum myGetProcAddressFunctions func)
|
||||||
|
|
|
@ -102,7 +102,8 @@ enum myGetProcAddressFunctions {
|
||||||
MGA_LookupPrivilegeValueA,
|
MGA_LookupPrivilegeValueA,
|
||||||
MGA_AdjustTokenPrivileges,
|
MGA_AdjustTokenPrivileges,
|
||||||
MGA_GetUserDefaultUILanguage,
|
MGA_GetUserDefaultUILanguage,
|
||||||
MGA_SHAutoComplete
|
MGA_SHAutoComplete,
|
||||||
|
MGA_SHGetFolderPathA
|
||||||
};
|
};
|
||||||
|
|
||||||
void * NSISCALL myGetProcAddress(const enum myGetProcAddressFunctions func);
|
void * NSISCALL myGetProcAddress(const enum myGetProcAddressFunctions func);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue