[SHELL32]

- Formatting. No code changes.

svn path=/trunk/; revision=54845
This commit is contained in:
Rafal Harabien 2012-01-05 18:34:35 +00:00
parent 898071bb08
commit 61e7814932
4 changed files with 725 additions and 776 deletions

View file

@ -259,7 +259,6 @@ static LRESULT WINAPI Control_WndProc(HWND hWnd, UINT wMsg,
case WM_CREATE:
Control_WndProc_Create(hWnd, (CREATESTRUCTW*)lParam2);
return 0;
case WM_DESTROY:
{
CPlApplet *applet = panel->first;
@ -267,8 +266,8 @@ static LRESULT WINAPI Control_WndProc(HWND hWnd, UINT wMsg,
applet = Control_UnloadApplet(applet);
PostQuitMessage(0);
}; break;
break;
}
case WM_PAINT:
return Control_WndProc_Paint(panel, lParam1);
case WM_LBUTTONUP:
@ -326,25 +325,24 @@ static void Control_DoInterface(CPanel* panel, HWND hWnd, HINSTANCE hInst)
static void Control_DoWindow(CPanel *panel, HWND hWnd, HINSTANCE hInst)
{
HANDLE h;
WIN32_FIND_DATAW fd;
WCHAR buffer[MAX_PATH];
static const WCHAR wszAllCpl[] = {'*','.','c','p','l',0};
WCHAR *p;
HANDLE hFind;
WIN32_FIND_DATAW wfd;
WCHAR wszPath[MAX_PATH];
WCHAR *Ptr = wszPath;
GetSystemDirectoryW( buffer, MAX_PATH );
p = buffer + wcslen(buffer);
*p++ = '\\';
wcscpy(p, wszAllCpl);
Ptr += GetSystemDirectoryW(wszPath, MAX_PATH);
*Ptr++ = '\\';
wcscpy(Ptr, L"*.cpl");
if ((h = FindFirstFileW(buffer, &fd)) != INVALID_HANDLE_VALUE)
hFind = FindFirstFileW(wszPath, &wfd);
if (hFind != INVALID_HANDLE_VALUE)
{
do
{
wcscpy(p, fd.cFileName);
Control_LoadApplet(hWnd, buffer, panel);
} while (FindNextFileW(h, &fd));
FindClose(h);
wcscpy(Ptr, wfd.cFileName);
Control_LoadApplet(hWnd, wszPath, panel);
} while (FindNextFileW(hFind, &wfd));
FindClose(hFind);
}
Control_DoInterface(panel, hWnd, hInst);

View file

@ -36,7 +36,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(shell);
class CControlPanelEnum :
public IEnumIDListImpl
{
private:
public:
CControlPanelEnum();
~CControlPanelEnum();

View file

@ -77,14 +77,12 @@ GetKeyDescription(LPWSTR szKeyName, LPWSTR szResult)
DWORD dwDesc, dwError;
WCHAR szDesc[100];
static const WCHAR szFriendlyTypeName[] = { '\\','F','r','i','e','n','d','l','y','T','y','p','e','N','a','m','e',0 };
TRACE("GetKeyDescription: keyname %s\n", debugstr_w(szKeyName));
if (RegOpenKeyExW(HKEY_CLASSES_ROOT, szKeyName, 0, KEY_READ | KEY_QUERY_VALUE, &hKey) != ERROR_SUCCESS)
return FALSE;
if (RegLoadMUIStringW(hKey,szFriendlyTypeName,szResult,MAX_PATH,&dwDesc,0,NULL) == ERROR_SUCCESS)
if (RegLoadMUIStringW(hKey, L"\\FriendlyTypeName", szResult, MAX_PATH, &dwDesc, 0, NULL) == ERROR_SUCCESS)
{
TRACE("result %s\n", debugstr_w(szResult));
RegCloseKey(hKey);
@ -124,37 +122,28 @@ GetKeyDescription(LPWSTR szKeyName, LPWSTR szResult)
CNewMenu::SHELLNEW_ITEM *CNewMenu::LoadItem(LPWSTR szKeyName)
{
HKEY hKey;
DWORD dwIndex;
DWORD dwIndex = 0;
WCHAR szName[MAX_PATH];
WCHAR szCommand[MAX_PATH];
WCHAR szDesc[MAX_PATH] = {0};
WCHAR szIcon[MAX_PATH] = {0};
WCHAR szDesc[MAX_PATH] = L"";
WCHAR szIcon[MAX_PATH] = L"";
DWORD dwName, dwCommand;
LONG result;
SHELLNEW_ITEM *pNewItem;
static const WCHAR szShellNew[] = { '\\','S','h','e','l','l','N','e','w',0 };
static const WCHAR szCmd[] = { 'C','o','m','m','a','n','d',0 };
static const WCHAR szData[] = { 'D','a','t','a',0 };
static const WCHAR szFileName[] = { 'F','i','l','e','N','a','m','e', 0 };
static const WCHAR szNullFile[] = { 'N','u','l','l','F','i','l','e', 0 };
SHELLNEW_ITEM *pNewItem = NULL;
wcscpy(szName, szKeyName);
GetKeyDescription(szKeyName, szDesc);
wcscat(szName, szShellNew);
wcscat(szName, L"\\ShellNew");
result = RegOpenKeyExW(HKEY_CLASSES_ROOT, szName, 0, KEY_READ, &hKey);
//TRACE("LoadItem dwName %d keyname %s szName %s szDesc %s szIcon %s\n", dwName, debugstr_w(szKeyName), debugstr_w(szName), debugstr_w(szDesc), debugstr_w(szIcon));
TRACE("LoadItem dwName %d keyname %s szName %s szDesc %s szIcon %s\n", dwName, debugstr_w(szKeyName), debugstr_w(szName), debugstr_w(szDesc), debugstr_w(szIcon));
if (result != ERROR_SUCCESS)
{
TRACE("Failed to open key\n");
return NULL;
}
dwIndex = 0;
pNewItem = NULL;
do
{
dwName = MAX_PATH;
@ -164,26 +153,27 @@ CNewMenu::SHELLNEW_ITEM *CNewMenu::LoadItem(LPWSTR szKeyName)
{
SHELLNEW_TYPE type = SHELLNEW_TYPE_INVALID;
LPWSTR szTarget = szCommand;
//TRACE("szName %s szCommand %s\n", debugstr_w(szName), debugstr_w(szCommand));
if (!wcsicmp(szName, szCmd))
{
TRACE("szName %s szCommand %s\n", debugstr_w(szName), debugstr_w(szCommand));
if (!wcsicmp(szName, L"Command"))
type = SHELLNEW_TYPE_COMMAND;
}else if (!wcsicmp(szName, szData))
{
else if (!wcsicmp(szName, L"Data"))
type = SHELLNEW_TYPE_DATA;
}
else if (!wcsicmp(szName, szFileName))
{
else if (!wcsicmp(szName, L"FileName"))
type = SHELLNEW_TYPE_FILENAME;
}
else if (!wcsicmp(szName, szNullFile))
else if (!wcsicmp(szName, L"NullFile"))
{
type = SHELLNEW_TYPE_NULLFILE;
szTarget = NULL;
}
if (type != SHELLNEW_TYPE_INVALID)
{
pNewItem = (SHELLNEW_ITEM *)HeapAlloc(GetProcessHeap(), 0, sizeof(SHELLNEW_ITEM));
if (!pNewItem)
break;
pNewItem->Type = type;
if (szTarget)
pNewItem->szTarget = _wcsdup(szTarget);
@ -203,7 +193,6 @@ CNewMenu::SHELLNEW_ITEM *CNewMenu::LoadItem(LPWSTR szKeyName)
return pNewItem;
}
BOOL
CNewMenu::LoadShellNewItems()
{
@ -212,12 +201,10 @@ CNewMenu::LoadShellNewItems()
LONG result;
SHELLNEW_ITEM *pNewItem;
SHELLNEW_ITEM *pCurItem = NULL;
static WCHAR szLnk[] = { '.','l','n','k',0 };
/* insert do new folder action */
if (!LoadStringW(shell32_hInstance, FCIDM_SHVIEW_NEW, szNew, sizeof(szNew) / sizeof(WCHAR)))
szNew[0] = 0;
szNew[MAX_PATH-1] = 0;
UnloadShellItems();
@ -230,7 +217,7 @@ CNewMenu::LoadShellNewItems()
pNewItem = LoadItem(szName);
if (pNewItem)
{
if (!wcsicmp(pNewItem->szExt, szLnk))
if (!wcsicmp(pNewItem->szExt, L".lnk"))
{
if (s_SnHead)
{
@ -355,9 +342,6 @@ CNewMenu::DoShellNewCmd(LPCMINVOKECOMMANDINFO lpcmi, IShellView *psv)
CComPtr<IShellFolder> parentFolder;
HRESULT hResult;
static const WCHAR szP1[] = { '%', '1', 0 };
static const WCHAR szFormat[] = {'%','s',' ','(','%','d',')','%','s',0 };
i = 1;
target = LOWORD(lpcmi->lpVerb);
@ -413,7 +397,7 @@ CNewMenu::DoShellNewCmd(LPCMINVOKECOMMANDINFO lpcmi, IShellView *psv)
break;
}
ptr = wcsstr(szBuffer, szP1);
ptr = wcsstr(szBuffer, L"%1");
if (ptr)
{
ptr[1] = 's';
@ -458,7 +442,7 @@ CNewMenu::DoShellNewCmd(LPCMINVOKECOMMANDINFO lpcmi, IShellView *psv)
dwError = GetLastError();
TRACE("FileName %s szBuffer %s i %u error %x\n", debugstr_w(szBuffer), debugstr_w(szPath), i, dwError);
swprintf(szBuffer, szFormat, szPath, i, pCurItem->szExt);
swprintf(szBuffer, L"%s (%d)%s", szPath, i, pCurItem->szExt);
i++;
} while(hFile == INVALID_HANDLE_VALUE && dwError == ERROR_FILE_EXISTS);
@ -642,11 +626,8 @@ CNewMenu::QueryContextMenu(HMENU hmenu,
TRACE("%p %p %u %u %u %u\n", this,
hmenu, indexMenu, idCmdFirst, idCmdLast, uFlags );
if (!LoadStringW(shell32_hInstance, FCIDM_SHVIEW_NEW, szBuffer, 200))
{
if (!LoadStringW(shell32_hInstance, FCIDM_SHVIEW_NEW, szBuffer, _countof(szBuffer)))
szBuffer[0] = 0;
}
szBuffer[199] = 0;
hSubMenu = CreateMenu();
memset( &mii, 0, sizeof(mii) );
@ -665,7 +646,6 @@ CNewMenu::QueryContextMenu(HMENU hmenu,
mii.hSubMenu = hSubMenu;
}
if (!InsertMenuItemW(hmenu, indexMenu, TRUE, &mii))
return E_FAIL;
@ -726,7 +706,6 @@ CNewMenu::HandleMenuMsg(UINT uMsg,
TRACE("INewItem_IContextMenu_fnHandleMenuMsg (%p)->(msg=%x wp=%lx lp=%lx)\n", this, uMsg, wParam, lParam);
switch(uMsg)
{
case WM_MEASUREITEM:

View file

@ -24,12 +24,10 @@
WINE_DEFAULT_DEBUG_CHANNEL(exec);
static const WCHAR wszOpen[] = {'o','p','e','n',0};
static const WCHAR wszExe[] = {'.','e','x','e',0};
static const WCHAR wszILPtr[] = {':','%','p',0};
static const WCHAR wszShell[] = {'\\','s','h','e','l','l','\\',0};
static const WCHAR wszFolder[] = {'F','o','l','d','e','r',0};
static const WCHAR wszEmpty[] = {0};
static const WCHAR wszOpen[] = L"open";
static const WCHAR wszExe[] = L".exe";
static const WCHAR wszShell[] = L"\\shell\\";
static const WCHAR wszFolder[] = L"Folder";
#define SEE_MASK_CLASSALL (SEE_MASK_CLASSNAME | SEE_MASK_CLASSKEY)
@ -205,7 +203,8 @@ static BOOL SHELL_ArgifyW(WCHAR* out, DWORD len, const WCHAR* fmt, const WCHAR*
used++;
if (used < len)
*res++ = '%';
}; break;
};
break;
case '*':
{
@ -226,7 +225,8 @@ static BOOL SHELL_ArgifyW(WCHAR* out, DWORD len, const WCHAR* fmt, const WCHAR*
break;
}
}
}; break;
};
break;
case '~':
@ -258,7 +258,8 @@ static BOOL SHELL_ArgifyW(WCHAR* out, DWORD len, const WCHAR* fmt, const WCHAR*
ParseNoTildeEffect(res, args, len, used, *fmt - '2');
}
}
}; break;
};
break;
case '1':
if (!done || (*fmt == '1'))
@ -309,7 +310,7 @@ static BOOL SHELL_ArgifyW(WCHAR* out, DWORD len, const WCHAR* fmt, const WCHAR*
LPVOID pv;
HGLOBAL hmem = SHAllocShared(pidl, ILGetSize(pidl), 0);
pv = SHLockShared(hmem, 0);
chars = swprintf(buf, wszILPtr, pv);
chars = swprintf(buf, L":%p", pv);
if (chars >= sizeof(buf) / sizeof(WCHAR))
ERR("pidl format buffer too small!\n");
@ -499,7 +500,7 @@ static UINT_PTR SHELL_ExecuteW(const WCHAR *lpCmd, WCHAR *env, BOOL shWait,
*/
static LPWSTR SHELL_BuildEnvW( const WCHAR *path )
{
static const WCHAR wPath[] = {'P','A','T','H','=',0};
static const WCHAR wPath[] = L"PATH=";
WCHAR *strings, *new_env;
WCHAR *p, *p2;
int total = wcslen(path) + 1;
@ -559,9 +560,6 @@ static LPWSTR SHELL_BuildEnvW( const WCHAR *path )
*/
static BOOL SHELL_TryAppPathW( LPCWSTR szName, LPWSTR lpResult, WCHAR **env)
{
static const WCHAR wszKeyAppPaths[] = {'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s',
'\\','C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\','A','p','p',' ','P','a','t','h','s','\\',0};
static const WCHAR wPath[] = {'P','a','t','h',0};
HKEY hkApp = 0;
WCHAR buffer[1024];
LONG len;
@ -569,7 +567,7 @@ static BOOL SHELL_TryAppPathW( LPCWSTR szName, LPWSTR lpResult, WCHAR **env)
BOOL found = FALSE;
if (env) *env = NULL;
wcscpy(buffer, wszKeyAppPaths);
wcscpy(buffer, L"Software\\Microsoft\\Windows\\CurrentVersion\\App Paths\\");
wcscat(buffer, szName);
res = RegOpenKeyExW(HKEY_LOCAL_MACHINE, buffer, 0, KEY_READ, &hkApp);
if (res) goto end;
@ -582,7 +580,7 @@ static BOOL SHELL_TryAppPathW( LPCWSTR szName, LPWSTR lpResult, WCHAR **env)
if (env)
{
DWORD count = sizeof(buffer);
if (!RegQueryValueExW(hkApp, wPath, NULL, NULL, (LPBYTE)buffer, &count) && buffer[0])
if (!RegQueryValueExW(hkApp, L"Path", NULL, NULL, (LPBYTE)buffer, &count) && buffer[0])
*env = SHELL_BuildEnvW(buffer);
}
@ -593,7 +591,7 @@ end:
static UINT SHELL_FindExecutableByOperation(LPCWSTR lpOperation, LPWSTR key, LPWSTR filetype, LPWSTR command, LONG commandlen)
{
static const WCHAR wCommand[] = {'\\','c','o','m','m','a','n','d',0};
static const WCHAR wCommand[] = L"\\command";
HKEY hkeyClass;
WCHAR verb[MAX_PATH];
@ -664,9 +662,6 @@ static UINT SHELL_FindExecutableByOperation(LPCWSTR lpOperation, LPWSTR key, LPW
static UINT SHELL_FindExecutable(LPCWSTR lpPath, LPCWSTR lpFile, LPCWSTR lpOperation,
LPWSTR lpResult, DWORD resultLen, LPWSTR key, WCHAR **env, LPITEMIDLIST pidl, LPCWSTR args)
{
static const WCHAR wWindows[] = {'w','i','n','d','o','w','s',0};
static const WCHAR wPrograms[] = {'p','r','o','g','r','a','m','s',0};
static const WCHAR wExtensions[] = {'e','x','e',' ','p','i','f',' ','b','a','t',' ','c','m','d',' ','c','o','m',0};
WCHAR *extension = NULL; /* pointer to file extension */
WCHAR filetype[256]; /* registry name for this filetype */
LONG filetypelen = sizeof(filetype); /* length of above */
@ -744,7 +739,7 @@ static UINT SHELL_FindExecutable(LPCWSTR lpPath, LPCWSTR lpFile, LPCWSTR lpOpera
/* See if it's a program - if GetProfileString fails, we skip this
* section. Actually, if GetProfileString fails, we've probably
* got a lot more to worry about than running a program... */
if (GetProfileStringW(wWindows, wPrograms, wExtensions, wBuffer, sizeof(wBuffer)/sizeof(WCHAR)) > 0)
if (GetProfileStringW(L"windows", L"programs", L"exe pif bat cmd com", wBuffer, sizeof(wBuffer) / sizeof(WCHAR)) > 0)
{
CharLowerW(wBuffer);
tok = wBuffer;
@ -824,11 +819,9 @@ static UINT SHELL_FindExecutable(LPCWSTR lpPath, LPCWSTR lpFile, LPCWSTR lpOpera
}
else /* Check win.ini */
{
static const WCHAR wExtensions[] = {'e','x','t','e','n','s','i','o','n','s',0};
/* Toss the leading dot */
extension++;
if (GetProfileStringW(wExtensions, extension, wszEmpty, command, sizeof(command)/sizeof(WCHAR)) > 0)
if (GetProfileStringW(L"extesions", extension, L"", command, sizeof(command) / sizeof(WCHAR)) > 0)
{
if (wcslen(command) != 0)
{
@ -881,8 +874,6 @@ static unsigned dde_connect(const WCHAR* key, const WCHAR* start, WCHAR* ddeexec
LPCWSTR szCommandline, LPITEMIDLIST pidl, SHELL_ExecuteW32 execfunc,
const SHELLEXECUTEINFOW *psei, LPSHELLEXECUTEINFOW psei_out)
{
static const WCHAR wApplication[] = {'\\','a','p','p','l','i','c','a','t','i','o','n',0};
static const WCHAR wTopic[] = {'\\','t','o','p','i','c',0};
WCHAR regkey[256];
WCHAR * endkey = regkey + wcslen(key);
WCHAR app[256], topic[256], ifexec[256], res[256];
@ -898,12 +889,12 @@ static unsigned dde_connect(const WCHAR* key, const WCHAR* start, WCHAR* ddeexec
BOOL unicode = !(GetVersion() & 0x80000000);
wcscpy(regkey, key);
wcscpy(endkey, wApplication);
wcscpy(endkey, L"application");
applen = sizeof(app);
if (RegQueryValueW(HKEY_CLASSES_ROOT, regkey, app, &applen) != ERROR_SUCCESS)
{
WCHAR command[1024], fullpath[MAX_PATH];
static const WCHAR wSo[] = { '.','s','o',0 };
static const WCHAR wSo[] = L".so";
DWORD sizeSo = sizeof(wSo) / sizeof(WCHAR);
LPWSTR ptr = NULL;
DWORD ret = 0;
@ -949,12 +940,11 @@ static unsigned dde_connect(const WCHAR* key, const WCHAR* start, WCHAR* ddeexec
*ptr = 0;
}
wcscpy(endkey, wTopic);
wcscpy(endkey, L"\\topic");
topiclen = sizeof(topic);
if (RegQueryValueW(HKEY_CLASSES_ROOT, regkey, topic, &topiclen) != ERROR_SUCCESS)
{
static const WCHAR wSystem[] = {'S','y','s','t','e','m',0};
wcscpy(topic, wSystem);
wcscpy(topic, L"System");
}
if (unicode)
@ -975,7 +965,6 @@ static unsigned dde_connect(const WCHAR* key, const WCHAR* start, WCHAR* ddeexec
exec = ddeexec;
if (!hConv)
{
static const WCHAR wIfexec[] = {'\\','i','f','e','x','e','c',0};
TRACE("Launching %s\n", debugstr_w(start));
ret = execfunc(start, env, TRUE, psei, psei_out);
if (ret <= 32)
@ -991,7 +980,7 @@ static unsigned dde_connect(const WCHAR* key, const WCHAR* start, WCHAR* ddeexec
SetLastError(ERROR_DDE_FAIL);
return 30; /* whatever */
}
strcpyW(endkey, wIfexec);
strcpyW(endkey, L"\\ifexec");
ifexeclen = sizeof(ifexec);
if (RegQueryValueW(HKEY_CLASSES_ROOT, regkey, ifexec, &ifexeclen) == ERROR_SUCCESS)
{
@ -1040,8 +1029,6 @@ static UINT_PTR execute_from_key(LPCWSTR key, LPCWSTR lpFile, WCHAR *env,
SHELL_ExecuteW32 execfunc,
LPSHELLEXECUTEINFOW psei, LPSHELLEXECUTEINFOW psei_out)
{
static const WCHAR wCommand[] = {'c','o','m','m','a','n','d',0};
static const WCHAR wDdeexec[] = {'d','d','e','e','x','e','c',0};
WCHAR cmd[256], param[1024], ddeexec[256];
DWORD cmdlen = sizeof(cmd), ddeexeclen = sizeof(ddeexec);
UINT_PTR retval = SE_ERR_NOASSOC;
@ -1071,9 +1058,9 @@ static UINT_PTR execute_from_key(LPCWSTR key, LPCWSTR lpFile, WCHAR *env,
/* Get the parameters needed by the application
from the associated ddeexec key */
tmp = const_cast<LPWSTR>(strstrW(key, wCommand));
tmp = const_cast<LPWSTR>(strstrW(key, L"command"));
assert(tmp);
wcscpy(tmp, wDdeexec);
wcscpy(tmp, L"ddeexec");
if (RegQueryValueW(HKEY_CLASSES_ROOT, key, ddeexec, (LONG *)&ddeexeclen) == ERROR_SUCCESS)
{
@ -1279,7 +1266,7 @@ static HRESULT shellex_run_context_menu_default( IShellExtInit *obj,
n = GetMenuItemCount(hmenu);
for (i = 0; i < n; i++)
{
memset( &info, 0, sizeof info );
memset(&info, 0, sizeof(info));
info.cbSize = sizeof info;
info.fMask = MIIM_FTYPE | MIIM_STRING | MIIM_STATE | MIIM_DATA | MIIM_ID;
info.dwTypeData = string;
@ -1378,8 +1365,6 @@ end:
*/
static LONG ShellExecute_FromContextMenu( LPSHELLEXECUTEINFOW sei )
{
static const WCHAR szcm[] = { 's','h','e','l','l','e','x','\\',
'C','o','n','t','e','x','t','M','e','n','u','H','a','n','d','l','e','r','s',0 };
HKEY hkey, hkeycm = 0;
WCHAR szguid[39];
HRESULT hr;
@ -1393,7 +1378,7 @@ static LONG ShellExecute_FromContextMenu( LPSHELLEXECUTEINFOW sei )
if (!hkey)
return ERROR_FUNCTION_FAILED;
r = RegOpenKeyW( hkey, szcm, &hkeycm );
r = RegOpenKeyW(hkey, L"shellex\\ContextMenuHandlers", &hkeycm);
if (r == ERROR_SUCCESS)
{
i = 0;
@ -1422,7 +1407,6 @@ static LONG ShellExecute_FromContextMenu( LPSHELLEXECUTEINFOW sei )
static UINT_PTR SHELL_execute_class(LPCWSTR wszApplicationName, LPSHELLEXECUTEINFOW psei, LPSHELLEXECUTEINFOW psei_out, SHELL_ExecuteW32 execfunc)
{
static const WCHAR wSpace[] = {' ',0};
WCHAR execCmd[1024], wcmd[1024];
/* launch a document by fileclass like 'WordPad.Document.1' */
/* the Commandline contains 'c:\Path\wordpad.exe "%1"' */
@ -1443,7 +1427,7 @@ static UINT_PTR SHELL_execute_class( LPCWSTR wszApplicationName, LPSHELLEXECUTEI
done = SHELL_ArgifyW(wcmd, sizeof(wcmd) / sizeof(WCHAR), execCmd, wszApplicationName, (LPITEMIDLIST)psei->lpIDList, NULL, &resultLen);
if (!done && wszApplicationName[0])
{
strcatW(wcmd, wSpace);
strcatW(wcmd, L" ");
strcatW(wcmd, wszApplicationName);
}
if (resultLen > sizeof(wcmd) / sizeof(WCHAR))
@ -1453,7 +1437,7 @@ static UINT_PTR SHELL_execute_class( LPCWSTR wszApplicationName, LPSHELLEXECUTEI
static BOOL SHELL_translate_idlist(LPSHELLEXECUTEINFOW sei, LPWSTR wszParameters, DWORD parametersLen, LPWSTR wszApplicationName, DWORD dwApplicationNameLen)
{
static const WCHAR wExplorer[] = {'e','x','p','l','o','r','e','r','.','e','x','e',0};
static const WCHAR wExplorer[] = L"explorer.exe";
WCHAR buffer[MAX_PATH];
BOOL appKnownSingular = FALSE;
@ -1499,8 +1483,6 @@ static BOOL SHELL_translate_idlist( LPSHELLEXECUTEINFOW sei, LPWSTR wszParameter
static UINT_PTR SHELL_quote_and_execute(LPCWSTR wcmd, LPCWSTR wszParameters, LPCWSTR lpstrProtocol, LPCWSTR wszApplicationName, LPWSTR env, LPSHELLEXECUTEINFOW psei, LPSHELLEXECUTEINFOW psei_out, SHELL_ExecuteW32 execfunc)
{
static const WCHAR wQuote[] = {'"',0};
static const WCHAR wSpace[] = {' ',0};
UINT_PTR retval;
DWORD len;
WCHAR *wszQuotedCmd;
@ -1516,12 +1498,12 @@ static UINT_PTR SHELL_quote_and_execute( LPCWSTR wcmd, LPCWSTR wszParameters, LP
/* Must quote to handle case where cmd contains spaces,
* else security hole if malicious user creates executable file "C:\\Program"
*/
strcpyW(wszQuotedCmd, wQuote);
strcpyW(wszQuotedCmd, L"\"");
strcatW(wszQuotedCmd, wcmd);
strcatW(wszQuotedCmd, wQuote);
strcatW(wszQuotedCmd, L"\"");
if (wszParameters[0])
{
strcatW(wszQuotedCmd, wSpace);
strcatW(wszQuotedCmd, " ");
strcatW(wszQuotedCmd, wszParameters);
}
@ -1537,8 +1519,8 @@ static UINT_PTR SHELL_quote_and_execute( LPCWSTR wcmd, LPCWSTR wszParameters, LP
static UINT_PTR SHELL_execute_url(LPCWSTR lpFile, LPCWSTR wFile, LPCWSTR wcmd, LPSHELLEXECUTEINFOW psei, LPSHELLEXECUTEINFOW psei_out, SHELL_ExecuteW32 execfunc)
{
static const WCHAR wShell[] = {'\\','s','h','e','l','l','\\',0};
static const WCHAR wCommand[] = {'\\','c','o','m','m','a','n','d',0};
static const WCHAR wShell[] = L"\\shell\\";
static const WCHAR wCommand[] = L"\\command";
UINT_PTR retval;
WCHAR *lpstrProtocol;
LPCWSTR lpstrRes;
@ -1605,10 +1587,6 @@ void do_error_dialog( UINT_PTR retval, HWND hwnd, WCHAR* filename)
*/
BOOL SHELL_execute(LPSHELLEXECUTEINFOW sei, SHELL_ExecuteW32 execfunc)
{
static const WCHAR wSpace[] = {' ',0};
static const WCHAR wWww[] = {'w','w','w',0};
static const WCHAR wFile[] = {'f','i','l','e',0};
static const WCHAR wHttp[] = {'h','t','t','p',':','/','/',0};
static const DWORD unsupportedFlags =
SEE_MASK_INVOKEIDLIST | SEE_MASK_ICON | SEE_MASK_HOTKEY |
SEE_MASK_CONNECTNETDRV | SEE_MASK_FLAG_DDEWAIT |
@ -1656,8 +1634,8 @@ BOOL SHELL_execute( LPSHELLEXECUTEINFOW sei, SHELL_ExecuteW32 execfunc )
wszApplicationName = (LPWSTR)HeapAlloc(GetProcessHeap(), 0, dwApplicationNameLen * sizeof(WCHAR));
memcpy(wszApplicationName, sei_tmp.lpFile + 1, (l + 1)*sizeof(WCHAR));
if (wszApplicationName[l-1] == '\"')
wszApplicationName[l-1] = '\0';
if (wszApplicationName[l-1] == L'\"')
wszApplicationName[l-1] = L'\0';
appKnownSingular = TRUE;
TRACE("wszApplicationName=%s\n", debugstr_w(wszApplicationName));
@ -1682,7 +1660,7 @@ BOOL SHELL_execute( LPSHELLEXECUTEINFOW sei, SHELL_ExecuteW32 execfunc )
strcpyW(wszParameters, sei_tmp.lpParameters);
}
else
*wszParameters = '\0';
*wszParameters = L'\0';
wszDir = dirBuffer;
if (sei_tmp.lpDirectory)
@ -1696,7 +1674,7 @@ BOOL SHELL_execute( LPSHELLEXECUTEINFOW sei, SHELL_ExecuteW32 execfunc )
strcpyW(wszDir, sei_tmp.lpDirectory);
}
else
*wszDir = '\0';
*wszDir = L'\0';
/* adjust string pointers to point to the new buffers */
sei_tmp.lpFile = wszApplicationName;
@ -1750,8 +1728,7 @@ BOOL SHELL_execute( LPSHELLEXECUTEINFOW sei, SHELL_ExecuteW32 execfunc )
if (sei_tmp.fMask & SEE_MASK_CLASSALL)
{
retval = SHELL_execute_class( wszApplicationName, &sei_tmp, sei,
execfunc );
retval = SHELL_execute_class(wszApplicationName, &sei_tmp, sei, execfunc);
if (retval <= 32 && !(sei_tmp.fMask & SEE_MASK_FLAG_NO_UI))
{
OPENASINFO Info;
@ -1839,19 +1816,19 @@ BOOL SHELL_execute( LPSHELLEXECUTEINFOW sei, SHELL_ExecuteW32 execfunc )
if (!*sei_tmp.lpParameters && !appKnownSingular)
{
/* If the executable path is quoted, handle the rest of the command line as parameters. */
if (sei_tmp.lpFile[0] == '"')
if (sei_tmp.lpFile[0] == L'"')
{
LPWSTR src = wszApplicationName/*sei_tmp.lpFile*/ + 1;
LPWSTR dst = wfileName;
LPWSTR end;
/* copy the unquoted executable path to 'wfileName' */
while(*src && *src!='"')
while(*src && *src != L'"')
*dst++ = *src++;
*dst = '\0';
*dst = L'\0';
if (*src == '"')
if (*src == L'"')
{
end = ++src;
@ -1865,7 +1842,7 @@ BOOL SHELL_execute( LPSHELLEXECUTEINFOW sei, SHELL_ExecuteW32 execfunc )
strcpyW(wszParameters, src);
/* terminate previous command string after the quote character */
*end = '\0';
*end = L'\0';
}
else
{
@ -1875,7 +1852,7 @@ BOOL SHELL_execute( LPSHELLEXECUTEINFOW sei, SHELL_ExecuteW32 execfunc )
LPWSTR space, s;
LPWSTR beg = wszApplicationName/*sei_tmp.lpFile*/;
for(s=beg; (space= const_cast<LPWSTR>(strchrW(s, ' '))); s=space+1)
for(s = beg; (space = const_cast<LPWSTR>(strchrW(s, L' '))); s = space + 1)
{
int idx = space - sei_tmp.lpFile;
memcpy(buffer, sei_tmp.lpFile, idx * sizeof(WCHAR));
@ -1891,7 +1868,7 @@ BOOL SHELL_execute( LPSHELLEXECUTEINFOW sei, SHELL_ExecuteW32 execfunc )
++p;
strcpyW(wszParameters, p);
*space = '\0';
*space = L'\0';
break;
}
@ -1917,7 +1894,7 @@ BOOL SHELL_execute( LPSHELLEXECUTEINFOW sei, SHELL_ExecuteW32 execfunc )
swprintf(wcmd, L"\"%s\"", wszApplicationName);
if (sei_tmp.lpParameters[0])
{
strcatW(wcmd, wSpace);
strcatW(wcmd, L" ");
strcatW(wcmd, wszParameters);
}
@ -1935,7 +1912,7 @@ BOOL SHELL_execute( LPSHELLEXECUTEINFOW sei, SHELL_ExecuteW32 execfunc )
}
/* Else, try to find the executable */
wcmd[0] = '\0';
wcmd[0] = L'\0';
retval = SHELL_FindExecutable(sei_tmp.lpDirectory, lpFile, sei_tmp.lpVerb, wcmd, wcmdLen, lpstrProtocol, &env, (LPITEMIDLIST)sei_tmp.lpIDList, sei_tmp.lpParameters);
if (retval > 32) /* Found */
{
@ -1946,21 +1923,17 @@ BOOL SHELL_execute( LPSHELLEXECUTEINFOW sei, SHELL_ExecuteW32 execfunc )
}
else if (PathIsDirectoryW(lpFile))
{
static const WCHAR wExplorer[] = {'e','x','p','l','o','r','e','r',0};
static const WCHAR wQuote[] = {'"',0};
WCHAR wExec[MAX_PATH];
WCHAR * lpQuotedFile = (LPWSTR)HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR) * (strlenW(lpFile) + 3));
if (lpQuotedFile)
{
retval = SHELL_FindExecutable( sei_tmp.lpDirectory, wExplorer,
retval = SHELL_FindExecutable(sei_tmp.lpDirectory, L"explorer",
wszOpen, wExec, MAX_PATH,
NULL, &env, NULL, NULL);
if (retval > 32)
{
strcpyW(lpQuotedFile, wQuote);
strcatW(lpQuotedFile, lpFile);
strcatW(lpQuotedFile, wQuote);
swprintf(lpQuotedFile, L"\"%s\"", lpFile);
retval = SHELL_quote_and_execute(wExec, lpQuotedFile,
lpstrProtocol,
wszApplicationName, env,
@ -1974,14 +1947,14 @@ BOOL SHELL_execute( LPSHELLEXECUTEINFOW sei, SHELL_ExecuteW32 execfunc )
}
else if (PathIsURLW(lpFile)) /* File not found, check for URL */
{
retval = SHELL_execute_url( lpFile, wFile, wcmd, &sei_tmp, sei, execfunc );
retval = SHELL_execute_url(lpFile, L"file", wcmd, &sei_tmp, sei, execfunc );
}
/* Check if file specified is in the form www.??????.*** */
else if (!strncmpiW(lpFile, wWww, 3))
else if (!strncmpiW(lpFile, L"www", 3))
{
/* if so, append lpFile http:// and call ShellExecute */
WCHAR lpstrTmpFile[256];
strcpyW(lpstrTmpFile, wHttp);
strcpyW(lpstrTmpFile, L"http://");
strcatW(lpstrTmpFile, lpFile);
retval = (UINT_PTR)ShellExecuteW(sei_tmp.hwnd, sei_tmp.lpVerb, lpstrTmpFile, NULL, NULL, 0);
}