ReactOS  0.4.15-dev-4914-g2220e56
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 172 of file COpenWithMenu.cpp.

173 {
174  SApp *pApp = AddInternal(PathFindFileNameW(pwszPath));
175 
176  if (pApp)
177  {
178  StringCbPrintfW(pApp->wszCmd, sizeof(pApp->wszCmd), L"\"%s\" \"%%1\"", pwszPath);
179  SaveApp(pApp);
180  }
181 
182  return pApp;
183 }
SApp * AddInternal(LPCWSTR pwszFilename)
#define L(x)
Definition: ntvdm.h:50
STRSAFEAPI StringCbPrintfW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:557
LPWSTR WINAPI PathFindFileNameW(LPCWSTR lpszPath)
Definition: path.c:394
static BOOL SaveApp(SApp *pApp)

Referenced by COpenWithDialog::Browse().

◆ AddAppToMRUList()

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

Definition at line 642 of file COpenWithMenu.cpp.

643 {
644  WCHAR wszBuf[100];
645  LPCWSTR pwszExt;
646  HKEY hKey;
647  HANDLE hList;
648 
649  /* Get file extension */
650  pwszExt = PathFindExtensionW(pwszFilename);
651  if (!pwszExt[0])
652  return FALSE;
653 
654  /* Build registry key */
655  if (FAILED(StringCbPrintfW(wszBuf, sizeof(wszBuf),
656  L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\FileExts\\%s",
657  pwszExt)))
658  {
659  ERR("insufficient buffer\n");
660  return FALSE;
661  }
662 
663  /* Open base key for this file extension */
665  return FALSE;
666 
667  /* Open MRU list */
669  if (hList)
670  {
671  /* Insert the entry */
672  AddMRUStringW(hList, pApp->wszFilename);
673 
674  /* Set MRU presence */
675  pApp->bMRUList = TRUE;
676 
677  /* Close MRU list */
679  }
680 
681  RegCloseKey(hKey);
682  return TRUE;
683 }
#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
#define L(x)
Definition: ntvdm.h:50
#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:447
#define KEY_WRITE
Definition: nt_native.h:1031
__wchar_t WCHAR
Definition: xmlstorage.h:180
#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)
#define RegCloseKey(hKey)
Definition: registry.h:47

Referenced by Execute().

◆ AddInternal()

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

Definition at line 292 of file COpenWithMenu.cpp.

293 {
294  /* Check for duplicate */
295  SApp *pApp = Find(pwszFilename);
296  if (pApp)
297  return pApp;
298 
299  /* Create new item */
300  if (!m_pApp)
301  m_pApp = static_cast<SApp *>(HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(m_pApp[0])));
302  else
303  m_pApp = static_cast<SApp *>(HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, m_pApp, (m_cApp + 1)*sizeof(m_pApp[0])));
304  if (!m_pApp)
305  {
306  ERR("Allocation failed\n");
307  return NULL;
308  }
309 
310  pApp = &m_pApp[m_cApp++];
311  wcscpy(pApp->wszFilename, pwszFilename);
312  return pApp;
313 }
#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 242 of file COpenWithMenu.cpp.

243 {
244  WCHAR wszBuf[256];
245  HKEY hKey;
246 
247  /* Add app to registry if it wasnt there before */
248  SaveApp(pApp);
249  if (!pApp->bMRUList)
250  AddAppToMRUList(pApp, pwszFilePath);
251 
252  /* Get a handle to the reg key */
253  StringCbPrintfW(wszBuf, sizeof(wszBuf), L"Applications\\%s", pApp->wszFilename);
255  {
256  ERR("RegOpenKeyEx failed\n");
257  return FALSE;
258  }
259 
260  /* Let ShellExecuteExW do the work */
262  sei.nShow = SW_SHOWNORMAL;
263  sei.hkeyClass = hKey;
264  sei.lpFile = pwszFilePath;
265 
266  ShellExecuteExW(&sei);
267 
268  return TRUE;
269 }
#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 L(x)
Definition: ntvdm.h:50
#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:2343
static BOOL SaveApp(SApp *pApp)
#define KEY_WRITE
Definition: nt_native.h:1031
WCHAR wszFilename[MAX_PATH]
__wchar_t WCHAR
Definition: xmlstorage.h:180
#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 204 of file COpenWithMenu.cpp.

205 {
206  for (UINT i = 0; i < m_cApp; ++i)
207  if (wcsicmp(m_pApp[i].wszFilename, pwszFilename) == 0)
208  return &m_pApp[i];
209  return NULL;
210 }
#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 227 of file COpenWithMenu.cpp.

228 {
229  if (!pApp->hIcon)
230  {
231  WCHAR wszPath[MAX_PATH];
232 
233  GetPathFromCmd(wszPath, pApp->wszCmd);
234  ExtractIconExW(wszPath, 0, NULL, &pApp->hIcon, 1);
235  }
236 
237  TRACE("%ls icon: %p\n", pApp->wszFilename, pApp->hIcon);
238 
239  return pApp->hIcon;
240 }
static VOID GetPathFromCmd(LPWSTR pwszAppPath, LPCWSTR pwszCmd)
UINT WINAPI ExtractIconExW(LPCWSTR lpszFile, INT nIconIndex, HICON *phiconLarge, HICON *phiconSmall, UINT nIcons)
Definition: iconcache.cpp:866
#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 212 of file COpenWithMenu.cpp.

213 {
214  if (!pApp->wszName[0])
215  {
216  if (!LoadInfo(pApp))
217  {
218  WARN("Failed to load %ls info\n", pApp->wszFilename);
219  StringCbCopyW(pApp->wszName, sizeof(pApp->wszName), pApp->wszFilename);
220  }
221  }
222 
223  TRACE("%ls name: %ls\n", pApp->wszFilename, pApp->wszName);
224  return pApp->wszName;
225 }
#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 379 of file COpenWithMenu.cpp.

380 {
381  WCHAR wszBuf[MAX_PATH], *pwszDest = wszBuf;
382 
383  /* Remove arguments */
384  if (pwszCmd[0] == '"')
385  {
386  for(LPCWSTR pwszSrc = pwszCmd + 1; *pwszSrc && *pwszSrc != '"'; ++pwszSrc)
387  *(pwszDest++) = *pwszSrc;
388  }
389  else
390  {
391  for(LPCWSTR pwszSrc = pwszCmd; *pwszSrc && *pwszSrc != ' '; ++pwszSrc)
392  *(pwszDest++) = *pwszSrc;
393  }
394 
395  *pwszDest = 0;
396 
397  /* Expand evn vers and optionally search for path */
398  ExpandEnvironmentStrings(wszBuf, pwszAppPath, MAX_PATH);
399  if (!PathFileExists(pwszAppPath))
400  SearchPath(NULL, pwszAppPath, NULL, MAX_PATH, pwszAppPath, NULL);
401 }
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
#define ExpandEnvironmentStrings
Definition: winbase.h:3635
#define SearchPath
Definition: winbase.h:3761
__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 271 of file COpenWithMenu.cpp.

272 {
273  WCHAR wszBuf[100];
274  DWORD dwSize = 0;
275 
276  if (pApp->bHidden)
277  return pApp->bHidden;
278 
279  if (FAILED(StringCbPrintfW(wszBuf, sizeof(wszBuf), L"Applications\\%s", pApp->wszFilename)))
280  {
281  ERR("insufficient buffer\n");
282  return FALSE;
283  }
284 
285  if (RegGetValueW(HKEY_CLASSES_ROOT, wszBuf, L"NoOpenWith", RRF_RT_REG_SZ, NULL, NULL, &dwSize) != ERROR_SUCCESS)
286  return FALSE;
287 
288  pApp->bHidden = TRUE;
289  return TRUE;
290 }
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 L(x)
Definition: ntvdm.h:50
#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
#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:56

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, hKeyApp;
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  if (RegOpenKeyW(hKey, wszName, &hKeyApp) == ERROR_SUCCESS)
135  {
136  if ((RegQueryValueExW(hKeyApp, L"NoOpenWith", NULL, NULL, NULL, NULL) != ERROR_SUCCESS) &&
137  (RegQueryValueExW(hKeyApp, L"NoStartPage", NULL, NULL, NULL, NULL) != ERROR_SUCCESS))
138  {
139  StringCbPrintfW(wszBuf, sizeof(wszBuf), L"%s\\shell\\open\\command", wszName);
140  dwSize = sizeof(pApp->wszCmd);
141  if (RegGetValueW(hKey, wszBuf, L"", RRF_RT_REG_SZ, NULL, pApp->wszCmd, &dwSize) != ERROR_SUCCESS)
142  {
143  ERR("Failed to add app %ls\n", wszName);
144  pApp->bHidden = TRUE;
145  }
146  else
147  {
148  TRACE("App added %ls\n", pApp->wszCmd);
149  }
150  }
151  else
152  {
153  pApp->bHidden = TRUE;
154  }
155  RegCloseKey(hKeyApp);
156  }
157  else
158  {
159  pApp->bHidden = TRUE;
160  }
161  }
162  else
163  {
164  ERR("AddInternal failed\n");
165  }
166  }
167 
168  RegCloseKey(hKey);
169  return TRUE;
170 }
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:2750
#define L(x)
Definition: ntvdm.h:50
#define FALSE
Definition: types.h:117
LONG WINAPI RegOpenKeyW(HKEY hKey, LPCWSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:3291
STRSAFEAPI StringCbPrintfW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:557
#define TRACE(s)
Definition: solgame.cpp:4
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4120
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define _countof(array)
Definition: sndvol32.h:68
unsigned long DWORD
Definition: ntddk_ex.h:95
#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
#define RegCloseKey(hKey)
Definition: registry.h:47
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56

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

◆ LoadAppList()

BOOL COpenWithList::LoadAppList ( HKEY  hKey)
private

Definition at line 502 of file COpenWithMenu.cpp.

503 {
504  WCHAR wszAppFilename[MAX_PATH];
505  HKEY hSubkey;
506  DWORD i = 0, cchAppFilename;
507 
508  if (RegOpenKeyExW(hKey, L"OpenWithList", 0, KEY_READ, &hSubkey) != ERROR_SUCCESS)
509  return FALSE;
510 
511  while (TRUE)
512  {
513  /* Enum registry keys - each of them is app name */
514  cchAppFilename = _countof(wszAppFilename);
515  if (RegEnumKeyExW(hSubkey, i++, wszAppFilename, &cchAppFilename, NULL, NULL, NULL, NULL) != ERROR_SUCCESS)
516  break;
517 
518  /* Set application as recommended */
519  SApp *pApp = Find(wszAppFilename);
520 
521  TRACE("Recommended app %ls: %p\n", wszAppFilename, pApp);
522  if (pApp)
523  SetRecommended(pApp);
524  }
525 
526  RegCloseKey(hSubkey);
527  return TRUE;
528 }
#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)
#define L(x)
Definition: ntvdm.h:50
#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
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:3356
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
#define RegCloseKey(hKey)
Definition: registry.h:47

Referenced by LoadRecommendedFromHKCR().

◆ LoadFromProgIdKey()

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

Definition at line 530 of file COpenWithMenu.cpp.

531 {
532  WCHAR wszCmd[MAX_PATH], wszPath[MAX_PATH];
533  DWORD dwSize = 0;
534 
535  /* Check if NoOpen value exists */
537  {
538  /* Display warning dialog */
539  m_bNoOpen = TRUE;
540  }
541 
542  /* Check if there is a directly available execute key */
543  dwSize = sizeof(wszCmd);
544  if (RegGetValueW(hKey, L"shell\\open\\command", NULL, RRF_RT_REG_SZ, NULL, (PVOID)wszCmd, &dwSize) == ERROR_SUCCESS)
545  {
546  /* Erase extra arguments */
547  GetPathFromCmd(wszPath, wszCmd);
548 
549  /* Add application */
550  SApp *pApp = AddInternal(PathFindFileNameW(wszPath));
551  TRACE("Add app %ls: %p\n", wszPath, pApp);
552 
553  if (pApp)
554  {
555  StringCbCopyW(pApp->wszCmd, sizeof(pApp->wszCmd), wszCmd);
556  SetRecommended(pApp);
557  }
558  }
559 }
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)
#define L(x)
Definition: ntvdm.h:50
LPWSTR WINAPI PathFindFileNameW(LPCWSTR lpszPath)
Definition: path.c:394
#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
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:56

Referenced by LoadProgIdList(), and LoadRecommendedFromHKCR().

◆ LoadInfo()

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

Definition at line 315 of file COpenWithMenu.cpp.

316 {
317  UINT cbSize, cchLen;
318  LPVOID pBuf;
319  WORD wLang = 0, wCode = 0;
320  LPLANGANDCODEPAGE lpLangCode;
321  WCHAR wszBuf[100];
322  WCHAR *pResult;
323  WCHAR wszPath[MAX_PATH];
324 
325  GetPathFromCmd(wszPath, pApp->wszCmd);
326  TRACE("LoadInfo %ls\n", wszPath);
327 
328  /* query version info size */
329  cbSize = GetFileVersionInfoSizeW(wszPath, NULL);
330  if (!cbSize)
331  {
332  ERR("GetFileVersionInfoSizeW %ls failed: %lu\n", wszPath, GetLastError());
333  return FALSE;
334  }
335 
336  /* allocate buffer */
337  pBuf = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, cbSize + 200);
338  if (!pBuf)
339  {
340  ERR("HeapAlloc failed\n");
341  return FALSE;
342  }
343 
344  /* query version info */
345  if (!GetFileVersionInfoW(wszPath, 0, cbSize, pBuf))
346  {
347  ERR("GetFileVersionInfoW %ls failed: %lu\n", wszPath, GetLastError());
348  HeapFree(GetProcessHeap(), 0, pBuf);
349  return FALSE;
350  }
351 
352  /* query lang code */
353  if (VerQueryValueW(pBuf, L"VarFileInfo\\Translation", (LPVOID*)&lpLangCode, &cbSize))
354  {
355  /* FIXME: find language from current locale / if not available,
356  * default to english
357  * for now default to first available language
358  */
359  wLang = lpLangCode->lang;
360  wCode = lpLangCode->code;
361  }
362 
363  /* Query name */
364  swprintf(wszBuf, L"\\StringFileInfo\\%04x%04x\\FileDescription", wLang, wCode);
365  if (VerQueryValueW(pBuf, wszBuf, (LPVOID *)&pResult, &cchLen))
366  StringCchCopyNW(pApp->wszName, _countof(pApp->wszName), pResult, cchLen);
367  else
368  ERR("Cannot get app name\n");
369 
370  /* Query manufacturer */
371  /*swprintf(wszBuf, L"\\StringFileInfo\\%04x%04x\\CompanyName", wLang, wCode);
372 
373  if (VerQueryValueW(pBuf, wszBuf, (LPVOID *)&pResult, &cchLen))
374  StringCchCopyNW(pApp->wszManufacturer, _countof(pApp->wszManufacturer), pResult, cchLen);*/
375  HeapFree(GetProcessHeap(), 0, pBuf);
376  return TRUE;
377 }
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:1040
static VOID GetPathFromCmd(LPWSTR pwszAppPath, LPCWSTR pwszCmd)
#define L(x)
Definition: ntvdm.h:50
#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
DWORD WINAPI GetFileVersionInfoSizeW(LPCWSTR filename, LPDWORD handle)
Definition: version.c:611
int _cdecl swprintf(const WCHAR *,...)
#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 463 of file COpenWithMenu.cpp.

464 {
465  HANDLE hList;
466  int nItem, nCount, nResult;
467  WCHAR wszAppFilename[MAX_PATH];
468 
469  /* Open MRU list */
471  if (!hList)
472  {
473  TRACE("OpenMRUList failed\n");
474  return FALSE;
475  }
476 
477  /* Get list count */
478  nCount = EnumMRUListW(hList, -1, NULL, 0);
479 
480  for(nItem = 0; nItem < nCount; nItem++)
481  {
482  nResult = EnumMRUListW(hList, nItem, wszAppFilename, _countof(wszAppFilename));
483  if (nResult <= 0)
484  continue;
485 
486  /* Insert item */
487  SApp *pApp = Find(wszAppFilename);
488 
489  TRACE("Recommended app %ls: %p\n", wszAppFilename, pApp);
490  if (pApp)
491  {
492  pApp->bMRUList = TRUE;
493  SetRecommended(pApp);
494  }
495  }
496 
497  /* Free the MRU list */
499  return TRUE;
500 }
#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 420 of file COpenWithMenu.cpp.

421 {
422  HKEY hSubkey, hSubkey2;
423  WCHAR wszProgId[256];
424  DWORD i = 0, cchProgId;
425 
426  if (RegOpenKeyExW(hKey, L"OpenWithProgIDs", 0, KEY_READ, &hSubkey) != ERROR_SUCCESS)
427  return FALSE;
428 
429  while (TRUE)
430  {
431  /* Enumerate values - value name is ProgId */
432  cchProgId = _countof(wszProgId);
433  if (RegEnumValue(hSubkey, i++, wszProgId, &cchProgId, NULL, NULL, NULL, NULL) != ERROR_SUCCESS)
434  break;
435 
436  /* If ProgId exists load it */
437  if (RegOpenKeyExW(HKEY_CLASSES_ROOT, wszProgId, 0, KEY_READ, &hSubkey2) == ERROR_SUCCESS)
438  {
439  LoadFromProgIdKey(hSubkey2, pwszExt);
440  RegCloseKey(hSubkey2);
441  }
442  }
443 
444  RegCloseKey(hSubkey);
445  return TRUE;
446 }
#define ERROR_SUCCESS
Definition: deptool.c:10
#define KEY_READ
Definition: nt_native.h:1023
#define TRUE
Definition: types.h:120
#define L(x)
Definition: ntvdm.h:50
#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
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:3356
#define HKEY_CLASSES_ROOT
Definition: winreg.h:10
#define RegEnumValue
Definition: winreg.h:511
#define RegCloseKey(hKey)
Definition: registry.h:47

Referenced by LoadRecommendedFromHKCR(), and LoadRecommendedFromHKCU().

◆ LoadRecommended()

BOOL COpenWithList::LoadRecommended ( LPCWSTR  pwszFilePath)

Definition at line 403 of file COpenWithMenu.cpp.

404 {
405  LPCWSTR pwszExt;
406 
407  pwszExt = PathFindExtensionW(pwszFilePath);
408  if (!pwszExt[0])
409  return FALSE;
410 
411  /* load programs directly associated from HKCU */
412  LoadRecommendedFromHKCU(pwszExt);
413 
414  /* load programs associated from HKCR\Extension */
415  LoadRecommendedFromHKCR(pwszExt);
416 
417  return TRUE;
418 }
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:447
VOID LoadRecommendedFromHKCR(LPCWSTR pwszExt)

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

◆ LoadRecommendedFromHKCR()

VOID COpenWithList::LoadRecommendedFromHKCR ( LPCWSTR  pwszExt)
private

Definition at line 561 of file COpenWithMenu.cpp.

562 {
563  HKEY hKey, hSubkey;
564  WCHAR wszBuf[MAX_PATH], wszBuf2[MAX_PATH];
565  DWORD dwSize;
566 
567  /* Check if extension exists */
569  {
570  /* Load items from SystemFileAssociations\Ext key */
571  StringCbPrintfW(wszBuf, sizeof(wszBuf), L"SystemFileAssociations\\%s", pwszExt);
573  return;
574  }
575 
576  /* Load programs referenced from HKCR\ProgId */
577  dwSize = sizeof(wszBuf);
578  if (RegGetValueW(hKey, NULL, L"", RRF_RT_REG_SZ, NULL, wszBuf, &dwSize) == ERROR_SUCCESS &&
579  RegOpenKeyExW(HKEY_CLASSES_ROOT, wszBuf, 0, KEY_READ, &hSubkey) == ERROR_SUCCESS)
580  {
581  LoadFromProgIdKey(hSubkey, pwszExt);
582  RegCloseKey(hSubkey);
583  }
584  else
585  LoadFromProgIdKey(hKey, pwszExt);
586 
587  /* Load items from HKCR\Ext\OpenWithList */
588  LoadAppList(hKey);
589 
590  /* Load items from HKCR\Ext\OpenWithProgIDs */
591  if (RegOpenKeyExW(hKey, L"OpenWithProgIDs", 0, KEY_READ, &hSubkey) == ERROR_SUCCESS)
592  {
593  LoadProgIdList(hSubkey, pwszExt);
594  RegCloseKey(hSubkey);
595  }
596 
597  /* Load additional items from referenced PerceivedType */
598  dwSize = sizeof(wszBuf);
599  if (RegGetValueW(hKey, NULL, L"PerceivedType", RRF_RT_REG_SZ, NULL, wszBuf, &dwSize) == ERROR_SUCCESS)
600  {
601  StringCbPrintfW(wszBuf2, sizeof(wszBuf2), L"SystemFileAssociations\\%s", wszBuf);
602  if (RegOpenKeyExW(HKEY_CLASSES_ROOT, wszBuf2, 0, KEY_READ | KEY_WRITE, &hSubkey) == ERROR_SUCCESS)
603  {
604  /* Load from OpenWithList key */
605  LoadAppList(hSubkey);
606  RegCloseKey(hSubkey);
607  }
608  }
609 
610  /* Close the key */
611  RegCloseKey(hKey);
612 }
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
#define L(x)
Definition: ntvdm.h:50
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
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:3356
#define HKEY_CLASSES_ROOT
Definition: winreg.h:10
#define RegCloseKey(hKey)
Definition: registry.h:47
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56

Referenced by LoadRecommended().

◆ LoadRecommendedFromHKCU()

VOID COpenWithList::LoadRecommendedFromHKCU ( LPCWSTR  pwszExt)
private

Definition at line 614 of file COpenWithMenu.cpp.

615 {
616  WCHAR wszBuf[MAX_PATH];
617  HKEY hKey;
618 
619  StringCbPrintfW(wszBuf, sizeof(wszBuf),
620  L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\FileExts\\%s",
621  pwszExt);
623  {
624  /* Load MRU and ProgId lists */
625  LoadMRUList(hKey);
626  LoadProgIdList(hKey, pwszExt);
627 
628  /* Handle "Aplication" value */
629  DWORD cbBuf = sizeof(wszBuf);
630  if (RegGetValueW(hKey, NULL, L"Application", RRF_RT_REG_SZ, NULL, wszBuf, &cbBuf) == ERROR_SUCCESS)
631  {
632  SApp *pApp = Find(wszBuf);
633  if (pApp)
634  SetRecommended(pApp);
635  }
636 
637  /* Close the key */
638  RegCloseKey(hKey);
639  }
640 }
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)
#define L(x)
Definition: ntvdm.h:50
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
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:3356
SApp * Find(LPCWSTR pwszFilename)
#define RegCloseKey(hKey)
Definition: registry.h:47

Referenced by LoadRecommended().

◆ OpenMRUList()

HANDLE COpenWithList::OpenMRUList ( HKEY  hKey)
staticprivate

Definition at line 448 of file COpenWithMenu.cpp.

449 {
450  MRUINFOW Info;
451 
452  /* Initialize mru list info */
453  Info.cbSize = sizeof(Info);
454  Info.uMax = 32;
455  Info.fFlags = MRU_STRING;
456  Info.hKey = hKey;
457  Info.lpszSubKey = L"OpenWithList";
458  Info.lpfnCompare = NULL;
459 
460  return CreateMRUListW(&Info);
461 }
_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)
#define L(x)
Definition: ntvdm.h:50
#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 185 of file COpenWithMenu.cpp.

186 {
187  WCHAR wszBuf[256];
188  HKEY hKey;
189 
190  StringCbPrintfW(wszBuf, sizeof(wszBuf), L"Applications\\%s\\shell\\open\\command", pApp->wszFilename);
192  {
193  ERR("RegOpenKeyEx failed\n");
194  return FALSE;
195  }
196 
197  if (RegSetValueEx(hKey, L"", 0, REG_SZ, (PBYTE)pApp->wszCmd, (wcslen(pApp->wszCmd)+1)*sizeof(WCHAR)) != ERROR_SUCCESS)
198  ERR("Cannot add app to registry\n");
199 
200  RegCloseKey(hKey);
201  return TRUE;
202 }
#define ERROR_SUCCESS
Definition: deptool.c:10
#define TRUE
Definition: types.h:120
#define L(x)
Definition: ntvdm.h:50
#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
#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 RegCloseKey(hKey)
Definition: registry.h:47
#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 685 of file COpenWithMenu.cpp.

686 {
687  HKEY hKey, hSrcKey, hDestKey;
688  WCHAR wszBuf[256];
689 
690  TRACE("SetDefaultHandler %ls %ls\n", pApp->wszFilename, pwszFilename);
691 
692  /* Extract file extension */
693  LPCWSTR pwszExt = PathFindExtensionW(pwszFilename);
694  if (!pwszExt[0] || !pwszExt[1])
695  return FALSE;
696 
697  /* Create file extension key */
699  {
700  ERR("Cannot open ext key\n");
701  return FALSE;
702  }
703 
704  DWORD dwSize = sizeof(wszBuf);
705  LONG lResult = RegGetValueW(hKey, NULL, L"", RRF_RT_REG_SZ, NULL, wszBuf, &dwSize);
706 
707  if (lResult == ERROR_FILE_NOT_FOUND)
708  {
709  /* A new entry was created or the default key is not set: set the prog key id */
710  StringCbPrintfW(wszBuf, sizeof(wszBuf), L"%s_auto_file", pwszExt + 1);
711  if (RegSetValueExW(hKey, L"", 0, REG_SZ, (const BYTE*)wszBuf, (wcslen(wszBuf) + 1) * sizeof(WCHAR)) != ERROR_SUCCESS)
712  {
713  RegCloseKey(hKey);
714  ERR("RegSetValueExW failed\n");
715  return FALSE;
716  }
717  }
718  else if (lResult != ERROR_SUCCESS)
719  {
720  RegCloseKey(hKey);
721  ERR("RegGetValueExW failed: 0x%08x\n", lResult);
722  return FALSE;
723  }
724 
725  /* Close file extension key */
726  RegCloseKey(hKey);
727 
728  /* Create prog id key */
730  {
731  ERR("RegCreateKeyExW failed\n");
732  return FALSE;
733  }
734 
735  /* Check if there already verbs existing for that app */
736  StringCbPrintfW(wszBuf, sizeof(wszBuf), L"Applications\\%s\\shell", pApp->wszFilename);
737  if (RegOpenKeyExW(HKEY_CLASSES_ROOT, wszBuf, 0, KEY_READ, &hSrcKey) != ERROR_SUCCESS)
738  {
739  ERR("RegOpenKeyExW %ls failed\n", wszBuf);
740  RegCloseKey(hKey);
741  return FALSE;
742  }
743 
744  /* Open destination key */
745  if (RegCreateKeyExW(hKey, L"shell", 0, NULL, 0, KEY_WRITE, NULL, &hDestKey, NULL) != ERROR_SUCCESS)
746  {
747  ERR("RegCreateKeyExW failed\n");
748  RegCloseKey(hSrcKey);
749  RegCloseKey(hKey);
750  return FALSE;
751  }
752 
753  /* Copy static verbs from Classes\Applications key */
754  /* FIXME: SHCopyKey does not copy the security attributes of the keys */
755  LSTATUS Result = SHCopyKeyW(hSrcKey, NULL, hDestKey, 0);
756  RegCloseKey(hDestKey);
757  RegCloseKey(hSrcKey);
758  RegCloseKey(hKey);
759 
760  if (Result != ERROR_SUCCESS)
761  {
762  ERR("SHCopyKeyW failed\n");
763  return FALSE;
764  }
765 
766  return TRUE;
767 }
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
#define L(x)
Definition: ntvdm.h:50
#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:447
#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:4899
#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
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:3356
#define HKEY_CLASSES_ROOT
Definition: winreg.h:10
#define RegCloseKey(hKey)
Definition: registry.h:47
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
#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: