Author: hbelusca
Date: Wed Jan 18 00:19:12 2017
New Revision: 73577
URL:
http://svn.reactos.org/svn/reactos?rev=73577&view=rev
Log:
[SYSSETUP][SHORTCUTS.INF]: Follow-up of r71049 and CORE-11020 :
- Make more shortcuts start from the user directory;
- The desktop shortcut of the ReadMe file should not use an icon location, so that the
shell correctly retrieves the icon to display from the type of the file (in our case,
.txt).
- Make the necessary adjustments in syssetup/install.c :
* opt-out setting the icon location;
* in addition, since we now support shell link targets containing environment variables,
don't always expand the target path before setting up the shortcut, but do it just in
the case we have to compute a suitable working directory.
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] Wed Jan 18 00:19:12 2017
@@ -1,21 +1,3 @@
-/*
- * ReactOS kernel
- * Copyright (C) 2003 ReactOS Team
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
@@ -96,24 +78,16 @@
hr = IShellLinkW_SetPath(psl, pszCmd);
if (pszArg)
- {
hr = IShellLinkW_SetArguments(psl, pszArg);
- }
if (pszDir)
- {
hr = IShellLinkW_SetWorkingDirectory(psl, pszDir);
- }
if (pszIconPath)
- {
hr = IShellLinkW_SetIconLocation(psl, pszIconPath, iIconNr);
- }
if (pszComment)
- {
hr = IShellLinkW_SetDescription(psl, pszComment);
- }
hr = IShellLinkW_QueryInterface(psl, &IID_IPersistFile, (LPVOID*)&ppf);
@@ -139,62 +113,59 @@
INT iIconNr,
LPCWSTR pszWorkingDir)
{
- WCHAR szPath[MAX_PATH];
- WCHAR szExeName[MAX_PATH];
- WCHAR szWorkingDirBuf[MAX_PATH];
+ DWORD dwLen;
LPWSTR Ptr;
LPWSTR lpFilePart;
- DWORD dwLen;
-
- if (ExpandEnvironmentStringsW(pszCommand, szPath, ARRAYSIZE(szPath)) == 0)
- {
- wcscpy(szPath, pszCommand);
- }
-
- if (_waccess(szPath, 0) == -1)
- /* Expected error, don't return FALSE */
- return TRUE;
-
- dwLen = GetFullPathNameW(szPath,
- ARRAYSIZE(szWorkingDirBuf),
- szWorkingDirBuf,
- &lpFilePart);
- if (dwLen != 0 && dwLen <= ARRAYSIZE(szWorkingDirBuf))
- {
- /* Since those should only be called with (.exe) files,
- lpFilePart has not to be NULL */
- ASSERT(lpFilePart != NULL);
-
- /* Save the file name */
- wcscpy(szExeName, lpFilePart);
-
- if (pszWorkingDir == NULL || pszWorkingDir[0] == L'\0')
- {
+ WCHAR szPath[MAX_PATH];
+ WCHAR szWorkingDirBuf[MAX_PATH];
+
+ /* If no working directory is provided, try to compute a default one */
+ if (pszWorkingDir == NULL || pszWorkingDir[0] == L'\0')
+ {
+ if (ExpandEnvironmentStringsW(pszCommand, szPath, ARRAYSIZE(szPath)) == 0)
+ wcscpy(szPath, pszCommand);
+
+ dwLen = GetFullPathNameW(szPath,
+ ARRAYSIZE(szWorkingDirBuf),
+ szWorkingDirBuf,
+ &lpFilePart);
+ if (dwLen != 0 && dwLen <= ARRAYSIZE(szWorkingDirBuf))
+ {
+ /* Since those should only be called with (.exe) files,
+ lpFilePart has not to be NULL */
+ ASSERT(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:\ */
+ is only going to be a drive, i.e. C:\ */
*(lpFilePart--) = L'\0';
- if (!(lpFilePart - szWorkingDirBuf == 2 && szWorkingDirBuf[1] ==
L':' &&
- szWorkingDirBuf[2] == L'\\'))
+ if (!(lpFilePart - szWorkingDirBuf == 2 &&
+ szWorkingDirBuf[1] == L':' && szWorkingDirBuf[2] ==
L'\\'))
{
*lpFilePart = L'\0';
}
pszWorkingDir = szWorkingDirBuf;
}
}
- else if (pszWorkingDir && pszWorkingDir[0] == L'\0')
- {
+
+ /* If we failed to compute a working directory, just do not use one */
+ if (pszWorkingDir && pszWorkingDir[0] == L'\0')
pszWorkingDir = NULL;
- }
-
+
+ /* Build the shortcut file name */
wcscpy(szPath, pszFolder);
-
Ptr = PathAddBackslash(szPath);
-
wcscpy(Ptr, pszName);
- // FIXME: we should pass 'command' straight in here, but shell32 doesn't
expand it
- return SUCCEEDED(CreateShellLink(szPath, szExeName, L"", pszWorkingDir,
szExeName, iIconNr, pszDescription));
+ /* Create the shortcut */
+ return SUCCEEDED(CreateShellLink(szPath,
+ pszCommand,
+ L"",
+ pszWorkingDir,
+ /* Special value to indicate no icon */
+ (iIconNr != -1 ? pszCommand : NULL),
+ iIconNr,
+ pszDescription));
}
@@ -202,11 +173,11 @@
{
INFCONTEXT Context;
DWORD dwFieldCount;
+ INT iIconNr;
WCHAR szCommand[MAX_PATH];
WCHAR szName[MAX_PATH];
WCHAR szDescription[MAX_PATH];
WCHAR szDirectory[MAX_PATH];
- INT iIconNr;
if (!SetupFindFirstLine(hinf, pszSection, NULL, &Context))
return FALSE;
@@ -214,7 +185,7 @@
do
{
dwFieldCount = SetupGetFieldCount(&Context);
- if (dwFieldCount < 4)
+ if (dwFieldCount < 3)
continue;
if (!SetupGetStringFieldW(&Context, 1, szCommand, ARRAYSIZE(szCommand),
NULL))
@@ -226,8 +197,8 @@
if (!SetupGetStringFieldW(&Context, 3, szDescription,
ARRAYSIZE(szDescription), NULL))
continue;
- if (!SetupGetIntField(&Context, 4, &iIconNr))
- continue;
+ if (dwFieldCount < 4 || !SetupGetIntField(&Context, 4, &iIconNr))
+ iIconNr = -1; /* Special value to indicate no icon */
if (dwFieldCount < 5 || !SetupGetStringFieldW(&Context, 5, szDirectory,
ARRAYSIZE(szDirectory), NULL))
szDirectory[0] = L'\0';
@@ -449,7 +420,7 @@
BOOL
-RegisterTypeLibraries (HINF hinf, LPCWSTR szSection)
+RegisterTypeLibraries(HINF hinf, LPCWSTR szSection)
{
INFCONTEXT InfContext;
BOOL res;
Modified: trunk/reactos/media/inf/shortcuts.inf
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/media/inf/shortcuts.inf?re…
==============================================================================
--- trunk/reactos/media/inf/shortcuts.inf [iso-8859-1] (original)
+++ trunk/reactos/media/inf/shortcuts.inf [iso-8859-1] Wed Jan 18 00:19:12 2017
@@ -14,12 +14,12 @@
GamesShortcuts=2, %GAMES%
[DesktopShortcuts]
-%SystemRoot%\readme.txt, %README_TITLE%, %README_DESC%, 0
+%SystemRoot%\readme.txt, %README_TITLE%, %README_DESC%
%SystemRoot%\system32\cmd.exe, %CMD_TITLE%, %CMD_DESC%, 0, %HOMEDRIVE%%HOMEPATH%
%SystemRoot%\system32\rapps.exe, %RAPPS_TITLE_SHORT%, %RAPPS_DESC%, 0
[ProgramShortcuts]
-%SystemRoot%\explorer.exe, %EXPLORER_TITLE%, %EXPLORER_DESC%, 1
+%SystemRoot%\explorer.exe, %EXPLORER_TITLE%, %EXPLORER_DESC%, 1, %HOMEDRIVE%%HOMEPATH%
%SystemRoot%\system32\rapps.exe, %RAPPS_TITLE%, %RAPPS_DESC%, 0
[AdminToolsShortcuts]
@@ -29,15 +29,15 @@
%SystemRoot%\system32\msconfig.exe, %MSCONFIG_TITLE%, %MSCONFIG_DESC%, 0
[CommunicationsShortcuts]
-%SystemRoot%\system32\mstsc.exe, %MSTSC_TITLE%, %MSTSC_DESC%, 0
+%SystemRoot%\system32\mstsc.exe, %MSTSC_TITLE%, %MSTSC_DESC%, 0, %HOMEDRIVE%%HOMEPATH%
[AccessoriesShortcuts]
-%SystemRoot%\system32\calc.exe, %CALC_TITLE%, %CALC_DESC%, 0
+%SystemRoot%\system32\calc.exe, %CALC_TITLE%, %CALC_DESC%, 0, %HOMEDRIVE%%HOMEPATH%
%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
-%SystemRoot%\system32\mspaint.exe, %MSPAINT_TITLE%, %MSPAINT_DESC%, 0
+%SystemRoot%\system32\notepad.exe, %NOTEPAD_TITLE%, %NOTEPAD_DESC%, 0,
%HOMEDRIVE%%HOMEPATH%
+%SystemRoot%\system32\screenshot.exe, %SCREENSHOT_TITLE%, %SCREENSHOT_DESC%, 0,
%HOMEDRIVE%%HOMEPATH%
+%SystemRoot%\system32\wordpad.exe, %WORDPAD_TITLE%, %WORDPAD_DESC%, 0,
%HOMEDRIVE%%HOMEPATH%
+%SystemRoot%\system32\mspaint.exe, %MSPAINT_TITLE%, %MSPAINT_DESC%, 0,
%HOMEDRIVE%%HOMEPATH%
[SystemToolsShortcuts]
%SystemRoot%\system32\charmap.exe, %CHARMAP_TITLE%, %CHARMAP_DESC%, 0
@@ -48,13 +48,13 @@
%SystemRoot%\system32\dxdiag.exe, %DXDIAG_TITLE%, %DXDIAG_DESC%, 0
[AccessibilityShortcuts]
-%SystemRoot%\system32\magnify.exe, %MAGNIFY_TITLE%, %MAGNIFY_DESC%, 0
-%SystemRoot%\system32\osk.exe, %OSK_TITLE%, %OSK_DESC%, 0
+%SystemRoot%\system32\magnify.exe, %MAGNIFY_TITLE%, %MAGNIFY_DESC%, 0,
%HOMEDRIVE%%HOMEPATH%
+%SystemRoot%\system32\osk.exe, %OSK_TITLE%, %OSK_DESC%, 0, %HOMEDRIVE%%HOMEPATH%
[EntertainmentShortcuts]
-%SystemRoot%\system32\mplay32.exe, %MPLAY_TITLE%, %MPLAY_DESC%, 0
+%SystemRoot%\system32\mplay32.exe, %MPLAY_TITLE%, %MPLAY_DESC%, 0, %HOMEDRIVE%%HOMEPATH%
%SystemRoot%\system32\sndvol32.exe, %SNDVOL_TITLE%, %SNDVOL_DESC%, 0
-%SystemRoot%\system32\sndrec32.exe, %SNDREC32_TITLE%, %SNDREC32_DESC%, 0
+%SystemRoot%\system32\sndrec32.exe, %SNDREC32_TITLE%, %SNDREC32_DESC%, 0,
%HOMEDRIVE%%HOMEPATH%
[GamesShortcuts]
%SystemRoot%\system32\sol.exe, %SOL_TITLE%, %SOL_DESC%, 0