From: <and...@us...> - 2022-10-23 18:09:48
|
Revision: 7369 http://sourceforge.net/p/nsis/code/7369 Author: anders_k Date: 2022-10-23 18:09:46 +0000 (Sun, 23 Oct 2022) Log Message: ----------- Use SHCloneSpecialIDList instead of SHGetSpecialFolderLocation so missing folders can be created on Win4.x Modified Paths: -------------- NSIS/trunk/Docs/src/history.but NSIS/trunk/Source/build.cpp NSIS/trunk/Source/exehead/util.c NSIS/trunk/Source/exehead/util.h Modified: NSIS/trunk/Docs/src/history.but =================================================================== --- NSIS/trunk/Docs/src/history.but 2022-09-20 21:38:03 UTC (rev 7368) +++ NSIS/trunk/Docs/src/history.but 2022-10-23 18:09:46 UTC (rev 7369) @@ -16,6 +16,8 @@ \b Fixed \cw{!uninstfinalize} bug on large uninstallers +\b Fixed creation of missing special folders on old Windows versions where SHGetFolderPath is not available. + \b Fixed plug-in call overwriting \cw{SetDetailsPrint lastused} (\W{http://sf.net/p/nsis/bugs/1271}{bug #1271}) \b Fixed \cw{!appendfile} not writing to non-empty files with a BOM Modified: NSIS/trunk/Source/build.cpp =================================================================== --- NSIS/trunk/Source/build.cpp 2022-09-20 21:38:03 UTC (rev 7368) +++ NSIS/trunk/Source/build.cpp 2022-10-23 18:09:46 UTC (rev 7369) @@ -379,7 +379,7 @@ m_ShellConstants.add(_T("CDBURN_AREA"), CSIDL_CDBURN_AREA, CSIDL_CDBURN_AREA); // Constants that are not affected by SetShellVarContext - m_ShellConstants.add(_T("USERAPPDATA"), CSIDL_APPDATA, CSIDL_APPDATA); + m_ShellConstants.add(_T("USERAPPDATA"), CSIDL_APPDATA, CSIDL_APPDATA|0x40); // 0x40 to differentiate it from $QUICKLAUNCH m_ShellConstants.add(_T("USERLOCALAPPDATA"), CSIDL_LOCAL_APPDATA, CSIDL_LOCAL_APPDATA); m_ShellConstants.add(_T("USERTEMPLATES"), CSIDL_TEMPLATES, CSIDL_TEMPLATES); m_ShellConstants.add(_T("USERSTARTMENU"), CSIDL_STARTMENU, CSIDL_STARTMENU); Modified: NSIS/trunk/Source/exehead/util.c =================================================================== --- NSIS/trunk/Source/exehead/util.c 2022-09-20 21:38:03 UTC (rev 7368) +++ NSIS/trunk/Source/exehead/util.c 2022-10-23 18:09:46 UTC (rev 7369) @@ -800,8 +800,9 @@ const TCHAR SYSREGKEY[] = _T("Software\\Microsoft\\Windows\\CurrentVersion"); const TCHAR QUICKLAUNCH[] = _T("\\Microsoft\\Internet Explorer\\Quick Launch"); -typedef HRESULT (__stdcall * PFNSHGETFOLDERPATH)(HWND, int, HANDLE, DWORD, LPTSTR); +typedef HRESULT (WINAPI* PFNSHGETFOLDERPATH)(HWND, int, HANDLE, DWORD, LPTSTR); extern void *g_SHGetFolderPath; +typedef LPITEMIDLIST (WINAPI* PFNSHCLONESPECIALIDLIST)(HWND, int, BOOL); // Based on Dave Laundon's simplified process_string // The string actually has a lot of different data encoded into it. This @@ -903,16 +904,22 @@ while (x--) { + PFNSHCLONESPECIALIDLIST SHCSILFunc; + int idandflags = fldrs[x] & ~0x40, create = idandflags & CSIDL_FLAG_CREATE; + if (g_SHGetFolderPath && use_shfolder) { PFNSHGETFOLDERPATH SHGetFolderPathFunc = (PFNSHGETFOLDERPATH) g_SHGetFolderPath; - if (!SHGetFolderPathFunc(g_hwnd, fldrs[x], NULL, SHGFP_TYPE_CURRENT, out)) + if (!SHGetFolderPathFunc(g_hwnd, idandflags, NULL, SHGFP_TYPE_CURRENT, out)) { break; } } - - if (!SHGetSpecialFolderLocation(g_hwnd, fldrs[x], &idl)) + + // This function exists in 95 & NT4 but was undocumented back then so we have to import it by ordinal. + SHCSILFunc = (PFNSHCLONESPECIALIDLIST) myGetProcAddress(MGA_SHCloneSpecialIDList); + idl = SHCSILFunc(g_hwnd, LOBYTE(idandflags), create); + if (idl) { BOOL res = SHGetPathFromIDList(idl, out); CoTaskMemFree(idl); @@ -1172,6 +1179,7 @@ {"ADVAPI32", "InitiateShutdownW"}, {"SHELL32", "SHGetKnownFolderPath"}, {"SHELL32", (CHAR*) 680}, // IsUserAnAdmin + {"SHELL32", (CHAR*) 89}, // SHCloneSpecialIDList #ifndef _WIN64 {"SHLWAPI", (CHAR*) 437}, // IsOS #endif @@ -1191,6 +1199,7 @@ {"ADVAPI32", "InitiateShutdownA"}, {"SHELL32", "SHGetKnownFolderPath"}, {"SHELL32", (CHAR*) 680}, // IsUserAnAdmin + {"SHELL32", (CHAR*) 89}, // SHCloneSpecialIDList #ifndef _WIN64 {"SHLWAPI", (CHAR*) 437}, // IsOS #endif Modified: NSIS/trunk/Source/exehead/util.h =================================================================== --- NSIS/trunk/Source/exehead/util.h 2022-09-20 21:38:03 UTC (rev 7368) +++ NSIS/trunk/Source/exehead/util.h 2022-10-23 18:09:46 UTC (rev 7369) @@ -175,6 +175,7 @@ MGA_InitiateShutdown, MGA_SHGetKnownFolderPath, MGA_IsUserAnAdmin, + MGA_SHCloneSpecialIDList, #ifndef _WIN64 MGA_IsOS, #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |