Replaced KNOWNFOLDER(LocalAppDataLow)\Temp with %Temp%\Low and now sets environment var
git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@6165 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
parent
b84d41e582
commit
6cd26f04e6
1 changed files with 14 additions and 34 deletions
|
@ -174,43 +174,23 @@ int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInst,LPTSTR lpszCmdPara
|
||||||
GetTempPath(NSIS_MAX_STRLEN, state_temp_dir);
|
GetTempPath(NSIS_MAX_STRLEN, state_temp_dir);
|
||||||
if (!ValidateTempDir())
|
if (!ValidateTempDir())
|
||||||
{
|
{
|
||||||
LPTSTR tstrslashtemp = _T("\\Temp");
|
|
||||||
GetWindowsDirectory(state_temp_dir, NSIS_MAX_STRLEN - 5); // leave space for \Temp
|
GetWindowsDirectory(state_temp_dir, NSIS_MAX_STRLEN - 5); // leave space for \Temp
|
||||||
mystrcat(state_temp_dir, tstrslashtemp);
|
mystrcat(state_temp_dir, _T("\\Temp"));
|
||||||
if (!ValidateTempDir())
|
if (!ValidateTempDir())
|
||||||
{
|
{
|
||||||
const int myKF_FLAG_CREATE=0x00008000;
|
// There does not seem to be a API to get the low temp dir directly, so we build the path on our own
|
||||||
const GUID myFOLDERID_LocalAppDataLow={0xA520A1A4,0x1780,0x4FF6,{0xBD,0x18,0x16,0x73,0x43,0xC5,0xAF,0x16}};
|
|
||||||
void* pfnSHGetKnownFolderPath=myGetProcAddress(MGA_SHGetKnownFolderPath);
|
GetTempPath(NSIS_MAX_STRLEN - 4, state_temp_dir); // leave space for \Low
|
||||||
WCHAR* localapplow;
|
mystrcat(state_temp_dir, _T("Low"));
|
||||||
HRESULT hr = E_NOTIMPL;
|
|
||||||
if (pfnSHGetKnownFolderPath)
|
// If we don't call SetEnvironmentVariable
|
||||||
{
|
// child processes will use %temp% and not %temp%\Low
|
||||||
// There does not seem to be a API to get the low temp dir directly, so we build the path on our own
|
// and some apps probably can't handle a read only %temp%
|
||||||
hr = ((HRESULT(WINAPI*)(void*,DWORD,HANDLE,WCHAR**))pfnSHGetKnownFolderPath)((void*)&myFOLDERID_LocalAppDataLow, myKF_FLAG_CREATE, NULL, &localapplow);
|
// Do it before ValidateTempDir() because it appends a backslash.
|
||||||
}
|
// TODO: Should this be moved to ValidateTempDir() so it also updates for %windir%\Temp?
|
||||||
if (S_OK == hr)
|
SetEnvironmentVariable(_T("TEMP"), state_temp_dir);
|
||||||
{
|
SetEnvironmentVariable(_T("TMP"), state_temp_dir);
|
||||||
#ifdef _UNICODE
|
|
||||||
if (mystrlen(localapplow) < NSIS_MAX_STRLEN - 5)
|
|
||||||
{
|
|
||||||
addtrailingslash(state_temp_dir);
|
|
||||||
mystrcat(state_temp_dir, &tstrslashtemp[1]);
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
if (lstrlenW(localapplow) < NSIS_MAX_STRLEN - 5)
|
|
||||||
{
|
|
||||||
BOOL useddefchar=FALSE;
|
|
||||||
WideCharToMultiByte(CP_ACP, WC_NO_BEST_FIT_CHARS, localapplow, -1, state_temp_dir, NSIS_MAX_STRLEN, NULL, &useddefchar);
|
|
||||||
if (!useddefchar)
|
|
||||||
{
|
|
||||||
addtrailingslash(state_temp_dir);
|
|
||||||
mystrcat(state_temp_dir, &tstrslashtemp[1]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
CoTaskMemFree(localapplow);
|
|
||||||
}
|
|
||||||
if (!ValidateTempDir())
|
if (!ValidateTempDir())
|
||||||
{
|
{
|
||||||
goto end;
|
goto end;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue