[DESK][SHELL32] Remove desk.cpl hacks for argument parsing (#7934)

Remove argument parsing hacks from desk.cpl that were originally introduced to
make it work with the previous broken implementation of `Control_RunDLLW`.

CORE-20076

- Remove argument parsing hacks from desk.cpl;
- Fix some issues with space separated string parsing in `Control_RunDLL`;
- Windows seems to allow invalid dialog-box names if there is only one dialog-box.
This commit is contained in:
Marcin Jabłoński
2025-05-04 17:47:28 +02:00
committed by GitHub
parent 9638666d84
commit 39ce22150a
2 changed files with 8 additions and 13 deletions

View File

@@ -174,23 +174,14 @@ DisplayApplet(HWND hwnd, UINT uMsg, LPARAM wParam, LPARAM lParam)
nPage = _wtoi((PWSTR)lParam);
#if 0
argv = CommandLineToArgvW((LPCWSTR)lParam, &argc);
#else
argv = CommandLineToArgvW(GetCommandLineW(), &argc);
#endif
if (argv && argc)
{
for (i = 0; i<argc; i++)
{
#if 0
if (argv[i][0] == L'@')
pwszSelectedTab = &argv[i][1];
#else
if (wcsncmp(argv[i], L"desk,@", 6) == 0)
pwszSelectedTab = &argv[i][6];
#endif
else if (wcsncmp(argv[i], L"/Action:", 8) == 0)
pwszAction = &argv[i][8];
else if (wcsncmp(argv[i], L"/file:", 6) == 0)

View File

@@ -1016,8 +1016,11 @@ static void Control_DoLaunch(CPanel* panel, HWND hWnd, LPCWSTR wszCmd)
else if (!pchSecondComma)
pchSecondComma = &wszCmd[i];
break;
case L' ':
pchLastUnquotedSpace = &wszCmd[i];
case L' ':
if (!pchFirstComma)
pchFirstComma = &wszCmd[i];
else
pchLastUnquotedSpace = &wszCmd[i];
break;
}
}
@@ -1047,7 +1050,7 @@ static void Control_DoLaunch(CPanel* panel, HWND hWnd, LPCWSTR wszCmd)
/* If an unquoted comma was found, there are at least two parts of the string:
* - the CPL path
* - either a dialog box number preceeded by @, or a dialog box name.
* If there was a second unqoted comma, there is another part of the string:
* If there was a second unquoted comma, there is another part of the string:
* - the rest of the parameters. */
else
{
@@ -1104,7 +1107,8 @@ static void Control_DoLaunch(CPanel* panel, HWND hWnd, LPCWSTR wszCmd)
}
}
if (sp >= applet->count && (wszDialogBoxName[0] == L'\0' || wszDialogBoxName[0] == L'@'))
if (applet->count == 1 ||
(sp >= applet->count && (wszDialogBoxName[0] == UNICODE_NULL || wszDialogBoxName[0] == L'@')))
{
sp = 0;
}