41 for (
LPCWSTR pwszSrc = pszIn; *pwszSrc && *pwszSrc != stop; ++pwszSrc)
45 *(pszOut++) = *pwszSrc;
61 PCWSTR pszDllStart = pszCmd + (pszName - szDll) +
lstrlenW(pszName);
63 if (*pszDllStart ==
'\"')
65 while (*pszDllStart <=
' ' && *pszDllStart)
69 BOOL quoted = *pszDllStart ==
'\"';
71 while (!quoted && pszComma > szDll && *pszComma !=
',' && *pszComma !=
'\\' && *pszComma !=
'/')
74 if (
cch <=
cchMax && (quoted || *pszComma ==
','))
150 m_pApp(
NULL), m_cApp(0), m_cRecommended(0), m_bNoOpen(
FALSE) {}
164 WCHAR wszName[256], wszBuf[100];
170 ERR(
"RegOpenKeyEx HKCR\\Applications failed!\n");
189 StringCbPrintfW(wszBuf,
sizeof(wszBuf),
L"%s\\shell\\open\\command", wszName);
193 ERR(
"Failed to add app %ls\n", wszName);
214 ERR(
"AddInternal failed\n");
243 ERR(
"RegOpenKeyEx failed\n");
248 ERR(
"Cannot add app to registry\n");
322 ERR(
"RegOpenKeyEx failed\n");
330 sei.
lpFile = pwszFilePath;
347 ERR(
"insufficient buffer\n");
372 ERR(
"Allocation failed\n");
385 WORD wLang = 0, wCode = 0;
393 TRACE(
"LoadInfo %ls\n", wszPath);
399 ERR(
"GetFileVersionInfoSizeW %ls failed: %lu\n", wszPath,
GetLastError());
407 ERR(
"HeapAlloc failed\n");
426 wLang = lpLangCode->
lang;
427 wCode = lpLangCode->
code;
431 swprintf(wszBuf,
L"\\StringFileInfo\\%04x%04x\\FileDescription", wLang, wCode);
436 ERR(
"Cannot get app name\n");
488 HKEY hSubkey, hSubkey2;
489 WCHAR wszProgId[256];
523 Info.lpszSubKey =
L"OpenWithList";
532 int nItem, nCount, nResult;
539 TRACE(
"OpenMRUList failed\n");
546 for(nItem = 0; nItem < nCount; nItem++)
555 TRACE(
"Recommended app %ls: %p\n", wszAppFilename, pApp);
572 DWORD i = 0, cchAppFilename;
580 cchAppFilename =
_countof(wszAppFilename);
587 TRACE(
"Recommended app %ls: %p\n", wszAppFilename, pApp);
617 TRACE(
"Add app %ls: %p\n", wszPath, pApp);
637 StringCbPrintfW(wszBuf,
sizeof(wszBuf),
L"SystemFileAssociations\\%s", pwszExt);
667 StringCbPrintfW(wszBuf2,
sizeof(wszBuf2),
L"SystemFileAssociations\\%s", wszBuf);
686 L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\FileExts\\%s",
695 DWORD cbBuf =
sizeof(wszBuf);
722 L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\FileExts\\%s",
725 ERR(
"insufficient buffer\n");
760 if (!pwszExt[0] || !pwszExt[1])
766 ERR(
"Can't open ext key\n");
780 ERR(
"RegSetValueExW failed\n");
787 ERR(
"RegGetValueExW failed: 0x%08x\n", lResult);
797 ERR(
"RegCreateKeyExW failed\n");
805 ERR(
"RegOpenKeyExW %ls failed\n", wszBuf);
813 ERR(
"RegCreateKeyExW failed\n");
843 ERR(
"SHCopyKeyW failed\n");
877 m_pInfo(pInfo), m_pAppList(pAppList), m_hImgList(
NULL), m_bNoOpen(
FALSE)
931 if (dReturnValue ==
IDNO)
933 else if (dReturnValue == -1)
935 ERR(
"IsNoOpen failed to load dialog box\n");
946 if (!pwszName)
return;
949 TRACE(
"AddApp Cmd %ls Name %ls\n", pApp->
wszCmd, pwszName);
957 tvins.hParent = tvins.hInsertAfter =
m_hOther;
960 tvins.item.pszText =
const_cast<LPWSTR>(pwszName);
961 tvins.item.lParam = (
LPARAM)pApp;
1029 TRACE(
"COpenWithDialog::Init hwnd %p\n",
hwnd);
1068 if (cRecommended > 0)
1073 tvins.hParent = tvins.hInsertAfter =
TVI_ROOT;
1075 tvins.item.pszText = (
LPWSTR)wszBuf;
1096 if (bNoAppSelected && (pAppList[
i].bRecommended || !cRecommended))
1099 bNoAppSelected =
FALSE;
1139 pThis->
Init(hwndDlg);
1192 TRACE(
"Destroying COpenWithMenu(%p)\n",
this);
1206 mii.
cbSize =
sizeof(mii);
1252 mii.
cbSize =
sizeof(mii);
1260 ERR(
"Failed to load string\n");
1278 if (!pwszName)
return;
1281 mii.
cbSize =
sizeof(mii);
1313 TRACE(
"hMenu %p indexMenu %u idFirst %u idLast %u uFlags %u\n", hMenu, indexMenu, idCmdFirst, idCmdLast,
uFlags);
1321 ERR(
"Failed to load string\n");
1330 if (DefaultPos != -1)
1355 mii.
cbSize =
sizeof(mii);
1369 if (DefaultPos == -1)
1412 mii.
cbSize =
sizeof(mii);
1432 TRACE(
"%p %lu %u %p %p %u\n",
this,
1433 idCmd, uType, pwReserved, pszName,
cchMax );
1447 TRACE(
"This %p uMsg %x\n",
this, uMsg);
1460 TRACE(
"This %p\n",
this);
1465 CDataObjectHIDA pida(pdtobj);
1468 ERR(
"pdtobj->GetData failed with 0x%x\n", pida.hr());
1479 TRACE(
"pidl is not a file\n");
1492 ERR(
"SHGetPathFromIDListW failed\n");
1501 TRACE(
"file is a executable or shortcut\n");
1513 TRACE(
"SHOpenWithDialog hwndParent %p poainfo %p\n",
hwndParent, poainfo);
#define shell32_hInstance
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
void shell(int argc, const char *argv[])
static WCHAR wszFilter[MAX_STRING_LEN *4+6 *3+5]
#define RegCloseKey(hKey)
EXTERN_C void WINAPI SHChangeNotify(LONG wEventId, UINT uFlags, LPCVOID dwItem1, LPCVOID dwItem2)
COpenWithList * m_pAppList
VOID AddApp(COpenWithList::SApp *pApp, BOOL bSelected)
static INT_PTR CALLBACK NoOpenDlgProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
COpenWithList::SApp * GetCurrentApp()
COpenWithDialog(const OPENASINFO *pInfo, COpenWithList *pAppList)
static INT_PTR CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
const OPENASINFO * m_pInfo
struct COpenWithList::_LANGANDCODEPAGE * LPLANGANDCODEPAGE
static BOOL SaveApp(SApp *pApp)
SApp * Find(LPCWSTR pwszFilename)
BOOL LoadRecommended(LPCWSTR pwszFilePath)
static LPCWSTR GetName(SApp *pApp)
BOOL LoadAppList(HKEY hKey)
static BOOL Execute(SApp *pApp, LPCWSTR pwszFilePath)
static BOOL GetPathFromCmd(LPWSTR pwszAppPath, LPCWSTR pwszCmd)
static BOOL LoadInfo(SApp *pApp)
VOID LoadRecommendedFromHKCR(LPCWSTR pwszExt)
UINT GetRecommendedCount()
static HICON GetIcon(SApp *pApp)
SApp * Add(LPCWSTR pwszPath)
BOOL SetDefaultHandler(SApp *pApp, LPCWSTR pwszFilename)
struct COpenWithList::_LANGANDCODEPAGE LANGANDCODEPAGE
VOID LoadRecommendedFromHKCU(LPCWSTR pwszExt)
static BOOL AddAppToMRUList(SApp *pApp, LPCWSTR pwszFilename)
SApp * AddInternal(LPCWSTR pwszFilename)
VOID SetRecommended(SApp *pApp)
static BOOL IsHidden(SApp *pApp)
static HANDLE OpenMRUList(HKEY hKey)
VOID LoadFromProgIdKey(HKEY hKey, LPCWSTR pwszExt)
BOOL LoadMRUList(HKEY hKey)
BOOL LoadProgIdList(HKEY hKey, LPCWSTR pwszExt)
INT WINAPI AddMRUStringW(HANDLE hList, LPCWSTR lpszString)
INT WINAPI EnumMRUListW(HANDLE hList, INT nItemPos, LPVOID lpBuffer, DWORD nBufferSize)
HANDLE WINAPI CreateMRUListW(const MRUINFOW *infoW)
void WINAPI FreeMRUList(HANDLE hMRUList)
VOID WINAPI InitCommonControls(void)
#define OFN_FILEMUSTEXIST
#define OFN_PATHMUSTEXIST
struct tagOFNW OPENFILENAMEW
static LSTATUS(WINAPI *pRegDeleteTreeW)(HKEY
LONG WINAPI RegCreateKeyExW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey, _In_ DWORD Reserved, _In_opt_ LPWSTR lpClass, _In_ DWORD dwOptions, _In_ REGSAM samDesired, _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, _Out_ PHKEY phkResult, _Out_opt_ LPDWORD lpdwDisposition)
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
LSTATUS WINAPI RegGetValueW(HKEY hKey, LPCWSTR pszSubKey, LPCWSTR pszValue, DWORD dwFlags, LPDWORD pdwType, PVOID pvData, LPDWORD pcbData)
LONG WINAPI RegEnumKeyExW(_In_ HKEY hKey, _In_ DWORD dwIndex, _Out_ LPWSTR lpName, _Inout_ LPDWORD lpcbName, _Reserved_ LPDWORD lpReserved, _Out_opt_ LPWSTR lpClass, _Inout_opt_ LPDWORD lpcbClass, _Out_opt_ PFILETIME lpftLastWriteTime)
LONG WINAPI RegOpenKeyW(HKEY hKey, LPCWSTR lpSubKey, PHKEY phkResult)
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
BOOL WINAPI ImageList_Destroy(HIMAGELIST himl)
HIMAGELIST WINAPI ImageList_Create(INT cx, INT cy, UINT flags, INT cInitial, INT cGrow)
BOOL WINAPI GetOpenFileNameW(OPENFILENAMEW *ofn)
#define HeapFree(x, y, z)
DWORD WINAPI SearchPathW(IN LPCWSTR lpPath OPTIONAL, IN LPCWSTR lpFileName, IN LPCWSTR lpExtension OPTIONAL, IN DWORD nBufferLength, OUT LPWSTR lpBuffer, OUT LPWSTR *lpFilePart OPTIONAL)
HRESULT SHELL_GetCommandStringImpl(SIZE_T CmdId, UINT uFlags, LPSTR Buf, UINT cchBuf, const CMVERBMAP *pMap)
HRESULT SHELL_MapContextMenuVerbToCmdId(LPCMINVOKECOMMANDINFO pICI, const CMVERBMAP *pMap)
static DWORD RegSetString(HKEY hKey, LPCWSTR Name, LPCWSTR Str, DWORD Type OPTIONAL_(REG_SZ))
LPWSTR WINAPI PathFindFileNameW(LPCWSTR lpszPath)
LPWSTR WINAPI PathFindExtensionW(LPCWSTR lpszPath)
DWORD WINAPI SHCopyKeyW(HKEY hKeySrc, LPCWSTR lpszSrcSubKey, HKEY hKeyDst, DWORD dwReserved)
BOOL WINAPI GetFileVersionInfoW(LPCWSTR filename, DWORD handle, DWORD datasize, LPVOID data)
BOOL WINAPI VerQueryValueW(LPCVOID pBlock, LPCWSTR lpSubBlock, LPVOID *lplpBuffer, PUINT puLen)
DWORD WINAPI GetFileVersionInfoSizeW(LPCWSTR filename, LPDWORD handle)
static const WCHAR Message[]
#define MAKE_HRESULT(sev, fac, code)
GLuint GLuint GLsizei count
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
UINT WINAPI ExtractIconExW(LPCWSTR lpszFile, INT nIconIndex, HICON *phiconLarge, HICON *phiconSmall, UINT nIcons)
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define ERROR_FILE_NOT_FOUND
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
static DWORD DWORD void LPSTR DWORD cch
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
unsigned __int3264 UINT_PTR
#define MAKEINTRESOURCE(i)
LPITEMIDLIST WINAPI ILCombine(LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2)
BOOL WINAPI SHGetPathFromIDListW(LPCITEMIDLIST pidl, LPWSTR pszPath)
BOOL _ILIsValue(LPCITEMIDLIST pidl)
#define TreeView_SelectItem(hwnd, hitem)
#define TreeView_GetSelection(hwnd)
#define TreeView_GetItem(hwnd, pitem)
#define ImageList_AddIcon(himl, hicon)
#define TreeView_SetImageList(hwnd, himl, iImage)
#define TreeView_InsertItem(hwnd, lpis)
#define TVIF_SELECTEDIMAGE
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
BOOL HCR_GetDefaultVerbW(HKEY hkeyClass, LPCWSTR szVerb, LPWSTR szDest, DWORD len)
DWORD_PTR WINAPI SHGetFileInfoW(LPCWSTR path, DWORD dwFileAttributes, SHFILEINFOW *psfi, UINT sizeofpsfi, UINT flags)
#define SEE_MASK_CLASSKEY
struct _SHELLEXECUTEINFOW SHELLEXECUTEINFOW
#define SHGFI_SHELLICONSIZE
static PCUIDLIST_RELATIVE HIDA_GetPIDLItem(CIDA const *pida, SIZE_T i)
static PCUIDLIST_ABSOLUTE HIDA_GetPIDLFolder(CIDA const *pida)
BOOL WINAPI DECLSPEC_HOTPATCH ShellExecuteExW(LPSHELLEXECUTEINFOW sei)
@ OAIF_ALLOW_REGISTRATION
@ OAIF_FORCE_REGISTRATION
#define SHCNE_ASSOCCHANGED
#define SHCNF_FLUSHNOWAIT
#define IDS_OPEN_WITH_FILTER
#define IDS_OPEN_WITH_CHOOSE
#define IDS_OPEN_WITH_RECOMMENDED
#define IDI_SHELL_PROGRAMS_FOLDER
#define IDS_OPEN_WITH_OTHER
const ITEMIDLIST UNALIGNED * LPCITEMIDLIST
STRSAFEAPI StringCbCopyW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszSrc)
STRSAFEAPI StringCchCopyW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
STRSAFEAPI StringCbPrintfW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszFormat,...)
STRSAFEAPI StringCchCopyNW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc, size_t cchToCopy)
WCHAR wszFilename[MAX_PATH]
OPEN_AS_INFO_FLAGS oaifInFlags
_Must_inspect_result_ _In_ WDFCHILDLIST _In_ PWDF_CHILD_LIST_ITERATOR _Out_ WDFDEVICE _Inout_opt_ PWDF_CHILD_RETRIEVE_INFO Info
_In_ WDFCOLLECTION _In_ ULONG Index
UINT WINAPI GetDlgItemTextW(HWND hDlg, int nIDDlgItem, LPWSTR lpString, int nMaxCount)
#define success(from, fromstr, to, tostr)
DWORD WINAPI GetLastError(void)
#define ExpandEnvironmentStrings
_In_ PSID _Out_writes_to_opt_ cchName LPSTR _Inout_ LPDWORD cchName
#define ERROR_BUFFER_OVERFLOW
#define HRESULT_FROM_WIN32(x)
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
HBITMAP WINAPI CreateCompatibleBitmap(_In_ HDC hdc, _In_ INT cx, _In_ INT cy)
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
BOOL WINAPI DeleteDC(_In_ HDC)
#define HKEY_CURRENT_USER
#define HKEY_CLASSES_ROOT
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
HMENU WINAPI CreatePopupMenu(void)
UINT WINAPI GetMenuDefaultItem(_In_ HMENU hMenu, _In_ UINT fByPos, _In_ UINT gmdiFlags)
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
int WINAPI GetMenuItemCount(_In_opt_ HMENU)
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
#define IS_INTRESOURCE(i)
BOOL WINAPI SetDlgItemTextW(_In_ HWND, _In_ int, _In_ LPCWSTR)
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
UINT WINAPI IsDlgButtonChecked(_In_ HWND, _In_ int)
BOOL WINAPI DrawIconEx(_In_ HDC, _In_ int, _In_ int, _In_ HICON, _In_ int, _In_ int, _In_ UINT, _In_opt_ HBRUSH, _In_ UINT)
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
HDC WINAPI GetDC(_In_opt_ HWND)
BOOL WINAPI GetMenuItemInfoW(_In_ HMENU, _In_ UINT, _In_ BOOL, _Inout_ LPMENUITEMINFOW)
int WINAPI GetSystemMetrics(_In_ int)
BOOL WINAPI InsertMenuItemW(_In_ HMENU, _In_ UINT, _In_ BOOL, _In_ LPCMENUITEMINFOW)
BOOL WINAPI SetRect(_Out_ LPRECT, _In_ int, _In_ int, _In_ int, _In_ int)
INT_PTR WINAPI DialogBoxParamW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _In_opt_ HWND, _In_opt_ DLGPROC, _In_ LPARAM)
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
BOOL WINAPI DestroyIcon(_In_ HICON)
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO