Author: hbelusca Date: Sat Mar 26 01:16:35 2016 New Revision: 71049
URL: http://svn.reactos.org/svn/reactos?rev=71049&view=rev Log: [SYSSETUP] Allow for an optional working directory in the shortcuts definitions in the shortcuts.inf file. Patch by Mark Jansen CORE-11020 #comment Thank you very much!
[SHORTCUTS.INF] As an application of the previous feature, make the shortcuts (desktop & start menu) of cmd.exe start it from the user directory. CORE-11018 #comment Please retest with r71049.
Modified: trunk/reactos/dll/win32/syssetup/install.c trunk/reactos/media/inf/shortcuts.inf
Modified: trunk/reactos/dll/win32/syssetup/install.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/syssetup/install.... ============================================================================== --- trunk/reactos/dll/win32/syssetup/install.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/syssetup/install.c [iso-8859-1] Sat Mar 26 01:16:35 2016 @@ -143,13 +143,13 @@ LPCTSTR pszName, LPCTSTR pszCommand, LPCTSTR pszDescription, - INT iIconNr) + INT iIconNr, + LPCTSTR pszWorkingDir) { TCHAR szPath[MAX_PATH]; TCHAR szExeName[MAX_PATH]; + TCHAR szWorkingDirBuf[MAX_PATH]; LPTSTR Ptr; - TCHAR szWorkingDirBuf[MAX_PATH]; - LPTSTR pszWorkingDir = NULL; LPTSTR lpFilePart; DWORD dwLen;
@@ -177,17 +177,23 @@ /* Save the file name */ _tcscpy(szExeName, lpFilePart);
- /* We're only interested in the path. Cut the file name off. - Also remove the trailing backslash unless the working directory - is only going to be a drive, ie. C:\ */ - *(lpFilePart--) = _T('\0'); - if (!(lpFilePart - szWorkingDirBuf == 2 && szWorkingDirBuf[1] == _T(':') && - szWorkingDirBuf[2] == _T('\'))) - { - *lpFilePart = _T('\0'); - } - - pszWorkingDir = szWorkingDirBuf; + if (pszWorkingDir == NULL || pszWorkingDir[0] == _T('\0')) + { + /* We're only interested in the path. Cut the file name off. + Also remove the trailing backslash unless the working directory + is only going to be a drive, ie. C:\ */ + *(lpFilePart--) = _T('\0'); + if (!(lpFilePart - szWorkingDirBuf == 2 && szWorkingDirBuf[1] == _T(':') && + szWorkingDirBuf[2] == _T('\'))) + { + *lpFilePart = _T('\0'); + } + pszWorkingDir = szWorkingDirBuf; + } + } + else if (pszWorkingDir && pszWorkingDir[0] == _T('\0')) + { + pszWorkingDir = NULL; }
_tcscpy(szPath, pszFolder); @@ -204,9 +210,11 @@ static BOOL CreateShortcutsFromSection(HINF hinf, LPWSTR pszSection, LPCWSTR pszFolder) { INFCONTEXT Context; + DWORD dwFieldCount; WCHAR szCommand[MAX_PATH]; WCHAR szName[MAX_PATH]; WCHAR szDescription[MAX_PATH]; + WCHAR szDirectory[MAX_PATH]; INT iIconNr;
if (!SetupFindFirstLine(hinf, pszSection, NULL, &Context)) @@ -214,7 +222,8 @@
do { - if (SetupGetFieldCount(&Context) < 4) + dwFieldCount = SetupGetFieldCount(&Context); + if (dwFieldCount < 4) continue;
if (!SetupGetStringFieldW(&Context, 1, szCommand, MAX_PATH, NULL)) @@ -229,11 +238,14 @@ if (!SetupGetIntField(&Context, 4, &iIconNr)) continue;
+ if (dwFieldCount < 5 || !SetupGetStringFieldW(&Context, 5, szDirectory, MAX_PATH, NULL)) + szDirectory[0] = L'\0'; + _tcscat(szName, L".lnk");
- CreateShortcut(pszFolder, szName, szCommand, szDescription, iIconNr); - - }while (SetupFindNextLine(&Context, &Context)); + CreateShortcut(pszFolder, szName, szCommand, szDescription, iIconNr, szDirectory); + + } while (SetupFindNextLine(&Context, &Context));
return TRUE; }
Modified: trunk/reactos/media/inf/shortcuts.inf URL: http://svn.reactos.org/svn/reactos/trunk/reactos/media/inf/shortcuts.inf?rev... ============================================================================== --- trunk/reactos/media/inf/shortcuts.inf [iso-8859-1] (original) +++ trunk/reactos/media/inf/shortcuts.inf [iso-8859-1] Sat Mar 26 01:16:35 2016 @@ -14,7 +14,7 @@ GamesShortcuts=2, %GAMES%
[DesktopShortcuts] -%SystemRoot%\system32\cmd.exe, %CMD_TITLE%, %CMD_DESC%, 0 +%SystemRoot%\system32\cmd.exe, %CMD_TITLE%, %CMD_DESC%, 0, %HOMEDRIVE%%HOMEPATH% %SystemRoot%\system32\rapps.exe, %RAPPS_TITLE_SHORT%, %RAPPS_DESC%, 0
[ProgramShortcuts] @@ -32,7 +32,7 @@
[AccessoriesShortcuts] %SystemRoot%\system32\calc.exe, %CALC_TITLE%, %CALC_DESC%, 0 -%SystemRoot%\system32\cmd.exe, %CMD_TITLE%, %CMD_DESC%, 0 +%SystemRoot%\system32\cmd.exe, %CMD_TITLE%, %CMD_DESC%, 0, %HOMEDRIVE%%HOMEPATH% %SystemRoot%\system32\notepad.exe, %NOTEPAD_TITLE%, %NOTEPAD_DESC%, 0 %SystemRoot%\system32\screenshot.exe, %SCREENSHOT_TITLE%, %SCREENSHOT_DESC%, 0 %SystemRoot%\system32\wordpad.exe, %WORDPAD_TITLE%, %WORDPAD_DESC%, 0