Author: rharabien Date: Thu Jan 5 18:34:35 2012 New Revision: 54845
URL: http://svn.reactos.org/svn/reactos?rev=54845&view=rev Log: [SHELL32] - Formatting. No code changes.
Modified: trunk/reactos/dll/win32/shell32/control.cpp trunk/reactos/dll/win32/shell32/folders/cpanel.cpp trunk/reactos/dll/win32/shell32/newmenu.cpp trunk/reactos/dll/win32/shell32/shlexec.cpp
Modified: trunk/reactos/dll/win32/shell32/control.cpp URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/shell32/control.c... ============================================================================== --- trunk/reactos/dll/win32/shell32/control.cpp [iso-8859-1] (original) +++ trunk/reactos/dll/win32/shell32/control.cpp [iso-8859-1] Thu Jan 5 18:34:35 2012 @@ -247,7 +247,7 @@ return 0; }
-static LRESULT WINAPI Control_WndProc(HWND hWnd, UINT wMsg, +static LRESULT WINAPI Control_WndProc(HWND hWnd, UINT wMsg, WPARAM lParam1, LPARAM lParam2) { CPanel* panel = (CPanel*)GetWindowLongPtrW(hWnd, 0); @@ -259,16 +259,15 @@ case WM_CREATE: Control_WndProc_Create(hWnd, (CREATESTRUCTW*)lParam2); return 0; - case WM_DESTROY: { - CPlApplet* applet = panel->first; + CPlApplet *applet = panel->first; while (applet) applet = Control_UnloadApplet(applet);
PostQuitMessage(0); - }; break; - + break; + } case WM_PAINT: return Control_WndProc_Paint(panel, lParam1); case WM_LBUTTONUP: @@ -324,27 +323,26 @@ } }
-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; - - GetSystemDirectoryW( buffer, MAX_PATH ); - p = buffer + wcslen(buffer); - *p++ = '\'; - wcscpy(p, wszAllCpl); - - if ((h = FindFirstFileW(buffer, &fd)) != INVALID_HANDLE_VALUE) +static void Control_DoWindow(CPanel *panel, HWND hWnd, HINSTANCE hInst) +{ + HANDLE hFind; + WIN32_FIND_DATAW wfd; + WCHAR wszPath[MAX_PATH]; + WCHAR *Ptr = wszPath; + + Ptr += GetSystemDirectoryW(wszPath, MAX_PATH); + *Ptr++ = '\'; + wcscpy(Ptr, L"*.cpl"); + + 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);
Modified: trunk/reactos/dll/win32/shell32/folders/cpanel.cpp URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/shell32/folders/c... ============================================================================== --- trunk/reactos/dll/win32/shell32/folders/cpanel.cpp [iso-8859-1] (original) +++ trunk/reactos/dll/win32/shell32/folders/cpanel.cpp [iso-8859-1] Thu Jan 5 18:34:35 2012 @@ -36,7 +36,6 @@ class CControlPanelEnum : public IEnumIDListImpl { - private: public: CControlPanelEnum(); ~CControlPanelEnum();
Modified: trunk/reactos/dll/win32/shell32/newmenu.cpp URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/shell32/newmenu.c... ============================================================================== --- trunk/reactos/dll/win32/shell32/newmenu.cpp [iso-8859-1] (original) +++ trunk/reactos/dll/win32/shell32/newmenu.cpp [iso-8859-1] Thu Jan 5 18:34:35 2012 @@ -73,305 +73,289 @@ BOOL GetKeyDescription(LPWSTR szKeyName, LPWSTR szResult) { - HKEY hKey; - 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) - { - TRACE("result %s\n", debugstr_w(szResult)); - RegCloseKey(hKey); - return TRUE; - } - /* fetch default value */ - dwDesc = sizeof(szDesc); - dwError = RegGetValueW(hKey,NULL,NULL, RRF_RT_REG_SZ,NULL,szDesc,&dwDesc); - if(dwError == ERROR_SUCCESS) - { - if (wcsncmp(szKeyName, szDesc, dwDesc / sizeof(WCHAR))) - { - /* recurse for to a linked key */ - if (!GetKeyDescription(szDesc, szResult)) - { - /* use description */ - wcscpy(szResult, szDesc); - } - } - else - { - /* use default value as description */ - wcscpy(szResult, szDesc); - } - } - else - { - /* registry key w/o default key?? */ - TRACE("RegGetValue failed with %x\n", dwError); - wcscpy(szResult, szKeyName); - } - - RegCloseKey(hKey); - return TRUE; + HKEY hKey; + DWORD dwDesc, dwError; + WCHAR szDesc[100]; + + 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, L"\FriendlyTypeName", szResult, MAX_PATH, &dwDesc, 0, NULL) == ERROR_SUCCESS) + { + TRACE("result %s\n", debugstr_w(szResult)); + RegCloseKey(hKey); + return TRUE; + } + /* fetch default value */ + dwDesc = sizeof(szDesc); + dwError = RegGetValueW(hKey, NULL, NULL, RRF_RT_REG_SZ, NULL, szDesc, &dwDesc); + if(dwError == ERROR_SUCCESS) + { + if (wcsncmp(szKeyName, szDesc, dwDesc / sizeof(WCHAR))) + { + /* recurse for to a linked key */ + if (!GetKeyDescription(szDesc, szResult)) + { + /* use description */ + wcscpy(szResult, szDesc); + } + } + else + { + /* use default value as description */ + wcscpy(szResult, szDesc); + } + } + else + { + /* registry key w/o default key?? */ + TRACE("RegGetValue failed with %x\n", dwError); + wcscpy(szResult, szKeyName); + } + + RegCloseKey(hKey); + return TRUE; }
CNewMenu::SHELLNEW_ITEM *CNewMenu::LoadItem(LPWSTR szKeyName) { - HKEY hKey; - DWORD dwIndex; - WCHAR szName[MAX_PATH]; - WCHAR szCommand[MAX_PATH]; - WCHAR szDesc[MAX_PATH] = {0}; - WCHAR szIcon[MAX_PATH] = {0}; - 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 }; - - - wcscpy(szName, szKeyName); - GetKeyDescription(szKeyName, szDesc); - wcscat(szName, szShellNew); - 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)); - - if (result != ERROR_SUCCESS) - { - return NULL; - } - - dwIndex = 0; - pNewItem = NULL; - - do - { - dwName = MAX_PATH; - dwCommand = MAX_PATH; - result = RegEnumValueW(hKey,dwIndex,szName,&dwName,NULL,NULL,(LPBYTE)szCommand, &dwCommand); - if (result == ERROR_SUCCESS) - { - 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)) - { - type = SHELLNEW_TYPE_COMMAND; - }else if (!wcsicmp(szName, szData)) - { - type = SHELLNEW_TYPE_DATA; - } - else if (!wcsicmp(szName, szFileName)) - { - type = SHELLNEW_TYPE_FILENAME; - } - else if (!wcsicmp(szName, szNullFile)) - { - type = SHELLNEW_TYPE_NULLFILE; - szTarget = NULL; - } - if (type != SHELLNEW_TYPE_INVALID) - { - pNewItem = (SHELLNEW_ITEM *)HeapAlloc(GetProcessHeap(), 0, sizeof(SHELLNEW_ITEM)); - pNewItem->Type = type; - if (szTarget) - pNewItem->szTarget = _wcsdup(szTarget); - else - pNewItem->szTarget = NULL; - - pNewItem->szDesc = _wcsdup(szDesc); - pNewItem->szIcon = _wcsdup(szIcon); - pNewItem->szExt = _wcsdup(szKeyName); - pNewItem->Next = NULL; - break; - } - } - dwIndex++; - }while(result != ERROR_NO_MORE_ITEMS); - RegCloseKey(hKey); - return pNewItem; -} - + HKEY hKey; + DWORD dwIndex = 0; + WCHAR szName[MAX_PATH]; + WCHAR szCommand[MAX_PATH]; + WCHAR szDesc[MAX_PATH] = L""; + WCHAR szIcon[MAX_PATH] = L""; + DWORD dwName, dwCommand; + LONG result; + SHELLNEW_ITEM *pNewItem = NULL; + + wcscpy(szName, szKeyName); + GetKeyDescription(szKeyName, szDesc); + 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)); + + if (result != ERROR_SUCCESS) + { + TRACE("Failed to open key\n"); + return NULL; + } + + do + { + dwName = MAX_PATH; + dwCommand = MAX_PATH; + result = RegEnumValueW(hKey, dwIndex, szName, &dwName, NULL, NULL, (LPBYTE)szCommand, &dwCommand); + if (result == ERROR_SUCCESS) + { + SHELLNEW_TYPE type = SHELLNEW_TYPE_INVALID; + LPWSTR szTarget = szCommand; + + 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, L"Data")) + type = SHELLNEW_TYPE_DATA; + else if (!wcsicmp(szName, L"FileName")) + type = SHELLNEW_TYPE_FILENAME; + 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); + else + pNewItem->szTarget = NULL; + + pNewItem->szDesc = _wcsdup(szDesc); + pNewItem->szIcon = _wcsdup(szIcon); + pNewItem->szExt = _wcsdup(szKeyName); + pNewItem->Next = NULL; + break; + } + } + dwIndex++; + } while(result != ERROR_NO_MORE_ITEMS); + RegCloseKey(hKey); + return pNewItem; +}
BOOL CNewMenu::LoadShellNewItems() { - DWORD dwIndex; - WCHAR szName[MAX_PATH]; - 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(); - - dwIndex = 0; - do - { - result = RegEnumKeyW(HKEY_CLASSES_ROOT,dwIndex,szName,MAX_PATH); - if (result == ERROR_SUCCESS) - { - pNewItem = LoadItem(szName); - if (pNewItem) - { - if (!wcsicmp(pNewItem->szExt, szLnk)) - { - if (s_SnHead) + DWORD dwIndex; + WCHAR szName[MAX_PATH]; + LONG result; + SHELLNEW_ITEM *pNewItem; + SHELLNEW_ITEM *pCurItem = NULL; + + /* insert do new folder action */ + if (!LoadStringW(shell32_hInstance, FCIDM_SHVIEW_NEW, szNew, sizeof(szNew) / sizeof(WCHAR))) + szNew[0] = 0; + + UnloadShellItems(); + + dwIndex = 0; + do + { + result = RegEnumKeyW(HKEY_CLASSES_ROOT, dwIndex, szName, MAX_PATH); + if (result == ERROR_SUCCESS) + { + pNewItem = LoadItem(szName); + if (pNewItem) + { + if (!wcsicmp(pNewItem->szExt, L".lnk")) { - pNewItem->Next = s_SnHead; - s_SnHead = pNewItem; + if (s_SnHead) + { + pNewItem->Next = s_SnHead; + s_SnHead = pNewItem; + } + else + { + s_SnHead = pCurItem = pNewItem; + } } else { - s_SnHead = pCurItem = pNewItem; + if (pCurItem) + { + pCurItem->Next = pNewItem; + pCurItem = pNewItem; + } + else + { + pCurItem = s_SnHead = pNewItem; + } } } - else - { - if (pCurItem) - { - pCurItem->Next = pNewItem; - pCurItem = pNewItem; - } - else - { - pCurItem = s_SnHead = pNewItem; - } - } - } - } - dwIndex++; - }while(result != ERROR_NO_MORE_ITEMS); - - if (s_SnHead == NULL) - return FALSE; - else - return TRUE; + } + dwIndex++; + } while(result != ERROR_NO_MORE_ITEMS); + + if (s_SnHead == NULL) + return FALSE; + else + return TRUE; }
UINT CNewMenu::InsertShellNewItems(HMENU hMenu, UINT idFirst, UINT idMenu) { - MENUITEMINFOW mii; - SHELLNEW_ITEM *pCurItem; - UINT i; - WCHAR szBuffer[MAX_PATH]; - - if (s_SnHead == NULL) - { - if (!LoadShellNewItems()) - return 0; - } - - ZeroMemory(&mii, sizeof(mii)); - mii.cbSize = sizeof(mii); - - /* insert do new shortcut action */ - if (!LoadStringW(shell32_hInstance, FCIDM_SHVIEW_NEWFOLDER, szBuffer, sizeof(szBuffer) / sizeof(szBuffer[0]))) - szBuffer[0] = 0; - szBuffer[MAX_PATH-1] = 0; - mii.fMask = MIIM_ID | MIIM_TYPE | MIIM_STATE | MIIM_DATA; - mii.fType = MFT_STRING; - mii.dwTypeData = szBuffer; - mii.cch = wcslen(mii.dwTypeData); - mii.wID = idFirst++; - InsertMenuItemW(hMenu, idMenu++, TRUE, &mii); - - /* insert do new shortcut action */ - if (!LoadStringW(shell32_hInstance, FCIDM_SHVIEW_NEWLINK, szBuffer, sizeof(szBuffer) / sizeof(szBuffer[0]))) - szBuffer[0] = 0; - szBuffer[MAX_PATH-1] = 0; - mii.dwTypeData = szBuffer; - mii.cch = wcslen(mii.dwTypeData); - mii.wID = idFirst++; - InsertMenuItemW(hMenu, idMenu++, TRUE, &mii); - - /* insert seperator for custom new action */ - mii.fMask = MIIM_TYPE | MIIM_ID; - mii.fType = MFT_SEPARATOR; - mii.wID = -1; - InsertMenuItemW(hMenu, idMenu++, TRUE, &mii); - - mii.fMask = MIIM_ID | MIIM_TYPE | MIIM_STATE | MIIM_DATA; - /* - * FIXME - * implement loading of icons - * and using MFT_OWNERDRAWN - */ - mii.fType = MFT_STRING; - mii.fState = MFS_ENABLED; - - pCurItem = s_SnHead; - i = 0; - - while(pCurItem) - { - if (i >= 1) - { - TRACE("szDesc %s\n", debugstr_w(pCurItem->szDesc)); - mii.dwTypeData = pCurItem->szDesc; - mii.cch = wcslen(mii.dwTypeData); - mii.wID = idFirst++; - InsertMenuItemW(hMenu, idMenu++, TRUE, &mii); - } - pCurItem = pCurItem->Next; - i++; - } - return (i+2); + MENUITEMINFOW mii; + SHELLNEW_ITEM *pCurItem; + UINT i; + WCHAR szBuffer[MAX_PATH]; + + if (s_SnHead == NULL) + { + if (!LoadShellNewItems()) + return 0; + } + + ZeroMemory(&mii, sizeof(mii)); + mii.cbSize = sizeof(mii); + + /* insert do new shortcut action */ + if (!LoadStringW(shell32_hInstance, FCIDM_SHVIEW_NEWFOLDER, szBuffer, sizeof(szBuffer) / sizeof(szBuffer[0]))) + szBuffer[0] = 0; + szBuffer[MAX_PATH-1] = 0; + mii.fMask = MIIM_ID | MIIM_TYPE | MIIM_STATE | MIIM_DATA; + mii.fType = MFT_STRING; + mii.dwTypeData = szBuffer; + mii.cch = wcslen(mii.dwTypeData); + mii.wID = idFirst++; + InsertMenuItemW(hMenu, idMenu++, TRUE, &mii); + + /* insert do new shortcut action */ + if (!LoadStringW(shell32_hInstance, FCIDM_SHVIEW_NEWLINK, szBuffer, sizeof(szBuffer) / sizeof(szBuffer[0]))) + szBuffer[0] = 0; + szBuffer[MAX_PATH-1] = 0; + mii.dwTypeData = szBuffer; + mii.cch = wcslen(mii.dwTypeData); + mii.wID = idFirst++; + InsertMenuItemW(hMenu, idMenu++, TRUE, &mii); + + /* insert seperator for custom new action */ + mii.fMask = MIIM_TYPE | MIIM_ID; + mii.fType = MFT_SEPARATOR; + mii.wID = -1; + InsertMenuItemW(hMenu, idMenu++, TRUE, &mii); + + mii.fMask = MIIM_ID | MIIM_TYPE | MIIM_STATE | MIIM_DATA; + /* + * FIXME + * implement loading of icons + * and using MFT_OWNERDRAWN + */ + mii.fType = MFT_STRING; + mii.fState = MFS_ENABLED; + + pCurItem = s_SnHead; + i = 0; + + while(pCurItem) + { + if (i >= 1) + { + TRACE("szDesc %s\n", debugstr_w(pCurItem->szDesc)); + mii.dwTypeData = pCurItem->szDesc; + mii.cch = wcslen(mii.dwTypeData); + mii.wID = idFirst++; + InsertMenuItemW(hMenu, idMenu++, TRUE, &mii); + } + pCurItem = pCurItem->Next; + i++; + } + return (i + 2); }
HRESULT CNewMenu::DoShellNewCmd(LPCMINVOKECOMMANDINFO lpcmi, IShellView *psv) { - SHELLNEW_ITEM *pCurItem = s_SnHead; - IPersistFolder3 * psf; - LPITEMIDLIST pidl; - STRRET strTemp; - WCHAR szTemp[MAX_PATH]; - WCHAR szBuffer[MAX_PATH]; - WCHAR szPath[MAX_PATH]; - STARTUPINFOW sInfo; - PROCESS_INFORMATION pi; - UINT i, target; - HANDLE hFile; - DWORD dwWritten, dwError; - CComPtr<IFolderView> folderView; - 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); - - while(pCurItem) - { - if (i == target) - break; - - pCurItem = pCurItem->Next; - i++; - } - - if (!pCurItem) - return E_UNEXPECTED; + SHELLNEW_ITEM *pCurItem = s_SnHead; + IPersistFolder3 * psf; + LPITEMIDLIST pidl; + STRRET strTemp; + WCHAR szTemp[MAX_PATH]; + WCHAR szBuffer[MAX_PATH]; + WCHAR szPath[MAX_PATH]; + STARTUPINFOW sInfo; + PROCESS_INFORMATION pi; + UINT i, target; + HANDLE hFile; + DWORD dwWritten, dwError; + CComPtr<IFolderView> folderView; + CComPtr<IShellFolder> parentFolder; + HRESULT hResult; + + i = 1; + target = LOWORD(lpcmi->lpVerb); + + while(pCurItem) + { + if (i == target) + break; + + pCurItem = pCurItem->Next; + i++; + } + + if (!pCurItem) + return E_UNEXPECTED;
//if (fSite == NULL) // return E_FAIL; @@ -382,111 +366,111 @@ if (FAILED(hResult)) return hResult;
- if (parentFolder->QueryInterface(IID_IPersistFolder2, (LPVOID*)&psf) != S_OK) - { - ERR("Failed to get interface IID_IPersistFolder2\n"); - return E_FAIL; - } - if (psf->GetCurFolder(&pidl) != S_OK) - { - ERR("IPersistFolder2_GetCurFolder failed\n"); - return E_FAIL; - } - - if (parentFolder == NULL || parentFolder->GetDisplayNameOf(pidl, SHGDN_FORPARSING, &strTemp) != S_OK) - { - ERR("IShellFolder_GetDisplayNameOf failed\n"); - return E_FAIL; - } - StrRetToBufW(&strTemp, pidl, szPath, MAX_PATH); - - switch(pCurItem->Type) - { - case SHELLNEW_TYPE_COMMAND: - { - LPWSTR ptr; - LPWSTR szCmd; - - if (!ExpandEnvironmentStringsW(pCurItem->szTarget, szBuffer, MAX_PATH)) - { - TRACE("ExpandEnvironmentStrings failed\n"); - break; - } - - ptr = wcsstr(szBuffer, szP1); - if (ptr) - { - ptr[1] = 's'; - swprintf(szTemp, szBuffer, szPath); - ptr = szTemp; - } - else - { - ptr = szBuffer; - } - - ZeroMemory(&sInfo, sizeof(sInfo)); - sInfo.cb = sizeof(sInfo); - szCmd = _wcsdup(ptr); - if (!szCmd) - break; - if (CreateProcessW(NULL, szCmd, NULL, NULL,FALSE,0,NULL,NULL,&sInfo, &pi)) - { - CloseHandle( pi.hProcess ); - CloseHandle( pi.hThread ); - } - free(szCmd); - break; - } - case SHELLNEW_TYPE_DATA: - case SHELLNEW_TYPE_FILENAME: - case SHELLNEW_TYPE_NULLFILE: - { - i = 2; - - PathAddBackslashW(szPath); - wcscat(szPath, szNew); - wcscat(szPath, L" "); - wcscat(szPath, pCurItem->szDesc); - wcscpy(szBuffer, szPath); - wcscat(szBuffer, pCurItem->szExt); - do - { - hFile = CreateFileW(szBuffer, GENERIC_WRITE, 0, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL); - if (hFile != INVALID_HANDLE_VALUE) + if (parentFolder->QueryInterface(IID_IPersistFolder2, (LPVOID*)&psf) != S_OK) + { + ERR("Failed to get interface IID_IPersistFolder2\n"); + return E_FAIL; + } + if (psf->GetCurFolder(&pidl) != S_OK) + { + ERR("IPersistFolder2_GetCurFolder failed\n"); + return E_FAIL; + } + + if (parentFolder == NULL || parentFolder->GetDisplayNameOf(pidl, SHGDN_FORPARSING, &strTemp) != S_OK) + { + ERR("IShellFolder_GetDisplayNameOf failed\n"); + return E_FAIL; + } + StrRetToBufW(&strTemp, pidl, szPath, MAX_PATH); + + switch(pCurItem->Type) + { + case SHELLNEW_TYPE_COMMAND: + { + LPWSTR ptr; + LPWSTR szCmd; + + if (!ExpandEnvironmentStringsW(pCurItem->szTarget, szBuffer, MAX_PATH)) + { + TRACE("ExpandEnvironmentStrings failed\n"); break; - 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); - i++; - }while(hFile == INVALID_HANDLE_VALUE && dwError == ERROR_FILE_EXISTS); - - if (hFile == INVALID_HANDLE_VALUE) - return E_FAIL; - - if (pCurItem->Type == SHELLNEW_TYPE_DATA) - { - i = WideCharToMultiByte(CP_ACP, 0, pCurItem->szTarget, -1, (LPSTR)szTemp, MAX_PATH*2, NULL, NULL); - if (i) - { - WriteFile(hFile, (LPCVOID)szTemp, i, &dwWritten, NULL); - } - } - CloseHandle(hFile); - if (pCurItem->Type == SHELLNEW_TYPE_FILENAME) - { - if (!CopyFileW(pCurItem->szTarget, szBuffer, FALSE)) + } + + ptr = wcsstr(szBuffer, L"%1"); + if (ptr) + { + ptr[1] = 's'; + swprintf(szTemp, szBuffer, szPath); + ptr = szTemp; + } + else + { + ptr = szBuffer; + } + + ZeroMemory(&sInfo, sizeof(sInfo)); + sInfo.cb = sizeof(sInfo); + szCmd = _wcsdup(ptr); + if (!szCmd) break; - } - TRACE("Notifying fs %s\n", debugstr_w(szBuffer)); - SHChangeNotify(SHCNE_CREATE, SHCNF_PATHW, (LPCVOID)szBuffer, NULL); - break; - case SHELLNEW_TYPE_INVALID: - break; - } - } - return S_OK; + if (CreateProcessW(NULL, szCmd, NULL, NULL, FALSE, 0, NULL, NULL, &sInfo, &pi)) + { + CloseHandle( pi.hProcess ); + CloseHandle( pi.hThread ); + } + free(szCmd); + break; + } + case SHELLNEW_TYPE_DATA: + case SHELLNEW_TYPE_FILENAME: + case SHELLNEW_TYPE_NULLFILE: + { + i = 2; + + PathAddBackslashW(szPath); + wcscat(szPath, szNew); + wcscat(szPath, L" "); + wcscat(szPath, pCurItem->szDesc); + wcscpy(szBuffer, szPath); + wcscat(szBuffer, pCurItem->szExt); + do + { + hFile = CreateFileW(szBuffer, GENERIC_WRITE, 0, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL); + if (hFile != INVALID_HANDLE_VALUE) + break; + dwError = GetLastError(); + + TRACE("FileName %s szBuffer %s i %u error %x\n", debugstr_w(szBuffer), debugstr_w(szPath), i, dwError); + swprintf(szBuffer, L"%s (%d)%s", szPath, i, pCurItem->szExt); + i++; + } while(hFile == INVALID_HANDLE_VALUE && dwError == ERROR_FILE_EXISTS); + + if (hFile == INVALID_HANDLE_VALUE) + return E_FAIL; + + if (pCurItem->Type == SHELLNEW_TYPE_DATA) + { + i = WideCharToMultiByte(CP_ACP, 0, pCurItem->szTarget, -1, (LPSTR)szTemp, MAX_PATH * 2, NULL, NULL); + if (i) + { + WriteFile(hFile, (LPCVOID)szTemp, i, &dwWritten, NULL); + } + } + CloseHandle(hFile); + if (pCurItem->Type == SHELLNEW_TYPE_FILENAME) + { + if (!CopyFileW(pCurItem->szTarget, szBuffer, FALSE)) + break; + } + TRACE("Notifying fs %s\n", debugstr_w(szBuffer)); + SHChangeNotify(SHCNE_CREATE, SHCNF_PATHW, (LPCVOID)szBuffer, NULL); + break; + case SHELLNEW_TYPE_INVALID: + break; + } + } + return S_OK; } /************************************************************************** * DoMeasureItem @@ -494,40 +478,40 @@ HRESULT CNewMenu::DoMeasureItem(HWND hWnd, MEASUREITEMSTRUCT * lpmis) { - SHELLNEW_ITEM *pCurItem; - SHELLNEW_ITEM *pItem; - UINT i; - HDC hDC; - SIZE size; - - TRACE("DoMeasureItem entered with id %x\n", lpmis->itemID); - - pCurItem = s_SnHead; - - i = 1; - pItem = NULL; - while(pCurItem) - { - if (i == lpmis->itemID) - { - pItem = pCurItem; - break; - } - pCurItem = pCurItem->Next; - i++; - } - - if (!pItem) - { - TRACE("DoMeasureItem no item found\n"); - return E_FAIL; - } - hDC = GetDC(hWnd); - GetTextExtentPoint32W(hDC, pCurItem->szDesc, wcslen(pCurItem->szDesc), &size); - lpmis->itemWidth = size.cx + 32; - lpmis->itemHeight = max(size.cy, 20); - ReleaseDC (hWnd, hDC); - return S_OK; + SHELLNEW_ITEM *pCurItem; + SHELLNEW_ITEM *pItem; + UINT i; + HDC hDC; + SIZE size; + + TRACE("DoMeasureItem entered with id %x\n", lpmis->itemID); + + pCurItem = s_SnHead; + + i = 1; + pItem = NULL; + while(pCurItem) + { + if (i == lpmis->itemID) + { + pItem = pCurItem; + break; + } + pCurItem = pCurItem->Next; + i++; + } + + if (!pItem) + { + TRACE("DoMeasureItem no item found\n"); + return E_FAIL; + } + hDC = GetDC(hWnd); + GetTextExtentPoint32W(hDC, pCurItem->szDesc, wcslen(pCurItem->szDesc), &size); + lpmis->itemWidth = size.cx + 32; + lpmis->itemHeight = max(size.cy, 20); + ReleaseDC (hWnd, hDC); + return S_OK; } /************************************************************************** * DoDrawItem @@ -535,33 +519,33 @@ HRESULT CNewMenu::DoDrawItem(HWND hWnd, DRAWITEMSTRUCT * drawItem) { - SHELLNEW_ITEM *pCurItem; - SHELLNEW_ITEM *pItem; - UINT i; - pCurItem = s_SnHead; - - TRACE("DoDrawItem entered with id %x\n", drawItem->itemID); - - i = 1; - pItem = NULL; - while(pCurItem) - { - if (i == drawItem->itemID) - { - pItem = pCurItem; - break; - } - pCurItem = pCurItem->Next; - i++; - } - - if (!pItem) - return E_FAIL; - - drawItem->rcItem.left += 20; - - DrawTextW(drawItem->hDC, pCurItem->szDesc, wcslen(pCurItem->szDesc), &drawItem->rcItem, 0); - return S_OK; + SHELLNEW_ITEM *pCurItem; + SHELLNEW_ITEM *pItem; + UINT i; + pCurItem = s_SnHead; + + TRACE("DoDrawItem entered with id %x\n", drawItem->itemID); + + i = 1; + pItem = NULL; + while(pCurItem) + { + if (i == drawItem->itemID) + { + pItem = pCurItem; + break; + } + pCurItem = pCurItem->Next; + i++; + } + + if (!pItem) + return E_FAIL; + + drawItem->rcItem.left += 20; + + DrawTextW(drawItem->hDC, pCurItem->szDesc, wcslen(pCurItem->szDesc), &drawItem->rcItem, 0); + return S_OK; }
/************************************************************************** @@ -570,11 +554,11 @@ void CNewMenu::DoNewFolder( IShellView *psv) { - ISFHelper * psfhlp; + ISFHelper *psfhlp; WCHAR wszName[MAX_PATH]; - CComPtr<IFolderView> folderView; - CComPtr<IShellFolder> parentFolder; - HRESULT hResult; + CComPtr<IFolderView> folderView; + CComPtr<IShellFolder> parentFolder; + HRESULT hResult;
//if (fSite == NULL) // return; @@ -588,25 +572,25 @@ parentFolder->QueryInterface(IID_ISFHelper, (LPVOID*)&psfhlp); if (psfhlp) { - LPITEMIDLIST pidl; - - if (psfhlp->GetUniqueName(wszName, MAX_PATH) != S_OK) - return; - if (psfhlp->AddFolder(0, wszName, &pidl) != S_OK) - return; - - if(psv) - { - psv->Refresh(); - /* if we are in a shellview do labeledit */ - psv->SelectItem( - pidl,(SVSI_DESELECTOTHERS | SVSI_EDIT | SVSI_ENSUREVISIBLE - |SVSI_FOCUSED|SVSI_SELECT)); - psv->Refresh(); - } - SHFree(pidl); - - psfhlp->Release(); + LPITEMIDLIST pidl; + + if (psfhlp->GetUniqueName(wszName, MAX_PATH) != S_OK) + return; + if (psfhlp->AddFolder(0, wszName, &pidl) != S_OK) + return; + + if(psv) + { + psv->Refresh(); + /* if we are in a shellview do labeledit */ + psv->SelectItem( + pidl, (SVSI_DESELECTOTHERS | SVSI_EDIT | SVSI_ENSUREVISIBLE + | SVSI_FOCUSED | SVSI_SELECT)); + psv->Refresh(); + } + SHFree(pidl); + + psfhlp->Release(); } }
@@ -629,10 +613,10 @@ HRESULT WINAPI CNewMenu::QueryContextMenu(HMENU hmenu, - UINT indexMenu, - UINT idCmdFirst, - UINT idCmdLast, - UINT uFlags) + UINT indexMenu, + UINT idCmdFirst, + UINT idCmdLast, + UINT uFlags) { WCHAR szBuffer[200]; MENUITEMINFOW mii; @@ -642,11 +626,8 @@ 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) ); @@ -655,34 +636,33 @@ mii.fType = MFT_STRING; mii.wID = idCmdFirst + id++; mii.dwTypeData = szBuffer; - mii.cch = wcslen( mii.dwTypeData ); + mii.cch = wcslen(mii.dwTypeData); mii.fState = MFS_ENABLED;
if (hSubMenu) { - id += InsertShellNewItems( hSubMenu, idCmdFirst, 0); + id += InsertShellNewItems(hSubMenu, idCmdFirst, 0); mii.fMask |= MIIM_SUBMENU; mii.hSubMenu = hSubMenu; }
- - if (!InsertMenuItemW( hmenu, indexMenu, TRUE, &mii )) + if (!InsertMenuItemW(hmenu, indexMenu, TRUE, &mii)) return E_FAIL;
- return MAKE_HRESULT( SEVERITY_SUCCESS, 0, id ); + return MAKE_HRESULT(SEVERITY_SUCCESS, 0, id); }
HRESULT WINAPI CNewMenu::InvokeCommand(LPCMINVOKECOMMANDINFO lpici) { - LPSHELLBROWSER lpSB; + LPSHELLBROWSER lpSB; LPSHELLVIEW lpSV = NULL; HRESULT hr;
- if((lpSB = (LPSHELLBROWSER)SendMessageA(lpici->hwnd, CWM_GETISHELLBROWSER,0,0))) - { - lpSB->QueryActiveShellView(&lpSV); + if((lpSB = (LPSHELLBROWSER)SendMessageA(lpici->hwnd, CWM_GETISHELLBROWSER, 0, 0))) + { + lpSB->QueryActiveShellView(&lpSV); }
if (LOWORD(lpici->lpVerb) == 0) @@ -704,10 +684,10 @@ HRESULT WINAPI CNewMenu::GetCommandString(UINT_PTR idCmd, - UINT uType, - UINT* pwReserved, - LPSTR pszName, - UINT cchMax) + UINT uType, + UINT* pwReserved, + LPSTR pszName, + UINT cchMax) { FIXME("%p %lu %u %p %p %u\n", this, idCmd, uType, pwReserved, pszName, cchMax ); @@ -715,26 +695,25 @@ return E_NOTIMPL; }
-HRESULT -WINAPI +HRESULT +WINAPI CNewMenu::HandleMenuMsg(UINT uMsg, - WPARAM wParam, - LPARAM lParam) -{ - DRAWITEMSTRUCT * lpids = (DRAWITEMSTRUCT*) lParam; + WPARAM wParam, + LPARAM lParam) +{ + DRAWITEMSTRUCT *lpids = (DRAWITEMSTRUCT*) lParam; MEASUREITEMSTRUCT *lpmis = (MEASUREITEMSTRUCT*) lParam;
- TRACE("INewItem_IContextMenu_fnHandleMenuMsg (%p)->(msg=%x wp=%lx lp=%lx)\n",this, uMsg, wParam, lParam); - + TRACE("INewItem_IContextMenu_fnHandleMenuMsg (%p)->(msg=%x wp=%lx lp=%lx)\n", this, uMsg, wParam, lParam);
switch(uMsg) { - case WM_MEASUREITEM: - return DoMeasureItem((HWND)wParam, lpmis); - break; - case WM_DRAWITEM: - return DoDrawItem((HWND)wParam, lpids); - break; + case WM_MEASUREITEM: + return DoMeasureItem((HWND)wParam, lpmis); + break; + case WM_DRAWITEM: + return DoDrawItem((HWND)wParam, lpids); + break; } return S_OK;
@@ -743,7 +722,7 @@
HRESULT WINAPI CNewMenu::Initialize(LPCITEMIDLIST pidlFolder, - IDataObject *pdtobj, HKEY hkeyProgID ) + IDataObject *pdtobj, HKEY hkeyProgID ) {
return S_OK;
Modified: trunk/reactos/dll/win32/shell32/shlexec.cpp URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/shell32/shlexec.c... ============================================================================== --- trunk/reactos/dll/win32/shell32/shlexec.cpp [iso-8859-1] (original) +++ trunk/reactos/dll/win32/shell32/shlexec.cpp [iso-8859-1] Thu Jan 5 18:34:35 2012 @@ -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)
@@ -39,7 +37,7 @@ bool quotes_opened = false; bool backslash_encountered = false;
- for (int curArg=0; curArg<=argNum && *args; ++curArg) + for (int curArg = 0; curArg <= argNum && *args; ++curArg) { firstCharQuote = false; if (*args == '"') @@ -60,7 +58,7 @@ { if (quotes_opened) { - if (*(args+1) != '"') + if (*(args + 1) != '"') { quotes_opened = false; args++; @@ -68,7 +66,7 @@ } else { - args++; + args++; } } else @@ -105,7 +103,7 @@ bool quotes_opened = false; bool backslash_encountered = false;
- for (int curArg=0; curArg<=argNum && *args; ++curArg) + for (int curArg = 0; curArg <= argNum && *args; ++curArg) { while(*args) { @@ -118,13 +116,13 @@ { if (quotes_opened) { - if (*(args+1) != '"') + if (*(args + 1) != '"') { quotes_opened = false; } else { - args++; + args++; } } else @@ -137,7 +135,7 @@ else { backslash_encountered = false; - if (*args == ' ' && !quotes_opened && curArg!=argNum) + if (*args == ' ' && !quotes_opened && curArg != argNum) break; }
@@ -205,7 +203,8 @@ used++; if (used < len) *res++ = '%'; - }; break; + }; + break;
case '*': { @@ -226,7 +225,8 @@ break; } } - }; break; + }; + break;
case '~':
@@ -238,7 +238,7 @@ case '7': case '8': case '9': - //case '0': + //case '0': { if (*fmt == '~') { @@ -258,13 +258,14 @@ ParseNoTildeEffect(res, args, len, used, *fmt - '2'); } } - }; break; + }; + break;
case '1': if (!done || (*fmt == '1')) { /*FIXME Is the call to SearchPathW() really needed? We already have separated out the parameter string in args. */ - if (SearchPathW(NULL, lpFile, wszExe, sizeof(xlpFile)/sizeof(WCHAR), xlpFile, NULL)) + if (SearchPathW(NULL, lpFile, wszExe, sizeof(xlpFile) / sizeof(WCHAR), xlpFile, NULL)) cmd = xlpFile; else cmd = lpFile; @@ -279,11 +280,11 @@ found_p1 = TRUE; break;
- /* - * IE uses this a lot for activating things such as windows media - * player. This is not verified to be fully correct but it appears - * to work just fine. - */ + /* + * IE uses this a lot for activating things such as windows media + * player. This is not verified to be fully correct but it appears + * to work just fine. + */ case 'l': case 'L': if (lpFile) @@ -309,16 +310,16 @@ LPVOID pv; HGLOBAL hmem = SHAllocShared(pidl, ILGetSize(pidl), 0); pv = SHLockShared(hmem, 0); - chars = swprintf(buf, wszILPtr, pv); - - if (chars >= sizeof(buf)/sizeof(WCHAR)) + chars = swprintf(buf, L":%p", pv); + + if (chars >= sizeof(buf) / sizeof(WCHAR)) ERR("pidl format buffer too small!\n");
used += chars;
if (used < len) { - wcscpy(res,buf); + wcscpy(res, buf); res += chars; } SHUnlockShared(pv); @@ -385,7 +386,7 @@ }
*res = '\0'; - TRACE("used %i of %i space\n",used,len); + TRACE("used %i of %i space\n", used, len); if (out_len) *out_len = used;
@@ -398,7 +399,7 @@ static HRESULT SHELL_GetPathFromIDListForExecuteW(LPCITEMIDLIST pidl, LPWSTR pszPath, UINT uOutSize) { STRRET strret; - IShellFolder* desktop; + IShellFolder *desktop;
HRESULT hr = SHGetDesktopFolder(&desktop);
@@ -420,7 +421,7 @@ * */ static UINT_PTR SHELL_ExecuteW(const WCHAR *lpCmd, WCHAR *env, BOOL shWait, - const SHELLEXECUTEINFOW *psei, LPSHELLEXECUTEINFOW psei_out) + const SHELLEXECUTEINFOW *psei, LPSHELLEXECUTEINFOW psei_out) { STARTUPINFOW startup; PROCESS_INFORMATION info; @@ -443,12 +444,12 @@
/* ShellExecute specifies the command from psei->lpDirectory * if present. Not from the current dir as CreateProcess does */ - if ( lpDirectory ) - if ( ( gcdret = GetCurrentDirectoryW( MAX_PATH, curdir))) - if ( !SetCurrentDirectoryW( lpDirectory)) + if (lpDirectory) + if ((gcdret = GetCurrentDirectoryW( MAX_PATH, curdir))) + if (!SetCurrentDirectoryW( lpDirectory)) ERR("cannot set directory %s\n", debugstr_w(lpDirectory));
- ZeroMemory(&startup,sizeof(STARTUPINFOW)); + ZeroMemory(&startup, sizeof(STARTUPINFOW)); startup.cb = sizeof(STARTUPINFOW); startup.dwFlags = STARTF_USESHOWWINDOW; startup.wShowWindow = psei->nShow; @@ -463,7 +464,7 @@ /* Give 30 seconds to the app to come up, if desired. Probably only needed when starting app immediately before making a DDE connection. */ if (shWait) - if (WaitForInputIdle( info.hProcess, 30000 ) == WAIT_FAILED) + if (WaitForInputIdle(info.hProcess, 30000) == WAIT_FAILED) WARN("WaitForInputIdle failed: Error %d\n", GetLastError() ); retval = 33;
@@ -483,8 +484,8 @@
psei_out->hInstApp = (HINSTANCE)retval;
- if( gcdret ) - if( !SetCurrentDirectoryW( curdir)) + if (gcdret) + if (!SetCurrentDirectoryW(curdir)) ERR("cannot return to directory %s\n", debugstr_w(curdir));
return retval; @@ -499,7 +500,7 @@ */ 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; @@ -517,9 +518,9 @@ if (!got_path) total += 5; /* we need to create PATH */ total++; /* terminating null */
- if (!(new_env = (LPWSTR)HeapAlloc( GetProcessHeap(), 0, total * sizeof(WCHAR) ))) - { - FreeEnvironmentStringsW( strings ); + if (!(new_env = (LPWSTR)HeapAlloc(GetProcessHeap(), 0, total * sizeof(WCHAR)))) + { + FreeEnvironmentStringsW(strings); return NULL; } p = strings; @@ -527,7 +528,7 @@ while (*p) { int len = wcslen(p) + 1; - memcpy( p2, p, len * sizeof(WCHAR) ); + memcpy(p2, p, len * sizeof(WCHAR)); if (!_wcsnicmp( p, wPath, 5 )) { p2[len - 1] = ';'; @@ -539,12 +540,12 @@ } if (!got_path) { - wcscpy( p2, wPath ); - wcscat( p2, path ); + wcscpy(p2, wPath); + wcscat(p2, path); p2 += wcslen(p2) + 1; } *p2 = 0; - FreeEnvironmentStringsW( strings ); + FreeEnvironmentStringsW(strings); return new_env; }
@@ -559,9 +560,6 @@ */ 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,12 +567,12 @@ 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;
- len = MAX_PATH*sizeof(WCHAR); + len = MAX_PATH * sizeof(WCHAR); res = RegQueryValueW(hkApp, NULL, lpResult, &len); if (res) goto end; found = TRUE; @@ -582,8 +580,8 @@ if (env) { DWORD count = sizeof(buffer); - if (!RegQueryValueExW(hkApp, wPath, NULL, NULL, (LPBYTE)buffer, &count) && buffer[0]) - *env = SHELL_BuildEnvW( buffer ); + if (!RegQueryValueExW(hkApp, L"Path", NULL, NULL, (LPBYTE)buffer, &count) && buffer[0]) + *env = SHELL_BuildEnvW(buffer); }
end: @@ -593,13 +591,13 @@
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];
if (RegOpenKeyExW(HKEY_CLASSES_ROOT, filetype, 0, 0x02000000, &hkeyClass)) return SE_ERR_NOASSOC; - if (!HCR_GetDefaultVerbW(hkeyClass, lpOperation, verb, sizeof(verb)/sizeof(verb[0]))) + if (!HCR_GetDefaultVerbW(hkeyClass, lpOperation, verb, sizeof(verb) / sizeof(verb[0]))) return SE_ERR_NOASSOC; RegCloseKey(hkeyClass);
@@ -617,7 +615,7 @@ LPWSTR tmp; WCHAR param[256]; LONG paramlen = sizeof(param); - static const WCHAR wSpace[] = {' ',0}; + static const WCHAR wSpace[] = {' ', 0};
/* FIXME: it seems all Windows version don't behave the same here. * the doc states that this ddeexec information can be found after @@ -662,11 +660,8 @@ * on the operation) */ 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}; + LPWSTR lpResult, DWORD resultLen, LPWSTR key, WCHAR **env, LPITEMIDLIST pidl, LPCWSTR args) +{ WCHAR *extension = NULL; /* pointer to file extension */ WCHAR filetype[256]; /* registry name for this filetype */ LONG filetypelen = sizeof(filetype); /* length of above */ @@ -700,7 +695,7 @@ return 33; }
- if (SearchPathW(lpPath, lpFile, wszExe, sizeof(xlpFile)/sizeof(WCHAR), xlpFile, NULL)) + if (SearchPathW(lpPath, lpFile, wszExe, sizeof(xlpFile) / sizeof(WCHAR), xlpFile, NULL)) { TRACE("SearchPathW returned non-zero\n"); lpFile = xlpFile; @@ -708,15 +703,15 @@ }
attribs = GetFileAttributesW(lpFile); - if (attribs!=INVALID_FILE_ATTRIBUTES && (attribs&FILE_ATTRIBUTE_DIRECTORY)) - { - wcscpy(filetype, wszFolder); - filetypelen = 6; /* strlen("Folder") */ + if (attribs != INVALID_FILE_ATTRIBUTES && (attribs & FILE_ATTRIBUTE_DIRECTORY)) + { + wcscpy(filetype, wszFolder); + filetypelen = 6; /* strlen("Folder") */ } else { /* Did we get something? Anything? */ - if (xlpFile[0]==0) + if (xlpFile[0] == 0) { TRACE("Returning SE_ERR_FNF\n"); return SE_ERR_FNF; @@ -727,7 +722,7 @@ /* .\FILE.EXE :( */ TRACE("xlpFile=%s,extension=%s\n", debugstr_w(xlpFile), debugstr_w(extension));
- if (extension == NULL || extension[1]==0) + if (extension == NULL || extension[1] == 0) { WARN("Returning SE_ERR_NOASSOC\n"); return SE_ERR_NOASSOC; @@ -744,7 +739,7 @@ /* 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; @@ -776,7 +771,7 @@ &filetypelen) == ERROR_SUCCESS) { filetypelen /= sizeof(WCHAR); - if (filetypelen == sizeof(filetype)/sizeof(WCHAR)) + if (filetypelen == sizeof(filetype) / sizeof(WCHAR)) filetypelen--;
filetype[filetypelen] = '\0'; @@ -818,17 +813,15 @@ WCHAR *p = lpResult; while (*p != ' ' && *p != '\0') p++; - *p='\0'; + *p = '\0'; } } } 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) { @@ -839,7 +832,7 @@ tok[0] = '\0'; wcscat(lpResult, xlpFile); /* what if no dir in xlpFile? */ tok = wcschr(command, '^'); /* see above */ - if ((tok != NULL) && (wcslen(tok)>5)) + if ((tok != NULL) && (wcslen(tok) > 5)) { wcscat(lpResult, &tok[5]); } @@ -863,7 +856,7 @@ ULONG_PTR dwData1, ULONG_PTR dwData2) { TRACE("dde_cb: %04x, %04x, %p, %p, %p, %p, %08lx, %08lx\n", - uType, uFmt, hConv, hsz1, hsz2, hData, dwData1, dwData2); + uType, uFmt, hConv, hsz1, hsz2, hData, dwData1, dwData2); return NULL; }
@@ -881,8 +874,6 @@ 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,37 +889,37 @@ 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 }; - DWORD sizeSo = sizeof(wSo)/sizeof(WCHAR); + static const WCHAR wSo[] = L".so"; + DWORD sizeSo = sizeof(wSo) / sizeof(WCHAR); LPWSTR ptr = NULL; DWORD ret = 0;
/* Get application command from start string and find filename of application */ if (*start == '"') { - wcscpy(command, start+1); + wcscpy(command, start + 1); if ((ptr = wcschr(command, '"'))) - *ptr = 0; - ret = SearchPathW(NULL, command, wszExe, sizeof(fullpath)/sizeof(WCHAR), fullpath, &ptr); + * ptr = 0; + ret = SearchPathW(NULL, command, wszExe, sizeof(fullpath) / sizeof(WCHAR), fullpath, &ptr); } else { - LPWSTR p,space; - for (p=(LPWSTR)start; (space= const_cast<LPWSTR>(strchrW(p, ' '))); p=space+1) + LPWSTR p, space; + for (p = (LPWSTR)start; (space = const_cast<LPWSTR>(strchrW(p, ' '))); p = space + 1) { - int idx = space-start; - memcpy(command, start, idx*sizeof(WCHAR)); + int idx = space - start; + memcpy(command, start, idx * sizeof(WCHAR)); command[idx] = '\0'; - if ((ret = SearchPathW(NULL, command, wszExe, sizeof(fullpath)/sizeof(WCHAR), fullpath, &ptr))) + if ((ret = SearchPathW(NULL, command, wszExe, sizeof(fullpath) / sizeof(WCHAR), fullpath, &ptr))) break; } if (!ret) - ret = SearchPathW(NULL, start, wszExe, sizeof(fullpath)/sizeof(WCHAR), fullpath, &ptr); + ret = SearchPathW(NULL, start, wszExe, sizeof(fullpath) / sizeof(WCHAR), fullpath, &ptr); }
if (!ret) @@ -939,9 +930,9 @@ wcscpy(app, ptr);
/* Remove extensions (including .so) */ - ptr = app + wcslen(app) - (sizeSo-1); + ptr = app + wcslen(app) - (sizeSo - 1); if (wcslen(app) >= sizeSo && - !wcscmp(ptr, wSo)) + !wcscmp(ptr, wSo)) *ptr = 0;
ptr = const_cast<LPWSTR>(strrchrW(app, '.')); @@ -949,12 +940,11 @@ *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 @@ 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 @@ 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) { @@ -999,8 +988,8 @@ } }
- SHELL_ArgifyW(res, sizeof(res)/sizeof(WCHAR), exec, lpFile, pidl, szCommandline, &resultLen); - if (resultLen > sizeof(res)/sizeof(WCHAR)) + SHELL_ArgifyW(res, sizeof(res) / sizeof(WCHAR), exec, lpFile, pidl, szCommandline, &resultLen); + if (resultLen > sizeof(res) / sizeof(WCHAR)) ERR("Argify buffer not large enough, truncated\n"); TRACE("%s %s => %s\n", debugstr_w(exec), debugstr_w(lpFile), debugstr_w(res));
@@ -1026,7 +1015,7 @@
DdeDisconnect(hConv);
- error: +error: DdeUninitialize(ddeInst);
return ret; @@ -1040,8 +1029,6 @@ 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; @@ -1049,7 +1036,7 @@ LPWSTR tmp;
TRACE("%s %s %s %s %s\n", debugstr_w(key), debugstr_w(lpFile), debugstr_w(env), - debugstr_w(szCommandline), debugstr_w(executable_name)); + debugstr_w(szCommandline), debugstr_w(executable_name));
cmd[0] = '\0'; param[0] = '\0'; @@ -1061,19 +1048,19 @@
/* Is there a replace() function anywhere? */ cmdlen /= sizeof(WCHAR); - if (cmdlen >= sizeof(cmd)/sizeof(WCHAR)) - cmdlen = sizeof(cmd)/sizeof(WCHAR)-1; + if (cmdlen >= sizeof(cmd) / sizeof(WCHAR)) + cmdlen = sizeof(cmd) / sizeof(WCHAR) - 1; cmd[cmdlen] = '\0'; - SHELL_ArgifyW(param, sizeof(param)/sizeof(WCHAR), cmd, lpFile, (LPITEMIDLIST)psei->lpIDList, szCommandline, &resultLen); - if (resultLen > sizeof(param)/sizeof(WCHAR)) + SHELL_ArgifyW(param, sizeof(param) / sizeof(WCHAR), cmd, lpFile, (LPITEMIDLIST)psei->lpIDList, szCommandline, &resultLen); + if (resultLen > sizeof(param) / sizeof(WCHAR)) ERR("Argify buffer not large enough, truncating\n"); }
/* 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) { @@ -1106,8 +1093,8 @@
retval = FindExecutableW(wFile, wDirectory, wResult); WideCharToMultiByte(CP_ACP, 0, wResult, -1, lpResult, MAX_PATH, NULL, NULL); - SHFree( wFile ); - SHFree( wDirectory ); + SHFree(wFile); + SHFree(wDirectory);
TRACE("returning %s\n", lpResult); return retval; @@ -1151,7 +1138,7 @@
if (lpDirectory) { - GetCurrentDirectoryW(sizeof(old_dir)/sizeof(WCHAR), old_dir); + GetCurrentDirectoryW(sizeof(old_dir) / sizeof(WCHAR), old_dir); SetCurrentDirectoryW(lpDirectory); }
@@ -1164,7 +1151,7 @@ }
/* FIXME: is this already implemented somewhere else? */ -static HKEY ShellExecute_GetClassKey( const SHELLEXECUTEINFOW *sei ) +static HKEY ShellExecute_GetClassKey(const SHELLEXECUTEINFOW *sei) { LPCWSTR ext = NULL, lpClass = NULL; LPWSTR cls = NULL; @@ -1179,35 +1166,35 @@ lpClass = sei->lpClass; else { - ext = PathFindExtensionW( sei->lpFile ); - TRACE("ext = %s\n", debugstr_w( ext ) ); + ext = PathFindExtensionW(sei->lpFile); + TRACE("ext = %s\n", debugstr_w(ext)); if (!ext) return hkey;
- r = RegOpenKeyW( HKEY_CLASSES_ROOT, ext, &hkey ); - if (r != ERROR_SUCCESS ) + r = RegOpenKeyW(HKEY_CLASSES_ROOT, ext, &hkey); + if (r != ERROR_SUCCESS) return hkey;
- r = RegQueryValueExW( hkey, NULL, 0, &type, NULL, &sz ); - if ( r == ERROR_SUCCESS && type == REG_SZ ) + r = RegQueryValueExW(hkey, NULL, 0, &type, NULL, &sz); + if (r == ERROR_SUCCESS && type == REG_SZ) { sz += sizeof (WCHAR); - cls = (LPWSTR)HeapAlloc( GetProcessHeap(), 0, sz ); + cls = (LPWSTR)HeapAlloc(GetProcessHeap(), 0, sz); cls[0] = 0; - RegQueryValueExW( hkey, NULL, 0, &type, (LPBYTE) cls, &sz ); + RegQueryValueExW(hkey, NULL, 0, &type, (LPBYTE) cls, &sz); }
RegCloseKey( hkey ); lpClass = cls; }
- TRACE("class = %s\n", debugstr_w(lpClass) ); + TRACE("class = %s\n", debugstr_w(lpClass));
hkey = 0; - if ( lpClass ) - RegOpenKeyW( HKEY_CLASSES_ROOT, lpClass, &hkey ); - - HeapFree( GetProcessHeap(), 0, cls ); + if (lpClass) + RegOpenKeyW( HKEY_CLASSES_ROOT, lpClass, &hkey); + + HeapFree(GetProcessHeap(), 0, cls);
return hkey; } @@ -1228,30 +1215,30 @@ BOOL ret;
fullpath[0] = 0; - ret = GetFullPathNameW( sei->lpFile, MAX_PATH, fullpath, NULL ); + ret = GetFullPathNameW(sei->lpFile, MAX_PATH, fullpath, NULL); if (!ret) goto end;
- pidl = ILCreateFromPathW( fullpath ); - } - - r = SHBindToParent( pidl, IID_IShellFolder, (LPVOID*)&shf, &pidllast ); - if ( FAILED( r ) ) + pidl = ILCreateFromPathW(fullpath); + } + + r = SHBindToParent(pidl, IID_IShellFolder, (LPVOID*)&shf, &pidllast); + if (FAILED(r)) goto end;
shf->GetUIObjectOf(NULL, 1, &pidllast, - IID_IDataObject, NULL, (LPVOID*) &dataobj ); + IID_IDataObject, NULL, (LPVOID*) &dataobj);
end: - if ( pidl != sei->lpIDList ) - ILFree( pidl ); - if ( shf ) + if (pidl != sei->lpIDList) + ILFree(pidl); + if (shf) shf->Release(); return dataobj; }
-static HRESULT shellex_run_context_menu_default( IShellExtInit *obj, - LPSHELLEXECUTEINFOW sei ) +static HRESULT shellex_run_context_menu_default(IShellExtInit *obj, + LPSHELLEXECUTEINFOW sei) { IContextMenu *cm = NULL; CMINVOKECOMMANDINFOEX ici; @@ -1261,36 +1248,36 @@ HMENU hmenu = 0; HRESULT r;
- TRACE("%p %p\n", obj, sei ); - - r = obj->QueryInterface(IID_IContextMenu, (LPVOID*) &cm ); - if ( FAILED( r ) ) + TRACE("%p %p\n", obj, sei); + + r = obj->QueryInterface(IID_IContextMenu, (LPVOID*) &cm); + if (FAILED(r)) return r;
hmenu = CreateMenu(); - if ( !hmenu ) + if (!hmenu) goto end;
/* the number of the last menu added is returned in r */ - r = cm->QueryContextMenu(hmenu, 0, 0x20, 0x7fff, CMF_DEFAULTONLY ); - if ( FAILED( r ) ) + r = cm->QueryContextMenu(hmenu, 0, 0x20, 0x7fff, CMF_DEFAULTONLY); + if (FAILED(r)) goto end;
- n = GetMenuItemCount( hmenu ); - for ( i = 0; i < n; i++ ) - { - memset( &info, 0, sizeof info ); + n = GetMenuItemCount(hmenu); + for (i = 0; i < n; i++) + { + memset(&info, 0, sizeof(info)); info.cbSize = sizeof info; info.fMask = MIIM_FTYPE | MIIM_STRING | MIIM_STATE | MIIM_DATA | MIIM_ID; info.dwTypeData = string; info.cch = sizeof string; string[0] = 0; - GetMenuItemInfoW( hmenu, i, TRUE, &info ); + GetMenuItemInfoW(hmenu, i, TRUE, &info);
TRACE("menu %d %s %08x %08lx %08x %08x\n", i, debugstr_w(string), - info.fState, info.dwItemData, info.fType, info.wID ); - if ( ( !sei->lpVerb && (info.fState & MFS_DEFAULT) ) || - ( sei->lpVerb && !lstrcmpiW( sei->lpVerb, string ) ) ) + info.fState, info.dwItemData, info.fType, info.wID); + if ((!sei->lpVerb && (info.fState & MFS_DEFAULT)) || + (sei->lpVerb && !lstrcmpiW(sei->lpVerb, string))) { def = i; break; @@ -1298,75 +1285,75 @@ }
r = E_FAIL; - if ( def == -1 ) + if (def == -1) goto end;
- memset( &ici, 0, sizeof ici ); + memset(&ici, 0, sizeof ici); ici.cbSize = sizeof ici; - ici.fMask = CMIC_MASK_UNICODE | (sei->fMask & (SEE_MASK_NOASYNC|SEE_MASK_ASYNCOK|SEE_MASK_FLAG_NO_UI)); + ici.fMask = CMIC_MASK_UNICODE | (sei->fMask & (SEE_MASK_NOASYNC | SEE_MASK_ASYNCOK | SEE_MASK_FLAG_NO_UI)); ici.nShow = sei->nShow; - ici.lpVerb = MAKEINTRESOURCEA( def ); + ici.lpVerb = MAKEINTRESOURCEA(def); ici.hwnd = sei->hwnd; ici.lpParametersW = sei->lpParameters;
- r = cm->InvokeCommand((LPCMINVOKECOMMANDINFO) &ici ); - - TRACE("invoke command returned %08x\n", r ); + r = cm->InvokeCommand((LPCMINVOKECOMMANDINFO)&ici); + + TRACE("invoke command returned %08x\n", r);
end: - if ( hmenu ) + if (hmenu) DestroyMenu( hmenu ); - if ( cm ) + if (cm) cm->Release(); return r; }
-static HRESULT shellex_load_object_and_run( HKEY hkey, LPCGUID guid, LPSHELLEXECUTEINFOW sei ) +static HRESULT shellex_load_object_and_run(HKEY hkey, LPCGUID guid, LPSHELLEXECUTEINFOW sei) { IDataObject *dataobj = NULL; IObjectWithSite *ows = NULL; IShellExtInit *obj = NULL; HRESULT r;
- TRACE("%p %s %p\n", hkey, debugstr_guid( guid ), sei ); - - r = CoInitialize( NULL ); - if ( FAILED( r ) ) + TRACE("%p %s %p\n", hkey, debugstr_guid(guid), sei); + + r = CoInitialize(NULL); + if (FAILED(r)) goto end;
r = CoCreateInstance(*guid, NULL, CLSCTX_INPROC_SERVER, - IID_IShellExtInit, (LPVOID*)&obj ); - if ( FAILED( r ) ) - { - ERR("failed %08x\n", r ); + IID_IShellExtInit, (LPVOID*)&obj); + if (FAILED(r)) + { + ERR("failed %08x\n", r); goto end; }
- dataobj = shellex_get_dataobj( sei ); - if ( !dataobj ) + dataobj = shellex_get_dataobj(sei); + if (!dataobj) { ERR("failed to get data object\n"); goto end; }
- r = obj->Initialize(NULL, dataobj, hkey ); - if ( FAILED( r ) ) + r = obj->Initialize(NULL, dataobj, hkey); + if (FAILED(r)) goto end;
- r = obj->QueryInterface(IID_IObjectWithSite, (LPVOID*) &ows ); - if ( FAILED( r ) ) + r = obj->QueryInterface(IID_IObjectWithSite, (LPVOID*) &ows); + if (FAILED(r)) goto end;
- ows->SetSite(NULL ); - - r = shellex_run_context_menu_default( obj, sei ); + ows->SetSite(NULL); + + r = shellex_run_context_menu_default(obj, sei);
end: - if ( ows ) + if (ows) ows->Release(); - if ( dataobj ) + if (dataobj) dataobj->Release(); - if ( obj ) + if (obj) obj->Release(); CoUninitialize(); return r; @@ -1378,8 +1365,6 @@ */ 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; @@ -1387,52 +1372,51 @@ DWORD i; LONG r;
- TRACE("%s\n", debugstr_w(sei->lpFile) ); - - hkey = ShellExecute_GetClassKey( sei ); - if ( !hkey ) + TRACE("%s\n", debugstr_w(sei->lpFile)); + + hkey = ShellExecute_GetClassKey(sei); + if (!hkey) return ERROR_FUNCTION_FAILED;
- r = RegOpenKeyW( hkey, szcm, &hkeycm ); - if ( r == ERROR_SUCCESS ) + r = RegOpenKeyW(hkey, L"shellex\ContextMenuHandlers", &hkeycm); + if (r == ERROR_SUCCESS) { i = 0; - while ( 1 ) - { - r = RegEnumKeyW( hkeycm, i++, szguid, sizeof(szguid)/sizeof(szguid[0]) ); - if ( r != ERROR_SUCCESS ) + while (1) + { + r = RegEnumKeyW(hkeycm, i++, szguid, sizeof(szguid) / sizeof(szguid[0])); + if (r != ERROR_SUCCESS) break;
- hr = CLSIDFromString( szguid, &guid ); + hr = CLSIDFromString(szguid, &guid); if (SUCCEEDED(hr)) { /* stop at the first one that succeeds in running */ - hr = shellex_load_object_and_run( hkey, &guid, sei ); - if ( SUCCEEDED( hr ) ) + hr = shellex_load_object_and_run(hkey, &guid, sei); + if (SUCCEEDED(hr)) break; } } - RegCloseKey( hkeycm ); - } - - if ( hkey != sei->hkeyClass ) - RegCloseKey( hkey ); + RegCloseKey(hkeycm); + } + + if (hkey != sei->hkeyClass) + RegCloseKey(hkey); return r; }
-static UINT_PTR SHELL_execute_class( LPCWSTR wszApplicationName, LPSHELLEXECUTEINFOW psei, LPSHELLEXECUTEINFOW psei_out, SHELL_ExecuteW32 execfunc ) -{ - static const WCHAR wSpace[] = {' ',0}; +static UINT_PTR SHELL_execute_class(LPCWSTR wszApplicationName, LPSHELLEXECUTEINFOW psei, LPSHELLEXECUTEINFOW psei_out, SHELL_ExecuteW32 execfunc) +{ WCHAR execCmd[1024], wcmd[1024]; /* launch a document by fileclass like 'WordPad.Document.1' */ /* the Commandline contains 'c:\Path\wordpad.exe "%1"' */ /* FIXME: wcmd should not be of a fixed size. Fixed to 1024, MAX_PATH is way too short! */ - ULONG cmask=(psei->fMask & SEE_MASK_CLASSALL); + ULONG cmask = (psei->fMask & SEE_MASK_CLASSALL); DWORD resultLen; BOOL done;
HCR_GetExecuteCommandW((cmask == SEE_MASK_CLASSKEY) ? psei->hkeyClass : NULL, - (cmask == SEE_MASK_CLASSNAME) ? psei->lpClass: NULL, + (cmask == SEE_MASK_CLASSNAME) ? psei->lpClass : NULL, psei->lpVerb, execCmd, sizeof(execCmd));
@@ -1440,26 +1424,26 @@ TRACE("SEE_MASK_CLASSNAME->%s, doc->%s\n", debugstr_w(execCmd), debugstr_w(wszApplicationName));
wcmd[0] = '\0'; - done = SHELL_ArgifyW(wcmd, sizeof(wcmd)/sizeof(WCHAR), execCmd, wszApplicationName, (LPITEMIDLIST)psei->lpIDList, NULL, &resultLen); + 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)) + if (resultLen > sizeof(wcmd) / sizeof(WCHAR)) ERR("Argify buffer not large enough... truncating\n"); return execfunc(wcmd, NULL, FALSE, psei, psei_out); }
-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 BOOL SHELL_translate_idlist(LPSHELLEXECUTEINFOW sei, LPWSTR wszParameters, DWORD parametersLen, LPWSTR wszApplicationName, DWORD dwApplicationNameLen) +{ + static const WCHAR wExplorer[] = L"explorer.exe"; WCHAR buffer[MAX_PATH]; BOOL appKnownSingular = FALSE;
/* last chance to translate IDList: now also allow CLSID paths */ if (SUCCEEDED(SHELL_GetPathFromIDListForExecuteW((LPCITEMIDLIST)sei->lpIDList, buffer, sizeof(buffer)))) { - if (buffer[0]==':' && buffer[1]==':') { + if (buffer[0] == ':' && buffer[1] == ':') { /* open shell folder for the specified class GUID */ if (strlenW(buffer) + 1 > parametersLen) ERR("parameters len exceeds buffer size (%i > %i), truncating\n", @@ -1481,10 +1465,10 @@ strcpyW(target, buffer); attribs = GetFileAttributesW(buffer); if (attribs != INVALID_FILE_ATTRIBUTES && - (attribs & FILE_ATTRIBUTE_DIRECTORY) && - HCR_GetExecuteCommandW(0, wszFolder, - sei->lpVerb, - buffer, sizeof(buffer))) { + (attribs & FILE_ATTRIBUTE_DIRECTORY) && + HCR_GetExecuteCommandW(0, wszFolder, + sei->lpVerb, + buffer, sizeof(buffer))) { SHELL_ArgifyW(wszApplicationName, dwApplicationNameLen, buffer, target, (LPITEMIDLIST)sei->lpIDList, NULL, &resultLen); if (resultLen > dwApplicationNameLen) @@ -1497,10 +1481,8 @@ return appKnownSingular; }
-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}; +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) +{ UINT_PTR retval; DWORD len; WCHAR *wszQuotedCmd; @@ -1516,12 +1498,12 @@ /* 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); }
@@ -1535,10 +1517,10 @@ return retval; }
-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 UINT_PTR SHELL_execute_url(LPCWSTR lpFile, LPCWSTR wFile, LPCWSTR wcmd, LPSHELLEXECUTEINFOW psei, LPSHELLEXECUTEINFOW psei_out, SHELL_ExecuteW32 execfunc) +{ + static const WCHAR wShell[] = L"\shell\"; + static const WCHAR wCommand[] = L"\command"; UINT_PTR retval; WCHAR *lpstrProtocol; LPCWSTR lpstrRes; @@ -1559,10 +1541,10 @@ else len += lstrlenW(wszOpen); lpstrProtocol = (LPWSTR)HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); - memcpy(lpstrProtocol, lpFile, iSize*sizeof(WCHAR)); + memcpy(lpstrProtocol, lpFile, iSize * sizeof(WCHAR)); lpstrProtocol[iSize] = '\0'; strcatW(lpstrProtocol, wShell); - strcatW(lpstrProtocol, psei->lpVerb? psei->lpVerb: wszOpen); + strcatW(lpstrProtocol, psei->lpVerb ? psei->lpVerb : wszOpen); strcatW(lpstrProtocol, wCommand);
/* Remove File Protocol from lpFile */ @@ -1578,7 +1560,7 @@ return retval; }
-void do_error_dialog( UINT_PTR retval, HWND hwnd, WCHAR* filename) +void do_error_dialog(UINT_PTR retval, HWND hwnd, WCHAR* filename) { WCHAR msg[2048]; DWORD_PTR msgArguments[3] = { (DWORD_PTR)filename, 0, 0 }; @@ -1587,14 +1569,14 @@ error_code = GetLastError();
if (retval == SE_ERR_NOASSOC) - LoadStringW(shell32_hInstance, IDS_SHLEXEC_NOASSOC, msg, sizeof(msg)/sizeof(WCHAR)); + LoadStringW(shell32_hInstance, IDS_SHLEXEC_NOASSOC, msg, sizeof(msg) / sizeof(WCHAR)); else FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ARGUMENT_ARRAY, NULL, error_code, LANG_USER_DEFAULT, msg, - sizeof(msg)/sizeof(WCHAR), + sizeof(msg) / sizeof(WCHAR), (va_list*)msgArguments);
MessageBoxW(hwnd, msg, NULL, MB_ICONERROR); @@ -1603,12 +1585,8 @@ /************************************************************************* * SHELL_execute [Internal] */ -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}; +BOOL SHELL_execute(LPSHELLEXECUTEINFOW sei, SHELL_ExecuteW32 execfunc) +{ static const DWORD unsupportedFlags = SEE_MASK_INVOKEIDLIST | SEE_MASK_ICON | SEE_MASK_HOTKEY | SEE_MASK_CONNECTNETDRV | SEE_MASK_FLAG_DDEWAIT | @@ -1616,7 +1594,7 @@
WCHAR parametersBuffer[1024], dirBuffer[MAX_PATH], wcmdBuffer[1024]; WCHAR *wszApplicationName, *wszParameters, *wszDir, *wcmd; - DWORD dwApplicationNameLen = MAX_PATH+2; + DWORD dwApplicationNameLen = MAX_PATH + 2; DWORD parametersLen = sizeof(parametersBuffer) / sizeof(WCHAR); DWORD dirLen = sizeof(dirBuffer) / sizeof(WCHAR); DWORD wcmdLen = sizeof(wcmdBuffer) / sizeof(WCHAR); @@ -1633,41 +1611,41 @@ sei_tmp = *sei;
TRACE("mask=0x%08x hwnd=%p verb=%s file=%s parm=%s dir=%s show=0x%08x class=%s\n", - sei_tmp.fMask, sei_tmp.hwnd, debugstr_w(sei_tmp.lpVerb), - debugstr_w(sei_tmp.lpFile), debugstr_w(sei_tmp.lpParameters), - debugstr_w(sei_tmp.lpDirectory), sei_tmp.nShow, - ((sei_tmp.fMask & SEE_MASK_CLASSALL) == SEE_MASK_CLASSNAME) ? - debugstr_w(sei_tmp.lpClass) : "not used"); + sei_tmp.fMask, sei_tmp.hwnd, debugstr_w(sei_tmp.lpVerb), + debugstr_w(sei_tmp.lpFile), debugstr_w(sei_tmp.lpParameters), + debugstr_w(sei_tmp.lpDirectory), sei_tmp.nShow, + ((sei_tmp.fMask & SEE_MASK_CLASSALL) == SEE_MASK_CLASSNAME) ? + debugstr_w(sei_tmp.lpClass) : "not used");
sei->hProcess = NULL;
/* make copies of all path/command strings */ if (!sei_tmp.lpFile) { - wszApplicationName = (LPWSTR)HeapAlloc(GetProcessHeap(), 0, dwApplicationNameLen*sizeof(WCHAR)); + wszApplicationName = (LPWSTR)HeapAlloc(GetProcessHeap(), 0, dwApplicationNameLen * sizeof(WCHAR)); *wszApplicationName = '\0'; } else if (*sei_tmp.lpFile == '"') { - DWORD l = strlenW(sei_tmp.lpFile+1); + DWORD l = strlenW(sei_tmp.lpFile + 1); if(l >= dwApplicationNameLen) - dwApplicationNameLen = l+1; - - 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'; + dwApplicationNameLen = l + 1; + + wszApplicationName = (LPWSTR)HeapAlloc(GetProcessHeap(), 0, dwApplicationNameLen * sizeof(WCHAR)); + memcpy(wszApplicationName, sei_tmp.lpFile + 1, (l + 1)*sizeof(WCHAR)); + + if (wszApplicationName[l-1] == L'"') + wszApplicationName[l-1] = L'\0'; appKnownSingular = TRUE;
- TRACE("wszApplicationName=%s\n",debugstr_w(wszApplicationName)); + TRACE("wszApplicationName=%s\n", debugstr_w(wszApplicationName)); } else { - DWORD l = strlenW(sei_tmp.lpFile)+1; - if(l > dwApplicationNameLen) dwApplicationNameLen = l+1; - wszApplicationName = (LPWSTR)HeapAlloc(GetProcessHeap(), 0, dwApplicationNameLen*sizeof(WCHAR)); - memcpy(wszApplicationName, sei_tmp.lpFile, l*sizeof(WCHAR)); + DWORD l = strlenW(sei_tmp.lpFile) + 1; + if(l > dwApplicationNameLen) dwApplicationNameLen = l + 1; + wszApplicationName = (LPWSTR)HeapAlloc(GetProcessHeap(), 0, dwApplicationNameLen * sizeof(WCHAR)); + memcpy(wszApplicationName, sei_tmp.lpFile, l * sizeof(WCHAR)); }
wszParameters = parametersBuffer; @@ -1682,7 +1660,7 @@ strcpyW(wszParameters, sei_tmp.lpParameters); } else - *wszParameters = '\0'; + *wszParameters = L'\0';
wszDir = dirBuffer; if (sei_tmp.lpDirectory) @@ -1696,7 +1674,7 @@ strcpyW(wszDir, sei_tmp.lpDirectory); } else - *wszDir = '\0'; + *wszDir = L'\0';
/* adjust string pointers to point to the new buffers */ sei_tmp.lpFile = wszApplicationName; @@ -1737,7 +1715,7 @@ TRACE("-- idlist=%p (%s)\n", sei_tmp.lpIDList, debugstr_w(wszApplicationName)); }
- if ( ERROR_SUCCESS == ShellExecute_FromContextMenu( &sei_tmp ) ) + if (ERROR_SUCCESS == ShellExecute_FromContextMenu(&sei_tmp)) { sei->hInstApp = (HINSTANCE) 33; HeapFree(GetProcessHeap(), 0, wszApplicationName); @@ -1750,8 +1728,7 @@
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; @@ -1764,7 +1741,7 @@ Info.oaifInFlags = OAIF_ALLOW_REGISTRATION | OAIF_EXEC;
//if (SHOpenWithDialog(sei_tmp.hwnd, &Info) != S_OK) - do_error_dialog(retval, sei_tmp.hwnd, wszApplicationName); + do_error_dialog(retval, sei_tmp.hwnd, wszApplicationName); } HeapFree(GetProcessHeap(), 0, wszApplicationName); if (wszParameters != parametersBuffer) @@ -1778,21 +1755,21 @@ if (sei_tmp.fMask & SEE_MASK_IDLIST) { appKnownSingular = SHELL_translate_idlist( &sei_tmp, wszParameters, - parametersLen, - wszApplicationName, - dwApplicationNameLen ); + parametersLen, + wszApplicationName, + dwApplicationNameLen ); }
/* expand environment strings */ len = ExpandEnvironmentStringsW(sei_tmp.lpFile, NULL, 0); - if (len>0) + if (len > 0) { LPWSTR buf; - buf = (LPWSTR)HeapAlloc(GetProcessHeap(),0,(len+1)*sizeof(WCHAR)); - - ExpandEnvironmentStringsW(sei_tmp.lpFile, buf, len+1); + buf = (LPWSTR)HeapAlloc(GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR)); + + ExpandEnvironmentStringsW(sei_tmp.lpFile, buf, len + 1); HeapFree(GetProcessHeap(), 0, wszApplicationName); - dwApplicationNameLen = len+1; + dwApplicationNameLen = len + 1; wszApplicationName = buf; /* appKnownSingular unmodified */
@@ -1806,7 +1783,7 @@ { LPWSTR buf; len++; - buf = (LPWSTR)HeapAlloc(GetProcessHeap(),0,len*sizeof(WCHAR)); + buf = (LPWSTR)HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); ExpandEnvironmentStringsW(sei_tmp.lpParameters, buf, len); if (wszParameters != parametersBuffer) HeapFree(GetProcessHeap(), 0, wszParameters); @@ -1823,7 +1800,7 @@ { LPWSTR buf; len++; - buf = (LPWSTR)HeapAlloc(GetProcessHeap(),0,len*sizeof(WCHAR)); + buf = (LPWSTR)HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); ExpandEnvironmentStringsW(sei_tmp.lpDirectory, buf, len); if (wszDir != dirBuffer) HeapFree(GetProcessHeap(), 0, wszDir); @@ -1833,25 +1810,25 @@ }
/* Else, try to execute the filename */ - TRACE("execute:%s,%s,%s\n", debugstr_w(wszApplicationName), debugstr_w(wszParameters), debugstr_w(wszDir)); + TRACE("execute: %s,%s,%s\n", debugstr_w(wszApplicationName), debugstr_w(wszParameters), debugstr_w(wszDir));
/* separate out command line arguments from executable file name */ 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!='"') - *dst++ = *src++; - - *dst = '\0'; - - if (*src == '"') + while(*src && *src != L'"') + *dst++ = *src++; + + *dst = L'\0'; + + if (*src == L'"') { end = ++src;
@@ -1865,7 +1842,7 @@ strcpyW(wszParameters, src);
/* terminate previous command string after the quote character */ - *end = '\0'; + *end = L'\0'; } else { @@ -1875,14 +1852,14 @@ 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; + int idx = space - sei_tmp.lpFile; memcpy(buffer, sei_tmp.lpFile, idx * sizeof(WCHAR)); buffer[idx] = '\0';
/*FIXME This finds directory paths if the targeted file name contains spaces. */ - if (SearchPathW(*sei_tmp.lpDirectory? sei_tmp.lpDirectory: NULL, buffer, wszExe, sizeof(xlpFile)/sizeof(xlpFile[0]), xlpFile, NULL)) + if (SearchPathW(*sei_tmp.lpDirectory ? sei_tmp.lpDirectory : NULL, buffer, wszExe, sizeof(xlpFile) / sizeof(xlpFile[0]), xlpFile, NULL)) { /* separate out command from parameter string */ LPCWSTR p = space + 1; @@ -1891,17 +1868,17 @@ ++p;
strcpyW(wszParameters, p); - *space = '\0'; + *space = L'\0';
break; } }
- lstrcpynW(wfileName, sei_tmp.lpFile,sizeof(wfileName)/sizeof(WCHAR)); + lstrcpynW(wfileName, sei_tmp.lpFile, sizeof(wfileName) / sizeof(WCHAR)); } } else - lstrcpynW(wfileName, sei_tmp.lpFile,sizeof(wfileName)/sizeof(WCHAR)); + lstrcpynW(wfileName, sei_tmp.lpFile, sizeof(wfileName) / sizeof(WCHAR));
lpFile = wfileName;
@@ -1917,7 +1894,7 @@ swprintf(wcmd, L""%s"", wszApplicationName); if (sei_tmp.lpParameters[0]) { - strcatW(wcmd, wSpace); + strcatW(wcmd, L" "); strcatW(wcmd, wszParameters); }
@@ -1935,53 +1912,49 @@ }
/* 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 */ { - retval = SHELL_quote_and_execute( wcmd, wszParameters, lpstrProtocol, - wszApplicationName, env, &sei_tmp, - sei, execfunc ); - HeapFree( GetProcessHeap(), 0, env ); + retval = SHELL_quote_and_execute(wcmd, wszParameters, lpstrProtocol, + wszApplicationName, env, &sei_tmp, + sei, execfunc); + HeapFree(GetProcessHeap(), 0, env); } 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) ); + WCHAR * lpQuotedFile = (LPWSTR)HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR) * (strlenW(lpFile) + 3));
if (lpQuotedFile) { - retval = SHELL_FindExecutable( sei_tmp.lpDirectory, wExplorer, - wszOpen, wExec, MAX_PATH, - NULL, &env, NULL, NULL ); + 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); - retval = SHELL_quote_and_execute( wExec, lpQuotedFile, - lpstrProtocol, - wszApplicationName, env, - &sei_tmp, sei, execfunc ); - HeapFree( GetProcessHeap(), 0, env ); + swprintf(lpQuotedFile, L""%s"", lpFile); + retval = SHELL_quote_and_execute(wExec, lpQuotedFile, + lpstrProtocol, + wszApplicationName, env, + &sei_tmp, sei, execfunc); + HeapFree(GetProcessHeap(), 0, env); } - HeapFree( GetProcessHeap(), 0, lpQuotedFile ); + HeapFree(GetProcessHeap(), 0, lpQuotedFile); } else retval = 0; /* Out of memory */ } 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); } @@ -2000,7 +1973,7 @@ Info.oaifInFlags = OAIF_ALLOW_REGISTRATION | OAIF_EXEC;
//if (SHOpenWithDialog(sei_tmp.hwnd, &Info) != S_OK) - do_error_dialog(retval, sei_tmp.hwnd, wszApplicationName); + do_error_dialog(retval, sei_tmp.hwnd, wszApplicationName); }
HeapFree(GetProcessHeap(), 0, wszApplicationName); @@ -2019,8 +1992,8 @@ /************************************************************************* * ShellExecuteA [SHELL32.290] */ -HINSTANCE WINAPI ShellExecuteA(HWND hWnd, LPCSTR lpOperation,LPCSTR lpFile, - LPCSTR lpParameters,LPCSTR lpDirectory, INT iShowCmd) +HINSTANCE WINAPI ShellExecuteA(HWND hWnd, LPCSTR lpOperation, LPCSTR lpFile, + LPCSTR lpParameters, LPCSTR lpDirectory, INT iShowCmd) { SHELLEXECUTEINFOA sei;
@@ -2042,7 +2015,7 @@ sei.dwHotKey = 0; sei.hProcess = 0;
- ShellExecuteExA (&sei); + ShellExecuteExA(&sei); return sei.hInstApp; }
@@ -2050,7 +2023,7 @@ * ShellExecuteExA [SHELL32.292] * */ -BOOL WINAPI ShellExecuteExA (LPSHELLEXECUTEINFOA sei) +BOOL WINAPI ShellExecuteExA(LPSHELLEXECUTEINFOA sei) { SHELLEXECUTEINFOW seiW; BOOL ret; @@ -2077,7 +2050,7 @@ else seiW.lpClass = NULL;
- ret = SHELL_execute( &seiW, SHELL_ExecuteW ); + ret = SHELL_execute(&seiW, SHELL_ExecuteW);
sei->hInstApp = seiW.hInstApp;
@@ -2097,9 +2070,9 @@ * ShellExecuteExW [SHELL32.293] * */ -BOOL WINAPI ShellExecuteExW (LPSHELLEXECUTEINFOW sei) -{ - return SHELL_execute( sei, SHELL_ExecuteW ); +BOOL WINAPI ShellExecuteExW(LPSHELLEXECUTEINFOW sei) +{ + return SHELL_execute(sei, SHELL_ExecuteW); }
/************************************************************************* @@ -2128,7 +2101,7 @@ sei.dwHotKey = 0; sei.hProcess = 0;
- SHELL_execute( &sei, SHELL_ExecuteW ); + SHELL_execute(&sei, SHELL_ExecuteW); return sei.hInstApp; }
@@ -2137,8 +2110,8 @@ * * FIXME: the callback function most likely doesn't work the same way on Windows. */ -EXTERN_C HINSTANCE WINAPI WOWShellExecute(HWND hWnd, LPCSTR lpOperation,LPCSTR lpFile, - LPCSTR lpParameters,LPCSTR lpDirectory, INT iShowCmd, void *callback) +EXTERN_C HINSTANCE WINAPI WOWShellExecute(HWND hWnd, LPCSTR lpOperation, LPCSTR lpFile, + LPCSTR lpParameters, LPCSTR lpDirectory, INT iShowCmd, void *callback) { SHELLEXECUTEINFOW seiW; WCHAR *wVerb = NULL, *wFile = NULL, *wParameters = NULL, *wDirectory = NULL; @@ -2159,7 +2132,7 @@ seiW.dwHotKey = 0; seiW.hProcess = hProcess;
- SHELL_execute( &seiW, (SHELL_ExecuteW32)callback ); + SHELL_execute(&seiW, (SHELL_ExecuteW32)callback);
SHFree(wVerb); SHFree(wFile);