2 * IQueryAssociations object and helper functions
4 * Copyright 2002 Jon Griffiths
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
31 #include "shell32_main.h"
33 #include "wine/unicode.h"
34 #include "wine/debug.h"
36 WINE_DEFAULT_DEBUG_CHANNEL(shell
);
38 /**************************************************************************
42 * This object provides a layer of abstraction over the system registry in
43 * order to simplify the process of parsing associations between files.
44 * Associations in this context means the registry entries that link (for
45 * example) the extension of a file with its description, list of
46 * applications to open the file with, and actions that can be performed on it
47 * (the shell displays such information in the context menu of explorer
48 * when you right-click on a file).
51 * You can use this object transparently by calling the helper functions
52 * AssocQueryKeyA(), AssocQueryStringA() and AssocQueryStringByKeyA(). These
53 * create an IQueryAssociations object, perform the requested actions
54 * and then dispose of the object. Alternatively, you can create an instance
55 * of the object using AssocCreate() and call the following methods on it:
62 IQueryAssociations IQueryAssociations_iface
;
66 } IQueryAssociationsImpl
;
70 IApplicationAssociationRegistration IApplicationAssociationRegistration_iface
;
72 } IApplicationAssociationRegistrationImpl
;
75 static inline IQueryAssociationsImpl
*impl_from_IQueryAssociations(IQueryAssociations
*iface
)
77 return CONTAINING_RECORD(iface
, IQueryAssociationsImpl
, IQueryAssociations_iface
);
80 /**************************************************************************
81 * IQueryAssociations_QueryInterface
83 * See IUnknown_QueryInterface.
85 static HRESULT WINAPI
IQueryAssociations_fnQueryInterface(
86 IQueryAssociations
* iface
,
90 IQueryAssociationsImpl
*This
= impl_from_IQueryAssociations(iface
);
92 TRACE("(%p,%s,%p)\n",This
, debugstr_guid(riid
), ppvObj
);
99 if (IsEqualIID(riid
, &IID_IUnknown
) ||
100 IsEqualIID(riid
, &IID_IQueryAssociations
))
102 *ppvObj
= &This
->IQueryAssociations_iface
;
104 IQueryAssociations_AddRef((IQueryAssociations
*)*ppvObj
);
105 TRACE("Returning IQueryAssociations (%p)\n", *ppvObj
);
108 TRACE("Returning E_NOINTERFACE\n");
109 return E_NOINTERFACE
;
112 /**************************************************************************
113 * IQueryAssociations_AddRef
115 * See IUnknown_AddRef.
117 static ULONG WINAPI
IQueryAssociations_fnAddRef(IQueryAssociations
*iface
)
119 IQueryAssociationsImpl
*This
= impl_from_IQueryAssociations(iface
);
120 ULONG refCount
= InterlockedIncrement(&This
->ref
);
122 TRACE("(%p)->(ref before=%u)\n",This
, refCount
- 1);
127 /**************************************************************************
128 * IQueryAssociations_Release
130 * See IUnknown_Release.
132 static ULONG WINAPI
IQueryAssociations_fnRelease(IQueryAssociations
*iface
)
134 IQueryAssociationsImpl
*This
= impl_from_IQueryAssociations(iface
);
135 ULONG refCount
= InterlockedDecrement(&This
->ref
);
137 TRACE("(%p)->(ref before=%u)\n",This
, refCount
+ 1);
141 TRACE("Destroying IQueryAssociations (%p)\n", This
);
142 RegCloseKey(This
->hkeySource
);
143 RegCloseKey(This
->hkeyProgID
);
150 /**************************************************************************
151 * IQueryAssociations_Init
153 * Initialise an IQueryAssociations object.
156 * iface [I] IQueryAssociations interface to initialise
157 * cfFlags [I] ASSOCF_ flags from "shlwapi.h"
158 * pszAssoc [I] String for the root key name, or NULL if hkeyProgid is given
159 * hkeyProgid [I] Handle for the root key, or NULL if pszAssoc is given
160 * hWnd [I] Reserved, must be NULL.
163 * Success: S_OK. iface is initialised with the parameters given.
164 * Failure: An HRESULT error code indicating the error.
166 static HRESULT WINAPI
IQueryAssociations_fnInit(
167 IQueryAssociations
*iface
,
173 static const WCHAR szProgID
[] = {'P','r','o','g','I','D',0};
174 IQueryAssociationsImpl
*This
= impl_from_IQueryAssociations(iface
);
177 TRACE("(%p)->(%d,%s,%p,%p)\n", iface
,
179 debugstr_w(pszAssoc
),
183 FIXME("hwnd != NULL not supported\n");
185 FIXME("unsupported flags: %x\n", cfFlags
);
187 RegCloseKey(This
->hkeySource
);
188 RegCloseKey(This
->hkeyProgID
);
189 This
->hkeySource
= This
->hkeyProgID
= NULL
;
190 if (pszAssoc
!= NULL
)
192 ret
= RegOpenKeyExW(HKEY_CLASSES_ROOT
,
199 /* if this is not a prog id */
200 if ((*pszAssoc
== '.') || (*pszAssoc
== '{'))
202 RegOpenKeyExW(This
->hkeySource
,
209 This
->hkeyProgID
= This
->hkeySource
;
212 else if (hkeyProgid
!= NULL
)
214 This
->hkeyProgID
= hkeyProgid
;
221 static HRESULT
ASSOC_GetValue(HKEY hkey
, const WCHAR
*name
, void **data
, DWORD
*data_size
)
226 ret
= RegQueryValueExW(hkey
, name
, 0, NULL
, NULL
, &size
);
227 if (ret
!= ERROR_SUCCESS
)
228 return HRESULT_FROM_WIN32(ret
);
231 *data
= HeapAlloc(GetProcessHeap(), 0, size
);
233 return E_OUTOFMEMORY
;
234 ret
= RegQueryValueExW(hkey
, name
, 0, NULL
, (LPBYTE
)*data
, &size
);
235 if (ret
!= ERROR_SUCCESS
)
237 HeapFree(GetProcessHeap(), 0, *data
);
238 return HRESULT_FROM_WIN32(ret
);
245 static HRESULT
ASSOC_GetCommand(IQueryAssociationsImpl
*This
, const WCHAR
*extra
, WCHAR
**command
)
252 WCHAR
*extra_from_reg
= NULL
;
254 static const WCHAR commandW
[] = { 'c','o','m','m','a','n','d',0 };
255 static const WCHAR shellW
[] = { 's','h','e','l','l',0 };
257 /* When looking for file extension it's possible to have a default value
258 that points to another key that contains 'shell/<verb>/command' subtree. */
259 hr
= ASSOC_GetValue(This
->hkeySource
, NULL
, (void**)&filetype
, NULL
);
264 ret
= RegOpenKeyExW(HKEY_CLASSES_ROOT
, filetype
, 0, KEY_READ
, &hkeyFile
);
265 HeapFree(GetProcessHeap(), 0, filetype
);
267 if (ret
== ERROR_SUCCESS
)
269 ret
= RegOpenKeyExW(hkeyFile
, shellW
, 0, KEY_READ
, &hkeyShell
);
270 RegCloseKey(hkeyFile
);
273 ret
= RegOpenKeyExW(This
->hkeySource
, shellW
, 0, KEY_READ
, &hkeyShell
);
276 ret
= RegOpenKeyExW(This
->hkeySource
, shellW
, 0, KEY_READ
, &hkeyShell
);
278 if (ret
) return HRESULT_FROM_WIN32(ret
);
282 /* check for default verb */
283 hr
= ASSOC_GetValue(hkeyShell
, NULL
, (void**)&extra_from_reg
, NULL
);
286 /* no default verb, try first subkey */
287 DWORD max_subkey_len
;
289 ret
= RegQueryInfoKeyW(hkeyShell
, NULL
, NULL
, NULL
, NULL
, &max_subkey_len
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
);
292 RegCloseKey(hkeyShell
);
293 return HRESULT_FROM_WIN32(ret
);
297 extra_from_reg
= HeapAlloc(GetProcessHeap(), 0, max_subkey_len
* sizeof(WCHAR
));
300 RegCloseKey(hkeyShell
);
301 return E_OUTOFMEMORY
;
304 ret
= RegEnumKeyExW(hkeyShell
, 0, extra_from_reg
, &max_subkey_len
, NULL
, NULL
, NULL
, NULL
);
307 HeapFree(GetProcessHeap(), 0, extra_from_reg
);
308 RegCloseKey(hkeyShell
);
309 return HRESULT_FROM_WIN32(ret
);
312 extra
= extra_from_reg
;
315 /* open verb subkey */
316 ret
= RegOpenKeyExW(hkeyShell
, extra
, 0, KEY_READ
, &hkeyVerb
);
317 HeapFree(GetProcessHeap(), 0, extra_from_reg
);
318 RegCloseKey(hkeyShell
);
319 if (ret
) return HRESULT_FROM_WIN32(ret
);
321 /* open command subkey */
322 ret
= RegOpenKeyExW(hkeyVerb
, commandW
, 0, KEY_READ
, &hkeyCommand
);
323 RegCloseKey(hkeyVerb
);
324 if (ret
) return HRESULT_FROM_WIN32(ret
);
326 hr
= ASSOC_GetValue(hkeyCommand
, NULL
, (void**)command
, NULL
);
327 RegCloseKey(hkeyCommand
);
331 static HRESULT
ASSOC_GetExecutable(IQueryAssociationsImpl
*This
,
332 LPCWSTR pszExtra
, LPWSTR path
,
333 DWORD pathlen
, DWORD
*len
)
340 hr
= ASSOC_GetCommand(This
, pszExtra
, &pszCommand
);
344 /* cleanup pszCommand */
345 if (pszCommand
[0] == '"')
347 pszStart
= pszCommand
+ 1;
348 pszEnd
= strchrW(pszStart
, '"');
351 *len
= SearchPathW(NULL
, pszStart
, NULL
, pathlen
, path
, NULL
);
355 pszStart
= pszCommand
;
356 for (pszEnd
= pszStart
; (pszEnd
= strchrW(pszEnd
, ' ')); pszEnd
++)
360 if ((*len
= SearchPathW(NULL
, pszStart
, NULL
, pathlen
, path
, NULL
)))
365 *len
= SearchPathW(NULL
, pszStart
, NULL
, pathlen
, path
, NULL
);
368 HeapFree(GetProcessHeap(), 0, pszCommand
);
370 return HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND
);
374 static HRESULT
ASSOC_ReturnData(void *out
, DWORD
*outlen
, const void *data
,
379 if (*outlen
< datalen
)
385 memcpy(out
, data
, datalen
);
395 static HRESULT
ASSOC_ReturnString(ASSOCF flags
, LPWSTR out
, DWORD
*outlen
, LPCWSTR data
, DWORD datalen
)
400 TRACE("flags=0x%08x, data=%s\n", flags
, debugstr_w(data
));
408 if (*outlen
< datalen
)
410 if (flags
& ASSOCF_NOTRUNCATE
)
413 if (*outlen
> 0) out
[0] = 0;
418 len
= min(*outlen
, datalen
);
419 hr
= E_NOT_SUFFICIENT_BUFFER
;
427 memcpy(out
, data
, len
*sizeof(WCHAR
));
432 /**************************************************************************
433 * IQueryAssociations_GetString
435 * Get a file association string from the registry.
438 * iface [I] IQueryAssociations interface to query
439 * cfFlags [I] ASSOCF_ flags from "shlwapi.h"
440 * str [I] Type of string to get (ASSOCSTR enum from "shlwapi.h")
441 * pszExtra [I] Extra information about the string location
442 * pszOut [O] Destination for the association string
443 * pcchOut [I/O] Length of pszOut
446 * Success: S_OK. pszOut contains the string, pcchOut contains its length.
447 * Failure: An HRESULT error code indicating the error.
449 static HRESULT WINAPI
IQueryAssociations_fnGetString(
450 IQueryAssociations
*iface
,
457 IQueryAssociationsImpl
*This
= impl_from_IQueryAssociations(iface
);
458 const ASSOCF unimplemented_flags
= ~ASSOCF_NOTRUNCATE
;
461 WCHAR path
[MAX_PATH
];
463 TRACE("(%p)->(0x%08x, %u, %s, %p, %p)\n", This
, flags
, str
, debugstr_w(pszExtra
), pszOut
, pcchOut
);
465 if (flags
& unimplemented_flags
)
466 FIXME("%08x: unimplemented flags\n", flags
& unimplemented_flags
);
471 if (!This
->hkeySource
&& !This
->hkeyProgID
)
472 return HRESULT_FROM_WIN32(ERROR_NO_ASSOCIATION
);
476 case ASSOCSTR_COMMAND
:
479 hr
= ASSOC_GetCommand(This
, pszExtra
, &command
);
482 hr
= ASSOC_ReturnString(flags
, pszOut
, pcchOut
, command
, strlenW(command
) + 1);
483 HeapFree(GetProcessHeap(), 0, command
);
488 case ASSOCSTR_EXECUTABLE
:
490 hr
= ASSOC_GetExecutable(This
, pszExtra
, path
, MAX_PATH
, &len
);
494 return ASSOC_ReturnString(flags
, pszOut
, pcchOut
, path
, len
);
497 case ASSOCSTR_FRIENDLYDOCNAME
:
503 hr
= ASSOC_GetValue(This
->hkeySource
, NULL
, (void**)&pszFileType
, NULL
);
507 ret
= RegGetValueW(HKEY_CLASSES_ROOT
, pszFileType
, NULL
, RRF_RT_REG_SZ
, NULL
, NULL
, &size
);
508 if (ret
== ERROR_SUCCESS
)
510 WCHAR
*docName
= HeapAlloc(GetProcessHeap(), 0, size
);
513 ret
= RegGetValueW(HKEY_CLASSES_ROOT
, pszFileType
, NULL
, RRF_RT_REG_SZ
, NULL
, docName
, &size
);
514 if (ret
== ERROR_SUCCESS
)
515 hr
= ASSOC_ReturnString(flags
, pszOut
, pcchOut
, docName
, strlenW(docName
) + 1);
517 hr
= HRESULT_FROM_WIN32(ret
);
518 HeapFree(GetProcessHeap(), 0, docName
);
524 hr
= HRESULT_FROM_WIN32(ret
);
525 HeapFree(GetProcessHeap(), 0, pszFileType
);
529 case ASSOCSTR_FRIENDLYAPPNAME
:
531 PVOID verinfoW
= NULL
;
532 DWORD size
, retval
= 0;
535 static const WCHAR translationW
[] = {
536 '\\','V','a','r','F','i','l','e','I','n','f','o',
537 '\\','T','r','a','n','s','l','a','t','i','o','n',0
539 static const WCHAR fileDescFmtW
[] = {
540 '\\','S','t','r','i','n','g','F','i','l','e','I','n','f','o',
541 '\\','%','0','4','x','%','0','4','x',
542 '\\','F','i','l','e','D','e','s','c','r','i','p','t','i','o','n',0
546 hr
= ASSOC_GetExecutable(This
, pszExtra
, path
, MAX_PATH
, &len
);
550 retval
= GetFileVersionInfoSizeW(path
, &size
);
552 goto get_friendly_name_fail
;
553 verinfoW
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, retval
);
555 return E_OUTOFMEMORY
;
556 if (!GetFileVersionInfoW(path
, 0, retval
, verinfoW
))
557 goto get_friendly_name_fail
;
558 if (VerQueryValueW(verinfoW
, translationW
, (LPVOID
*)&bufW
, &flen
))
561 DWORD
*langCodeDesc
= (DWORD
*)bufW
;
562 for (i
= 0; i
< flen
/ sizeof(DWORD
); i
++)
564 sprintfW(fileDescW
, fileDescFmtW
, LOWORD(langCodeDesc
[i
]),
565 HIWORD(langCodeDesc
[i
]));
566 if (VerQueryValueW(verinfoW
, fileDescW
, (LPVOID
*)&bufW
, &flen
))
568 /* Does strlenW(bufW) == 0 mean we use the filename? */
569 len
= strlenW(bufW
) + 1;
570 TRACE("found FileDescription: %s\n", debugstr_w(bufW
));
571 hr
= ASSOC_ReturnString(flags
, pszOut
, pcchOut
, bufW
, len
);
572 HeapFree(GetProcessHeap(), 0, verinfoW
);
577 get_friendly_name_fail
:
578 PathRemoveExtensionW(path
);
579 PathStripPathW(path
);
580 TRACE("using filename: %s\n", debugstr_w(path
));
581 hr
= ASSOC_ReturnString(flags
, pszOut
, pcchOut
, path
, strlenW(path
) + 1);
582 HeapFree(GetProcessHeap(), 0, verinfoW
);
586 case ASSOCSTR_CONTENTTYPE
:
588 static const WCHAR Content_TypeW
[] = {'C','o','n','t','e','n','t',' ','T','y','p','e',0};
594 ret
= RegGetValueW(This
->hkeySource
, NULL
, Content_TypeW
, RRF_RT_REG_SZ
, NULL
, NULL
, &size
);
595 if (ret
!= ERROR_SUCCESS
)
596 return HRESULT_FROM_WIN32(ret
);
597 contentType
= HeapAlloc(GetProcessHeap(), 0, size
);
598 if (contentType
!= NULL
)
600 ret
= RegGetValueW(This
->hkeySource
, NULL
, Content_TypeW
, RRF_RT_REG_SZ
, NULL
, contentType
, &size
);
601 if (ret
== ERROR_SUCCESS
)
602 hr
= ASSOC_ReturnString(flags
, pszOut
, pcchOut
, contentType
, strlenW(contentType
) + 1);
604 hr
= HRESULT_FROM_WIN32(ret
);
605 HeapFree(GetProcessHeap(), 0, contentType
);
612 case ASSOCSTR_DEFAULTICON
:
614 static const WCHAR DefaultIconW
[] = {'D','e','f','a','u','l','t','I','c','o','n',0};
620 hr
= ASSOC_GetValue(This
->hkeySource
, NULL
, (void**)&pszFileType
, NULL
);
623 ret
= RegOpenKeyExW(HKEY_CLASSES_ROOT
, pszFileType
, 0, KEY_READ
, &hkeyFile
);
624 if (ret
== ERROR_SUCCESS
)
627 ret
= RegGetValueW(hkeyFile
, DefaultIconW
, NULL
, RRF_RT_REG_SZ
, NULL
, NULL
, &size
);
628 if (ret
== ERROR_SUCCESS
)
630 WCHAR
*icon
= HeapAlloc(GetProcessHeap(), 0, size
);
633 ret
= RegGetValueW(hkeyFile
, DefaultIconW
, NULL
, RRF_RT_REG_SZ
, NULL
, icon
, &size
);
634 if (ret
== ERROR_SUCCESS
)
635 hr
= ASSOC_ReturnString(flags
, pszOut
, pcchOut
, icon
, strlenW(icon
) + 1);
637 hr
= HRESULT_FROM_WIN32(ret
);
638 HeapFree(GetProcessHeap(), 0, icon
);
644 hr
= HRESULT_FROM_WIN32(ret
);
645 RegCloseKey(hkeyFile
);
648 hr
= HRESULT_FROM_WIN32(ret
);
649 HeapFree(GetProcessHeap(), 0, pszFileType
);
652 case ASSOCSTR_SHELLEXTENSION
:
654 static const WCHAR shellexW
[] = {'S','h','e','l','l','E','x','\\',0};
655 WCHAR keypath
[sizeof(shellexW
) / sizeof(shellexW
[0]) + 39], guid
[39];
661 hr
= CLSIDFromString(pszExtra
, &clsid
);
662 if (FAILED(hr
)) return hr
;
664 strcpyW(keypath
, shellexW
);
665 strcatW(keypath
, pszExtra
);
666 ret
= RegOpenKeyExW(This
->hkeySource
, keypath
, 0, KEY_READ
, &hkey
);
667 if (ret
) return HRESULT_FROM_WIN32(ret
);
670 ret
= RegGetValueW(hkey
, NULL
, NULL
, RRF_RT_REG_SZ
, NULL
, guid
, &size
);
672 if (ret
) return HRESULT_FROM_WIN32(ret
);
674 return ASSOC_ReturnString(flags
, pszOut
, pcchOut
, guid
, size
/ sizeof(WCHAR
));
678 FIXME("assocstr %d unimplemented!\n", str
);
683 /**************************************************************************
684 * IQueryAssociations_GetKey
686 * Get a file association key from the registry.
689 * iface [I] IQueryAssociations interface to query
690 * cfFlags [I] ASSOCF_ flags from "shlwapi.h"
691 * assockey [I] Type of key to get (ASSOCKEY enum from "shlwapi.h")
692 * pszExtra [I] Extra information about the key location
693 * phkeyOut [O] Destination for the association key
696 * Success: S_OK. phkeyOut contains a handle to the key.
697 * Failure: An HRESULT error code indicating the error.
699 static HRESULT WINAPI
IQueryAssociations_fnGetKey(
700 IQueryAssociations
*iface
,
706 IQueryAssociationsImpl
*This
= impl_from_IQueryAssociations(iface
);
708 FIXME("(%p,0x%8x,0x%8x,%s,%p)-stub!\n", This
, cfFlags
, assockey
,
709 debugstr_w(pszExtra
), phkeyOut
);
713 /**************************************************************************
714 * IQueryAssociations_GetData
716 * Get the data for a file association key from the registry.
719 * iface [I] IQueryAssociations interface to query
720 * cfFlags [I] ASSOCF_ flags from "shlwapi.h"
721 * assocdata [I] Type of data to get (ASSOCDATA enum from "shlwapi.h")
722 * pszExtra [I] Extra information about the data location
723 * pvOut [O] Destination for the association key
724 * pcbOut [I/O] Size of pvOut
727 * Success: S_OK. pszOut contains the data, pcbOut contains its length.
728 * Failure: An HRESULT error code indicating the error.
730 static HRESULT WINAPI
IQueryAssociations_fnGetData(IQueryAssociations
*iface
,
731 ASSOCF cfFlags
, ASSOCDATA assocdata
, LPCWSTR pszExtra
, LPVOID pvOut
,
734 static const WCHAR edit_flags
[] = {'E','d','i','t','F','l','a','g','s',0};
736 IQueryAssociationsImpl
*This
= impl_from_IQueryAssociations(iface
);
741 TRACE("(%p,0x%8x,0x%8x,%s,%p,%p)\n", This
, cfFlags
, assocdata
,
742 debugstr_w(pszExtra
), pvOut
, pcbOut
);
745 FIXME("Unsupported flags: %x\n", cfFlags
);
748 case ASSOCDATA_EDITFLAGS
:
749 if(!This
->hkeyProgID
)
750 return HRESULT_FROM_WIN32(ERROR_NO_ASSOCIATION
);
752 hres
= ASSOC_GetValue(This
->hkeyProgID
, edit_flags
, &data
, &size
);
753 if(FAILED(hres
) || !pcbOut
)
756 hres
= ASSOC_ReturnData(pvOut
, pcbOut
, data
, size
);
757 HeapFree(GetProcessHeap(), 0, data
);
760 FIXME("Unsupported ASSOCDATA value: %d\n", assocdata
);
765 /**************************************************************************
766 * IQueryAssociations_GetEnum
768 * Not yet implemented in native Win32.
771 * iface [I] IQueryAssociations interface to query
772 * cfFlags [I] ASSOCF_ flags from "shlwapi.h"
773 * assocenum [I] Type of enum to get (ASSOCENUM enum from "shlwapi.h")
774 * pszExtra [I] Extra information about the enum location
775 * riid [I] REFIID to look for
776 * ppvOut [O] Destination for the interface.
780 * Failure: An HRESULT error code indicating the error.
783 * Presumably this function returns an enumerator object.
785 static HRESULT WINAPI
IQueryAssociations_fnGetEnum(
786 IQueryAssociations
*iface
,
793 IQueryAssociationsImpl
*This
= impl_from_IQueryAssociations(iface
);
795 FIXME("(%p,0x%8x,0x%8x,%s,%s,%p)-stub!\n", This
, cfFlags
, assocenum
,
796 debugstr_w(pszExtra
), debugstr_guid(riid
), ppvOut
);
800 static const IQueryAssociationsVtbl IQueryAssociations_vtbl
=
802 IQueryAssociations_fnQueryInterface
,
803 IQueryAssociations_fnAddRef
,
804 IQueryAssociations_fnRelease
,
805 IQueryAssociations_fnInit
,
806 IQueryAssociations_fnGetString
,
807 IQueryAssociations_fnGetKey
,
808 IQueryAssociations_fnGetData
,
809 IQueryAssociations_fnGetEnum
812 /**************************************************************************
813 * IApplicationAssociationRegistration implementation
815 static inline IApplicationAssociationRegistrationImpl
*impl_from_IApplicationAssociationRegistration(IApplicationAssociationRegistration
*iface
)
817 return CONTAINING_RECORD(iface
, IApplicationAssociationRegistrationImpl
, IApplicationAssociationRegistration_iface
);
820 static HRESULT WINAPI
ApplicationAssociationRegistration_QueryInterface(
821 IApplicationAssociationRegistration
* iface
, REFIID riid
, LPVOID
*ppv
)
823 IApplicationAssociationRegistrationImpl
*This
= impl_from_IApplicationAssociationRegistration(iface
);
825 TRACE("(%p, %s, %p)\n",This
, debugstr_guid(riid
), ppv
);
830 if (IsEqualGUID(&IID_IUnknown
, riid
) ||
831 IsEqualGUID(&IID_IApplicationAssociationRegistration
, riid
)) {
832 *ppv
= &This
->IApplicationAssociationRegistration_iface
;
833 IUnknown_AddRef((IUnknown
*)*ppv
);
834 TRACE("returning IApplicationAssociationRegistration: %p\n", *ppv
);
839 FIXME("(%p)->(%s %p) interface not supported\n", This
, debugstr_guid(riid
), ppv
);
840 return E_NOINTERFACE
;
843 static ULONG WINAPI
ApplicationAssociationRegistration_AddRef(IApplicationAssociationRegistration
*iface
)
845 IApplicationAssociationRegistrationImpl
*This
= impl_from_IApplicationAssociationRegistration(iface
);
846 ULONG ref
= InterlockedIncrement(&This
->ref
);
848 TRACE("(%p) ref=%d\n", This
, ref
);
852 static ULONG WINAPI
ApplicationAssociationRegistration_Release(IApplicationAssociationRegistration
*iface
)
854 IApplicationAssociationRegistrationImpl
*This
= impl_from_IApplicationAssociationRegistration(iface
);
855 ULONG ref
= InterlockedDecrement(&This
->ref
);
857 TRACE("(%p) ref=%d\n", This
, ref
);
865 static HRESULT WINAPI
ApplicationAssociationRegistration_QueryCurrentDefault(IApplicationAssociationRegistration
* This
, LPCWSTR query
,
866 ASSOCIATIONTYPE type
, ASSOCIATIONLEVEL level
, LPWSTR
*association
)
868 FIXME("(%p)->(%s, %d, %d, %p)\n", This
, debugstr_w(query
), type
, level
, association
);
872 static HRESULT WINAPI
ApplicationAssociationRegistration_QueryAppIsDefault(IApplicationAssociationRegistration
* This
, LPCWSTR query
,
873 ASSOCIATIONTYPE type
, ASSOCIATIONLEVEL level
, LPCWSTR appname
, BOOL
*is_default
)
875 FIXME("(%p)->(%s, %d, %d, %s, %p)\n", This
, debugstr_w(query
), type
, level
, debugstr_w(appname
), is_default
);
879 static HRESULT WINAPI
ApplicationAssociationRegistration_QueryAppIsDefaultAll(IApplicationAssociationRegistration
* This
, ASSOCIATIONLEVEL level
,
880 LPCWSTR appname
, BOOL
*is_default
)
882 FIXME("(%p)->(%d, %s, %p)\n", This
, level
, debugstr_w(appname
), is_default
);
886 static HRESULT WINAPI
ApplicationAssociationRegistration_SetAppAsDefault(IApplicationAssociationRegistration
* This
, LPCWSTR appname
,
887 LPCWSTR set
, ASSOCIATIONTYPE set_type
)
889 FIXME("(%p)->(%s, %s, %d)\n", This
, debugstr_w(appname
), debugstr_w(set
), set_type
);
893 static HRESULT WINAPI
ApplicationAssociationRegistration_SetAppAsDefaultAll(IApplicationAssociationRegistration
* This
, LPCWSTR appname
)
895 FIXME("(%p)->(%s)\n", This
, debugstr_w(appname
));
900 static HRESULT WINAPI
ApplicationAssociationRegistration_ClearUserAssociations(IApplicationAssociationRegistration
* This
)
902 FIXME("(%p)\n", This
);
907 static const IApplicationAssociationRegistrationVtbl IApplicationAssociationRegistration_vtbl
=
909 ApplicationAssociationRegistration_QueryInterface
,
910 ApplicationAssociationRegistration_AddRef
,
911 ApplicationAssociationRegistration_Release
,
912 ApplicationAssociationRegistration_QueryCurrentDefault
,
913 ApplicationAssociationRegistration_QueryAppIsDefault
,
914 ApplicationAssociationRegistration_QueryAppIsDefaultAll
,
915 ApplicationAssociationRegistration_SetAppAsDefault
,
916 ApplicationAssociationRegistration_SetAppAsDefaultAll
,
917 ApplicationAssociationRegistration_ClearUserAssociations
920 /**************************************************************************
921 * IQueryAssociations_Constructor [internal]
923 * Construct a new IQueryAssociations object.
925 HRESULT WINAPI
QueryAssociations_Constructor(IUnknown
*pUnkOuter
, REFIID riid
, LPVOID
*ppOutput
)
927 IQueryAssociationsImpl
* this;
930 if (pUnkOuter
) return CLASS_E_NOAGGREGATION
;
932 if (!(this = SHAlloc(sizeof(*this)))) return E_OUTOFMEMORY
;
933 this->IQueryAssociations_iface
.lpVtbl
= &IQueryAssociations_vtbl
;
935 this->hkeySource
= 0;
936 this->hkeyProgID
= 0;
937 if (FAILED(ret
= IQueryAssociations_QueryInterface(&this->IQueryAssociations_iface
, riid
, ppOutput
))) SHFree( this );
938 TRACE("returning %p\n", *ppOutput
);
942 /**************************************************************************
943 * ApplicationAssociationRegistration_Constructor [internal]
945 * Construct a IApplicationAssociationRegistration object.
947 HRESULT WINAPI
ApplicationAssociationRegistration_Constructor(IUnknown
*outer
, REFIID riid
, LPVOID
*ppv
)
949 IApplicationAssociationRegistrationImpl
*This
;
953 return CLASS_E_NOAGGREGATION
;
955 if (!(This
= SHAlloc(sizeof(*This
))))
956 return E_OUTOFMEMORY
;
958 This
->IApplicationAssociationRegistration_iface
.lpVtbl
= &IApplicationAssociationRegistration_vtbl
;
961 hr
= IApplicationAssociationRegistration_QueryInterface(&This
->IApplicationAssociationRegistration_iface
, riid
, ppv
);
965 TRACE("returning 0x%x with %p\n", hr
, *ppv
);