ReactOS  0.4.15-dev-2153-g62b4c61
COpenWithList Class Reference
Collaboration diagram for COpenWithList:

Classes

struct  _LANGANDCODEPAGE
 
struct  SApp
 

Public Member Functions

 COpenWithList ()
 
 ~COpenWithList ()
 
BOOL Load ()
 
SAppAdd (LPCWSTR pwszPath)
 
SAppFind (LPCWSTR pwszFilename)
 
BOOL IsNoOpen (VOID)
 
BOOL LoadRecommended (LPCWSTR pwszFilePath)
 
BOOL SetDefaultHandler (SApp *pApp, LPCWSTR pwszFilename)
 
SAppGetList ()
 
UINT GetCount ()
 
UINT GetRecommendedCount ()
 

Static Public Member Functions

static BOOL SaveApp (SApp *pApp)
 
static LPCWSTR GetName (SApp *pApp)
 
static HICON GetIcon (SApp *pApp)
 
static BOOL Execute (SApp *pApp, LPCWSTR pwszFilePath)
 
static BOOL IsHidden (SApp *pApp)
 

Private Types

typedef struct COpenWithList::_LANGANDCODEPAGE LANGANDCODEPAGE
 
typedef struct COpenWithList::_LANGANDCODEPAGELPLANGANDCODEPAGE
 

Private Member Functions

SAppAddInternal (LPCWSTR pwszFilename)
 
BOOL LoadProgIdList (HKEY hKey, LPCWSTR pwszExt)
 
BOOL LoadMRUList (HKEY hKey)
 
BOOL LoadAppList (HKEY hKey)
 
VOID LoadFromProgIdKey (HKEY hKey, LPCWSTR pwszExt)
 
VOID LoadRecommendedFromHKCR (LPCWSTR pwszExt)
 
VOID LoadRecommendedFromHKCU (LPCWSTR pwszExt)
 
VOID SetRecommended (SApp *pApp)
 

Static Private Member Functions

static BOOL LoadInfo (SApp *pApp)
 
static VOID GetPathFromCmd (LPWSTR pwszAppPath, LPCWSTR pwszCmd)
 
static HANDLE OpenMRUList (HKEY hKey)
 
static BOOL AddAppToMRUList (SApp *pApp, LPCWSTR pwszFilename)
 

Private Attributes

SAppm_pApp
 
UINT m_cApp
 
UINT m_cRecommended
 
BOOL m_bNoOpen
 

Detailed Description

Definition at line 34 of file COpenWithMenu.cpp.

Member Typedef Documentation

◆ LANGANDCODEPAGE

◆ LPLANGANDCODEPAGE

Constructor & Destructor Documentation

◆ COpenWithList()

COpenWithList::COpenWithList ( )

Definition at line 99 of file COpenWithMenu.cpp.

99  :
#define FALSE
Definition: types.h:117
#define NULL
Definition: types.h:112

◆ ~COpenWithList()

COpenWithList::~COpenWithList ( )

Definition at line 102 of file COpenWithMenu.cpp.

103 {
104  for (UINT i = 0; i < m_cApp; ++i)
105  if (m_pApp[i].hIcon)
107 
109 }
BOOL WINAPI DestroyIcon(_In_ HICON)
Definition: cursoricon.c:2022
#define GetProcessHeap()
Definition: compat.h:595
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
Definition: glfuncs.h:248
HICON hIcon
Definition: msconfig.c:44
unsigned int UINT
Definition: ndis.h:50
#define HeapFree(x, y, z)
Definition: compat.h:594

Member Function Documentation

◆ Add()

COpenWithList::SApp * COpenWithList::Add ( LPCWSTR  pwszPath)

Definition at line 152 of file COpenWithMenu.cpp.

153 {
154  SApp *pApp = AddInternal(PathFindFileNameW(pwszPath));
155 
156  if (pApp)
157  {
158  StringCbPrintfW(pApp->wszCmd, sizeof(pApp->wszCmd), L"\"%s\" \"%%1\"", pwszPath);
159  SaveApp(pApp);
160  }
161 
162  return pApp;
163 }
SApp * AddInternal(LPCWSTR pwszFilename)
STRSAFEAPI StringCbPrintfW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:557
LPWSTR WINAPI PathFindFileNameW(LPCWSTR lpszPath)
Definition: path.c:389
static BOOL SaveApp(SApp *pApp)
static const WCHAR L[]
Definition: oid.c:1250

Referenced by COpenWithDialog::Browse().

◆ AddAppToMRUList()

BOOL COpenWithList::AddAppToMRUList ( SApp pApp,
LPCWSTR  pwszFilename 
)
staticprivate

Definition at line 622 of file COpenWithMenu.cpp.

623 {
624  WCHAR wszBuf[100];
625  LPCWSTR pwszExt;
626  HKEY hKey;
627  HANDLE hList;
628 
629  /* Get file extension */
630  pwszExt = PathFindExtensionW(pwszFilename);
631  if (!pwszExt[0])
632  return FALSE;
633 
634  /* Build registry key */
635  if (FAILED(StringCbPrintfW(wszBuf, sizeof(wszBuf),
636  L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\FileExts\\%s",
637  pwszExt)))
638  {
639  ERR("insufficient buffer\n");
640  return FALSE;
641  }
642 
643  /* Open base key for this file extension */
645  return FALSE;
646 
647  /* Open MRU list */
649  if (hList)
650  {
651  /* Insert the entry */
652  AddMRUStringW(hList, pApp->wszFilename);
653 
654  /* Set MRU presence */
655  pApp->bMRUList = TRUE;
656 
657  /* Close MRU list */
659  }
660 
661  RegCloseKey(hKey);
662  return TRUE;
663 }
#define ERROR_SUCCESS
Definition: deptool.c:10
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
#define KEY_READ
Definition: nt_native.h:1023
#define TRUE
Definition: types.h:120
#define HKEY_CURRENT_USER
Definition: winreg.h:11
INT WINAPI AddMRUStringW(HANDLE hList, LPCWSTR lpszString)
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)
Definition: reg.c:1091
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
#define FALSE
Definition: types.h:117
STRSAFEAPI StringCbPrintfW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:557
LPWSTR WINAPI PathFindExtensionW(LPCWSTR lpszPath)
Definition: path.c:442
#define KEY_WRITE
Definition: nt_native.h:1031
__wchar_t WCHAR
Definition: xmlstorage.h:180
static const WCHAR L[]
Definition: oid.c:1250
#define ERR(fmt,...)
Definition: debug.h:110
HWND hList
Definition: livecd.c:10
void WINAPI FreeMRUList(HANDLE hMRUList)
FxAutoRegKey hKey
#define NULL
Definition: types.h:112
static HANDLE OpenMRUList(HKEY hKey)

Referenced by Execute().

◆ AddInternal()

COpenWithList::SApp * COpenWithList::AddInternal ( LPCWSTR  pwszFilename)
private

Definition at line 272 of file COpenWithMenu.cpp.

273 {
274  /* Check for duplicate */
275  SApp *pApp = Find(pwszFilename);
276  if (pApp)
277  return pApp;
278 
279  /* Create new item */
280  if (!m_pApp)
281  m_pApp = static_cast<SApp *>(HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(m_pApp[0])));
282  else
283  m_pApp = static_cast<SApp *>(HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, m_pApp, (m_cApp + 1)*sizeof(m_pApp[0])));
284  if (!m_pApp)
285  {
286  ERR("Allocation failed\n");
287  return NULL;
288  }
289 
290  pApp = &m_pApp[m_cApp++];
291  wcscpy(pApp->wszFilename, pwszFilename);
292  return pApp;
293 }
#define GetProcessHeap()
Definition: compat.h:595
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
#define ERR(fmt,...)
Definition: debug.h:110
#define HeapReAlloc
Definition: compat.h:593
#define NULL
Definition: types.h:112
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
SApp * Find(LPCWSTR pwszFilename)

Referenced by Add(), Load(), and LoadFromProgIdKey().

◆ Execute()

BOOL COpenWithList::Execute ( COpenWithList::SApp pApp,
LPCWSTR  pwszFilePath 
)
static

Definition at line 222 of file COpenWithMenu.cpp.

223 {
224  WCHAR wszBuf[256];
225  HKEY hKey;
226 
227  /* Add app to registry if it wasnt there before */
228  SaveApp(pApp);
229  if (!pApp->bMRUList)
230  AddAppToMRUList(pApp, pwszFilePath);
231 
232  /* Get a handle to the reg key */
233  StringCbPrintfW(wszBuf, sizeof(wszBuf), L"Applications\\%s", pApp->wszFilename);
235  {
236  ERR("RegOpenKeyEx failed\n");
237  return FALSE;
238  }
239 
240  /* Let ShellExecuteExW do the work */
242  sei.nShow = SW_SHOWNORMAL;
243  sei.hkeyClass = hKey;
244  sei.lpFile = pwszFilePath;
245 
246  ShellExecuteExW(&sei);
247 
248  return TRUE;
249 }
#define SEE_MASK_CLASSKEY
Definition: shellapi.h:26
#define ERROR_SUCCESS
Definition: deptool.c:10
#define TRUE
Definition: types.h:120
static BOOL AddAppToMRUList(SApp *pApp, LPCWSTR pwszFilename)
#define FALSE
Definition: types.h:117
STRSAFEAPI StringCbPrintfW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:557
BOOL WINAPI DECLSPEC_HOTPATCH ShellExecuteExW(LPSHELLEXECUTEINFOW sei)
Definition: shlexec.cpp:2263
static BOOL SaveApp(SApp *pApp)
#define KEY_WRITE
Definition: nt_native.h:1031
WCHAR wszFilename[MAX_PATH]
__wchar_t WCHAR
Definition: xmlstorage.h:180
static const WCHAR L[]
Definition: oid.c:1250
#define ERR(fmt,...)
Definition: debug.h:110
#define SW_SHOWNORMAL
Definition: winuser.h:764
FxAutoRegKey hKey
#define NULL
Definition: types.h:112
struct _SHELLEXECUTEINFOW SHELLEXECUTEINFOW
#define HKEY_CLASSES_ROOT
Definition: winreg.h:10
#define RegCreateKeyEx
Definition: winreg.h:501

Referenced by COpenWithDialog::Accept(), and COpenWithMenu::InvokeCommand().

◆ Find()

COpenWithList::SApp * COpenWithList::Find ( LPCWSTR  pwszFilename)

Definition at line 184 of file COpenWithMenu.cpp.

185 {
186  for (UINT i = 0; i < m_cApp; ++i)
187  if (wcsicmp(m_pApp[i].wszFilename, pwszFilename) == 0)
188  return &m_pApp[i];
189  return NULL;
190 }
#define wcsicmp
Definition: compat.h:15
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
Definition: glfuncs.h:248
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112

Referenced by AddInternal(), LoadAppList(), LoadMRUList(), and LoadRecommendedFromHKCU().

◆ GetCount()

UINT COpenWithList::GetCount ( )
inline

Definition at line 65 of file COpenWithMenu.cpp.

65 { return m_cApp; }

Referenced by COpenWithDialog::Init(), and COpenWithMenu::QueryContextMenu().

◆ GetIcon()

HICON COpenWithList::GetIcon ( SApp pApp)
static

Definition at line 207 of file COpenWithMenu.cpp.

208 {
209  if (!pApp->hIcon)
210  {
211  WCHAR wszPath[MAX_PATH];
212 
213  GetPathFromCmd(wszPath, pApp->wszCmd);
214  ExtractIconExW(wszPath, 0, NULL, &pApp->hIcon, 1);
215  }
216 
217  TRACE("%ls icon: %p\n", pApp->wszFilename, pApp->hIcon);
218 
219  return pApp->hIcon;
220 }
static VOID GetPathFromCmd(LPWSTR pwszAppPath, LPCWSTR pwszCmd)
UINT WINAPI ExtractIconExW(LPCWSTR lpszFile, INT nIconIndex, HICON *phiconLarge, HICON *phiconSmall, UINT nIcons)
Definition: iconcache.cpp:872
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:34
#define NULL
Definition: types.h:112

Referenced by COpenWithMenu::AddApp(), and COpenWithDialog::AddApp().

◆ GetList()

SApp* COpenWithList::GetList ( )
inline

Definition at line 64 of file COpenWithMenu.cpp.

64 { return m_pApp; }

Referenced by COpenWithDialog::Init(), and COpenWithMenu::QueryContextMenu().

◆ GetName()

LPCWSTR COpenWithList::GetName ( SApp pApp)
static

Definition at line 192 of file COpenWithMenu.cpp.

193 {
194  if (!pApp->wszName[0])
195  {
196  if (!LoadInfo(pApp))
197  {
198  WARN("Failed to load %ls info\n", pApp->wszFilename);
199  StringCbCopyW(pApp->wszName, sizeof(pApp->wszName), pApp->wszFilename);
200  }
201  }
202 
203  TRACE("%ls name: %ls\n", pApp->wszFilename, pApp->wszName);
204  return pApp->wszName;
205 }
#define WARN(fmt,...)
Definition: debug.h:112
#define TRACE(s)
Definition: solgame.cpp:4
static BOOL LoadInfo(SApp *pApp)
STRSAFEAPI StringCbCopyW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:166

Referenced by COpenWithMenu::AddApp(), and COpenWithDialog::AddApp().

◆ GetPathFromCmd()

VOID COpenWithList::GetPathFromCmd ( LPWSTR  pwszAppPath,
LPCWSTR  pwszCmd 
)
staticprivate

Definition at line 359 of file COpenWithMenu.cpp.

360 {
361  WCHAR wszBuf[MAX_PATH], *pwszDest = wszBuf;
362 
363  /* Remove arguments */
364  if (pwszCmd[0] == '"')
365  {
366  for(LPCWSTR pwszSrc = pwszCmd + 1; *pwszSrc && *pwszSrc != '"'; ++pwszSrc)
367  *(pwszDest++) = *pwszSrc;
368  }
369  else
370  {
371  for(LPCWSTR pwszSrc = pwszCmd; *pwszSrc && *pwszSrc != ' '; ++pwszSrc)
372  *(pwszDest++) = *pwszSrc;
373  }
374 
375  *pwszDest = 0;
376 
377  /* Expand evn vers and optionally search for path */
378  ExpandEnvironmentStrings(wszBuf, pwszAppPath, MAX_PATH);
379  if (!PathFileExists(pwszAppPath))
380  SearchPath(NULL, pwszAppPath, NULL, MAX_PATH, pwszAppPath, NULL);
381 }
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
#define ExpandEnvironmentStrings
Definition: winbase.h:3630
#define SearchPath
Definition: winbase.h:3756
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:34
#define PathFileExists
Definition: shlwapi.h:899
#define NULL
Definition: types.h:112

Referenced by GetIcon(), LoadFromProgIdKey(), and LoadInfo().

◆ GetRecommendedCount()

UINT COpenWithList::GetRecommendedCount ( )
inline

Definition at line 66 of file COpenWithMenu.cpp.

66 { return m_cRecommended; }

Referenced by COpenWithDialog::Init(), and COpenWithMenu::QueryContextMenu().

◆ IsHidden()

BOOL COpenWithList::IsHidden ( SApp pApp)
static

Definition at line 251 of file COpenWithMenu.cpp.

252 {
253  WCHAR wszBuf[100];
254  DWORD dwSize = 0;
255 
256  if (pApp->bHidden)
257  return pApp->bHidden;
258 
259  if (FAILED(StringCbPrintfW(wszBuf, sizeof(wszBuf), L"Applications\\%s", pApp->wszFilename)))
260  {
261  ERR("insufficient buffer\n");
262  return FALSE;
263  }
264 
265  if (RegGetValueW(HKEY_CLASSES_ROOT, wszBuf, L"NoOpenWith", RRF_RT_REG_SZ, NULL, NULL, &dwSize) != ERROR_SUCCESS)
266  return FALSE;
267 
268  pApp->bHidden = TRUE;
269  return TRUE;
270 }
LSTATUS WINAPI RegGetValueW(HKEY hKey, LPCWSTR pszSubKey, LPCWSTR pszValue, DWORD dwFlags, LPDWORD pdwType, PVOID pvData, LPDWORD pcbData)
Definition: reg.c:1965
#define ERROR_SUCCESS
Definition: deptool.c:10
#define TRUE
Definition: types.h:120
#define RRF_RT_REG_SZ
Definition: driver.c:575
#define FALSE
Definition: types.h:117
STRSAFEAPI StringCbPrintfW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:557
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
static const WCHAR L[]
Definition: oid.c:1250
#define ERR(fmt,...)
Definition: debug.h:110
#define NULL
Definition: types.h:112
#define HKEY_CLASSES_ROOT
Definition: winreg.h:10
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54

Referenced by COpenWithDialog::Init().

◆ IsNoOpen()

BOOL COpenWithList::IsNoOpen ( VOID  )
inline

Definition at line 60 of file COpenWithMenu.cpp.

60 { return m_bNoOpen; }

Referenced by COpenWithDialog::Init().

◆ Load()

BOOL COpenWithList::Load ( )

Definition at line 111 of file COpenWithMenu.cpp.

112 {
113  HKEY hKey;
114  WCHAR wszName[256], wszBuf[100];
115  DWORD i = 0, cchName, dwSize;
116  SApp *pApp;
117 
118  if (RegOpenKeyEx(HKEY_CLASSES_ROOT, L"Applications", 0, KEY_READ, &hKey) != ERROR_SUCCESS)
119  {
120  ERR("RegOpenKeyEx HKCR\\Applications failed!\n");
121  return FALSE;
122  }
123 
124  while (TRUE)
125  {
126  cchName = _countof(wszName);
127  if (RegEnumKeyEx(hKey, i++, wszName, &cchName, NULL, NULL, NULL, NULL) != ERROR_SUCCESS)
128  break;
129 
130  pApp = AddInternal(wszName);
131 
132  if (pApp)
133  {
134  StringCbPrintfW(wszBuf, sizeof(wszBuf), L"%s\\shell\\open\\command", wszName);
135  dwSize = sizeof(pApp->wszCmd);
136  if (RegGetValueW(hKey, wszBuf, L"", RRF_RT_REG_SZ, NULL, pApp->wszCmd, &dwSize) != ERROR_SUCCESS)
137  {
138  ERR("Failed to add app %ls\n", wszName);
139  pApp->bHidden = TRUE;
140  }
141  else
142  TRACE("App added %ls\n", pApp->wszCmd);
143  }
144  else
145  ERR("AddInternal failed\n");
146  }
147 
148  RegCloseKey(hKey);
149  return TRUE;
150 }
LSTATUS WINAPI RegGetValueW(HKEY hKey, LPCWSTR pszSubKey, LPCWSTR pszValue, DWORD dwFlags, LPDWORD pdwType, PVOID pvData, LPDWORD pcbData)
Definition: reg.c:1965
SApp * AddInternal(LPCWSTR pwszFilename)
#define ERROR_SUCCESS
Definition: deptool.c:10
#define KEY_READ
Definition: nt_native.h:1023
#define TRUE
Definition: types.h:120
#define RRF_RT_REG_SZ
Definition: driver.c:575
_In_ PSID _Out_writes_to_opt_ cchName LPSTR _Inout_ LPDWORD cchName
Definition: winbase.h:2745
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
#define FALSE
Definition: types.h:117
STRSAFEAPI StringCbPrintfW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:557
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define _countof(array)
Definition: sndvol32.h:68
unsigned long DWORD
Definition: ntddk_ex.h:95
static const WCHAR L[]
Definition: oid.c:1250
#define RegEnumKeyEx
Definition: winreg.h:510
#define ERR(fmt,...)
Definition: debug.h:110
#define RegOpenKeyEx
Definition: winreg.h:520
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
Definition: glfuncs.h:248
FxAutoRegKey hKey
#define NULL
Definition: types.h:112
#define HKEY_CLASSES_ROOT
Definition: winreg.h:10
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54

Referenced by COpenWithDialog::Init(), and COpenWithMenu::QueryContextMenu().

◆ LoadAppList()

BOOL COpenWithList::LoadAppList ( HKEY  hKey)
private

Definition at line 482 of file COpenWithMenu.cpp.

483 {
484  WCHAR wszAppFilename[MAX_PATH];
485  HKEY hSubkey;
486  DWORD i = 0, cchAppFilename;
487 
488  if (RegOpenKeyExW(hKey, L"OpenWithList", 0, KEY_READ, &hSubkey) != ERROR_SUCCESS)
489  return FALSE;
490 
491  while (TRUE)
492  {
493  /* Enum registry keys - each of them is app name */
494  cchAppFilename = _countof(wszAppFilename);
495  if (RegEnumKeyExW(hSubkey, i++, wszAppFilename, &cchAppFilename, NULL, NULL, NULL, NULL) != ERROR_SUCCESS)
496  break;
497 
498  /* Set application as recommended */
499  SApp *pApp = Find(wszAppFilename);
500 
501  TRACE("Recommended app %ls: %p\n", wszAppFilename, pApp);
502  if (pApp)
503  SetRecommended(pApp);
504  }
505 
506  RegCloseKey(hSubkey);
507  return TRUE;
508 }
#define ERROR_SUCCESS
Definition: deptool.c:10
#define KEY_READ
Definition: nt_native.h:1023
#define TRUE
Definition: types.h:120
VOID SetRecommended(SApp *pApp)
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
#define FALSE
Definition: types.h:117
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define _countof(array)
Definition: sndvol32.h:68
#define MAX_PATH
Definition: compat.h:34
unsigned long DWORD
Definition: ntddk_ex.h:95
static const WCHAR L[]
Definition: oid.c:1250
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
Definition: glfuncs.h:248
FxAutoRegKey hKey
#define NULL
Definition: types.h:112
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366
SApp * Find(LPCWSTR pwszFilename)
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)
Definition: reg.c:2527

Referenced by LoadRecommendedFromHKCR().

◆ LoadFromProgIdKey()

VOID COpenWithList::LoadFromProgIdKey ( HKEY  hKey,
LPCWSTR  pwszExt 
)
private

Definition at line 510 of file COpenWithMenu.cpp.

511 {
512  WCHAR wszCmd[MAX_PATH], wszPath[MAX_PATH];
513  DWORD dwSize = 0;
514 
515  /* Check if NoOpen value exists */
517  {
518  /* Display warning dialog */
519  m_bNoOpen = TRUE;
520  }
521 
522  /* Check if there is a directly available execute key */
523  dwSize = sizeof(wszCmd);
524  if (RegGetValueW(hKey, L"shell\\open\\command", NULL, RRF_RT_REG_SZ, NULL, (PVOID)wszCmd, &dwSize) == ERROR_SUCCESS)
525  {
526  /* Erase extra arguments */
527  GetPathFromCmd(wszPath, wszCmd);
528 
529  /* Add application */
530  SApp *pApp = AddInternal(PathFindFileNameW(wszPath));
531  TRACE("Add app %ls: %p\n", wszPath, pApp);
532 
533  if (pApp)
534  {
535  StringCbCopyW(pApp->wszCmd, sizeof(pApp->wszCmd), wszCmd);
536  SetRecommended(pApp);
537  }
538  }
539 }
LSTATUS WINAPI RegGetValueW(HKEY hKey, LPCWSTR pszSubKey, LPCWSTR pszValue, DWORD dwFlags, LPDWORD pdwType, PVOID pvData, LPDWORD pcbData)
Definition: reg.c:1965
SApp * AddInternal(LPCWSTR pwszFilename)
#define ERROR_SUCCESS
Definition: deptool.c:10
#define TRUE
Definition: types.h:120
#define RRF_RT_REG_SZ
Definition: driver.c:575
VOID SetRecommended(SApp *pApp)
static VOID GetPathFromCmd(LPWSTR pwszAppPath, LPCWSTR pwszCmd)
LPWSTR WINAPI PathFindFileNameW(LPCWSTR lpszPath)
Definition: path.c:389
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:34
unsigned long DWORD
Definition: ntddk_ex.h:95
static const WCHAR L[]
Definition: oid.c:1250
FxAutoRegKey hKey
#define NULL
Definition: types.h:112
STRSAFEAPI StringCbCopyW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:166
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54

Referenced by LoadProgIdList(), and LoadRecommendedFromHKCR().

◆ LoadInfo()

BOOL COpenWithList::LoadInfo ( COpenWithList::SApp pApp)
staticprivate

Definition at line 295 of file COpenWithMenu.cpp.

296 {
297  UINT cbSize, cchLen;
298  LPVOID pBuf;
299  WORD wLang = 0, wCode = 0;
300  LPLANGANDCODEPAGE lpLangCode;
301  WCHAR wszBuf[100];
302  WCHAR *pResult;
303  WCHAR wszPath[MAX_PATH];
304 
305  GetPathFromCmd(wszPath, pApp->wszCmd);
306  TRACE("LoadInfo %ls\n", wszPath);
307 
308  /* query version info size */
309  cbSize = GetFileVersionInfoSizeW(wszPath, NULL);
310  if (!cbSize)
311  {
312  ERR("GetFileVersionInfoSizeW %ls failed: %lu\n", wszPath, GetLastError());
313  return FALSE;
314  }
315 
316  /* allocate buffer */
317  pBuf = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, cbSize + 200);
318  if (!pBuf)
319  {
320  ERR("HeapAlloc failed\n");
321  return FALSE;
322  }
323 
324  /* query version info */
325  if (!GetFileVersionInfoW(wszPath, 0, cbSize, pBuf))
326  {
327  ERR("GetFileVersionInfoW %ls failed: %lu\n", wszPath, GetLastError());
328  HeapFree(GetProcessHeap(), 0, pBuf);
329  return FALSE;
330  }
331 
332  /* query lang code */
333  if (VerQueryValueW(pBuf, L"VarFileInfo\\Translation", (LPVOID*)&lpLangCode, &cbSize))
334  {
335  /* FIXME: find language from current locale / if not available,
336  * default to english
337  * for now default to first available language
338  */
339  wLang = lpLangCode->lang;
340  wCode = lpLangCode->code;
341  }
342 
343  /* Query name */
344  swprintf(wszBuf, L"\\StringFileInfo\\%04x%04x\\FileDescription", wLang, wCode);
345  if (VerQueryValueW(pBuf, wszBuf, (LPVOID *)&pResult, &cchLen))
346  StringCchCopyNW(pApp->wszName, _countof(pApp->wszName), pResult, cchLen);
347  else
348  ERR("Cannot get app name\n");
349 
350  /* Query manufacturer */
351  /*swprintf(wszBuf, L"\\StringFileInfo\\%04x%04x\\CompanyName", wLang, wCode);
352 
353  if (VerQueryValueW(pBuf, wszBuf, (LPVOID *)&pResult, &cchLen))
354  StringCchCopyNW(pApp->wszManufacturer, _countof(pApp->wszManufacturer), pResult, cchLen);*/
355  HeapFree(GetProcessHeap(), 0, pBuf);
356  return TRUE;
357 }
STRSAFEAPI StringCchCopyNW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc, size_t cchToCopy)
Definition: strsafe.h:236
#define TRUE
Definition: types.h:120
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
#define swprintf
Definition: precomp.h:40
static VOID GetPathFromCmd(LPWSTR pwszAppPath, LPCWSTR pwszCmd)
#define FALSE
Definition: types.h:117
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:595
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define _countof(array)
Definition: sndvol32.h:68
#define MAX_PATH
Definition: compat.h:34
unsigned short WORD
Definition: ntddk_ex.h:93
static const WCHAR L[]
Definition: oid.c:1250
DWORD WINAPI GetFileVersionInfoSizeW(LPCWSTR filename, LPDWORD handle)
Definition: version.c:611
#define ERR(fmt,...)
Definition: debug.h:110
WCHAR wszCmd[MAX_PATH]
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
BOOL WINAPI GetFileVersionInfoW(LPCWSTR filename, DWORD handle, DWORD datasize, LPVOID data)
Definition: version.c:845
#define HeapFree(x, y, z)
Definition: compat.h:594
BOOL WINAPI VerQueryValueW(LPCVOID pBlock, LPCWSTR lpSubBlock, LPVOID *lplpBuffer, PUINT puLen)
Definition: version.c:1049

Referenced by GetName().

◆ LoadMRUList()

BOOL COpenWithList::LoadMRUList ( HKEY  hKey)
private

Definition at line 443 of file COpenWithMenu.cpp.

444 {
445  HANDLE hList;
446  int nItem, nCount, nResult;
447  WCHAR wszAppFilename[MAX_PATH];
448 
449  /* Open MRU list */
451  if (!hList)
452  {
453  TRACE("OpenMRUList failed\n");
454  return FALSE;
455  }
456 
457  /* Get list count */
458  nCount = EnumMRUListW(hList, -1, NULL, 0);
459 
460  for(nItem = 0; nItem < nCount; nItem++)
461  {
462  nResult = EnumMRUListW(hList, nItem, wszAppFilename, _countof(wszAppFilename));
463  if (nResult <= 0)
464  continue;
465 
466  /* Insert item */
467  SApp *pApp = Find(wszAppFilename);
468 
469  TRACE("Recommended app %ls: %p\n", wszAppFilename, pApp);
470  if (pApp)
471  {
472  pApp->bMRUList = TRUE;
473  SetRecommended(pApp);
474  }
475  }
476 
477  /* Free the MRU list */
479  return TRUE;
480 }
#define TRUE
Definition: types.h:120
VOID SetRecommended(SApp *pApp)
#define FALSE
Definition: types.h:117
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define _countof(array)
Definition: sndvol32.h:68
#define MAX_PATH
Definition: compat.h:34
INT WINAPI EnumMRUListW(HANDLE hList, INT nItemPos, LPVOID lpBuffer, DWORD nBufferSize)
HWND hList
Definition: livecd.c:10
void WINAPI FreeMRUList(HANDLE hMRUList)
FxAutoRegKey hKey
#define NULL
Definition: types.h:112
static HANDLE OpenMRUList(HKEY hKey)
SApp * Find(LPCWSTR pwszFilename)

Referenced by LoadRecommendedFromHKCU().

◆ LoadProgIdList()

BOOL COpenWithList::LoadProgIdList ( HKEY  hKey,
LPCWSTR  pwszExt 
)
private

Definition at line 400 of file COpenWithMenu.cpp.

401 {
402  HKEY hSubkey, hSubkey2;
403  WCHAR wszProgId[256];
404  DWORD i = 0, cchProgId;
405 
406  if (RegOpenKeyExW(hKey, L"OpenWithProgIDs", 0, KEY_READ, &hSubkey) != ERROR_SUCCESS)
407  return FALSE;
408 
409  while (TRUE)
410  {
411  /* Enumerate values - value name is ProgId */
412  cchProgId = _countof(wszProgId);
413  if (RegEnumValue(hSubkey, i++, wszProgId, &cchProgId, NULL, NULL, NULL, NULL) != ERROR_SUCCESS)
414  break;
415 
416  /* If ProgId exists load it */
417  if (RegOpenKeyExW(HKEY_CLASSES_ROOT, wszProgId, 0, KEY_READ, &hSubkey2) == ERROR_SUCCESS)
418  {
419  LoadFromProgIdKey(hSubkey2, pwszExt);
420  RegCloseKey(hSubkey2);
421  }
422  }
423 
424  RegCloseKey(hSubkey);
425  return TRUE;
426 }
#define ERROR_SUCCESS
Definition: deptool.c:10
#define KEY_READ
Definition: nt_native.h:1023
#define TRUE
Definition: types.h:120
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
#define FALSE
Definition: types.h:117
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define _countof(array)
Definition: sndvol32.h:68
unsigned long DWORD
Definition: ntddk_ex.h:95
static const WCHAR L[]
Definition: oid.c:1250
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
Definition: glfuncs.h:248
FxAutoRegKey hKey
#define NULL
Definition: types.h:112
VOID LoadFromProgIdKey(HKEY hKey, LPCWSTR pwszExt)
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366
#define HKEY_CLASSES_ROOT
Definition: winreg.h:10
#define RegEnumValue
Definition: winreg.h:511

Referenced by LoadRecommendedFromHKCR(), and LoadRecommendedFromHKCU().

◆ LoadRecommended()

BOOL COpenWithList::LoadRecommended ( LPCWSTR  pwszFilePath)

Definition at line 383 of file COpenWithMenu.cpp.

384 {
385  LPCWSTR pwszExt;
386 
387  pwszExt = PathFindExtensionW(pwszFilePath);
388  if (!pwszExt[0])
389  return FALSE;
390 
391  /* load programs directly associated from HKCU */
392  LoadRecommendedFromHKCU(pwszExt);
393 
394  /* load programs associated from HKCR\Extension */
395  LoadRecommendedFromHKCR(pwszExt);
396 
397  return TRUE;
398 }
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
#define TRUE
Definition: types.h:120
VOID LoadRecommendedFromHKCU(LPCWSTR pwszExt)
#define FALSE
Definition: types.h:117
LPWSTR WINAPI PathFindExtensionW(LPCWSTR lpszPath)
Definition: path.c:442
VOID LoadRecommendedFromHKCR(LPCWSTR pwszExt)

Referenced by COpenWithDialog::Init(), and COpenWithMenu::QueryContextMenu().

◆ LoadRecommendedFromHKCR()

VOID COpenWithList::LoadRecommendedFromHKCR ( LPCWSTR  pwszExt)
private

Definition at line 541 of file COpenWithMenu.cpp.

542 {
543  HKEY hKey, hSubkey;
544  WCHAR wszBuf[MAX_PATH], wszBuf2[MAX_PATH];
545  DWORD dwSize;
546 
547  /* Check if extension exists */
549  {
550  /* Load items from SystemFileAssociations\Ext key */
551  StringCbPrintfW(wszBuf, sizeof(wszBuf), L"SystemFileAssociations\\%s", pwszExt);
553  return;
554  }
555 
556  /* Load programs referenced from HKCR\ProgId */
557  dwSize = sizeof(wszBuf);
558  if (RegGetValueW(hKey, NULL, L"", RRF_RT_REG_SZ, NULL, wszBuf, &dwSize) == ERROR_SUCCESS &&
559  RegOpenKeyExW(HKEY_CLASSES_ROOT, wszBuf, 0, KEY_READ, &hSubkey) == ERROR_SUCCESS)
560  {
561  LoadFromProgIdKey(hSubkey, pwszExt);
562  RegCloseKey(hSubkey);
563  }
564  else
565  LoadFromProgIdKey(hKey, pwszExt);
566 
567  /* Load items from HKCR\Ext\OpenWithList */
568  LoadAppList(hKey);
569 
570  /* Load items from HKCR\Ext\OpenWithProgIDs */
571  if (RegOpenKeyExW(hKey, L"OpenWithProgIDs", 0, KEY_READ, &hSubkey) == ERROR_SUCCESS)
572  {
573  LoadProgIdList(hSubkey, pwszExt);
574  RegCloseKey(hSubkey);
575  }
576 
577  /* Load additional items from referenced PerceivedType */
578  dwSize = sizeof(wszBuf);
579  if (RegGetValueW(hKey, NULL, L"PerceivedType", RRF_RT_REG_SZ, NULL, wszBuf, &dwSize) == ERROR_SUCCESS)
580  {
581  StringCbPrintfW(wszBuf2, sizeof(wszBuf2), L"SystemFileAssociations\\%s", wszBuf);
582  if (RegOpenKeyExW(HKEY_CLASSES_ROOT, wszBuf2, 0, KEY_READ | KEY_WRITE, &hSubkey) == ERROR_SUCCESS)
583  {
584  /* Load from OpenWithList key */
585  LoadAppList(hSubkey);
586  RegCloseKey(hSubkey);
587  }
588  }
589 
590  /* Close the key */
591  RegCloseKey(hKey);
592 }
LSTATUS WINAPI RegGetValueW(HKEY hKey, LPCWSTR pszSubKey, LPCWSTR pszValue, DWORD dwFlags, LPDWORD pdwType, PVOID pvData, LPDWORD pcbData)
Definition: reg.c:1965
BOOL LoadProgIdList(HKEY hKey, LPCWSTR pwszExt)
#define ERROR_SUCCESS
Definition: deptool.c:10
BOOL LoadAppList(HKEY hKey)
#define KEY_READ
Definition: nt_native.h:1023
#define RRF_RT_REG_SZ
Definition: driver.c:575
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
STRSAFEAPI StringCbPrintfW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:557
#define KEY_WRITE
Definition: nt_native.h:1031
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:34
unsigned long DWORD
Definition: ntddk_ex.h:95
static const WCHAR L[]
Definition: oid.c:1250
FxAutoRegKey hKey
#define NULL
Definition: types.h:112
VOID LoadFromProgIdKey(HKEY hKey, LPCWSTR pwszExt)
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366
#define HKEY_CLASSES_ROOT
Definition: winreg.h:10
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54

Referenced by LoadRecommended().

◆ LoadRecommendedFromHKCU()

VOID COpenWithList::LoadRecommendedFromHKCU ( LPCWSTR  pwszExt)
private

Definition at line 594 of file COpenWithMenu.cpp.

595 {
596  WCHAR wszBuf[MAX_PATH];
597  HKEY hKey;
598 
599  StringCbPrintfW(wszBuf, sizeof(wszBuf),
600  L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\FileExts\\%s",
601  pwszExt);
603  {
604  /* Load MRU and ProgId lists */
605  LoadMRUList(hKey);
606  LoadProgIdList(hKey, pwszExt);
607 
608  /* Handle "Aplication" value */
609  DWORD cbBuf = sizeof(wszBuf);
610  if (RegGetValueW(hKey, NULL, L"Application", RRF_RT_REG_SZ, NULL, wszBuf, &cbBuf) == ERROR_SUCCESS)
611  {
612  SApp *pApp = Find(wszBuf);
613  if (pApp)
614  SetRecommended(pApp);
615  }
616 
617  /* Close the key */
618  RegCloseKey(hKey);
619  }
620 }
LSTATUS WINAPI RegGetValueW(HKEY hKey, LPCWSTR pszSubKey, LPCWSTR pszValue, DWORD dwFlags, LPDWORD pdwType, PVOID pvData, LPDWORD pcbData)
Definition: reg.c:1965
BOOL LoadProgIdList(HKEY hKey, LPCWSTR pwszExt)
#define ERROR_SUCCESS
Definition: deptool.c:10
#define KEY_READ
Definition: nt_native.h:1023
#define HKEY_CURRENT_USER
Definition: winreg.h:11
#define RRF_RT_REG_SZ
Definition: driver.c:575
VOID SetRecommended(SApp *pApp)
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
STRSAFEAPI StringCbPrintfW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:557
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:34
unsigned long DWORD
Definition: ntddk_ex.h:95
static const WCHAR L[]
Definition: oid.c:1250
BOOL LoadMRUList(HKEY hKey)
FxAutoRegKey hKey
#define NULL
Definition: types.h:112
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366
SApp * Find(LPCWSTR pwszFilename)

Referenced by LoadRecommended().

◆ OpenMRUList()

HANDLE COpenWithList::OpenMRUList ( HKEY  hKey)
staticprivate

Definition at line 428 of file COpenWithMenu.cpp.

429 {
430  MRUINFOW Info;
431 
432  /* Initialize mru list info */
433  Info.cbSize = sizeof(Info);
434  Info.uMax = 32;
435  Info.fFlags = MRU_STRING;
436  Info.hKey = hKey;
437  Info.lpszSubKey = L"OpenWithList";
438  Info.lpfnCompare = NULL;
439 
440  return CreateMRUListW(&Info);
441 }
_Must_inspect_result_ _In_ WDFCHILDLIST _In_ PWDF_CHILD_LIST_ITERATOR _Out_ WDFDEVICE _Inout_opt_ PWDF_CHILD_RETRIEVE_INFO Info
Definition: wdfchildlist.h:683
HANDLE WINAPI CreateMRUListW(const MRUINFOW *infoW)
static const WCHAR L[]
Definition: oid.c:1250
#define MRU_STRING
FxAutoRegKey hKey
#define NULL
Definition: types.h:112

Referenced by AddAppToMRUList(), and LoadMRUList().

◆ SaveApp()

BOOL COpenWithList::SaveApp ( SApp pApp)
static

Definition at line 165 of file COpenWithMenu.cpp.

166 {
167  WCHAR wszBuf[256];
168  HKEY hKey;
169 
170  StringCbPrintfW(wszBuf, sizeof(wszBuf), L"Applications\\%s\\shell\\open\\command", pApp->wszFilename);
172  {
173  ERR("RegOpenKeyEx failed\n");
174  return FALSE;
175  }
176 
177  if (RegSetValueEx(hKey, L"", 0, REG_SZ, (PBYTE)pApp->wszCmd, (wcslen(pApp->wszCmd)+1)*sizeof(WCHAR)) != ERROR_SUCCESS)
178  ERR("Cannot add app to registry\n");
179 
180  RegCloseKey(hKey);
181  return TRUE;
182 }
#define ERROR_SUCCESS
Definition: deptool.c:10
#define TRUE
Definition: types.h:120
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
#define FALSE
Definition: types.h:117
STRSAFEAPI StringCbPrintfW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:557
#define KEY_WRITE
Definition: nt_native.h:1031
__wchar_t WCHAR
Definition: xmlstorage.h:180
static const WCHAR L[]
Definition: oid.c:1250
#define ERR(fmt,...)
Definition: debug.h:110
FxAutoRegKey hKey
#define NULL
Definition: types.h:112
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define HKEY_CLASSES_ROOT
Definition: winreg.h:10
BYTE * PBYTE
Definition: pedump.c:66
#define RegSetValueEx
Definition: winreg.h:533
#define RegCreateKeyEx
Definition: winreg.h:501
#define REG_SZ
Definition: layer.c:22

Referenced by Add(), and Execute().

◆ SetDefaultHandler()

BOOL COpenWithList::SetDefaultHandler ( SApp pApp,
LPCWSTR  pwszFilename 
)

Definition at line 665 of file COpenWithMenu.cpp.

666 {
667  HKEY hKey, hSrcKey, hDestKey;
668  WCHAR wszBuf[256];
669 
670  TRACE("SetDefaultHandler %ls %ls\n", pApp->wszFilename, pwszFilename);
671 
672  /* Extract file extension */
673  LPCWSTR pwszExt = PathFindExtensionW(pwszFilename);
674  if (!pwszExt[0] || !pwszExt[1])
675  return FALSE;
676 
677  /* Create file extension key */
679  {
680  ERR("Cannot open ext key");
681  return FALSE;
682  }
683 
684  DWORD dwSize = sizeof(wszBuf);
685  LONG lResult = RegGetValueW(hKey, NULL, L"", RRF_RT_REG_SZ, NULL, wszBuf, &dwSize);
686 
687  if (lResult == ERROR_FILE_NOT_FOUND)
688  {
689  /* A new entry was created or the default key is not set: set the prog key id */
690  StringCbPrintfW(wszBuf, sizeof(wszBuf), L"%s_auto_file", pwszExt + 1);
691  if (RegSetValueExW(hKey, L"", 0, REG_SZ, (const BYTE*)wszBuf, (wcslen(wszBuf) + 1) * sizeof(WCHAR)) != ERROR_SUCCESS)
692  {
693  RegCloseKey(hKey);
694  ERR("RegSetValueExW failed\n");
695  return FALSE;
696  }
697  }
698  else if (lResult != ERROR_SUCCESS)
699  {
700  RegCloseKey(hKey);
701  ERR("RegGetValueExW failed: 0x%08x\n", lResult);
702  return FALSE;
703  }
704 
705  /* Close file extension key */
706  RegCloseKey(hKey);
707 
708  /* Create prog id key */
710  {
711  ERR("RegCreateKeyExW failed\n");
712  return FALSE;
713  }
714 
715  /* Check if there already verbs existing for that app */
716  StringCbPrintfW(wszBuf, sizeof(wszBuf), L"Applications\\%s\\shell", pApp->wszFilename);
717  if (RegOpenKeyExW(HKEY_CLASSES_ROOT, wszBuf, 0, KEY_READ, &hSrcKey) != ERROR_SUCCESS)
718  {
719  ERR("RegOpenKeyExW %ls failed\n", wszBuf);
720  RegCloseKey(hKey);
721  return FALSE;
722  }
723 
724  /* Open destination key */
725  if (RegCreateKeyExW(hKey, L"shell", 0, NULL, 0, KEY_WRITE, NULL, &hDestKey, NULL) != ERROR_SUCCESS)
726  {
727  ERR("RegCreateKeyExW failed\n");
728  RegCloseKey(hSrcKey);
729  RegCloseKey(hKey);
730  return FALSE;
731  }
732 
733  /* Copy static verbs from Classes\Applications key */
734  /* FIXME: SHCopyKey does not copy the security attributes of the keys */
735  LSTATUS Result = SHCopyKeyW(hSrcKey, NULL, hDestKey, 0);
736  RegCloseKey(hDestKey);
737  RegCloseKey(hSrcKey);
738  RegCloseKey(hKey);
739 
740  if (Result != ERROR_SUCCESS)
741  {
742  ERR("SHCopyKeyW failed\n");
743  return FALSE;
744  }
745 
746  return TRUE;
747 }
LSTATUS WINAPI RegGetValueW(HKEY hKey, LPCWSTR pszSubKey, LPCWSTR pszValue, DWORD dwFlags, LPDWORD pdwType, PVOID pvData, LPDWORD pcbData)
Definition: reg.c:1965
DWORD WINAPI SHCopyKeyW(HKEY hKeySrc, LPCWSTR lpszSrcSubKey, HKEY hKeyDst, DWORD dwReserved)
Definition: reg.c:2261
#define ERROR_SUCCESS
Definition: deptool.c:10
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
#define KEY_READ
Definition: nt_native.h:1023
#define TRUE
Definition: types.h:120
#define RRF_RT_REG_SZ
Definition: driver.c:575
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)
Definition: reg.c:1091
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
#define FALSE
Definition: types.h:117
long LONG
Definition: pedump.c:60
STRSAFEAPI StringCbPrintfW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:557
_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
Definition: wsk.h:426
LPWSTR WINAPI PathFindExtensionW(LPCWSTR lpszPath)
Definition: path.c:442
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
#define KEY_WRITE
Definition: nt_native.h:1031
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
Definition: reg.c:4895
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
static LSTATUS(WINAPI *pRegDeleteTreeW)(HKEY
static const WCHAR L[]
Definition: oid.c:1250
unsigned char BYTE
Definition: xxhash.c:193
#define ERR(fmt,...)
Definition: debug.h:110
FxAutoRegKey hKey
#define NULL
Definition: types.h:112
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366
#define HKEY_CLASSES_ROOT
Definition: winreg.h:10
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54
#define REG_SZ
Definition: layer.c:22

Referenced by COpenWithDialog::Accept().

◆ SetRecommended()

VOID COpenWithList::SetRecommended ( SApp pApp)
inlineprivate

Definition at line 91 of file COpenWithMenu.cpp.

92  {
93  if (!pApp->bRecommended)
95  pApp->bRecommended = TRUE;
96  }
#define TRUE
Definition: types.h:120

Referenced by LoadAppList(), LoadFromProgIdKey(), LoadMRUList(), and LoadRecommendedFromHKCU().

Member Data Documentation

◆ m_bNoOpen

BOOL COpenWithList::m_bNoOpen
private

Definition at line 77 of file COpenWithMenu.cpp.

Referenced by IsNoOpen(), and LoadFromProgIdKey().

◆ m_cApp

UINT COpenWithList::m_cApp
private

Definition at line 76 of file COpenWithMenu.cpp.

Referenced by AddInternal(), Find(), GetCount(), and ~COpenWithList().

◆ m_cRecommended

UINT COpenWithList::m_cRecommended
private

Definition at line 76 of file COpenWithMenu.cpp.

Referenced by GetRecommendedCount(), and SetRecommended().

◆ m_pApp

SApp* COpenWithList::m_pApp
private

Definition at line 75 of file COpenWithMenu.cpp.

Referenced by AddInternal(), Find(), GetList(), and ~COpenWithList().


The documentation for this class was generated from the following file: