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
32 #include "shell32_main.h"
34 #include "wine/unicode.h"
35 #include "wine/debug.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(shell
);
39 /**************************************************************************
43 * This object provides a layer of abstraction over the system registry in
44 * order to simplify the process of parsing associations between files.
45 * Associations in this context means the registry entries that link (for
46 * example) the extension of a file with its description, list of
47 * applications to open the file with, and actions that can be performed on it
48 * (the shell displays such information in the context menu of explorer
49 * when you right-click on a file).
52 * You can use this object transparently by calling the helper functions
53 * AssocQueryKeyA(), AssocQueryStringA() and AssocQueryStringByKeyA(). These
54 * create an IQueryAssociations object, perform the requested actions
55 * and then dispose of the object. Alternatively, you can create an instance
56 * of the object using AssocCreate() and call the following methods on it:
63 IQueryAssociations IQueryAssociations_iface
;
67 } IQueryAssociationsImpl
;
71 IApplicationAssociationRegistration IApplicationAssociationRegistration_iface
;
73 } IApplicationAssociationRegistrationImpl
;
76 static inline IQueryAssociationsImpl
*impl_from_IQueryAssociations(IQueryAssociations
*iface
)
78 return CONTAINING_RECORD(iface
, IQueryAssociationsImpl
, IQueryAssociations_iface
);
81 /**************************************************************************
82 * IQueryAssociations_QueryInterface
84 * See IUnknown_QueryInterface.
86 static HRESULT WINAPI
IQueryAssociations_fnQueryInterface(
87 IQueryAssociations
* iface
,
91 IQueryAssociationsImpl
*This
= impl_from_IQueryAssociations(iface
);
93 TRACE("(%p,%s,%p)\n",This
, debugstr_guid(riid
), ppvObj
);
100 if (IsEqualIID(riid
, &IID_IUnknown
) ||
101 IsEqualIID(riid
, &IID_IQueryAssociations
))
105 IQueryAssociations_AddRef((IQueryAssociations
*)*ppvObj
);
106 TRACE("Returning IQueryAssociations (%p)\n", *ppvObj
);
109 TRACE("Returning E_NOINTERFACE\n");
110 return E_NOINTERFACE
;
113 /**************************************************************************
114 * IQueryAssociations_AddRef
116 * See IUnknown_AddRef.
118 static ULONG WINAPI
IQueryAssociations_fnAddRef(IQueryAssociations
*iface
)
120 IQueryAssociationsImpl
*This
= impl_from_IQueryAssociations(iface
);
121 ULONG refCount
= InterlockedIncrement(&This
->ref
);
123 TRACE("(%p)->(ref before=%u)\n",This
, refCount
- 1);
128 /**************************************************************************
129 * IQueryAssociations_Release
131 * See IUnknown_Release.
133 static ULONG WINAPI
IQueryAssociations_fnRelease(IQueryAssociations
*iface
)
135 IQueryAssociationsImpl
*This
= impl_from_IQueryAssociations(iface
);
136 ULONG refCount
= InterlockedDecrement(&This
->ref
);
138 TRACE("(%p)->(ref before=%u)\n",This
, refCount
+ 1);
142 TRACE("Destroying IQueryAssociations (%p)\n", This
);
143 RegCloseKey(This
->hkeySource
);
144 RegCloseKey(This
->hkeyProgID
);
151 /**************************************************************************
152 * IQueryAssociations_Init
154 * Initialise an IQueryAssociations object.
157 * iface [I] IQueryAssociations interface to initialise
158 * cfFlags [I] ASSOCF_ flags from "shlwapi.h"
159 * pszAssoc [I] String for the root key name, or NULL if hkeyProgid is given
160 * hkeyProgid [I] Handle for the root key, or NULL if pszAssoc is given
161 * hWnd [I] Reserved, must be NULL.
164 * Success: S_OK. iface is initialised with the parameters given.
165 * Failure: An HRESULT error code indicating the error.
167 static HRESULT WINAPI
IQueryAssociations_fnInit(
168 IQueryAssociations
*iface
,
174 static const WCHAR szProgID
[] = {'P','r','o','g','I','D',0};
175 IQueryAssociationsImpl
*This
= impl_from_IQueryAssociations(iface
);
178 TRACE("(%p)->(%d,%s,%p,%p)\n", iface
,
180 debugstr_w(pszAssoc
),
184 FIXME("hwnd != NULL not supported\n");
186 FIXME("unsupported flags: %x\n", cfFlags
);
187 if (pszAssoc
!= NULL
)
189 ret
= RegOpenKeyExW(HKEY_CLASSES_ROOT
,
194 if (ret
!= ERROR_SUCCESS
)
196 /* if this is not a prog id */
197 if ((*pszAssoc
== '.') || (*pszAssoc
== '{'))
199 RegOpenKeyExW(This
->hkeySource
,
206 This
->hkeyProgID
= This
->hkeySource
;
209 else if (hkeyProgid
!= NULL
)
211 This
->hkeyProgID
= hkeyProgid
;
218 static HRESULT
ASSOC_GetValue(HKEY hkey
, const WCHAR
*name
, void **data
, DWORD
*data_size
)
224 ret
= RegQueryValueExW(hkey
, name
, 0, NULL
, NULL
, &size
);
225 if (ret
!= ERROR_SUCCESS
)
226 return HRESULT_FROM_WIN32(ret
);
229 *data
= HeapAlloc(GetProcessHeap(), 0, size
);
231 return E_OUTOFMEMORY
;
232 ret
= RegQueryValueExW(hkey
, name
, 0, NULL
, (LPBYTE
)*data
, &size
);
233 if (ret
!= ERROR_SUCCESS
)
235 HeapFree(GetProcessHeap(), 0, *data
);
236 return HRESULT_FROM_WIN32(ret
);
243 static HRESULT
ASSOC_GetCommand(IQueryAssociationsImpl
*This
,
244 LPCWSTR pszExtra
, WCHAR
**ppszCommand
)
252 WCHAR
* pszExtraFromReg
= 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 hr
= ASSOC_GetValue(This
->hkeySource
, NULL
, (void**)&pszFileType
, NULL
);
260 ret
= RegOpenKeyExW(HKEY_CLASSES_ROOT
, pszFileType
, 0, KEY_READ
, &hkeyFile
);
261 HeapFree(GetProcessHeap(), 0, pszFileType
);
262 if (ret
!= ERROR_SUCCESS
)
263 return HRESULT_FROM_WIN32(ret
);
265 ret
= RegOpenKeyExW(hkeyFile
, shellW
, 0, KEY_READ
, &hkeyShell
);
266 RegCloseKey(hkeyFile
);
267 if (ret
!= ERROR_SUCCESS
)
268 return HRESULT_FROM_WIN32(ret
);
272 hr
= ASSOC_GetValue(hkeyShell
, NULL
, (void**)&pszExtraFromReg
, NULL
);
273 /* if no default action */
274 if (hr
== E_FAIL
|| hr
== HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND
))
277 ret
= RegQueryInfoKeyW(hkeyShell
, 0, 0, 0, 0, &rlen
, 0, 0, 0, 0, 0, 0);
278 if (ret
!= ERROR_SUCCESS
)
280 RegCloseKey(hkeyShell
);
281 return HRESULT_FROM_WIN32(ret
);
284 pszExtraFromReg
= HeapAlloc(GetProcessHeap(), 0, rlen
* sizeof(WCHAR
));
285 if (!pszExtraFromReg
)
287 RegCloseKey(hkeyShell
);
288 return E_OUTOFMEMORY
;
290 ret
= RegEnumKeyExW(hkeyShell
, 0, pszExtraFromReg
, &rlen
, 0, NULL
, NULL
, NULL
);
291 if (ret
!= ERROR_SUCCESS
)
293 RegCloseKey(hkeyShell
);
294 return HRESULT_FROM_WIN32(ret
);
299 RegCloseKey(hkeyShell
);
304 ret
= RegOpenKeyExW(hkeyShell
, pszExtra
? pszExtra
: pszExtraFromReg
, 0,
305 KEY_READ
, &hkeyVerb
);
306 HeapFree(GetProcessHeap(), 0, pszExtraFromReg
);
307 RegCloseKey(hkeyShell
);
308 if (ret
!= ERROR_SUCCESS
)
309 return HRESULT_FROM_WIN32(ret
);
311 ret
= RegOpenKeyExW(hkeyVerb
, commandW
, 0, KEY_READ
, &hkeyCommand
);
312 RegCloseKey(hkeyVerb
);
313 if (ret
!= ERROR_SUCCESS
)
314 return HRESULT_FROM_WIN32(ret
);
315 hr
= ASSOC_GetValue(hkeyCommand
, NULL
, (void**)ppszCommand
, NULL
);
316 RegCloseKey(hkeyCommand
);
320 static HRESULT
ASSOC_GetExecutable(IQueryAssociationsImpl
*This
,
321 LPCWSTR pszExtra
, LPWSTR path
,
322 DWORD pathlen
, DWORD
*len
)
331 hr
= ASSOC_GetCommand(This
, pszExtra
, &pszCommand
);
335 /* cleanup pszCommand */
336 if (pszCommand
[0] == '"')
338 pszStart
= pszCommand
+ 1;
339 pszEnd
= strchrW(pszStart
, '"');
342 *len
= SearchPathW(NULL
, pszStart
, NULL
, pathlen
, path
, NULL
);
346 pszStart
= pszCommand
;
347 for (pszEnd
= pszStart
; (pszEnd
= strchrW(pszEnd
, ' ')); pszEnd
++)
351 if ((*len
= SearchPathW(NULL
, pszStart
, NULL
, pathlen
, path
, NULL
)))
356 *len
= SearchPathW(NULL
, pszStart
, NULL
, pathlen
, path
, NULL
);
359 HeapFree(GetProcessHeap(), 0, pszCommand
);
361 return HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND
);
365 static HRESULT
ASSOC_ReturnData(void *out
, DWORD
*outlen
, const void *data
,
372 if (*outlen
< datalen
)
378 memcpy(out
, data
, datalen
);
388 static HRESULT
ASSOC_ReturnString(LPWSTR out
, DWORD
*outlen
, LPCWSTR data
,
395 *outlen
*= sizeof(WCHAR
);
396 hres
= ASSOC_ReturnData(out
, outlen
, data
, datalen
*sizeof(WCHAR
));
397 *outlen
/= sizeof(WCHAR
);
401 /**************************************************************************
402 * IQueryAssociations_GetString
404 * Get a file association string from the registry.
407 * iface [I] IQueryAssociations interface to query
408 * cfFlags [I] ASSOCF_ flags from "shlwapi.h"
409 * str [I] Type of string to get (ASSOCSTR enum from "shlwapi.h")
410 * pszExtra [I] Extra information about the string location
411 * pszOut [O] Destination for the association string
412 * pcchOut [I/O] Length of pszOut
415 * Success: S_OK. pszOut contains the string, pcchOut contains its length.
416 * Failure: An HRESULT error code indicating the error.
418 static HRESULT WINAPI
IQueryAssociations_fnGetString(
419 IQueryAssociations
*iface
,
426 IQueryAssociationsImpl
*This
= impl_from_IQueryAssociations(iface
);
427 const ASSOCF cfUnimplemented
= ~(0);
430 WCHAR path
[MAX_PATH
];
432 TRACE("(%p,0x%08x,%u,%s,%p,%p)\n", This
, cfFlags
, str
,
433 debugstr_w(pszExtra
), pszOut
, pcchOut
);
435 if (cfFlags
& cfUnimplemented
)
436 FIXME("%08x: unimplemented flags!\n", cfFlags
& cfUnimplemented
);
443 case ASSOCSTR_COMMAND
:
446 hr
= ASSOC_GetCommand(This
, pszExtra
, &command
);
449 hr
= ASSOC_ReturnString(pszOut
, pcchOut
, command
, strlenW(command
) + 1);
450 HeapFree(GetProcessHeap(), 0, command
);
455 case ASSOCSTR_EXECUTABLE
:
457 hr
= ASSOC_GetExecutable(This
, pszExtra
, path
, MAX_PATH
, &len
);
461 return ASSOC_ReturnString(pszOut
, pcchOut
, path
, len
);
464 case ASSOCSTR_FRIENDLYDOCNAME
:
470 hr
= ASSOC_GetValue(This
->hkeySource
, NULL
, (void**)&pszFileType
, NULL
);
474 ret
= RegGetValueW(HKEY_CLASSES_ROOT
, pszFileType
, NULL
, RRF_RT_REG_SZ
, NULL
, NULL
, &size
);
475 if (ret
== ERROR_SUCCESS
)
477 WCHAR
*docName
= HeapAlloc(GetProcessHeap(), 0, size
);
480 ret
= RegGetValueW(HKEY_CLASSES_ROOT
, pszFileType
, NULL
, RRF_RT_REG_SZ
, NULL
, docName
, &size
);
481 if (ret
== ERROR_SUCCESS
)
482 hr
= ASSOC_ReturnString(pszOut
, pcchOut
, docName
, strlenW(docName
) + 1);
484 hr
= HRESULT_FROM_WIN32(ret
);
485 HeapFree(GetProcessHeap(), 0, docName
);
491 hr
= HRESULT_FROM_WIN32(ret
);
492 HeapFree(GetProcessHeap(), 0, pszFileType
);
496 case ASSOCSTR_FRIENDLYAPPNAME
:
498 PVOID verinfoW
= NULL
;
499 DWORD size
, retval
= 0;
502 static const WCHAR translationW
[] = {
503 '\\','V','a','r','F','i','l','e','I','n','f','o',
504 '\\','T','r','a','n','s','l','a','t','i','o','n',0
506 static const WCHAR fileDescFmtW
[] = {
507 '\\','S','t','r','i','n','g','F','i','l','e','I','n','f','o',
508 '\\','%','0','4','x','%','0','4','x',
509 '\\','F','i','l','e','D','e','s','c','r','i','p','t','i','o','n',0
513 hr
= ASSOC_GetExecutable(This
, pszExtra
, path
, MAX_PATH
, &len
);
517 retval
= GetFileVersionInfoSizeW(path
, &size
);
519 goto get_friendly_name_fail
;
520 verinfoW
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, retval
);
522 return E_OUTOFMEMORY
;
523 if (!GetFileVersionInfoW(path
, 0, retval
, verinfoW
))
524 goto get_friendly_name_fail
;
525 if (VerQueryValueW(verinfoW
, translationW
, (LPVOID
*)&bufW
, &flen
))
528 DWORD
*langCodeDesc
= (DWORD
*)bufW
;
529 for (i
= 0; i
< flen
/ sizeof(DWORD
); i
++)
531 sprintfW(fileDescW
, fileDescFmtW
, LOWORD(langCodeDesc
[i
]),
532 HIWORD(langCodeDesc
[i
]));
533 if (VerQueryValueW(verinfoW
, fileDescW
, (LPVOID
*)&bufW
, &flen
))
535 /* Does strlenW(bufW) == 0 mean we use the filename? */
536 len
= strlenW(bufW
) + 1;
537 TRACE("found FileDescription: %s\n", debugstr_w(bufW
));
538 hr
= ASSOC_ReturnString(pszOut
, pcchOut
, bufW
, len
);
539 HeapFree(GetProcessHeap(), 0, verinfoW
);
544 get_friendly_name_fail
:
545 PathRemoveExtensionW(path
);
546 PathStripPathW(path
);
547 TRACE("using filename: %s\n", debugstr_w(path
));
548 hr
= ASSOC_ReturnString(pszOut
, pcchOut
, path
, strlenW(path
) + 1);
549 HeapFree(GetProcessHeap(), 0, verinfoW
);
553 case ASSOCSTR_CONTENTTYPE
:
555 static const WCHAR Content_TypeW
[] = {'C','o','n','t','e','n','t',' ','T','y','p','e',0};
561 ret
= RegGetValueW(This
->hkeySource
, NULL
, Content_TypeW
, RRF_RT_REG_SZ
, NULL
, NULL
, &size
);
562 if (ret
!= ERROR_SUCCESS
)
563 return HRESULT_FROM_WIN32(ret
);
564 contentType
= HeapAlloc(GetProcessHeap(), 0, size
);
565 if (contentType
!= NULL
)
567 ret
= RegGetValueW(This
->hkeySource
, NULL
, Content_TypeW
, RRF_RT_REG_SZ
, NULL
, contentType
, &size
);
568 if (ret
== ERROR_SUCCESS
)
569 hr
= ASSOC_ReturnString(pszOut
, pcchOut
, contentType
, strlenW(contentType
) + 1);
571 hr
= HRESULT_FROM_WIN32(ret
);
572 HeapFree(GetProcessHeap(), 0, contentType
);
579 case ASSOCSTR_DEFAULTICON
:
581 static const WCHAR DefaultIconW
[] = {'D','e','f','a','u','l','t','I','c','o','n',0};
587 hr
= ASSOC_GetValue(This
->hkeySource
, NULL
, (void**)&pszFileType
, NULL
);
590 ret
= RegOpenKeyExW(HKEY_CLASSES_ROOT
, pszFileType
, 0, KEY_READ
, &hkeyFile
);
591 if (ret
== ERROR_SUCCESS
)
594 ret
= RegGetValueW(hkeyFile
, DefaultIconW
, NULL
, RRF_RT_REG_SZ
, NULL
, NULL
, &size
);
595 if (ret
== ERROR_SUCCESS
)
597 WCHAR
*icon
= HeapAlloc(GetProcessHeap(), 0, size
);
600 ret
= RegGetValueW(hkeyFile
, DefaultIconW
, NULL
, RRF_RT_REG_SZ
, NULL
, icon
, &size
);
601 if (ret
== ERROR_SUCCESS
)
602 hr
= ASSOC_ReturnString(pszOut
, pcchOut
, icon
, strlenW(icon
) + 1);
604 hr
= HRESULT_FROM_WIN32(ret
);
605 HeapFree(GetProcessHeap(), 0, icon
);
611 hr
= HRESULT_FROM_WIN32(ret
);
612 RegCloseKey(hkeyFile
);
615 hr
= HRESULT_FROM_WIN32(ret
);
616 HeapFree(GetProcessHeap(), 0, pszFileType
);
619 case ASSOCSTR_SHELLEXTENSION
:
621 static const WCHAR shellexW
[] = {'S','h','e','l','l','E','x','\\',0};
622 WCHAR keypath
[sizeof(shellexW
) / sizeof(shellexW
[0]) + 39], guid
[39];
628 hr
= CLSIDFromString(pszExtra
, &clsid
);
629 if (FAILED(hr
)) return hr
;
631 strcpyW(keypath
, shellexW
);
632 strcatW(keypath
, pszExtra
);
633 ret
= RegOpenKeyExW(This
->hkeySource
, keypath
, 0, KEY_READ
, &hkey
);
634 if (ret
) return HRESULT_FROM_WIN32(ret
);
637 ret
= RegGetValueW(hkey
, NULL
, NULL
, RRF_RT_REG_SZ
, NULL
, guid
, &size
);
639 if (ret
) return HRESULT_FROM_WIN32(ret
);
641 return ASSOC_ReturnString(pszOut
, pcchOut
, guid
, size
/ sizeof(WCHAR
));
645 FIXME("assocstr %d unimplemented!\n", str
);
650 /**************************************************************************
651 * IQueryAssociations_GetKey
653 * Get a file association key from the registry.
656 * iface [I] IQueryAssociations interface to query
657 * cfFlags [I] ASSOCF_ flags from "shlwapi.h"
658 * assockey [I] Type of key to get (ASSOCKEY enum from "shlwapi.h")
659 * pszExtra [I] Extra information about the key location
660 * phkeyOut [O] Destination for the association key
663 * Success: S_OK. phkeyOut contains a handle to the key.
664 * Failure: An HRESULT error code indicating the error.
666 static HRESULT WINAPI
IQueryAssociations_fnGetKey(
667 IQueryAssociations
*iface
,
673 IQueryAssociationsImpl
*This
= impl_from_IQueryAssociations(iface
);
675 FIXME("(%p,0x%8x,0x%8x,%s,%p)-stub!\n", This
, cfFlags
, assockey
,
676 debugstr_w(pszExtra
), phkeyOut
);
680 /**************************************************************************
681 * IQueryAssociations_GetData
683 * Get the data for a file association key from the registry.
686 * iface [I] IQueryAssociations interface to query
687 * cfFlags [I] ASSOCF_ flags from "shlwapi.h"
688 * assocdata [I] Type of data to get (ASSOCDATA enum from "shlwapi.h")
689 * pszExtra [I] Extra information about the data location
690 * pvOut [O] Destination for the association key
691 * pcbOut [I/O] Size of pvOut
694 * Success: S_OK. pszOut contains the data, pcbOut contains its length.
695 * Failure: An HRESULT error code indicating the error.
697 static HRESULT WINAPI
IQueryAssociations_fnGetData(IQueryAssociations
*iface
,
698 ASSOCF cfFlags
, ASSOCDATA assocdata
, LPCWSTR pszExtra
, LPVOID pvOut
,
701 static const WCHAR edit_flags
[] = {'E','d','i','t','F','l','a','g','s',0};
703 IQueryAssociationsImpl
*This
= impl_from_IQueryAssociations(iface
);
708 TRACE("(%p,0x%8x,0x%8x,%s,%p,%p)\n", This
, cfFlags
, assocdata
,
709 debugstr_w(pszExtra
), pvOut
, pcbOut
);
712 FIXME("Unsupported flags: %x\n", cfFlags
);
715 case ASSOCDATA_EDITFLAGS
:
716 if(!This
->hkeyProgID
)
717 return HRESULT_FROM_WIN32(ERROR_NO_ASSOCIATION
);
719 hres
= ASSOC_GetValue(This
->hkeyProgID
, edit_flags
, &data
, &size
);
720 if(FAILED(hres
) || !pcbOut
)
723 hres
= ASSOC_ReturnData(pvOut
, pcbOut
, data
, size
);
724 HeapFree(GetProcessHeap(), 0, data
);
727 FIXME("Unsupported ASSOCDATA value: %d\n", assocdata
);
732 /**************************************************************************
733 * IQueryAssociations_GetEnum
735 * Not yet implemented in native Win32.
738 * iface [I] IQueryAssociations interface to query
739 * cfFlags [I] ASSOCF_ flags from "shlwapi.h"
740 * assocenum [I] Type of enum to get (ASSOCENUM enum from "shlwapi.h")
741 * pszExtra [I] Extra information about the enum location
742 * riid [I] REFIID to look for
743 * ppvOut [O] Destination for the interface.
747 * Failure: An HRESULT error code indicating the error.
750 * Presumably this function returns an enumerator object.
752 static HRESULT WINAPI
IQueryAssociations_fnGetEnum(
753 IQueryAssociations
*iface
,
760 IQueryAssociationsImpl
*This
= impl_from_IQueryAssociations(iface
);
762 FIXME("(%p,0x%8x,0x%8x,%s,%s,%p)-stub!\n", This
, cfFlags
, assocenum
,
763 debugstr_w(pszExtra
), debugstr_guid(riid
), ppvOut
);
767 static const IQueryAssociationsVtbl IQueryAssociations_vtbl
=
769 IQueryAssociations_fnQueryInterface
,
770 IQueryAssociations_fnAddRef
,
771 IQueryAssociations_fnRelease
,
772 IQueryAssociations_fnInit
,
773 IQueryAssociations_fnGetString
,
774 IQueryAssociations_fnGetKey
,
775 IQueryAssociations_fnGetData
,
776 IQueryAssociations_fnGetEnum
779 /**************************************************************************
780 * IApplicationAssociationRegistration implementation
782 static inline IApplicationAssociationRegistrationImpl
*impl_from_IApplicationAssociationRegistration(IApplicationAssociationRegistration
*iface
)
784 return CONTAINING_RECORD(iface
, IApplicationAssociationRegistrationImpl
, IApplicationAssociationRegistration_iface
);
787 static HRESULT WINAPI
ApplicationAssociationRegistration_QueryInterface(
788 IApplicationAssociationRegistration
* iface
, REFIID riid
, LPVOID
*ppv
)
790 IApplicationAssociationRegistrationImpl
*This
= impl_from_IApplicationAssociationRegistration(iface
);
792 TRACE("(%p, %s, %p)\n",This
, debugstr_guid(riid
), ppv
);
797 if (IsEqualGUID(&IID_IUnknown
, riid
) ||
798 IsEqualGUID(&IID_IApplicationAssociationRegistration
, riid
)) {
799 *ppv
= &This
->IApplicationAssociationRegistration_iface
;
800 IUnknown_AddRef((IUnknown
*)*ppv
);
801 TRACE("returning IApplicationAssociationRegistration: %p\n", *ppv
);
806 FIXME("(%p)->(%s %p) interface not supported\n", This
, debugstr_guid(riid
), ppv
);
807 return E_NOINTERFACE
;
810 static ULONG WINAPI
ApplicationAssociationRegistration_AddRef(IApplicationAssociationRegistration
*iface
)
812 IApplicationAssociationRegistrationImpl
*This
= impl_from_IApplicationAssociationRegistration(iface
);
813 ULONG ref
= InterlockedIncrement(&This
->ref
);
815 TRACE("(%p) ref=%d\n", This
, ref
);
819 static ULONG WINAPI
ApplicationAssociationRegistration_Release(IApplicationAssociationRegistration
*iface
)
821 IApplicationAssociationRegistrationImpl
*This
= impl_from_IApplicationAssociationRegistration(iface
);
822 ULONG ref
= InterlockedDecrement(&This
->ref
);
824 TRACE("(%p) ref=%d\n", This
, ref
);
832 static HRESULT WINAPI
ApplicationAssociationRegistration_QueryCurrentDefault(IApplicationAssociationRegistration
* This
, LPCWSTR query
,
833 ASSOCIATIONTYPE type
, ASSOCIATIONLEVEL level
, LPWSTR
*association
)
835 FIXME("(%p)->(%s, %d, %d, %p)\n", This
, debugstr_w(query
), type
, level
, association
);
839 static HRESULT WINAPI
ApplicationAssociationRegistration_QueryAppIsDefault(IApplicationAssociationRegistration
* This
, LPCWSTR query
,
840 ASSOCIATIONTYPE type
, ASSOCIATIONLEVEL level
, LPCWSTR appname
, BOOL
*is_default
)
842 FIXME("(%p)->(%s, %d, %d, %s, %p)\n", This
, debugstr_w(query
), type
, level
, debugstr_w(appname
), is_default
);
846 static HRESULT WINAPI
ApplicationAssociationRegistration_QueryAppIsDefaultAll(IApplicationAssociationRegistration
* This
, ASSOCIATIONLEVEL level
,
847 LPCWSTR appname
, BOOL
*is_default
)
849 FIXME("(%p)->(%d, %s, %p)\n", This
, level
, debugstr_w(appname
), is_default
);
853 static HRESULT WINAPI
ApplicationAssociationRegistration_SetAppAsDefault(IApplicationAssociationRegistration
* This
, LPCWSTR appname
,
854 LPCWSTR set
, ASSOCIATIONTYPE set_type
)
856 FIXME("(%p)->(%s, %s, %d)\n", This
, debugstr_w(appname
), debugstr_w(set
), set_type
);
860 static HRESULT WINAPI
ApplicationAssociationRegistration_SetAppAsDefaultAll(IApplicationAssociationRegistration
* This
, LPCWSTR appname
)
862 FIXME("(%p)->(%s)\n", This
, debugstr_w(appname
));
867 static HRESULT WINAPI
ApplicationAssociationRegistration_ClearUserAssociations(IApplicationAssociationRegistration
* This
)
869 FIXME("(%p)\n", This
);
874 static const IApplicationAssociationRegistrationVtbl IApplicationAssociationRegistration_vtbl
=
876 ApplicationAssociationRegistration_QueryInterface
,
877 ApplicationAssociationRegistration_AddRef
,
878 ApplicationAssociationRegistration_Release
,
879 ApplicationAssociationRegistration_QueryCurrentDefault
,
880 ApplicationAssociationRegistration_QueryAppIsDefault
,
881 ApplicationAssociationRegistration_QueryAppIsDefaultAll
,
882 ApplicationAssociationRegistration_SetAppAsDefault
,
883 ApplicationAssociationRegistration_SetAppAsDefaultAll
,
884 ApplicationAssociationRegistration_ClearUserAssociations
887 /**************************************************************************
888 * IQueryAssociations_Constructor [internal]
890 * Construct a new IQueryAssociations object.
892 HRESULT WINAPI
QueryAssociations_Constructor(IUnknown
*pUnkOuter
, REFIID riid
, LPVOID
*ppOutput
)
894 IQueryAssociationsImpl
* this;
897 if (pUnkOuter
) return CLASS_E_NOAGGREGATION
;
899 if (!(this = SHAlloc(sizeof(*this)))) return E_OUTOFMEMORY
;
900 this->IQueryAssociations_iface
.lpVtbl
= &IQueryAssociations_vtbl
;
902 this->hkeySource
= 0;
903 this->hkeyProgID
= 0;
904 if (FAILED(ret
= IUnknown_QueryInterface((IUnknown
*)this, riid
, ppOutput
))) SHFree( this );
905 TRACE("returning %p\n", *ppOutput
);
909 /**************************************************************************
910 * ApplicationAssociationRegistration_Constructor [internal]
912 * Construct a IApplicationAssociationRegistration object.
914 HRESULT WINAPI
ApplicationAssociationRegistration_Constructor(IUnknown
*outer
, REFIID riid
, LPVOID
*ppv
)
916 IApplicationAssociationRegistrationImpl
*This
;
920 return CLASS_E_NOAGGREGATION
;
922 if (!(This
= SHAlloc(sizeof(*This
))))
923 return E_OUTOFMEMORY
;
925 This
->IApplicationAssociationRegistration_iface
.lpVtbl
= &IApplicationAssociationRegistration_vtbl
;
928 hr
= IApplicationAssociationRegistration_QueryInterface(&This
->IApplicationAssociationRegistration_iface
, riid
, ppv
);
932 TRACE("returning 0x%x with %p\n", hr
, *ppv
);