From 14c9f8917db9cc2381ef6c73c261f63ae8a3d2a0 Mon Sep 17 00:00:00 2001 From: Thomas Bluemel Date: Wed, 11 Jul 2007 18:49:01 +0000 Subject: [PATCH] Set a working directory for the start menu items svn path=/trunk/; revision=27595 --- reactos/dll/win32/syssetup/install.c | 30 +++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/reactos/dll/win32/syssetup/install.c b/reactos/dll/win32/syssetup/install.c index 0a141bf08f2..5404231d6ca 100644 --- a/reactos/dll/win32/syssetup/install.c +++ b/reactos/dll/win32/syssetup/install.c @@ -148,6 +148,10 @@ CreateShortcut(int csidl, LPCTSTR folder, UINT nIdName, LPCTSTR command, UINT nI LPTSTR p = path; TCHAR szSystemPath[MAX_PATH]; TCHAR szProgramPath[MAX_PATH]; + TCHAR szWorkingDir[MAX_PATH]; + LPTSTR lpWorkingDir = NULL; + LPTSTR lpFilePart; + DWORD dwLen; if (bCheckExistence) { @@ -178,7 +182,31 @@ CreateShortcut(int csidl, LPCTSTR folder, UINT nIdName, LPCTSTR command, UINT nI if (!LoadString(hDllInstance, nIdTitle, title, sizeof(title)/sizeof(title[0]))) return FALSE; - return SUCCEEDED(CreateShellLink(path, command, _T(""), NULL, NULL, 0, title)); + dwLen = GetFullPathName(path, + sizeof(szWorkingDir) / sizeof(szWorkingDir[0]), + szWorkingDir, + &lpFilePart); + if (dwLen != 0 && dwLen <= sizeof(szWorkingDir) / sizeof(szWorkingDir[0])) + { + /* Successfully determined the file path */ + + if (lpFilePart != NULL) + { + /* 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 - szWorkingDir == 2 && szWorkingDir[1] == _T(':') && + szWorkingDir[2] == _T('\\'))) + { + *lpFilePart = _T('\0'); + } + } + + lpWorkingDir = szWorkingDir; + } + + return SUCCEEDED(CreateShellLink(path, command, _T(""), lpWorkingDir, NULL, 0, title)); }