ReactOS  0.4.15-dev-5112-g22d8c0f
CQueryAssociations Class Reference

#include <CQueryAssociations.h>

Inheritance diagram for CQueryAssociations:
Collaboration diagram for CQueryAssociations:

Public Member Functions

 CQueryAssociations ()
 
 ~CQueryAssociations ()
 
virtual HRESULT STDMETHODCALLTYPE Init (ASSOCF flags, LPCWSTR pwszAssoc, HKEY hkProgid, HWND hwnd)
 
virtual HRESULT STDMETHODCALLTYPE GetString (ASSOCF flags, ASSOCSTR str, LPCWSTR pwszExtra, LPWSTR pwszOut, DWORD *pcchOut)
 
virtual HRESULT STDMETHODCALLTYPE GetKey (ASSOCF flags, ASSOCKEY key, LPCWSTR pwszExtra, HKEY *phkeyOut)
 
virtual HRESULT STDMETHODCALLTYPE GetData (ASSOCF flags, ASSOCDATA data, LPCWSTR pwszExtra, void *pvOut, DWORD *pcbOut)
 
virtual HRESULT STDMETHODCALLTYPE GetEnum (ASSOCF cfFlags, ASSOCENUM assocenum, LPCWSTR pszExtra, REFIID riid, LPVOID *ppvOut)
 
- Public Member Functions inherited from ATL::CComObjectRootEx< CComMultiThreadModelNoCS >
 ~CComObjectRootEx ()
 
ULONG InternalAddRef ()
 
ULONG InternalRelease ()
 
void Lock ()
 
void Unlock ()
 
HRESULT _AtlInitialConstruct ()
 
- Public Member Functions inherited from ATL::CComObjectRootBase
 CComObjectRootBase ()
 
 ~CComObjectRootBase ()
 
void SetVoid (void *)
 
HRESULT _AtlFinalConstruct ()
 
HRESULT FinalConstruct ()
 
void InternalFinalConstructAddRef ()
 
void InternalFinalConstructRelease ()
 
void FinalRelease ()
 

Private Member Functions

HRESULT GetValue (HKEY hkey, const WCHAR *name, void **data, DWORD *data_size)
 
HRESULT GetCommand (const WCHAR *extra, WCHAR **command)
 
HRESULT GetExecutable (LPCWSTR pszExtra, LPWSTR path, DWORD pathlen, DWORD *len)
 
HRESULT ReturnData (void *out, DWORD *outlen, const void *data, DWORD datalen)
 
HRESULT ReturnString (ASSOCF flags, LPWSTR out, DWORD *outlen, LPCWSTR data, DWORD datalen)
 

Private Attributes

HKEY hkeySource
 
HKEY hkeyProgID
 

Additional Inherited Members

- Static Public Member Functions inherited from ATL::CComObjectRootBase
static void WINAPI ObjectMain (bool)
 
static const struct _ATL_CATMAP_ENTRYGetCategoryMap ()
 
static HRESULT WINAPI InternalQueryInterface (void *pThis, const _ATL_INTMAP_ENTRY *pEntries, REFIID iid, void **ppvObject)
 
- Public Attributes inherited from ATL::CComObjectRootBase
LONG m_dwRef
 

Detailed Description

Definition at line 3 of file CQueryAssociations.h.

Constructor & Destructor Documentation

◆ CQueryAssociations()

CQueryAssociations::CQueryAssociations ( )

Definition at line 47 of file CQueryAssociations.cpp.

47  : hkeySource(0), hkeyProgID(0)
48 {
49 }

◆ ~CQueryAssociations()

CQueryAssociations::~CQueryAssociations ( )

Definition at line 51 of file CQueryAssociations.cpp.

52 {
53 }

Member Function Documentation

◆ GetCommand()

HRESULT CQueryAssociations::GetCommand ( const WCHAR extra,
WCHAR **  command 
)
private

Definition at line 563 of file CQueryAssociations.cpp.

564 {
565  HKEY hkeyCommand;
566  HKEY hkeyShell;
567  HKEY hkeyVerb;
568  HRESULT hr;
569  LONG ret;
570  WCHAR *extra_from_reg = NULL;
571  WCHAR *filetype;
572 
573  /* When looking for file extension it's possible to have a default value
574  that points to another key that contains 'shell/<verb>/command' subtree. */
575  hr = this->GetValue(this->hkeySource, NULL, (void**)&filetype, NULL);
576  if (hr == S_OK)
577  {
578  HKEY hkeyFile;
579 
582 
583  if (ret == ERROR_SUCCESS)
584  {
585  ret = RegOpenKeyExW(hkeyFile, L"shell", 0, KEY_READ, &hkeyShell);
586  RegCloseKey(hkeyFile);
587  }
588  else
589  {
590  ret = RegOpenKeyExW(this->hkeySource, L"shell", 0, KEY_READ, &hkeyShell);
591  }
592  }
593  else
594  {
595  ret = RegOpenKeyExW(this->hkeySource, L"shell", 0, KEY_READ, &hkeyShell);
596  }
597 
598  if (ret)
599  {
600  return HRESULT_FROM_WIN32(ret);
601  }
602 
603  if (!extra)
604  {
605  /* check for default verb */
606  hr = this->GetValue(hkeyShell, NULL, (void**)&extra_from_reg, NULL);
607  if (FAILED(hr))
608  {
609  /* no default verb, try first subkey */
610  DWORD max_subkey_len;
611 
612  ret = RegQueryInfoKeyW(hkeyShell, NULL, NULL, NULL, NULL, &max_subkey_len, NULL, NULL, NULL, NULL, NULL, NULL);
613  if (ret)
614  {
615  RegCloseKey(hkeyShell);
616  return HRESULT_FROM_WIN32(ret);
617  }
618 
619  max_subkey_len++;
620  extra_from_reg = static_cast<WCHAR*>(HeapAlloc(GetProcessHeap(), 0, max_subkey_len * sizeof(WCHAR)));
621  if (!extra_from_reg)
622  {
623  RegCloseKey(hkeyShell);
624  return E_OUTOFMEMORY;
625  }
626 
627  ret = RegEnumKeyExW(hkeyShell, 0, extra_from_reg, &max_subkey_len, NULL, NULL, NULL, NULL);
628  if (ret)
629  {
630  HeapFree(GetProcessHeap(), 0, extra_from_reg);
631  RegCloseKey(hkeyShell);
632  return HRESULT_FROM_WIN32(ret);
633  }
634  }
635  extra = extra_from_reg;
636  }
637 
638  /* open verb subkey */
639  ret = RegOpenKeyExW(hkeyShell, extra, 0, KEY_READ, &hkeyVerb);
640  HeapFree(GetProcessHeap(), 0, extra_from_reg);
641  RegCloseKey(hkeyShell);
642  if (ret)
643  {
644  return HRESULT_FROM_WIN32(ret);
645  }
646  /* open command subkey */
647  ret = RegOpenKeyExW(hkeyVerb, L"command", 0, KEY_READ, &hkeyCommand);
648  RegCloseKey(hkeyVerb);
649  if (ret)
650  {
651  return HRESULT_FROM_WIN32(ret);
652  }
653  hr = this->GetValue(hkeyCommand, NULL, (void**)command, NULL);
654  RegCloseKey(hkeyCommand);
655  return hr;
656 }
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
#define ERROR_SUCCESS
Definition: deptool.c:10
HRESULT hr
Definition: shlfolder.c:183
#define KEY_READ
Definition: nt_native.h:1023
HRESULT GetValue(HKEY hkey, const WCHAR *name, void **data, DWORD *data_size)
#define L(x)
Definition: ntvdm.h:50
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
long LONG
Definition: pedump.c:60
#define GetProcessHeap()
Definition: compat.h:595
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
Definition: id3.c:95
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:79
unsigned long DWORD
Definition: ntddk_ex.h:95
LONG WINAPI RegQueryInfoKeyW(HKEY hKey, LPWSTR lpClass, LPDWORD lpcClass, LPDWORD lpReserved, LPDWORD lpcSubKeys, LPDWORD lpcMaxSubKeyLen, LPDWORD lpcMaxClassLen, LPDWORD lpcValues, LPDWORD lpcMaxValueNameLen, LPDWORD lpcMaxValueLen, LPDWORD lpcbSecurityDescriptor, PFILETIME lpftLastWriteTime)
Definition: reg.c:3690
int ret
#define S_OK
Definition: intsafe.h:52
#define NULL
Definition: types.h:112
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3356
LOCAL char * filetype(int t)
Definition: tree.c:114
#define HKEY_CLASSES_ROOT
Definition: winreg.h:10
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 HeapFree(x, y, z)
Definition: compat.h:594
#define RegCloseKey(hKey)
Definition: registry.h:47

Referenced by GetExecutable(), and GetString().

◆ GetData()

HRESULT STDMETHODCALLTYPE CQueryAssociations::GetData ( ASSOCF  flags,
ASSOCDATA  data,
LPCWSTR  pwszExtra,
void pvOut,
DWORD pcbOut 
)
virtual

Definition at line 457 of file CQueryAssociations.cpp.

458 {
459  TRACE("(%p,0x%8x,0x%8x,%s,%p,%p)\n", this, cfFlags, assocdata,
460  debugstr_w(pszExtra), pvOut, pcbOut);
461 
462  if(cfFlags)
463  {
464  FIXME("Unsupported flags: %x\n", cfFlags);
465  }
466 
467  switch(assocdata)
468  {
469  case ASSOCDATA_EDITFLAGS:
470  {
471  if(!this->hkeyProgID)
472  {
474  }
475 
476  void *data;
477  DWORD size;
478  HRESULT hres = this->GetValue(this->hkeyProgID, L"EditFlags", &data, &size);
479  if(FAILED(hres))
480  {
481  return hres;
482  }
483 
484  if (!pcbOut)
485  {
487  return hres;
488  }
489 
490  hres = this->ReturnData(pvOut, pcbOut, data, size);
492  return hres;
493  }
494  default:
495  {
496  FIXME("Unsupported ASSOCDATA value: %d\n", assocdata);
497  return E_NOTIMPL;
498  }
499  }
500 }
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
HRESULT ReturnData(void *out, DWORD *outlen, const void *data, DWORD datalen)
HRESULT GetValue(HKEY hkey, const WCHAR *name, void **data, DWORD *data_size)
#define L(x)
Definition: ntvdm.h:50
#define debugstr_w
Definition: kernel32.h:32
#define FIXME(fmt,...)
Definition: debug.h:111
#define TRACE(s)
Definition: solgame.cpp:4
GLsizeiptr size
Definition: glext.h:5919
HRESULT hres
Definition: protocol.c:465
#define GetProcessHeap()
Definition: compat.h:595
LONG HRESULT
Definition: typedefs.h:79
unsigned long DWORD
Definition: ntddk_ex.h:95
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
#define ERROR_NO_ASSOCIATION
Definition: winerror.h:677
#define E_NOTIMPL
Definition: ddrawi.h:99
#define HeapFree(x, y, z)
Definition: compat.h:594

◆ GetEnum()

HRESULT STDMETHODCALLTYPE CQueryAssociations::GetEnum ( ASSOCF  cfFlags,
ASSOCENUM  assocenum,
LPCWSTR  pszExtra,
REFIID  riid,
LPVOID ppvOut 
)
virtual

Definition at line 521 of file CQueryAssociations.cpp.

527 {
528  return E_NOTIMPL;
529 }
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ GetExecutable()

HRESULT CQueryAssociations::GetExecutable ( LPCWSTR  pszExtra,
LPWSTR  path,
DWORD  pathlen,
DWORD len 
)
private

Definition at line 658 of file CQueryAssociations.cpp.

659 {
660  WCHAR *pszCommand;
661  WCHAR *pszStart;
662  WCHAR *pszEnd;
663 
664  HRESULT hr = this->GetCommand(pszExtra, &pszCommand);
665  if (FAILED(hr))
666  {
667  return hr;
668  }
669 
670  DWORD expLen = ExpandEnvironmentStringsW(pszCommand, NULL, 0);
671  if (expLen > 0)
672  {
673  expLen++;
674  WCHAR *buf = static_cast<WCHAR *>(HeapAlloc(GetProcessHeap(), 0, expLen * sizeof(WCHAR)));
675  ExpandEnvironmentStringsW(pszCommand, buf, expLen);
676  HeapFree(GetProcessHeap(), 0, pszCommand);
677  pszCommand = buf;
678  }
679 
680  /* cleanup pszCommand */
681  if (pszCommand[0] == '"')
682  {
683  pszStart = pszCommand + 1;
684  pszEnd = strchrW(pszStart, '"');
685  if (pszEnd)
686  {
687  *pszEnd = 0;
688  }
689  *len = SearchPathW(NULL, pszStart, NULL, pathlen, path, NULL);
690  }
691  else
692  {
693  pszStart = pszCommand;
694  for (pszEnd = pszStart; (pszEnd = strchrW(pszEnd, ' ')); pszEnd++)
695  {
696  WCHAR c = *pszEnd;
697  *pszEnd = 0;
698  if ((*len = SearchPathW(NULL, pszStart, NULL, pathlen, path, NULL)))
699  {
700  break;
701  }
702  *pszEnd = c;
703  }
704  if (!pszEnd)
705  {
706  *len = SearchPathW(NULL, pszStart, NULL, pathlen, path, NULL);
707  }
708  }
709 
710  HeapFree(GetProcessHeap(), 0, pszCommand);
711  if (!*len)
712  {
714  }
715  return S_OK;
716 }
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
HRESULT hr
Definition: shlfolder.c:183
WINE_UNICODE_INLINE WCHAR * strchrW(const WCHAR *str, WCHAR ch)
Definition: unicode.h:248
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
HRESULT GetCommand(const WCHAR *extra, WCHAR **command)
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
#define GetProcessHeap()
Definition: compat.h:595
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:79
const GLubyte * c
Definition: glext.h:8905
unsigned long DWORD
Definition: ntddk_ex.h:95
GLenum GLsizei len
Definition: glext.h:6722
DWORD WINAPI SearchPathW(IN LPCWSTR lpPath OPTIONAL, IN LPCWSTR lpFileName, IN LPCWSTR lpExtension OPTIONAL, IN DWORD nBufferLength, OUT LPWSTR lpBuffer, OUT LPWSTR *lpFilePart OPTIONAL)
Definition: path.c:1298
#define S_OK
Definition: intsafe.h:52
#define NULL
Definition: types.h:112
DWORD WINAPI ExpandEnvironmentStringsW(IN LPCWSTR lpSrc, IN LPWSTR lpDst, IN DWORD nSize)
Definition: environ.c:519
#define c
Definition: ke_i.h:80
#define HeapFree(x, y, z)
Definition: compat.h:594

Referenced by GetString().

◆ GetKey()

HRESULT STDMETHODCALLTYPE CQueryAssociations::GetKey ( ASSOCF  flags,
ASSOCKEY  key,
LPCWSTR  pwszExtra,
HKEY phkeyOut 
)
virtual

Definition at line 430 of file CQueryAssociations.cpp.

435 {
436  FIXME("(%p,0x%8x,0x%8x,%s,%p)-stub!\n", this, cfFlags, assockey,
437  debugstr_w(pszExtra), phkeyOut);
438  return E_NOTIMPL;
439 }
#define debugstr_w
Definition: kernel32.h:32
#define FIXME(fmt,...)
Definition: debug.h:111
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ GetString()

HRESULT STDMETHODCALLTYPE CQueryAssociations::GetString ( ASSOCF  flags,
ASSOCSTR  str,
LPCWSTR  pwszExtra,
LPWSTR  pwszOut,
DWORD pcchOut 
)
virtual

Definition at line 175 of file CQueryAssociations.cpp.

181 {
182  const ASSOCF unimplemented_flags = ~ASSOCF_NOTRUNCATE;
183  DWORD len = 0;
184  HRESULT hr;
186 
187  TRACE("(%p)->(0x%08x, %u, %s, %p, %p)\n", this, flags, str, debugstr_w(pszExtra), pszOut, pcchOut);
188  if (flags & unimplemented_flags)
189  {
190  FIXME("%08x: unimplemented flags\n", flags & unimplemented_flags);
191  }
192 
193  if (!pcchOut)
194  {
195  return E_UNEXPECTED;
196  }
197 
198  if (!this->hkeySource && !this->hkeyProgID)
199  {
201  }
202 
203  switch (str)
204  {
205  case ASSOCSTR_COMMAND:
206  {
207  WCHAR *command;
208  hr = this->GetCommand(pszExtra, &command);
209  if (SUCCEEDED(hr))
210  {
211  hr = this->ReturnString(flags, pszOut, pcchOut, command, strlenW(command) + 1);
213  }
214  return hr;
215  }
216  case ASSOCSTR_EXECUTABLE:
217  {
218  hr = this->GetExecutable(pszExtra, path, MAX_PATH, &len);
219  if (FAILED(hr))
220  {
221  return hr;
222  }
223  len++;
224  return this->ReturnString(flags, pszOut, pcchOut, path, len);
225  }
227  {
228  WCHAR *pszFileType;
229 
230  hr = this->GetValue(this->hkeySource, NULL, (void**)&pszFileType, NULL);
231  if (FAILED(hr))
232  {
233  return hr;
234  }
235  DWORD size = 0;
237  if (ret == ERROR_SUCCESS)
238  {
239  WCHAR *docName = static_cast<WCHAR *>(HeapAlloc(GetProcessHeap(), 0, size));
240  if (docName)
241  {
242  ret = RegGetValueW(HKEY_CLASSES_ROOT, pszFileType, NULL, RRF_RT_REG_SZ, NULL, docName, &size);
243  if (ret == ERROR_SUCCESS)
244  {
245  hr = this->ReturnString(flags, pszOut, pcchOut, docName, strlenW(docName) + 1);
246  }
247  else
248  {
250  }
251  HeapFree(GetProcessHeap(), 0, docName);
252  }
253  else
254  {
255  hr = E_OUTOFMEMORY;
256  }
257  }
258  else
259  {
261  }
262  HeapFree(GetProcessHeap(), 0, pszFileType);
263  return hr;
264  }
266  {
267  PVOID verinfoW = NULL;
268  DWORD size, retval = 0;
269  UINT flen;
270  WCHAR *bufW;
271  WCHAR fileDescW[41];
272 
273  hr = this->GetExecutable(pszExtra, path, MAX_PATH, &len);
274  if (FAILED(hr))
275  {
276  return hr;
277  }
278  retval = GetFileVersionInfoSizeW(path, &size);
279  if (!retval)
280  {
281  goto get_friendly_name_fail;
282  }
283  verinfoW = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, retval);
284  if (!verinfoW)
285  {
286  return E_OUTOFMEMORY;
287  }
288  if (!GetFileVersionInfoW(path, 0, retval, verinfoW))
289  {
290  goto get_friendly_name_fail;
291  }
292  if (VerQueryValueW(verinfoW, L"\\VarFileInfo\\Translation", (LPVOID *)&bufW, &flen))
293  {
294  UINT i;
295  DWORD *langCodeDesc = (DWORD *)bufW;
296  for (i = 0; i < flen / sizeof(DWORD); i++)
297  {
298  sprintfW(fileDescW, L"\\StringFileInfo\\%04x%04x\\FileDescription",
299  LOWORD(langCodeDesc[i]), HIWORD(langCodeDesc[i]));
300  if (VerQueryValueW(verinfoW, fileDescW, (LPVOID *)&bufW, &flen))
301  {
302  /* Does strlenW(bufW) == 0 mean we use the filename? */
303  len = strlenW(bufW) + 1;
304  TRACE("found FileDescription: %s\n", debugstr_w(bufW));
305  hr = this->ReturnString(flags, pszOut, pcchOut, bufW, len);
306  HeapFree(GetProcessHeap(), 0, verinfoW);
307  return hr;
308  }
309  }
310  }
311  get_friendly_name_fail:
314  TRACE("using filename: %s\n", debugstr_w(path));
315  hr = this->ReturnString(flags, pszOut, pcchOut, path, strlenW(path) + 1);
316  HeapFree(GetProcessHeap(), 0, verinfoW);
317  return hr;
318  }
320  {
321  DWORD size = 0;
322  DWORD ret = RegGetValueW(this->hkeySource, NULL, L"Content Type", RRF_RT_REG_SZ, NULL, NULL, &size);
323  if (ret != ERROR_SUCCESS)
324  {
325  return HRESULT_FROM_WIN32(ret);
326  }
327  WCHAR *contentType = static_cast<WCHAR *>(HeapAlloc(GetProcessHeap(), 0, size));
328  if (contentType != NULL)
329  {
330  ret = RegGetValueW(this->hkeySource, NULL, L"Content Type", RRF_RT_REG_SZ, NULL, contentType, &size);
331  if (ret == ERROR_SUCCESS)
332  {
333  hr = this->ReturnString(flags, pszOut, pcchOut, contentType, strlenW(contentType) + 1);
334  }
335  else
336  {
338  }
339  HeapFree(GetProcessHeap(), 0, contentType);
340  }
341  else
342  {
343  hr = E_OUTOFMEMORY;
344  }
345  return hr;
346  }
348  {
349  DWORD ret;
350  DWORD size = 0;
351  ret = RegGetValueW(this->hkeyProgID, L"DefaultIcon", NULL, RRF_RT_REG_SZ, NULL, NULL, &size);
352  if (ret == ERROR_SUCCESS)
353  {
354  WCHAR *icon = static_cast<WCHAR *>(HeapAlloc(GetProcessHeap(), 0, size));
355  if (icon)
356  {
357  ret = RegGetValueW(this->hkeyProgID, L"DefaultIcon", NULL, RRF_RT_REG_SZ, NULL, icon, &size);
358  if (ret == ERROR_SUCCESS)
359  {
360  hr = this->ReturnString(flags, pszOut, pcchOut, icon, strlenW(icon) + 1);
361  }
362  else
363  {
365  }
366  HeapFree(GetProcessHeap(), 0, icon);
367  }
368  else
369  {
371  }
372  }
373  else
374  {
376  }
377  return hr;
378  }
380  {
381  WCHAR keypath[ARRAY_SIZE(L"ShellEx\\") + 39], guid[39];
382  CLSID clsid;
383  HKEY hkey;
384 
385  hr = CLSIDFromString(pszExtra, &clsid);
386  if (FAILED(hr))
387  {
388  return hr;
389  }
390  strcpyW(keypath, L"ShellEx\\");
391  strcatW(keypath, pszExtra);
392  LONG ret = RegOpenKeyExW(this->hkeySource, keypath, 0, KEY_READ, &hkey);
393  if (ret)
394  {
395  return HRESULT_FROM_WIN32(ret);
396  }
397  DWORD size = sizeof(guid);
399  RegCloseKey(hkey);
400  if (ret)
401  {
402  return HRESULT_FROM_WIN32(ret);
403  }
404  return this->ReturnString(flags, pszOut, pcchOut, guid, size / sizeof(WCHAR));
405  }
406 
407  default:
408  {
409  FIXME("assocstr %d unimplemented!\n", str);
410  return E_NOTIMPL;
411  }
412  }
413 }
LSTATUS WINAPI RegGetValueW(HKEY hKey, LPCWSTR pszSubKey, LPCWSTR pszValue, DWORD dwFlags, LPDWORD pdwType, PVOID pvData, LPDWORD pcbData)
Definition: reg.c:1965
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
#define ERROR_SUCCESS
Definition: deptool.c:10
void WINAPI PathStripPathW(LPWSTR lpszPath)
Definition: path.c:694
HRESULT hr
Definition: shlfolder.c:183
#define KEY_READ
Definition: nt_native.h:1023
#define RRF_RT_REG_SZ
Definition: driver.c:575
#define DWORD
Definition: nt_native.h:44
HRESULT GetValue(HKEY hkey, const WCHAR *name, void **data, DWORD *data_size)
const GUID * guid
#define L(x)
Definition: ntvdm.h:50
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
void WINAPI PathRemoveExtensionW(LPWSTR lpszPath)
Definition: path.c:823
long LONG
Definition: pedump.c:60
HRESULT GetCommand(const WCHAR *extra, WCHAR **command)
if SUCCEEDED(hr)
#define debugstr_w
Definition: kernel32.h:32
#define FIXME(fmt,...)
Definition: debug.h:111
const WCHAR * str
#define TRACE(s)
Definition: solgame.cpp:4
GLsizeiptr size
Definition: glext.h:5919
#define GetProcessHeap()
Definition: compat.h:595
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:79
HRESULT GetExecutable(LPCWSTR pszExtra, LPWSTR path, DWORD pathlen, DWORD *len)
#define MAX_PATH
Definition: compat.h:34
unsigned long DWORD
Definition: ntddk_ex.h:95
GLbitfield flags
Definition: glext.h:7161
int ret
REFCLSID clsid
Definition: msctf.c:82
DWORD WINAPI GetFileVersionInfoSizeW(LPCWSTR filename, LPDWORD handle)
Definition: version.c:611
HRESULT ReturnString(ASSOCF flags, LPWSTR out, DWORD *outlen, LPCWSTR data, DWORD datalen)
GLenum GLsizei len
Definition: glext.h:6722
WINE_UNICODE_INLINE WCHAR * strcpyW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:219
#define ERROR_NO_ASSOCIATION
Definition: winerror.h:677
DWORD ASSOCF
Definition: shlwapi.h:599
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
#define ARRAY_SIZE(a)
Definition: main.h:24
#define E_NOTIMPL
Definition: ddrawi.h:99
#define sprintfW
Definition: unicode.h:58
WINE_UNICODE_INLINE WCHAR * strcatW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:242
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 E_UNEXPECTED
Definition: winerror.h:2456
int command(const char *fmt,...)
Definition: ftp.c:266
HRESULT WINAPI CLSIDFromString(LPCOLESTR idstr, LPCLSID id)
Definition: compobj.c:2338
#define HIWORD(l)
Definition: typedefs.h:247
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 LOWORD(l)
Definition: pedump.c:82
#define HeapFree(x, y, z)
Definition: compat.h:594
#define RegCloseKey(hKey)
Definition: registry.h:47
BOOL WINAPI VerQueryValueW(LPCVOID pBlock, LPCWSTR lpSubBlock, LPVOID *lplpBuffer, PUINT puLen)
Definition: version.c:1049

◆ GetValue()

HRESULT CQueryAssociations::GetValue ( HKEY  hkey,
const WCHAR name,
void **  data,
DWORD data_size 
)
private

Definition at line 531 of file CQueryAssociations.cpp.

532 {
533  DWORD size;
534  LONG ret;
535 
536  ret = RegQueryValueExW(hkey, name, 0, NULL, NULL, &size);
537  if (ret != ERROR_SUCCESS)
538  {
539  return HRESULT_FROM_WIN32(ret);
540  }
541  if (!size)
542  {
543  return E_FAIL;
544  }
545  *data = HeapAlloc(GetProcessHeap(), 0, size);
546  if (!*data)
547  {
548  return E_OUTOFMEMORY;
549  }
550  ret = RegQueryValueExW(hkey, name, 0, NULL, (LPBYTE)*data, &size);
551  if (ret != ERROR_SUCCESS)
552  {
553  HeapFree(GetProcessHeap(), 0, *data);
554  return HRESULT_FROM_WIN32(ret);
555  }
556  if(data_size)
557  {
558  *data_size = size;
559  }
560  return S_OK;
561 }
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
#define ERROR_SUCCESS
Definition: deptool.c:10
#define E_FAIL
Definition: ddrawi.h:102
unsigned char * LPBYTE
Definition: typedefs.h:53
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
long LONG
Definition: pedump.c:60
GLsizeiptr size
Definition: glext.h:5919
#define GetProcessHeap()
Definition: compat.h:595
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
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
unsigned long DWORD
Definition: ntddk_ex.h:95
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
int ret
#define S_OK
Definition: intsafe.h:52
#define NULL
Definition: types.h:112
Definition: name.c:38
#define HeapFree(x, y, z)
Definition: compat.h:594

Referenced by GetCommand(), GetData(), GetString(), and Init().

◆ Init()

HRESULT STDMETHODCALLTYPE CQueryAssociations::Init ( ASSOCF  flags,
LPCWSTR  pwszAssoc,
HKEY  hkProgid,
HWND  hwnd 
)
virtual

Definition at line 70 of file CQueryAssociations.cpp.

75 {
76  TRACE("(%p)->(%d,%s,%p,%p)\n", this,
77  cfFlags,
78  debugstr_w(pszAssoc),
79  hkeyProgid,
80  hWnd);
81 
82  if (hWnd != NULL)
83  {
84  FIXME("hwnd != NULL not supported\n");
85  }
86 
87  if (cfFlags != 0)
88  {
89  FIXME("unsupported flags: %x\n", cfFlags);
90  }
91 
92  RegCloseKey(this->hkeySource);
93  RegCloseKey(this->hkeyProgID);
94  this->hkeySource = this->hkeyProgID = NULL;
95  if (pszAssoc != NULL)
96  {
97  WCHAR *progId;
98  HRESULT hr;
99 
101  pszAssoc,
102  0,
103  KEY_READ,
104  &this->hkeySource);
105  if (ret)
106  {
107  return S_OK;
108  }
109 
110  /* if this is a progid */
111  if (*pszAssoc != '.' && *pszAssoc != '{')
112  {
113  this->hkeyProgID = this->hkeySource;
114  return S_OK;
115  }
116 
117  /* if it's not a progid, it's a file extension or clsid */
118  if (*pszAssoc == '.')
119  {
120  /* for a file extension, the progid is the default value */
121  hr = this->GetValue(this->hkeySource, NULL, (void**)&progId, NULL);
122  if (FAILED(hr))
123  return S_OK;
124  }
125  else /* if (*pszAssoc == '{') */
126  {
127  HKEY progIdKey;
128  /* for a clsid, the progid is the default value of the ProgID subkey */
129  ret = RegOpenKeyExW(this->hkeySource, L"ProgID", 0, KEY_READ, &progIdKey);
130  if (ret != ERROR_SUCCESS)
131  return S_OK;
132  hr = this->GetValue(progIdKey, NULL, (void**)&progId, NULL);
133  if (FAILED(hr))
134  return S_OK;
135  RegCloseKey(progIdKey);
136  }
137 
138  /* open the actual progid key, the one with the shell subkey */
140  progId,
141  0,
142  KEY_READ,
143  &this->hkeyProgID);
144  HeapFree(GetProcessHeap(), 0, progId);
145 
146  return S_OK;
147  }
148  else if (hkeyProgid != NULL)
149  {
150  /* reopen the key so we don't end up closing a key owned by the caller */
151  RegOpenKeyExW(hkeyProgid, NULL, 0, KEY_READ, &this->hkeyProgID);
152  this->hkeySource = this->hkeyProgID;
153  return S_OK;
154  }
155  else
156  return E_INVALIDARG;
157 }
#define ERROR_SUCCESS
Definition: deptool.c:10
HRESULT hr
Definition: shlfolder.c:183
#define KEY_READ
Definition: nt_native.h:1023
HWND hWnd
Definition: settings.c:17
HRESULT GetValue(HKEY hkey, const WCHAR *name, void **data, DWORD *data_size)
#define L(x)
Definition: ntvdm.h:50
long LONG
Definition: pedump.c:60
#define debugstr_w
Definition: kernel32.h:32
#define FIXME(fmt,...)
Definition: debug.h:111
#define E_INVALIDARG
Definition: ddrawi.h:101
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:595
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:79
int ret
#define S_OK
Definition: intsafe.h:52
#define NULL
Definition: types.h:112
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 HeapFree(x, y, z)
Definition: compat.h:594
#define RegCloseKey(hKey)
Definition: registry.h:47

◆ ReturnData()

HRESULT CQueryAssociations::ReturnData ( void out,
DWORD outlen,
const void data,
DWORD  datalen 
)
private

Definition at line 718 of file CQueryAssociations.cpp.

719 {
720  if (out)
721  {
722  if (*outlen < datalen)
723  {
724  *outlen = datalen;
725  return E_POINTER;
726  }
727  *outlen = datalen;
728  memcpy(out, data, datalen);
729  return S_OK;
730  }
731  else
732  {
733  *outlen = datalen;
734  return S_FALSE;
735  }
736 }
int const JOCTET unsigned int datalen
Definition: jpeglib.h:1030
#define S_FALSE
Definition: winerror.h:2357
static FILE * out
Definition: regtests2xml.c:44
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define S_OK
Definition: intsafe.h:52
#define E_POINTER
Definition: winerror.h:2365

Referenced by GetData().

◆ ReturnString()

HRESULT CQueryAssociations::ReturnString ( ASSOCF  flags,
LPWSTR  out,
DWORD outlen,
LPCWSTR  data,
DWORD  datalen 
)
private

Definition at line 738 of file CQueryAssociations.cpp.

739 {
740  HRESULT hr = S_OK;
741  DWORD len;
742 
743  TRACE("flags=0x%08x, data=%s\n", flags, debugstr_w(data));
744 
745  if (!out)
746  {
747  *outlen = datalen;
748  return S_FALSE;
749  }
750 
751  if (*outlen < datalen)
752  {
753  if (flags & ASSOCF_NOTRUNCATE)
754  {
755  len = 0;
756  if (*outlen > 0) out[0] = 0;
757  hr = E_POINTER;
758  }
759  else
760  {
761  len = min(*outlen, datalen);
763  }
764  *outlen = datalen;
765  }
766  else
767  {
768  len = datalen;
769  }
770 
771  if (len)
772  {
773  memcpy(out, data, len*sizeof(WCHAR));
774  }
775 
776  return hr;
777 }
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
HRESULT hr
Definition: shlfolder.c:183
int const JOCTET unsigned int datalen
Definition: jpeglib.h:1030
#define debugstr_w
Definition: kernel32.h:32
#define S_FALSE
Definition: winerror.h:2357
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:79
static FILE * out
Definition: regtests2xml.c:44
unsigned long DWORD
Definition: ntddk_ex.h:95
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLbitfield flags
Definition: glext.h:7161
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLenum GLsizei len
Definition: glext.h:6722
#define S_OK
Definition: intsafe.h:52
#define min(a, b)
Definition: monoChain.cc:55
#define E_POINTER
Definition: winerror.h:2365
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

Referenced by GetString().

Member Data Documentation

◆ hkeyProgID

HKEY CQueryAssociations::hkeyProgID
private

Definition at line 10 of file CQueryAssociations.h.

Referenced by GetData(), GetString(), and Init().

◆ hkeySource

HKEY CQueryAssociations::hkeySource
private

Definition at line 9 of file CQueryAssociations.h.

Referenced by GetCommand(), GetString(), and Init().


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