ReactOS 0.4.16-dev-197-g92996da
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 47 of file CQueryAssociations.cpp.

◆ ~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 568 of file CQueryAssociations.cpp.

569{
570 HKEY hkeyCommand;
571 HKEY hkeyShell;
572 HKEY hkeyVerb;
573 HRESULT hr;
574 LONG ret;
575 WCHAR *extra_from_reg = NULL;
577
578 /* When looking for file extension it's possible to have a default value
579 that points to another key that contains 'shell/<verb>/command' subtree. */
580 hr = this->GetValue(this->hkeySource, NULL, (void**)&filetype, NULL);
581 if (hr == S_OK)
582 {
583 HKEY hkeyFile;
584
587
588 if (ret == ERROR_SUCCESS)
589 {
590 ret = RegOpenKeyExW(hkeyFile, L"shell", 0, KEY_READ, &hkeyShell);
591 RegCloseKey(hkeyFile);
592 }
593 else
594 {
595 ret = RegOpenKeyExW(this->hkeySource, L"shell", 0, KEY_READ, &hkeyShell);
596 }
597 }
598 else
599 {
600 ret = RegOpenKeyExW(this->hkeySource, L"shell", 0, KEY_READ, &hkeyShell);
601 }
602
603 if (ret)
604 {
605 return HRESULT_FROM_WIN32(ret);
606 }
607
608 if (!extra)
609 {
610 /* check for default verb */
611 hr = this->GetValue(hkeyShell, NULL, (void**)&extra_from_reg, NULL);
612 if (FAILED(hr))
613 hr = this->GetValue(hkeyShell, L"open", (void**)&extra_from_reg, NULL);
614 if (FAILED(hr))
615 {
616 /* no default verb, try first subkey */
617 DWORD max_subkey_len;
618
619 ret = RegQueryInfoKeyW(hkeyShell, NULL, NULL, NULL, NULL, &max_subkey_len, NULL, NULL, NULL, NULL, NULL, NULL);
620 if (ret)
621 {
622 RegCloseKey(hkeyShell);
623 return HRESULT_FROM_WIN32(ret);
624 }
625
626 max_subkey_len++;
627 extra_from_reg = static_cast<WCHAR*>(HeapAlloc(GetProcessHeap(), 0, max_subkey_len * sizeof(WCHAR)));
628 if (!extra_from_reg)
629 {
630 RegCloseKey(hkeyShell);
631 return E_OUTOFMEMORY;
632 }
633
634 ret = RegEnumKeyExW(hkeyShell, 0, extra_from_reg, &max_subkey_len, NULL, NULL, NULL, NULL);
635 if (ret)
636 {
637 HeapFree(GetProcessHeap(), 0, extra_from_reg);
638 RegCloseKey(hkeyShell);
639 return HRESULT_FROM_WIN32(ret);
640 }
641 }
642 extra = extra_from_reg;
643 }
644
645 /* open verb subkey */
646 ret = RegOpenKeyExW(hkeyShell, extra, 0, KEY_READ, &hkeyVerb);
647 HeapFree(GetProcessHeap(), 0, extra_from_reg);
648 RegCloseKey(hkeyShell);
649 if (ret)
650 {
651 return HRESULT_FROM_WIN32(ret);
652 }
653 /* open command subkey */
654 ret = RegOpenKeyExW(hkeyVerb, L"command", 0, KEY_READ, &hkeyCommand);
655 RegCloseKey(hkeyVerb);
656 if (ret)
657 {
658 return HRESULT_FROM_WIN32(ret);
659 }
660 hr = this->GetValue(hkeyCommand, NULL, (void**)command, NULL);
661 RegCloseKey(hkeyCommand);
662 return hr;
663}
#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 465 of file CQueryAssociations.cpp.

466{
467 TRACE("(%p,0x%8x,0x%8x,%s,%p,%p)\n", this, cfFlags, assocdata,
468 debugstr_w(pszExtra), pvOut, pcbOut);
469
470 if(cfFlags)
471 {
472 FIXME("Unsupported flags: %x\n", cfFlags);
473 }
474
475 switch(assocdata)
476 {
478 {
479 if(!this->hkeyProgID)
480 {
482 }
483
484 void *data;
485 DWORD size;
486 HRESULT hres = this->GetValue(this->hkeyProgID, L"EditFlags", &data, &size);
487 if(FAILED(hres))
488 {
489 return hres;
490 }
491
492 if (!pcbOut)
493 {
495 return hres;
496 }
497
498 hres = this->ReturnData(pvOut, pcbOut, data, size);
500 return hres;
501 }
502 default:
503 {
504 FIXME("Unsupported ASSOCDATA value: %d\n", assocdata);
505 return E_NOTIMPL;
506 }
507 }
508}
#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 529 of file CQueryAssociations.cpp.

535{
536 return E_NOTIMPL;
537}

◆ GetExecutable()

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

Definition at line 665 of file CQueryAssociations.cpp.

666{
667 WCHAR *pszCommand;
668 WCHAR *pszStart;
669 WCHAR *pszEnd;
670
671 HRESULT hr = this->GetCommand(pszExtra, &pszCommand);
673 {
674 return hr;
675 }
676
677 DWORD expLen = ExpandEnvironmentStringsW(pszCommand, NULL, 0);
678 if (expLen > 0)
679 {
680 expLen++;
681 WCHAR *buf = static_cast<WCHAR *>(HeapAlloc(GetProcessHeap(), 0, expLen * sizeof(WCHAR)));
682 ExpandEnvironmentStringsW(pszCommand, buf, expLen);
683 HeapFree(GetProcessHeap(), 0, pszCommand);
684 pszCommand = buf;
685 }
686
687 /* cleanup pszCommand */
688 if (pszCommand[0] == '"')
689 {
690 pszStart = pszCommand + 1;
691 pszEnd = strchrW(pszStart, '"');
692 if (pszEnd)
693 {
694 *pszEnd = 0;
695 }
696 *len = SearchPathW(NULL, pszStart, NULL, pathlen, path, NULL);
697 }
698 else
699 {
700 pszStart = pszCommand;
701 for (pszEnd = pszStart; (pszEnd = strchrW(pszEnd, ' ')); pszEnd++)
702 {
703 WCHAR c = *pszEnd;
704 *pszEnd = 0;
705 if ((*len = SearchPathW(NULL, pszStart, NULL, pathlen, path, NULL)))
706 {
707 break;
708 }
709 *pszEnd = c;
710 }
711 if (!pszEnd)
712 {
713 *len = SearchPathW(NULL, pszStart, NULL, pathlen, path, NULL);
714 }
715 }
716
717 HeapFree(GetProcessHeap(), 0, pszCommand);
718 if (!*len)
719 {
721 }
722 return S_OK;
723}
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 438 of file CQueryAssociations.cpp.

443{
444 FIXME("(%p,0x%8x,0x%8x,%s,%p)-stub!\n", this, cfFlags, assockey,
445 debugstr_w(pszExtra), phkeyOut);
446 return E_NOTIMPL;
447}

◆ GetString()

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

Definition at line 183 of file CQueryAssociations.cpp.

189{
190 const ASSOCF unimplemented_flags = ~ASSOCF_NOTRUNCATE;
191 DWORD len = 0;
192 HRESULT hr;
194
195 TRACE("(%p)->(0x%08x, %u, %s, %p, %p)\n", this, flags, str, debugstr_w(pszExtra), pszOut, pcchOut);
196 if (flags & unimplemented_flags)
197 {
198 FIXME("%08x: unimplemented flags\n", flags & unimplemented_flags);
199 }
200
201 if (!pcchOut)
202 {
203 return E_UNEXPECTED;
204 }
205
206 if (!this->hkeySource && !this->hkeyProgID)
207 {
209 }
210
211 switch (str)
212 {
213 case ASSOCSTR_COMMAND:
214 {
215 WCHAR *command;
216 hr = this->GetCommand(pszExtra, &command);
217 if (SUCCEEDED(hr))
218 {
219 hr = this->ReturnString(flags, pszOut, pcchOut, command, strlenW(command) + 1);
221 }
222 return hr;
223 }
225 {
226 hr = this->GetExecutable(pszExtra, path, MAX_PATH, &len);
228 {
229 return hr;
230 }
231 len++;
232 return this->ReturnString(flags, pszOut, pcchOut, path, len);
233 }
235 {
236 WCHAR *pszFileType;
237
238 hr = this->GetValue(this->hkeySource, NULL, (void**)&pszFileType, NULL);
239 if (FAILED(hr))
240 {
241 return hr;
242 }
243 DWORD size = 0;
245 if (ret == ERROR_SUCCESS)
246 {
247 WCHAR *docName = static_cast<WCHAR *>(HeapAlloc(GetProcessHeap(), 0, size));
248 if (docName)
249 {
250 ret = RegGetValueW(HKEY_CLASSES_ROOT, pszFileType, NULL, RRF_RT_REG_SZ, NULL, docName, &size);
251 if (ret == ERROR_SUCCESS)
252 {
253 hr = this->ReturnString(flags, pszOut, pcchOut, docName, strlenW(docName) + 1);
254 }
255 else
256 {
258 }
259 HeapFree(GetProcessHeap(), 0, docName);
260 }
261 else
262 {
264 }
265 }
266 else
267 {
269 }
270 HeapFree(GetProcessHeap(), 0, pszFileType);
271 return hr;
272 }
274 {
275 PVOID verinfoW = NULL;
276 DWORD size, retval = 0;
277 UINT flen;
278 WCHAR *bufW;
279 WCHAR fileDescW[41];
280
281 hr = this->GetExecutable(pszExtra, path, MAX_PATH, &len);
282 if (FAILED(hr))
283 {
284 return hr;
285 }
287 if (!retval)
288 {
289 goto get_friendly_name_fail;
290 }
291 verinfoW = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, retval);
292 if (!verinfoW)
293 {
294 return E_OUTOFMEMORY;
295 }
296 if (!GetFileVersionInfoW(path, 0, retval, verinfoW))
297 {
298 goto get_friendly_name_fail;
299 }
300 if (VerQueryValueW(verinfoW, L"\\VarFileInfo\\Translation", (LPVOID *)&bufW, &flen))
301 {
302 UINT i;
303 DWORD *langCodeDesc = (DWORD *)bufW;
304 for (i = 0; i < flen / sizeof(DWORD); i++)
305 {
306 sprintfW(fileDescW, L"\\StringFileInfo\\%04x%04x\\FileDescription",
307 LOWORD(langCodeDesc[i]), HIWORD(langCodeDesc[i]));
308 if (VerQueryValueW(verinfoW, fileDescW, (LPVOID *)&bufW, &flen))
309 {
310 /* Does strlenW(bufW) == 0 mean we use the filename? */
311 len = strlenW(bufW) + 1;
312 TRACE("found FileDescription: %s\n", debugstr_w(bufW));
313 hr = this->ReturnString(flags, pszOut, pcchOut, bufW, len);
314 HeapFree(GetProcessHeap(), 0, verinfoW);
315 return hr;
316 }
317 }
318 }
319 get_friendly_name_fail:
322 TRACE("using filename: %s\n", debugstr_w(path));
323 hr = this->ReturnString(flags, pszOut, pcchOut, path, strlenW(path) + 1);
324 HeapFree(GetProcessHeap(), 0, verinfoW);
325 return hr;
326 }
328 {
329 DWORD size = 0;
330 DWORD ret = RegGetValueW(this->hkeySource, NULL, L"Content Type", RRF_RT_REG_SZ, NULL, NULL, &size);
331 if (ret != ERROR_SUCCESS)
332 {
333 return HRESULT_FROM_WIN32(ret);
334 }
335 WCHAR *contentType = static_cast<WCHAR *>(HeapAlloc(GetProcessHeap(), 0, size));
336 if (contentType != NULL)
337 {
338 ret = RegGetValueW(this->hkeySource, NULL, L"Content Type", RRF_RT_REG_SZ, NULL, contentType, &size);
339 if (ret == ERROR_SUCCESS)
340 {
341 hr = this->ReturnString(flags, pszOut, pcchOut, contentType, strlenW(contentType) + 1);
342 }
343 else
344 {
346 }
347 HeapFree(GetProcessHeap(), 0, contentType);
348 }
349 else
350 {
352 }
353 return hr;
354 }
356 {
357 DWORD ret;
358 DWORD size = 0;
359 ret = RegGetValueW(this->hkeyProgID, L"DefaultIcon", NULL, RRF_RT_REG_SZ, NULL, NULL, &size);
360 if (ret == ERROR_SUCCESS)
361 {
362 WCHAR *icon = static_cast<WCHAR *>(HeapAlloc(GetProcessHeap(), 0, size));
363 if (icon)
364 {
365 ret = RegGetValueW(this->hkeyProgID, L"DefaultIcon", NULL, RRF_RT_REG_SZ, NULL, icon, &size);
366 if (ret == ERROR_SUCCESS)
367 {
368 hr = this->ReturnString(flags, pszOut, pcchOut, icon, strlenW(icon) + 1);
369 }
370 else
371 {
373 }
374 HeapFree(GetProcessHeap(), 0, icon);
375 }
376 else
377 {
379 }
380 }
381 else
382 {
384 }
385 return hr;
386 }
388 {
389 WCHAR keypath[ARRAY_SIZE(L"ShellEx\\") + 39], guid[39];
390 CLSID clsid;
391 HKEY hkey;
392
393 hr = CLSIDFromString(pszExtra, &clsid);
394 if (FAILED(hr))
395 {
396 return hr;
397 }
398 strcpyW(keypath, L"ShellEx\\");
399 strcatW(keypath, pszExtra);
400 LONG ret = RegOpenKeyExW(this->hkeySource, keypath, 0, KEY_READ, &hkey);
401 if (ret)
402 {
403 return HRESULT_FROM_WIN32(ret);
404 }
405 DWORD size = sizeof(guid);
407 RegCloseKey(hkey);
408 if (ret)
409 {
410 return HRESULT_FROM_WIN32(ret);
411 }
412 return this->ReturnString(flags, pszOut, pcchOut, guid, size / sizeof(WCHAR));
413 }
414
415 default:
416 {
417 FIXME("assocstr %d unimplemented!\n", str);
418 return E_NOTIMPL;
419 }
420 }
421}
#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 539 of file CQueryAssociations.cpp.

540{
541 DWORD size;
542 LONG ret;
543
544 ret = RegQueryValueExW(hkey, name, 0, NULL, NULL, &size);
545 if (ret != ERROR_SUCCESS)
546 return HRESULT_FROM_WIN32(ret);
547
548 if (!size)
549 return E_FAIL;
550
552 if (!*data)
553 return E_OUTOFMEMORY;
554
555 ret = RegQueryValueExW(hkey, name, 0, NULL, (LPBYTE)*data, &size);
556 if (ret != ERROR_SUCCESS)
557 {
559 return HRESULT_FROM_WIN32(ret);
560 }
561
562 if (data_size)
563 *data_size = size;
564
565 return S_OK;
566}
#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 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
94 this->hkeySource = this->hkeyProgID = NULL;
95 if (pszAssoc != NULL)
96 {
97 WCHAR *progId;
98 HRESULT hr;
99 LPCWSTR pchDotExt;
100
101 if (StrChrW(pszAssoc, L'\\'))
102 {
103 pchDotExt = PathFindExtensionW(pszAssoc);
104 if (pchDotExt && *pchDotExt)
105 pszAssoc = pchDotExt;
106 }
107
109 pszAssoc,
110 0,
111 KEY_READ,
112 &this->hkeySource);
113 if (ret)
114 {
115 return S_OK;
116 }
117
118 /* if this is a progid */
119 if (*pszAssoc != '.' && *pszAssoc != '{')
120 {
121 this->hkeyProgID = this->hkeySource;
122 return S_OK;
123 }
124
125 /* if it's not a progid, it's a file extension or clsid */
126 if (*pszAssoc == '.')
127 {
128 /* for a file extension, the progid is the default value */
129 hr = this->GetValue(this->hkeySource, NULL, (void**)&progId, NULL);
130 if (FAILED(hr))
131 return S_OK;
132 }
133 else /* if (*pszAssoc == '{') */
134 {
135 HKEY progIdKey;
136 /* for a clsid, the progid is the default value of the ProgID subkey */
137 ret = RegOpenKeyExW(this->hkeySource, L"ProgID", 0, KEY_READ, &progIdKey);
138 if (ret != ERROR_SUCCESS)
139 return S_OK;
140 hr = this->GetValue(progIdKey, NULL, (void**)&progId, NULL);
141 if (FAILED(hr))
142 return S_OK;
143 RegCloseKey(progIdKey);
144 }
145
146 /* open the actual progid key, the one with the shell subkey */
148 progId,
149 0,
150 KEY_READ,
151 &this->hkeyProgID);
152 HeapFree(GetProcessHeap(), 0, progId);
153
154 return S_OK;
155 }
156 else if (hkeyProgid != NULL)
157 {
158 /* reopen the key so we don't end up closing a key owned by the caller */
159 RegOpenKeyExW(hkeyProgid, NULL, 0, KEY_READ, &this->hkeyProgID);
160 this->hkeySource = this->hkeyProgID;
161 return S_OK;
162 }
163 else
164 return E_INVALIDARG;
165}
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 725 of file CQueryAssociations.cpp.

726{
727 if (out)
728 {
729 if (*outlen < datalen)
730 {
731 *outlen = datalen;
732 return E_POINTER;
733 }
734 *outlen = datalen;
736 return S_OK;
737 }
738 else
739 {
740 *outlen = datalen;
741 return S_FALSE;
742 }
743}
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 745 of file CQueryAssociations.cpp.

746{
747 HRESULT hr = S_OK;
748 DWORD len;
749
750 TRACE("flags=0x%08x, data=%s\n", flags, debugstr_w(data));
751
752 if (!out)
753 {
754 *outlen = datalen;
755 return S_FALSE;
756 }
757
758 if (*outlen < datalen)
759 {
761 {
762 len = 0;
763 if (*outlen > 0) out[0] = 0;
764 hr = E_POINTER;
765 }
766 else
767 {
768 len = min(*outlen, datalen);
770 }
771 *outlen = datalen;
772 }
773 else
774 {
775 *outlen = len = datalen;
776 }
777
778 if (len)
779 {
780 memcpy(out, data, len*sizeof(WCHAR));
781 }
782
783 return hr;
784}
#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: