- Prevent a crash by checking the applet name if it is empty and does exist

- %1 is used for file argument, where %2, %3, %n indicate the index of the passed param, %* is the rest of the command
- Directly pass the full filename to ShellExecuteExW from the default context menu
- Should fix executing cpl in default shellview

svn path=/trunk/; revision=35643
This commit is contained in:
Johannes Anderwald 2008-08-25 21:02:21 +00:00
parent d0e1f5701b
commit 909de8f972
3 changed files with 29 additions and 6 deletions

View file

@ -427,12 +427,20 @@ static void Control_DoLaunch(CPanel* panel, HWND hWnd, LPCWSTR wszCmd)
sp = 0; sp = 0;
} }
if ((extraPmts)&&(!spSet)) if ((extraPmts) && extraPmts[0] &&(!spSet))
{ {
while ((lstrcmpiW(extraPmts, applet->info[sp].szName)) && (sp < applet->count)) while ((lstrcmpiW(extraPmts, applet->info[sp].szName)) && (sp < applet->count))
sp++; sp++;
}
if (sp >= applet->count)
{
ReleaseMutex(hMutex);
CloseHandle(hMutex);
Control_UnloadApplet(applet);
HeapFree(GetProcessHeap(), 0, buffer);
return;
}
}
if (applet->info[sp].dwSize) { if (applet->info[sp].dwSize) {
if (!applet->proc(applet->hWnd, CPL_STARTWPARMSA, sp, (LPARAM)extraPmts)) if (!applet->proc(applet->hWnd, CPL_STARTWPARMSA, sp, (LPARAM)extraPmts))
applet->proc(applet->hWnd, CPL_DBLCLK, sp, applet->info[sp].lData); applet->proc(applet->hWnd, CPL_DBLCLK, sp, applet->info[sp].lData);

View file

@ -129,6 +129,7 @@ static BOOL SHELL_ArgifyW(WCHAR* out, int len, const WCHAR* fmt, const WCHAR* lp
used++; used++;
if (used < len) if (used < len)
*res++ = '"'; *res++ = '"';
break;
} }
else else
{ {
@ -146,7 +147,10 @@ static BOOL SHELL_ArgifyW(WCHAR* out, int len, const WCHAR* fmt, const WCHAR* lp
} }
break; break;
} }
/* else fall through */ else
{
break;
}
case '1': case '1':
if (!done || (*fmt == '1')) if (!done || (*fmt == '1'))
{ {

View file

@ -1508,6 +1508,8 @@ DoStaticShellExtensions(
IDefaultContextMenuImpl *This, IDefaultContextMenuImpl *This,
LPCMINVOKECOMMANDINFO lpcmi) LPCMINVOKECOMMANDINFO lpcmi)
{ {
STRRET strFile;
WCHAR szPath[MAX_PATH];
SHELLEXECUTEINFOW sei; SHELLEXECUTEINFOW sei;
PStaticShellEntry pCurrent = This->shead; PStaticShellEntry pCurrent = This->shead;
int verb = LOWORD(lpcmi->lpVerb) - This->iIdSCMFirst; int verb = LOWORD(lpcmi->lpVerb) - This->iIdSCMFirst;
@ -1520,16 +1522,25 @@ DoStaticShellExtensions(
return E_FAIL; return E_FAIL;
if (IShellFolder2_GetDisplayNameOf(This->dcm.psf, This->dcm.apidl[0], SHGDN_FORPARSING, &strFile) != S_OK)
{
ERR("IShellFolder_GetDisplayNameOf failed for apidl\n");
return E_FAIL;
}
if (StrRetToBufW(&strFile, This->dcm.apidl[0], szPath, MAX_PATH) != S_OK)
return E_FAIL;
ZeroMemory(&sei, sizeof(sei)); ZeroMemory(&sei, sizeof(sei));
sei.cbSize = sizeof(sei); sei.cbSize = sizeof(sei);
sei.fMask = SEE_MASK_CLASSNAME | SEE_MASK_IDLIST; sei.fMask = SEE_MASK_CLASSNAME;
sei.lpClass = pCurrent->szClass; sei.lpClass = pCurrent->szClass;
sei.hwnd = lpcmi->hwnd; sei.hwnd = lpcmi->hwnd;
sei.nShow = SW_SHOWNORMAL; sei.nShow = SW_SHOWNORMAL;
sei.lpVerb = pCurrent->szVerb; sei.lpVerb = pCurrent->szVerb;
sei.lpIDList = ILCombine(This->dcm.pidlFolder, This->dcm.apidl[0]); sei.lpFile = szPath;
ShellExecuteExW(&sei); ShellExecuteExW(&sei);
SHFree(sei.lpIDList);
return S_OK; return S_OK;
} }