ReactOS 0.4.16-dev-456-ga97fcf1
CQueryAssociations Class Reference

#include <CQueryAssociations.h>

Inheritance diagram for CQueryAssociations:
Collaboration diagram for CQueryAssociations:

Public Member Functions

 CQueryAssociations ()
 
 ~CQueryAssociations ()
 
STDMETHOD() Init (ASSOCF flags, LPCWSTR pwszAssoc, HKEY hkProgid, HWND hwnd) override
 
STDMETHOD() GetString (ASSOCF flags, ASSOCSTR str, LPCWSTR pwszExtra, LPWSTR pwszOut, DWORD *pcchOut) override
 
STDMETHOD() GetKey (ASSOCF flags, ASSOCKEY key, LPCWSTR pwszExtra, HKEY *phkeyOut) override
 
STDMETHOD() GetData (ASSOCF flags, ASSOCDATA data, LPCWSTR pwszExtra, void *pvOut, DWORD *pcbOut) override
 
STDMETHOD() GetEnum (ASSOCF cfFlags, ASSOCENUM assocenum, LPCWSTR pszExtra, REFIID riid, LPVOID *ppvOut) override
 
- 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 97 of file CQueryAssociations.cpp.

◆ ~CQueryAssociations()

CQueryAssociations::~CQueryAssociations ( )

Definition at line 101 of file CQueryAssociations.cpp.

102{
103}

Member Function Documentation

◆ GetCommand()

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

Definition at line 618 of file CQueryAssociations.cpp.

619{
620 HKEY hkeyCommand;
621 HKEY hkeyShell;
622 HKEY hkeyVerb;
623 HRESULT hr;
624 LONG ret;
625 WCHAR *extra_from_reg = NULL;
627
628 /* When looking for file extension it's possible to have a default value
629 that points to another key that contains 'shell/<verb>/command' subtree. */
630 hr = this->GetValue(this->hkeySource, NULL, (void**)&filetype, NULL);
631 if (hr == S_OK)
632 {
633 HKEY hkeyFile;
634
637
638 if (ret == ERROR_SUCCESS)
639 {
640 ret = RegOpenKeyExW(hkeyFile, L"shell", 0, KEY_READ, &hkeyShell);
641 RegCloseKey(hkeyFile);
642 }
643 else
644 {
645 ret = RegOpenKeyExW(this->hkeySource, L"shell", 0, KEY_READ, &hkeyShell);
646 }
647 }
648 else
649 {
650 ret = RegOpenKeyExW(this->hkeySource, L"shell", 0, KEY_READ, &hkeyShell);
651 }
652
653 if (ret)
654 {
655 return HRESULT_FROM_WIN32(ret);
656 }
657
658 if (!extra)
659 {
660 /* check for default verb */
661 hr = this->GetValue(hkeyShell, NULL, (void**)&extra_from_reg, NULL);
662 if (FAILED(hr))
663 hr = this->GetValue(hkeyShell, L"open", (void**)&extra_from_reg, NULL);
664 if (FAILED(hr))
665 {
666 /* no default verb, try first subkey */
667 DWORD max_subkey_len;
668
669 ret = RegQueryInfoKeyW(hkeyShell, NULL, NULL, NULL, NULL, &max_subkey_len, NULL, NULL, NULL, NULL, NULL, NULL);
670 if (ret)
671 {
672 RegCloseKey(hkeyShell);
673 return HRESULT_FROM_WIN32(ret);
674 }
675
676 max_subkey_len++;
677 extra_from_reg = static_cast<WCHAR*>(HeapAlloc(GetProcessHeap(), 0, max_subkey_len * sizeof(WCHAR)));
678 if (!extra_from_reg)
679 {
680 RegCloseKey(hkeyShell);
681 return E_OUTOFMEMORY;
682 }
683
684 ret = RegEnumKeyExW(hkeyShell, 0, extra_from_reg, &max_subkey_len, NULL, NULL, NULL, NULL);
685 if (ret)
686 {
687 HeapFree(GetProcessHeap(), 0, extra_from_reg);
688 RegCloseKey(hkeyShell);
689 return HRESULT_FROM_WIN32(ret);
690 }
691 }
692 extra = extra_from_reg;
693 }
694
695 /* open verb subkey */
696 ret = RegOpenKeyExW(hkeyShell, extra, 0, KEY_READ, &hkeyVerb);
697 HeapFree(GetProcessHeap(), 0, extra_from_reg);
698 RegCloseKey(hkeyShell);
699 if (ret)
700 {
701 return HRESULT_FROM_WIN32(ret);
702 }
703 /* open command subkey */
704 ret = RegOpenKeyExW(hkeyVerb, L"command", 0, KEY_READ, &hkeyCommand);
705 RegCloseKey(hkeyVerb);
706 if (ret)
707 {
708 return HRESULT_FROM_WIN32(ret);
709 }
710 hr = this->GetValue(hkeyCommand, NULL, (void**)command, NULL);
711 RegCloseKey(hkeyCommand);
712 return hr;
713}
#define RegCloseKey(hKey)
Definition: registry.h:49
HRESULT GetValue(HKEY hkey, const WCHAR *name, void **data, DWORD *data_size)
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NULL
Definition: types.h:112
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3333
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:2504
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:3662
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
unsigned long DWORD
Definition: ntddk_ex.h:95
@ extra
Definition: id3.c:95
#define S_OK
Definition: intsafe.h:52
#define FAILED(hr)
Definition: intsafe.h:51
#define KEY_READ
Definition: nt_native.h:1023
#define L(x)
Definition: ntvdm.h:50
long LONG
Definition: pedump.c:60
LOCAL char * filetype(int t)
Definition: tree.c:114
HRESULT hr
Definition: shlfolder.c:183
int ret
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
#define HKEY_CLASSES_ROOT
Definition: winreg.h:10
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by GetExecutable(), and GetString().

◆ GetData()

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

Definition at line 515 of file CQueryAssociations.cpp.

516{
517 TRACE("(%p,0x%8x,0x%8x,%s,%p,%p)\n", this, cfFlags, assocdata,
518 debugstr_w(pszExtra), pvOut, pcbOut);
519
520 if(cfFlags)
521 {
522 FIXME("Unsupported flags: %x\n", cfFlags);
523 }
524
525 switch(assocdata)
526 {
528 {
529 if(!this->hkeyProgID)
530 {
532 }
533
534 void *data;
535 DWORD size;
536 HRESULT hres = this->GetValue(this->hkeyProgID, L"EditFlags", &data, &size);
537 if(FAILED(hres))
538 {
539 return hres;
540 }
541
542 if (!pcbOut)
543 {
545 return hres;
546 }
547
548 hres = this->ReturnData(pvOut, pcbOut, data, size);
550 return hres;
551 }
552 default:
553 {
554 FIXME("Unsupported ASSOCDATA value: %d\n", assocdata);
555 return E_NOTIMPL;
556 }
557 }
558}
#define FIXME(fmt,...)
Definition: precomp.h:53
HRESULT ReturnData(void *out, DWORD *outlen, const void *data, DWORD datalen)
#define E_NOTIMPL
Definition: ddrawi.h:99
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLsizeiptr size
Definition: glext.h:5919
#define debugstr_w
Definition: kernel32.h:32
HRESULT hres
Definition: protocol.c:465
@ ASSOCDATA_EDITFLAGS
Definition: shlwapi.h:637
#define TRACE(s)
Definition: solgame.cpp:4
#define ERROR_NO_ASSOCIATION
Definition: winerror.h:677

◆ GetEnum()

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

Definition at line 579 of file CQueryAssociations.cpp.

585{
586 return E_NOTIMPL;
587}

◆ GetExecutable()

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

Definition at line 715 of file CQueryAssociations.cpp.

716{
717 WCHAR *pszCommand;
718 WCHAR *pszStart;
719 WCHAR *pszEnd;
720
721 HRESULT hr = this->GetCommand(pszExtra, &pszCommand);
723 {
724 return hr;
725 }
726
727 DWORD expLen = ExpandEnvironmentStringsW(pszCommand, NULL, 0);
728 if (expLen > 0)
729 {
730 expLen++;
731 WCHAR *buf = static_cast<WCHAR *>(HeapAlloc(GetProcessHeap(), 0, expLen * sizeof(WCHAR)));
732 ExpandEnvironmentStringsW(pszCommand, buf, expLen);
733 HeapFree(GetProcessHeap(), 0, pszCommand);
734 pszCommand = buf;
735 }
736
737 /* cleanup pszCommand */
738 if (pszCommand[0] == '"')
739 {
740 pszStart = pszCommand + 1;
741 pszEnd = strchrW(pszStart, '"');
742 if (pszEnd)
743 {
744 *pszEnd = 0;
745 }
746 *len = SearchPathW(NULL, pszStart, NULL, pathlen, path, NULL);
747 }
748 else
749 {
750 pszStart = pszCommand;
751 for (pszEnd = pszStart; (pszEnd = strchrW(pszEnd, ' ')); pszEnd++)
752 {
753 WCHAR c = *pszEnd;
754 *pszEnd = 0;
755 if ((*len = SearchPathW(NULL, pszStart, NULL, pathlen, path, NULL)))
756 {
757 break;
758 }
759 *pszEnd = c;
760 }
761 if (!pszEnd)
762 {
763 *len = SearchPathW(NULL, pszStart, NULL, pathlen, path, NULL);
764 }
765 }
766
767 HeapFree(GetProcessHeap(), 0, pszCommand);
768 if (!*len)
769 {
771 }
772 return S_OK;
773}
HRESULT GetCommand(const WCHAR *extra, WCHAR **command)
#define FAILED_UNEXPECTEDLY(hr)
Definition: precomp.h:121
DWORD WINAPI ExpandEnvironmentStringsW(IN LPCWSTR lpSrc, IN LPWSTR lpDst, IN DWORD nSize)
Definition: environ.c:519
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
const GLubyte * c
Definition: glext.h:8905
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLenum GLsizei len
Definition: glext.h:6722
#define c
Definition: ke_i.h:80
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
#define strchrW(s, c)
Definition: unicode.h:40

Referenced by GetString().

◆ GetKey()

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

Definition at line 488 of file CQueryAssociations.cpp.

493{
494 FIXME("(%p,0x%8x,0x%8x,%s,%p)-stub!\n", this, cfFlags, assockey,
495 debugstr_w(pszExtra), phkeyOut);
496 return E_NOTIMPL;
497}

◆ GetString()

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

Definition at line 233 of file CQueryAssociations.cpp.

239{
240 const ASSOCF unimplemented_flags = ~ASSOCF_NOTRUNCATE;
241 DWORD len = 0;
242 HRESULT hr;
244
245 TRACE("(%p)->(0x%08x, %u, %s, %p, %p)\n", this, flags, str, debugstr_w(pszExtra), pszOut, pcchOut);
246 if (flags & unimplemented_flags)
247 {
248 FIXME("%08x: unimplemented flags\n", flags & unimplemented_flags);
249 }
250
251 if (!pcchOut)
252 {
253 return E_UNEXPECTED;
254 }
255
256 if (!this->hkeySource && !this->hkeyProgID)
257 {
259 }
260
261 switch (str)
262 {
263 case ASSOCSTR_COMMAND:
264 {
265 WCHAR *command;
266 hr = this->GetCommand(pszExtra, &command);
267 if (SUCCEEDED(hr))
268 {
269 hr = this->ReturnString(flags, pszOut, pcchOut, command, strlenW(command) + 1);
271 }
272 return hr;
273 }
275 {
276 hr = this->GetExecutable(pszExtra, path, MAX_PATH, &len);
278 {
279 return hr;
280 }
281 len++;
282 return this->ReturnString(flags, pszOut, pcchOut, path, len);
283 }
285 {
286 WCHAR *pszFileType;
287
288 hr = this->GetValue(this->hkeySource, NULL, (void**)&pszFileType, NULL);
289 if (FAILED(hr))
290 {
291 return hr;
292 }
293 DWORD size = 0;
295 if (ret == ERROR_SUCCESS)
296 {
297 WCHAR *docName = static_cast<WCHAR *>(HeapAlloc(GetProcessHeap(), 0, size));
298 if (docName)
299 {
300 ret = RegGetValueW(HKEY_CLASSES_ROOT, pszFileType, NULL, RRF_RT_REG_SZ, NULL, docName, &size);
301 if (ret == ERROR_SUCCESS)
302 {
303 hr = this->ReturnString(flags, pszOut, pcchOut, docName, strlenW(docName) + 1);
304 }
305 else
306 {
308 }
309 HeapFree(GetProcessHeap(), 0, docName);
310 }
311 else
312 {
314 }
315 }
316 else
317 {
319 }
320 HeapFree(GetProcessHeap(), 0, pszFileType);
321 return hr;
322 }
324 {
325 PVOID verinfoW = NULL;
326 DWORD size, retval = 0;
327 UINT flen;
328 WCHAR *bufW;
329 WCHAR fileDescW[41];
330
331 hr = this->GetExecutable(pszExtra, path, MAX_PATH, &len);
332 if (FAILED(hr))
333 {
334 return hr;
335 }
337 if (!retval)
338 {
339 goto get_friendly_name_fail;
340 }
341 verinfoW = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, retval);
342 if (!verinfoW)
343 {
344 return E_OUTOFMEMORY;
345 }
346 if (!GetFileVersionInfoW(path, 0, retval, verinfoW))
347 {
348 goto get_friendly_name_fail;
349 }
350 if (VerQueryValueW(verinfoW, L"\\VarFileInfo\\Translation", (LPVOID *)&bufW, &flen))
351 {
352 UINT i;
353 DWORD *langCodeDesc = (DWORD *)bufW;
354 for (i = 0; i < flen / sizeof(DWORD); i++)
355 {
356 sprintfW(fileDescW, L"\\StringFileInfo\\%04x%04x\\FileDescription",
357 LOWORD(langCodeDesc[i]), HIWORD(langCodeDesc[i]));
358 if (VerQueryValueW(verinfoW, fileDescW, (LPVOID *)&bufW, &flen))
359 {
360 /* Does strlenW(bufW) == 0 mean we use the filename? */
361 len = strlenW(bufW) + 1;
362 TRACE("found FileDescription: %s\n", debugstr_w(bufW));
363 hr = this->ReturnString(flags, pszOut, pcchOut, bufW, len);
364 HeapFree(GetProcessHeap(), 0, verinfoW);
365 return hr;
366 }
367 }
368 }
369 get_friendly_name_fail:
372 TRACE("using filename: %s\n", debugstr_w(path));
373 hr = this->ReturnString(flags, pszOut, pcchOut, path, strlenW(path) + 1);
374 HeapFree(GetProcessHeap(), 0, verinfoW);
375 return hr;
376 }
378 {
379 DWORD size = 0;
380 DWORD ret = RegGetValueW(this->hkeySource, NULL, L"Content Type", RRF_RT_REG_SZ, NULL, NULL, &size);
381 if (ret != ERROR_SUCCESS)
382 {
383 return HRESULT_FROM_WIN32(ret);
384 }
385 WCHAR *contentType = static_cast<WCHAR *>(HeapAlloc(GetProcessHeap(), 0, size));
386 if (contentType != NULL)
387 {
388 ret = RegGetValueW(this->hkeySource, NULL, L"Content Type", RRF_RT_REG_SZ, NULL, contentType, &size);
389 if (ret == ERROR_SUCCESS)
390 {
391 hr = this->ReturnString(flags, pszOut, pcchOut, contentType, strlenW(contentType) + 1);
392 }
393 else
394 {
396 }
397 HeapFree(GetProcessHeap(), 0, contentType);
398 }
399 else
400 {
402 }
403 return hr;
404 }
406 {
407 DWORD ret;
408 DWORD size = 0;
409 ret = RegGetValueW(this->hkeyProgID, L"DefaultIcon", NULL, RRF_RT_REG_SZ, NULL, NULL, &size);
410 if (ret == ERROR_SUCCESS)
411 {
412 WCHAR *icon = static_cast<WCHAR *>(HeapAlloc(GetProcessHeap(), 0, size));
413 if (icon)
414 {
415 ret = RegGetValueW(this->hkeyProgID, L"DefaultIcon", NULL, RRF_RT_REG_SZ, NULL, icon, &size);
416 if (ret == ERROR_SUCCESS)
417 {
418 hr = this->ReturnString(flags, pszOut, pcchOut, icon, strlenW(icon) + 1);
419 }
420 else
421 {
423 }
424 HeapFree(GetProcessHeap(), 0, icon);
425 }
426 else
427 {
429 }
430 }
431 else
432 {
434 }
435 return hr;
436 }
438 {
439 WCHAR keypath[ARRAY_SIZE(L"ShellEx\\") + 39], guid[39];
440 CLSID clsid;
441 HKEY hkey;
442
443 hr = CLSIDFromString(pszExtra, &clsid);
444 if (FAILED(hr))
445 {
446 return hr;
447 }
448 strcpyW(keypath, L"ShellEx\\");
449 strcatW(keypath, pszExtra);
450 LONG ret = RegOpenKeyExW(this->hkeySource, keypath, 0, KEY_READ, &hkey);
451 if (ret)
452 {
453 return HRESULT_FROM_WIN32(ret);
454 }
455 DWORD size = sizeof(guid);
457 RegCloseKey(hkey);
458 if (ret)
459 {
460 return HRESULT_FROM_WIN32(ret);
461 }
462 return this->ReturnString(flags, pszOut, pcchOut, guid, size / sizeof(WCHAR));
463 }
464
465 default:
466 {
467 FIXME("assocstr %d unimplemented!\n", str);
468 return E_NOTIMPL;
469 }
470 }
471}
#define ARRAY_SIZE(A)
Definition: main.h:20
HRESULT ReturnString(ASSOCF flags, LPWSTR out, DWORD *outlen, LPCWSTR data, DWORD datalen)
HRESULT GetExecutable(LPCWSTR pszExtra, LPWSTR path, DWORD pathlen, DWORD *len)
LSTATUS WINAPI RegGetValueW(HKEY hKey, LPCWSTR pszSubKey, LPCWSTR pszValue, DWORD dwFlags, LPDWORD pdwType, PVOID pvData, LPDWORD pcbData)
Definition: reg.c:1931
#define MAX_PATH
Definition: compat.h:34
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
HRESULT WINAPI CLSIDFromString(LPCOLESTR idstr, LPCLSID id)
Definition: compobj.c:2338
#define RRF_RT_REG_SZ
Definition: driver.c:575
void WINAPI PathStripPathW(LPWSTR lpszPath)
Definition: path.c:694
void WINAPI PathRemoveExtensionW(LPWSTR lpszPath)
Definition: path.c:823
BOOL WINAPI GetFileVersionInfoW(LPCWSTR filename, DWORD handle, DWORD datasize, LPVOID data)
Definition: version.c:845
BOOL WINAPI VerQueryValueW(LPCVOID pBlock, LPCWSTR lpSubBlock, LPVOID *lplpBuffer, PUINT puLen)
Definition: version.c:1057
DWORD WINAPI GetFileVersionInfoSizeW(LPCWSTR filename, LPDWORD handle)
Definition: version.c:611
GLbitfield flags
Definition: glext.h:7161
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 SUCCEEDED(hr)
Definition: intsafe.h:50
const GUID * guid
REFCLSID clsid
Definition: msctf.c:82
unsigned int UINT
Definition: ndis.h:50
#define DWORD
Definition: nt_native.h:44
#define LOWORD(l)
Definition: pedump.c:82
#define strlenW(s)
Definition: unicode.h:34
#define strcatW(d, s)
Definition: unicode.h:36
#define sprintfW
Definition: unicode.h:64
#define strcpyW(d, s)
Definition: unicode.h:35
const WCHAR * str
@ ASSOCSTR_CONTENTTYPE
Definition: shlwapi.h:616
@ ASSOCSTR_SHELLEXTENSION
Definition: shlwapi.h:618
@ ASSOCSTR_COMMAND
Definition: shlwapi.h:603
@ ASSOCSTR_FRIENDLYDOCNAME
Definition: shlwapi.h:605
@ ASSOCSTR_FRIENDLYAPPNAME
Definition: shlwapi.h:606
@ ASSOCSTR_EXECUTABLE
Definition: shlwapi.h:604
@ ASSOCSTR_DEFAULTICON
Definition: shlwapi.h:617
DWORD ASSOCF
Definition: shlwapi.h:599
#define HIWORD(l)
Definition: typedefs.h:247
#define E_UNEXPECTED
Definition: winerror.h:2456

◆ GetValue()

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

Definition at line 589 of file CQueryAssociations.cpp.

590{
591 DWORD size;
592 LONG ret;
593
594 ret = RegQueryValueExW(hkey, name, 0, NULL, NULL, &size);
595 if (ret != ERROR_SUCCESS)
596 return HRESULT_FROM_WIN32(ret);
597
598 if (!size)
599 return E_FAIL;
600
602 if (!*data)
603 return E_OUTOFMEMORY;
604
605 ret = RegQueryValueExW(hkey, name, 0, NULL, (LPBYTE)*data, &size);
606 if (ret != ERROR_SUCCESS)
607 {
609 return HRESULT_FROM_WIN32(ret);
610 }
611
612 if (data_size)
613 *data_size = size;
614
615 return S_OK;
616}
#define E_FAIL
Definition: ddrawi.h:102
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4103
Definition: name.c:39
unsigned char * LPBYTE
Definition: typedefs.h:53

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

◆ Init()

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

Definition at line 120 of file CQueryAssociations.cpp.

125{
126 TRACE("(%p)->(%d,%s,%p,%p)\n", this,
127 cfFlags,
128 debugstr_w(pszAssoc),
129 hkeyProgid,
130 hWnd);
131
132 if (hWnd != NULL)
133 {
134 FIXME("hwnd != NULL not supported\n");
135 }
136
137 if (cfFlags != 0)
138 {
139 FIXME("unsupported flags: %x\n", cfFlags);
140 }
141
142 RegCloseKey(this->hkeySource);
143 RegCloseKey(this->hkeyProgID);
144 this->hkeySource = this->hkeyProgID = NULL;
145 if (pszAssoc != NULL)
146 {
147 WCHAR *progId;
148 HRESULT hr;
149 LPCWSTR pchDotExt;
150
151 if (StrChrW(pszAssoc, L'\\'))
152 {
153 pchDotExt = PathFindExtensionW(pszAssoc);
154 if (pchDotExt && *pchDotExt)
155 pszAssoc = pchDotExt;
156 }
157
159 pszAssoc,
160 0,
161 KEY_READ,
162 &this->hkeySource);
163 if (ret)
164 {
165 return S_OK;
166 }
167
168 /* if this is a progid */
169 if (*pszAssoc != '.' && *pszAssoc != '{')
170 {
171 this->hkeyProgID = this->hkeySource;
172 return S_OK;
173 }
174
175 /* if it's not a progid, it's a file extension or clsid */
176 if (*pszAssoc == '.')
177 {
178 /* for a file extension, the progid is the default value */
179 hr = this->GetValue(this->hkeySource, NULL, (void**)&progId, NULL);
180 if (FAILED(hr))
181 return S_OK;
182 }
183 else /* if (*pszAssoc == '{') */
184 {
185 HKEY progIdKey;
186 /* for a clsid, the progid is the default value of the ProgID subkey */
187 ret = RegOpenKeyExW(this->hkeySource, L"ProgID", 0, KEY_READ, &progIdKey);
188 if (ret != ERROR_SUCCESS)
189 return S_OK;
190 hr = this->GetValue(progIdKey, NULL, (void**)&progId, NULL);
191 if (FAILED(hr))
192 return S_OK;
193 RegCloseKey(progIdKey);
194 }
195
196 /* open the actual progid key, the one with the shell subkey */
198 progId,
199 0,
200 KEY_READ,
201 &this->hkeyProgID);
202 HeapFree(GetProcessHeap(), 0, progId);
203
204 return S_OK;
205 }
206 else if (hkeyProgid != NULL)
207 {
208 /* reopen the key so we don't end up closing a key owned by the caller */
209 RegOpenKeyExW(hkeyProgid, NULL, 0, KEY_READ, &this->hkeyProgID);
210 this->hkeySource = this->hkeyProgID;
211 return S_OK;
212 }
213 else
214 return E_INVALIDARG;
215}
HWND hWnd
Definition: settings.c:17
#define E_INVALIDARG
Definition: ddrawi.h:101
LPWSTR WINAPI StrChrW(LPCWSTR lpszStr, WCHAR ch)
Definition: string.c:464
LPWSTR WINAPI PathFindExtensionW(LPCWSTR lpszPath)
Definition: path.c:447
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185

◆ ReturnData()

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

Definition at line 775 of file CQueryAssociations.cpp.

776{
777 if (out)
778 {
779 if (*outlen < datalen)
780 {
781 *outlen = datalen;
782 return E_POINTER;
783 }
784 *outlen = datalen;
786 return S_OK;
787 }
788 else
789 {
790 *outlen = datalen;
791 return S_FALSE;
792 }
793}
int const JOCTET unsigned int datalen
Definition: jpeglib.h:1031
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static FILE * out
Definition: regtests2xml.c:44
#define S_FALSE
Definition: winerror.h:2357
#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 795 of file CQueryAssociations.cpp.

796{
797 HRESULT hr = S_OK;
798 DWORD len;
799
800 TRACE("flags=0x%08x, data=%s\n", flags, debugstr_w(data));
801
802 if (!out)
803 {
804 *outlen = datalen;
805 return S_FALSE;
806 }
807
808 if (*outlen < datalen)
809 {
811 {
812 len = 0;
813 if (*outlen > 0) out[0] = 0;
814 hr = E_POINTER;
815 }
816 else
817 {
818 len = min(*outlen, datalen);
820 }
821 *outlen = datalen;
822 }
823 else
824 {
825 *outlen = len = datalen;
826 }
827
828 if (len)
829 {
830 memcpy(out, data, len*sizeof(WCHAR));
831 }
832
833 return hr;
834}
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
#define min(a, b)
Definition: monoChain.cc:55
@ ASSOCF_NOTRUNCATE
Definition: shlwapi.h:588

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: