2009-08-25 09:13:26 +00:00
|
|
|
/*
|
|
|
|
* IQueryAssociations object and helper functions
|
|
|
|
*
|
|
|
|
* Copyright 2002 Jon Griffiths
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include <assert.h>
|
|
|
|
|
|
|
|
#define COBJMACROS
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "winnls.h"
|
|
|
|
#include "winreg.h"
|
|
|
|
#include "objbase.h"
|
|
|
|
#include "shlguid.h"
|
|
|
|
#include "shlwapi.h"
|
2012-01-15 23:06:15 +00:00
|
|
|
#include "shobjidl.h"
|
2009-08-25 09:13:26 +00:00
|
|
|
#include "shell32_main.h"
|
|
|
|
#include "ver.h"
|
|
|
|
#include "wine/unicode.h"
|
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(shell);
|
|
|
|
|
|
|
|
/**************************************************************************
|
2012-01-11 22:58:09 +00:00
|
|
|
* IQueryAssociations
|
2009-08-25 09:13:26 +00:00
|
|
|
*
|
|
|
|
* DESCRIPTION
|
|
|
|
* This object provides a layer of abstraction over the system registry in
|
|
|
|
* order to simplify the process of parsing associations between files.
|
|
|
|
* Associations in this context means the registry entries that link (for
|
|
|
|
* example) the extension of a file with its description, list of
|
|
|
|
* applications to open the file with, and actions that can be performed on it
|
|
|
|
* (the shell displays such information in the context menu of explorer
|
|
|
|
* when you right-click on a file).
|
|
|
|
*
|
|
|
|
* HELPERS
|
|
|
|
* You can use this object transparently by calling the helper functions
|
|
|
|
* AssocQueryKeyA(), AssocQueryStringA() and AssocQueryStringByKeyA(). These
|
|
|
|
* create an IQueryAssociations object, perform the requested actions
|
|
|
|
* and then dispose of the object. Alternatively, you can create an instance
|
|
|
|
* of the object using AssocCreate() and call the following methods on it:
|
|
|
|
*
|
|
|
|
* METHODS
|
|
|
|
*/
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
2010-12-04 21:16:32 +00:00
|
|
|
IQueryAssociations IQueryAssociations_iface;
|
2009-08-25 09:13:26 +00:00
|
|
|
LONG ref;
|
|
|
|
HKEY hkeySource;
|
|
|
|
HKEY hkeyProgID;
|
|
|
|
} IQueryAssociationsImpl;
|
|
|
|
|
2012-01-15 23:06:15 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
IApplicationAssociationRegistration IApplicationAssociationRegistration_iface;
|
|
|
|
LONG ref;
|
|
|
|
} IApplicationAssociationRegistrationImpl;
|
|
|
|
|
|
|
|
|
2010-12-04 21:16:32 +00:00
|
|
|
static inline IQueryAssociationsImpl *impl_from_IQueryAssociations(IQueryAssociations *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, IQueryAssociationsImpl, IQueryAssociations_iface);
|
|
|
|
}
|
|
|
|
|
2009-08-25 09:13:26 +00:00
|
|
|
/**************************************************************************
|
2012-01-11 22:58:09 +00:00
|
|
|
* IQueryAssociations_QueryInterface
|
2009-08-25 09:13:26 +00:00
|
|
|
*
|
|
|
|
* See IUnknown_QueryInterface.
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI IQueryAssociations_fnQueryInterface(
|
|
|
|
IQueryAssociations* iface,
|
|
|
|
REFIID riid,
|
|
|
|
LPVOID *ppvObj)
|
|
|
|
{
|
2010-12-04 21:16:32 +00:00
|
|
|
IQueryAssociationsImpl *This = impl_from_IQueryAssociations(iface);
|
2009-08-25 09:13:26 +00:00
|
|
|
|
|
|
|
TRACE("(%p,%s,%p)\n",This, debugstr_guid(riid), ppvObj);
|
|
|
|
|
2012-01-15 23:06:14 +00:00
|
|
|
if (ppvObj == NULL)
|
|
|
|
return E_POINTER;
|
|
|
|
|
2009-08-25 09:13:26 +00:00
|
|
|
*ppvObj = NULL;
|
|
|
|
|
|
|
|
if (IsEqualIID(riid, &IID_IUnknown) ||
|
|
|
|
IsEqualIID(riid, &IID_IQueryAssociations))
|
|
|
|
{
|
2013-09-03 13:09:07 +00:00
|
|
|
*ppvObj = &This->IQueryAssociations_iface;
|
2009-08-25 09:13:26 +00:00
|
|
|
|
|
|
|
IQueryAssociations_AddRef((IQueryAssociations*)*ppvObj);
|
|
|
|
TRACE("Returning IQueryAssociations (%p)\n", *ppvObj);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
TRACE("Returning E_NOINTERFACE\n");
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
2012-01-11 22:58:09 +00:00
|
|
|
* IQueryAssociations_AddRef
|
2009-08-25 09:13:26 +00:00
|
|
|
*
|
|
|
|
* See IUnknown_AddRef.
|
|
|
|
*/
|
|
|
|
static ULONG WINAPI IQueryAssociations_fnAddRef(IQueryAssociations *iface)
|
|
|
|
{
|
2010-12-04 21:16:32 +00:00
|
|
|
IQueryAssociationsImpl *This = impl_from_IQueryAssociations(iface);
|
2009-08-25 09:13:26 +00:00
|
|
|
ULONG refCount = InterlockedIncrement(&This->ref);
|
|
|
|
|
|
|
|
TRACE("(%p)->(ref before=%u)\n",This, refCount - 1);
|
|
|
|
|
|
|
|
return refCount;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
2012-01-11 22:58:09 +00:00
|
|
|
* IQueryAssociations_Release
|
2009-08-25 09:13:26 +00:00
|
|
|
*
|
|
|
|
* See IUnknown_Release.
|
|
|
|
*/
|
|
|
|
static ULONG WINAPI IQueryAssociations_fnRelease(IQueryAssociations *iface)
|
|
|
|
{
|
2010-12-04 21:16:32 +00:00
|
|
|
IQueryAssociationsImpl *This = impl_from_IQueryAssociations(iface);
|
2009-08-25 09:13:26 +00:00
|
|
|
ULONG refCount = InterlockedDecrement(&This->ref);
|
|
|
|
|
|
|
|
TRACE("(%p)->(ref before=%u)\n",This, refCount + 1);
|
|
|
|
|
|
|
|
if (!refCount)
|
|
|
|
{
|
|
|
|
TRACE("Destroying IQueryAssociations (%p)\n", This);
|
|
|
|
RegCloseKey(This->hkeySource);
|
|
|
|
RegCloseKey(This->hkeyProgID);
|
2012-01-15 23:06:12 +00:00
|
|
|
SHFree(This);
|
2009-08-25 09:13:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return refCount;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
2012-01-11 22:58:09 +00:00
|
|
|
* IQueryAssociations_Init
|
2009-08-25 09:13:26 +00:00
|
|
|
*
|
|
|
|
* Initialise an IQueryAssociations object.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* iface [I] IQueryAssociations interface to initialise
|
|
|
|
* cfFlags [I] ASSOCF_ flags from "shlwapi.h"
|
|
|
|
* pszAssoc [I] String for the root key name, or NULL if hkeyProgid is given
|
|
|
|
* hkeyProgid [I] Handle for the root key, or NULL if pszAssoc is given
|
|
|
|
* hWnd [I] Reserved, must be NULL.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: S_OK. iface is initialised with the parameters given.
|
|
|
|
* Failure: An HRESULT error code indicating the error.
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI IQueryAssociations_fnInit(
|
|
|
|
IQueryAssociations *iface,
|
|
|
|
ASSOCF cfFlags,
|
|
|
|
LPCWSTR pszAssoc,
|
|
|
|
HKEY hkeyProgid,
|
|
|
|
HWND hWnd)
|
|
|
|
{
|
|
|
|
static const WCHAR szProgID[] = {'P','r','o','g','I','D',0};
|
2010-12-04 21:16:32 +00:00
|
|
|
IQueryAssociationsImpl *This = impl_from_IQueryAssociations(iface);
|
2009-08-25 09:13:26 +00:00
|
|
|
LONG ret;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%d,%s,%p,%p)\n", iface,
|
|
|
|
cfFlags,
|
|
|
|
debugstr_w(pszAssoc),
|
|
|
|
hkeyProgid,
|
|
|
|
hWnd);
|
|
|
|
if (hWnd != NULL)
|
|
|
|
FIXME("hwnd != NULL not supported\n");
|
|
|
|
if (cfFlags != 0)
|
|
|
|
FIXME("unsupported flags: %x\n", cfFlags);
|
|
|
|
if (pszAssoc != NULL)
|
|
|
|
{
|
|
|
|
ret = RegOpenKeyExW(HKEY_CLASSES_ROOT,
|
|
|
|
pszAssoc,
|
|
|
|
0,
|
|
|
|
KEY_READ,
|
|
|
|
&This->hkeySource);
|
|
|
|
if (ret != ERROR_SUCCESS)
|
|
|
|
return E_FAIL;
|
|
|
|
/* if this is not a prog id */
|
|
|
|
if ((*pszAssoc == '.') || (*pszAssoc == '{'))
|
|
|
|
{
|
|
|
|
RegOpenKeyExW(This->hkeySource,
|
|
|
|
szProgID,
|
|
|
|
0,
|
|
|
|
KEY_READ,
|
|
|
|
&This->hkeyProgID);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
This->hkeyProgID = This->hkeySource;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
else if (hkeyProgid != NULL)
|
|
|
|
{
|
|
|
|
This->hkeyProgID = hkeyProgid;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return E_INVALIDARG;
|
|
|
|
}
|
|
|
|
|
2012-03-27 10:04:55 +00:00
|
|
|
static HRESULT ASSOC_GetValue(HKEY hkey, const WCHAR *name, void **data, DWORD *data_size)
|
2009-08-25 09:13:26 +00:00
|
|
|
{
|
2012-03-27 10:04:55 +00:00
|
|
|
DWORD size;
|
2009-08-25 09:13:26 +00:00
|
|
|
LONG ret;
|
|
|
|
|
2012-03-27 10:04:55 +00:00
|
|
|
assert(data);
|
|
|
|
ret = RegQueryValueExW(hkey, name, 0, NULL, NULL, &size);
|
2009-08-25 09:13:26 +00:00
|
|
|
if (ret != ERROR_SUCCESS)
|
|
|
|
return HRESULT_FROM_WIN32(ret);
|
2012-03-27 10:04:55 +00:00
|
|
|
if (!size)
|
2009-08-25 09:13:26 +00:00
|
|
|
return E_FAIL;
|
2012-03-27 10:04:55 +00:00
|
|
|
*data = HeapAlloc(GetProcessHeap(), 0, size);
|
|
|
|
if (!*data)
|
2009-08-25 09:13:26 +00:00
|
|
|
return E_OUTOFMEMORY;
|
2012-03-27 10:04:55 +00:00
|
|
|
ret = RegQueryValueExW(hkey, name, 0, NULL, (LPBYTE)*data, &size);
|
2009-08-25 09:13:26 +00:00
|
|
|
if (ret != ERROR_SUCCESS)
|
|
|
|
{
|
2012-03-27 10:04:55 +00:00
|
|
|
HeapFree(GetProcessHeap(), 0, *data);
|
2009-08-25 09:13:26 +00:00
|
|
|
return HRESULT_FROM_WIN32(ret);
|
|
|
|
}
|
2012-03-27 10:04:55 +00:00
|
|
|
if(data_size)
|
|
|
|
*data_size = size;
|
2009-08-25 09:13:26 +00:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2013-09-09 05:26:40 +00:00
|
|
|
static HRESULT ASSOC_GetCommand(IQueryAssociationsImpl *This, const WCHAR *extra, WCHAR **command)
|
2009-08-25 09:13:26 +00:00
|
|
|
{
|
|
|
|
HKEY hkeyCommand;
|
|
|
|
HKEY hkeyShell;
|
|
|
|
HKEY hkeyVerb;
|
|
|
|
HRESULT hr;
|
|
|
|
LONG ret;
|
2013-09-09 05:26:40 +00:00
|
|
|
WCHAR *extra_from_reg = NULL;
|
|
|
|
WCHAR *filetype;
|
2009-08-25 09:13:26 +00:00
|
|
|
static const WCHAR commandW[] = { 'c','o','m','m','a','n','d',0 };
|
|
|
|
static const WCHAR shellW[] = { 's','h','e','l','l',0 };
|
|
|
|
|
2013-09-09 05:26:40 +00:00
|
|
|
/* When looking for file extension it's possible to have a default value
|
|
|
|
that points to another key that contains 'shell/<verb>/command' subtree. */
|
|
|
|
hr = ASSOC_GetValue(This->hkeySource, NULL, (void**)&filetype, NULL);
|
|
|
|
if (hr == S_OK)
|
|
|
|
{
|
|
|
|
HKEY hkeyFile;
|
2009-08-25 09:13:26 +00:00
|
|
|
|
2013-09-09 05:26:40 +00:00
|
|
|
ret = RegOpenKeyExW(HKEY_CLASSES_ROOT, filetype, 0, KEY_READ, &hkeyFile);
|
|
|
|
HeapFree(GetProcessHeap(), 0, filetype);
|
|
|
|
if (ret) return HRESULT_FROM_WIN32(ret);
|
2009-08-25 09:13:26 +00:00
|
|
|
|
2013-09-09 05:26:40 +00:00
|
|
|
ret = RegOpenKeyExW(hkeyFile, shellW, 0, KEY_READ, &hkeyShell);
|
|
|
|
RegCloseKey(hkeyFile);
|
|
|
|
if (ret) return HRESULT_FROM_WIN32(ret);
|
|
|
|
}
|
|
|
|
else
|
2009-08-25 09:13:26 +00:00
|
|
|
{
|
2013-09-09 05:26:40 +00:00
|
|
|
ret = RegOpenKeyExW(This->hkeySource, shellW, 0, KEY_READ, &hkeyShell);
|
|
|
|
if (ret) return HRESULT_FROM_WIN32(ret);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!extra)
|
|
|
|
{
|
|
|
|
/* check for default verb */
|
|
|
|
hr = ASSOC_GetValue(hkeyShell, NULL, (void**)&extra_from_reg, NULL);
|
|
|
|
if (FAILED(hr))
|
2009-08-25 09:13:26 +00:00
|
|
|
{
|
2013-09-09 05:26:40 +00:00
|
|
|
/* no default verb, try first subkey */
|
|
|
|
DWORD max_subkey_len;
|
|
|
|
|
|
|
|
ret = RegQueryInfoKeyW(hkeyShell, NULL, NULL, NULL, NULL, &max_subkey_len, NULL, NULL, NULL, NULL, NULL, NULL);
|
|
|
|
if (ret)
|
|
|
|
{
|
|
|
|
RegCloseKey(hkeyShell);
|
|
|
|
return HRESULT_FROM_WIN32(ret);
|
|
|
|
}
|
|
|
|
|
|
|
|
max_subkey_len++;
|
|
|
|
extra_from_reg = HeapAlloc(GetProcessHeap(), 0, max_subkey_len * sizeof(WCHAR));
|
|
|
|
if (!extra_from_reg)
|
|
|
|
{
|
|
|
|
RegCloseKey(hkeyShell);
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = RegEnumKeyExW(hkeyShell, 0, extra_from_reg, &max_subkey_len, NULL, NULL, NULL, NULL);
|
|
|
|
if (ret)
|
|
|
|
{
|
|
|
|
HeapFree(GetProcessHeap(), 0, extra_from_reg);
|
|
|
|
RegCloseKey(hkeyShell);
|
|
|
|
return HRESULT_FROM_WIN32(ret);
|
|
|
|
}
|
2009-08-25 09:13:26 +00:00
|
|
|
}
|
2013-09-09 05:26:40 +00:00
|
|
|
extra = extra_from_reg;
|
2009-08-25 09:13:26 +00:00
|
|
|
}
|
|
|
|
|
2013-09-09 05:26:40 +00:00
|
|
|
/* open verb subkey */
|
|
|
|
ret = RegOpenKeyExW(hkeyShell, extra, 0, KEY_READ, &hkeyVerb);
|
|
|
|
HeapFree(GetProcessHeap(), 0, extra_from_reg);
|
2009-08-25 09:13:26 +00:00
|
|
|
RegCloseKey(hkeyShell);
|
2013-09-09 05:26:40 +00:00
|
|
|
if (ret) return HRESULT_FROM_WIN32(ret);
|
2009-08-25 09:13:26 +00:00
|
|
|
|
2013-09-09 05:26:40 +00:00
|
|
|
/* open command subkey */
|
2009-08-25 09:13:26 +00:00
|
|
|
ret = RegOpenKeyExW(hkeyVerb, commandW, 0, KEY_READ, &hkeyCommand);
|
|
|
|
RegCloseKey(hkeyVerb);
|
2013-09-09 05:26:40 +00:00
|
|
|
if (ret) return HRESULT_FROM_WIN32(ret);
|
|
|
|
|
|
|
|
hr = ASSOC_GetValue(hkeyCommand, NULL, (void**)command, NULL);
|
2009-08-25 09:13:26 +00:00
|
|
|
RegCloseKey(hkeyCommand);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT ASSOC_GetExecutable(IQueryAssociationsImpl *This,
|
|
|
|
LPCWSTR pszExtra, LPWSTR path,
|
|
|
|
DWORD pathlen, DWORD *len)
|
|
|
|
{
|
|
|
|
WCHAR *pszCommand;
|
|
|
|
WCHAR *pszStart;
|
|
|
|
WCHAR *pszEnd;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
assert(len);
|
|
|
|
|
|
|
|
hr = ASSOC_GetCommand(This, pszExtra, &pszCommand);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
/* cleanup pszCommand */
|
|
|
|
if (pszCommand[0] == '"')
|
|
|
|
{
|
|
|
|
pszStart = pszCommand + 1;
|
|
|
|
pszEnd = strchrW(pszStart, '"');
|
2009-11-23 19:43:42 +00:00
|
|
|
if (pszEnd)
|
|
|
|
*pszEnd = 0;
|
|
|
|
*len = SearchPathW(NULL, pszStart, NULL, pathlen, path, NULL);
|
2009-08-25 09:13:26 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pszStart = pszCommand;
|
2009-11-23 19:43:42 +00:00
|
|
|
for (pszEnd = pszStart; (pszEnd = strchrW(pszEnd, ' ')); pszEnd++)
|
|
|
|
{
|
|
|
|
WCHAR c = *pszEnd;
|
|
|
|
*pszEnd = 0;
|
|
|
|
if ((*len = SearchPathW(NULL, pszStart, NULL, pathlen, path, NULL)))
|
|
|
|
break;
|
|
|
|
*pszEnd = c;
|
|
|
|
}
|
|
|
|
if (!pszEnd)
|
|
|
|
*len = SearchPathW(NULL, pszStart, NULL, pathlen, path, NULL);
|
2009-08-25 09:13:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, pszCommand);
|
|
|
|
if (!*len)
|
|
|
|
return HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2012-03-27 10:04:55 +00:00
|
|
|
static HRESULT ASSOC_ReturnData(void *out, DWORD *outlen, const void *data,
|
2009-08-25 09:13:26 +00:00
|
|
|
DWORD datalen)
|
|
|
|
{
|
|
|
|
assert(outlen);
|
|
|
|
|
|
|
|
if (out)
|
|
|
|
{
|
|
|
|
if (*outlen < datalen)
|
|
|
|
{
|
|
|
|
*outlen = datalen;
|
|
|
|
return E_POINTER;
|
|
|
|
}
|
|
|
|
*outlen = datalen;
|
2012-03-27 10:04:55 +00:00
|
|
|
memcpy(out, data, datalen);
|
2009-08-25 09:13:26 +00:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*outlen = datalen;
|
|
|
|
return S_FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-03-27 10:04:55 +00:00
|
|
|
static HRESULT ASSOC_ReturnString(LPWSTR out, DWORD *outlen, LPCWSTR data,
|
|
|
|
DWORD datalen)
|
|
|
|
{
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
assert(outlen);
|
|
|
|
|
|
|
|
*outlen *= sizeof(WCHAR);
|
|
|
|
hres = ASSOC_ReturnData(out, outlen, data, datalen*sizeof(WCHAR));
|
|
|
|
*outlen /= sizeof(WCHAR);
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
2009-08-25 09:13:26 +00:00
|
|
|
/**************************************************************************
|
2012-01-11 22:58:09 +00:00
|
|
|
* IQueryAssociations_GetString
|
2009-08-25 09:13:26 +00:00
|
|
|
*
|
|
|
|
* Get a file association string from the registry.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* iface [I] IQueryAssociations interface to query
|
|
|
|
* cfFlags [I] ASSOCF_ flags from "shlwapi.h"
|
|
|
|
* str [I] Type of string to get (ASSOCSTR enum from "shlwapi.h")
|
|
|
|
* pszExtra [I] Extra information about the string location
|
|
|
|
* pszOut [O] Destination for the association string
|
|
|
|
* pcchOut [I/O] Length of pszOut
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: S_OK. pszOut contains the string, pcchOut contains its length.
|
|
|
|
* Failure: An HRESULT error code indicating the error.
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI IQueryAssociations_fnGetString(
|
|
|
|
IQueryAssociations *iface,
|
|
|
|
ASSOCF cfFlags,
|
|
|
|
ASSOCSTR str,
|
|
|
|
LPCWSTR pszExtra,
|
|
|
|
LPWSTR pszOut,
|
|
|
|
DWORD *pcchOut)
|
|
|
|
{
|
2010-12-04 21:16:32 +00:00
|
|
|
IQueryAssociationsImpl *This = impl_from_IQueryAssociations(iface);
|
2009-08-25 09:13:26 +00:00
|
|
|
const ASSOCF cfUnimplemented = ~(0);
|
|
|
|
DWORD len = 0;
|
|
|
|
HRESULT hr;
|
|
|
|
WCHAR path[MAX_PATH];
|
|
|
|
|
2013-05-09 14:42:07 +00:00
|
|
|
TRACE("(%p,0x%08x,%u,%s,%p,%p)\n", This, cfFlags, str,
|
2009-08-25 09:13:26 +00:00
|
|
|
debugstr_w(pszExtra), pszOut, pcchOut);
|
|
|
|
|
|
|
|
if (cfFlags & cfUnimplemented)
|
|
|
|
FIXME("%08x: unimplemented flags!\n", cfFlags & cfUnimplemented);
|
|
|
|
|
|
|
|
if (!pcchOut)
|
|
|
|
return E_UNEXPECTED;
|
|
|
|
|
|
|
|
switch (str)
|
|
|
|
{
|
|
|
|
case ASSOCSTR_COMMAND:
|
|
|
|
{
|
|
|
|
WCHAR *command;
|
|
|
|
hr = ASSOC_GetCommand(This, pszExtra, &command);
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
2012-03-27 10:04:55 +00:00
|
|
|
hr = ASSOC_ReturnString(pszOut, pcchOut, command, strlenW(command) + 1);
|
2009-08-25 09:13:26 +00:00
|
|
|
HeapFree(GetProcessHeap(), 0, command);
|
|
|
|
}
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
case ASSOCSTR_EXECUTABLE:
|
|
|
|
{
|
|
|
|
hr = ASSOC_GetExecutable(This, pszExtra, path, MAX_PATH, &len);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
len++;
|
2012-03-27 10:04:55 +00:00
|
|
|
return ASSOC_ReturnString(pszOut, pcchOut, path, len);
|
2009-08-25 09:13:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
case ASSOCSTR_FRIENDLYDOCNAME:
|
|
|
|
{
|
|
|
|
WCHAR *pszFileType;
|
|
|
|
DWORD ret;
|
|
|
|
DWORD size;
|
|
|
|
|
2012-03-27 10:04:55 +00:00
|
|
|
hr = ASSOC_GetValue(This->hkeySource, NULL, (void**)&pszFileType, NULL);
|
2009-08-25 09:13:26 +00:00
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
size = 0;
|
|
|
|
ret = RegGetValueW(HKEY_CLASSES_ROOT, pszFileType, NULL, RRF_RT_REG_SZ, NULL, NULL, &size);
|
|
|
|
if (ret == ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
WCHAR *docName = HeapAlloc(GetProcessHeap(), 0, size);
|
|
|
|
if (docName)
|
|
|
|
{
|
|
|
|
ret = RegGetValueW(HKEY_CLASSES_ROOT, pszFileType, NULL, RRF_RT_REG_SZ, NULL, docName, &size);
|
|
|
|
if (ret == ERROR_SUCCESS)
|
2012-03-27 10:04:55 +00:00
|
|
|
hr = ASSOC_ReturnString(pszOut, pcchOut, docName, strlenW(docName) + 1);
|
2009-08-25 09:13:26 +00:00
|
|
|
else
|
|
|
|
hr = HRESULT_FROM_WIN32(ret);
|
|
|
|
HeapFree(GetProcessHeap(), 0, docName);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
hr = E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
hr = HRESULT_FROM_WIN32(ret);
|
|
|
|
HeapFree(GetProcessHeap(), 0, pszFileType);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
case ASSOCSTR_FRIENDLYAPPNAME:
|
|
|
|
{
|
|
|
|
PVOID verinfoW = NULL;
|
|
|
|
DWORD size, retval = 0;
|
|
|
|
UINT flen;
|
|
|
|
WCHAR *bufW;
|
|
|
|
static const WCHAR translationW[] = {
|
|
|
|
'\\','V','a','r','F','i','l','e','I','n','f','o',
|
|
|
|
'\\','T','r','a','n','s','l','a','t','i','o','n',0
|
|
|
|
};
|
|
|
|
static const WCHAR fileDescFmtW[] = {
|
|
|
|
'\\','S','t','r','i','n','g','F','i','l','e','I','n','f','o',
|
|
|
|
'\\','%','0','4','x','%','0','4','x',
|
|
|
|
'\\','F','i','l','e','D','e','s','c','r','i','p','t','i','o','n',0
|
|
|
|
};
|
|
|
|
WCHAR fileDescW[41];
|
|
|
|
|
|
|
|
hr = ASSOC_GetExecutable(This, pszExtra, path, MAX_PATH, &len);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
retval = GetFileVersionInfoSizeW(path, &size);
|
|
|
|
if (!retval)
|
|
|
|
goto get_friendly_name_fail;
|
|
|
|
verinfoW = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, retval);
|
|
|
|
if (!verinfoW)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
if (!GetFileVersionInfoW(path, 0, retval, verinfoW))
|
|
|
|
goto get_friendly_name_fail;
|
|
|
|
if (VerQueryValueW(verinfoW, translationW, (LPVOID *)&bufW, &flen))
|
|
|
|
{
|
|
|
|
UINT i;
|
|
|
|
DWORD *langCodeDesc = (DWORD *)bufW;
|
|
|
|
for (i = 0; i < flen / sizeof(DWORD); i++)
|
|
|
|
{
|
|
|
|
sprintfW(fileDescW, fileDescFmtW, LOWORD(langCodeDesc[i]),
|
|
|
|
HIWORD(langCodeDesc[i]));
|
|
|
|
if (VerQueryValueW(verinfoW, fileDescW, (LPVOID *)&bufW, &flen))
|
|
|
|
{
|
|
|
|
/* Does strlenW(bufW) == 0 mean we use the filename? */
|
|
|
|
len = strlenW(bufW) + 1;
|
|
|
|
TRACE("found FileDescription: %s\n", debugstr_w(bufW));
|
2012-03-27 10:04:55 +00:00
|
|
|
hr = ASSOC_ReturnString(pszOut, pcchOut, bufW, len);
|
2009-12-29 19:02:54 +00:00
|
|
|
HeapFree(GetProcessHeap(), 0, verinfoW);
|
|
|
|
return hr;
|
2009-08-25 09:13:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
get_friendly_name_fail:
|
|
|
|
PathRemoveExtensionW(path);
|
|
|
|
PathStripPathW(path);
|
|
|
|
TRACE("using filename: %s\n", debugstr_w(path));
|
2012-03-27 10:04:55 +00:00
|
|
|
hr = ASSOC_ReturnString(pszOut, pcchOut, path, strlenW(path) + 1);
|
2009-12-29 19:02:54 +00:00
|
|
|
HeapFree(GetProcessHeap(), 0, verinfoW);
|
|
|
|
return hr;
|
2009-08-25 09:13:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
case ASSOCSTR_CONTENTTYPE:
|
|
|
|
{
|
|
|
|
static const WCHAR Content_TypeW[] = {'C','o','n','t','e','n','t',' ','T','y','p','e',0};
|
|
|
|
WCHAR *contentType;
|
|
|
|
DWORD ret;
|
|
|
|
DWORD size;
|
|
|
|
|
|
|
|
size = 0;
|
|
|
|
ret = RegGetValueW(This->hkeySource, NULL, Content_TypeW, RRF_RT_REG_SZ, NULL, NULL, &size);
|
|
|
|
if (ret != ERROR_SUCCESS)
|
|
|
|
return HRESULT_FROM_WIN32(ret);
|
|
|
|
contentType = HeapAlloc(GetProcessHeap(), 0, size);
|
|
|
|
if (contentType != NULL)
|
|
|
|
{
|
|
|
|
ret = RegGetValueW(This->hkeySource, NULL, Content_TypeW, RRF_RT_REG_SZ, NULL, contentType, &size);
|
|
|
|
if (ret == ERROR_SUCCESS)
|
2012-03-27 10:04:55 +00:00
|
|
|
hr = ASSOC_ReturnString(pszOut, pcchOut, contentType, strlenW(contentType) + 1);
|
2009-08-25 09:13:26 +00:00
|
|
|
else
|
|
|
|
hr = HRESULT_FROM_WIN32(ret);
|
|
|
|
HeapFree(GetProcessHeap(), 0, contentType);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
hr = E_OUTOFMEMORY;
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
case ASSOCSTR_DEFAULTICON:
|
|
|
|
{
|
|
|
|
static const WCHAR DefaultIconW[] = {'D','e','f','a','u','l','t','I','c','o','n',0};
|
|
|
|
WCHAR *pszFileType;
|
|
|
|
DWORD ret;
|
|
|
|
DWORD size;
|
|
|
|
HKEY hkeyFile;
|
|
|
|
|
2012-03-27 10:04:55 +00:00
|
|
|
hr = ASSOC_GetValue(This->hkeySource, NULL, (void**)&pszFileType, NULL);
|
2009-08-25 09:13:26 +00:00
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
ret = RegOpenKeyExW(HKEY_CLASSES_ROOT, pszFileType, 0, KEY_READ, &hkeyFile);
|
|
|
|
if (ret == ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
size = 0;
|
|
|
|
ret = RegGetValueW(hkeyFile, DefaultIconW, NULL, RRF_RT_REG_SZ, NULL, NULL, &size);
|
|
|
|
if (ret == ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
WCHAR *icon = HeapAlloc(GetProcessHeap(), 0, size);
|
|
|
|
if (icon)
|
|
|
|
{
|
|
|
|
ret = RegGetValueW(hkeyFile, DefaultIconW, NULL, RRF_RT_REG_SZ, NULL, icon, &size);
|
|
|
|
if (ret == ERROR_SUCCESS)
|
2012-03-27 10:04:55 +00:00
|
|
|
hr = ASSOC_ReturnString(pszOut, pcchOut, icon, strlenW(icon) + 1);
|
2009-08-25 09:13:26 +00:00
|
|
|
else
|
|
|
|
hr = HRESULT_FROM_WIN32(ret);
|
|
|
|
HeapFree(GetProcessHeap(), 0, icon);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
hr = E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
hr = HRESULT_FROM_WIN32(ret);
|
|
|
|
RegCloseKey(hkeyFile);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
hr = HRESULT_FROM_WIN32(ret);
|
|
|
|
HeapFree(GetProcessHeap(), 0, pszFileType);
|
|
|
|
return hr;
|
|
|
|
}
|
2013-05-09 14:42:07 +00:00
|
|
|
case ASSOCSTR_SHELLEXTENSION:
|
|
|
|
{
|
|
|
|
static const WCHAR shellexW[] = {'S','h','e','l','l','E','x','\\',0};
|
|
|
|
WCHAR keypath[sizeof(shellexW) / sizeof(shellexW[0]) + 39], guid[39];
|
|
|
|
CLSID clsid;
|
|
|
|
HKEY hkey;
|
|
|
|
DWORD size;
|
|
|
|
LONG ret;
|
|
|
|
|
|
|
|
hr = CLSIDFromString(pszExtra, &clsid);
|
|
|
|
if (FAILED(hr)) return hr;
|
|
|
|
|
|
|
|
strcpyW(keypath, shellexW);
|
|
|
|
strcatW(keypath, pszExtra);
|
|
|
|
ret = RegOpenKeyExW(This->hkeySource, keypath, 0, KEY_READ, &hkey);
|
|
|
|
if (ret) return HRESULT_FROM_WIN32(ret);
|
|
|
|
|
|
|
|
size = sizeof(guid);
|
|
|
|
ret = RegGetValueW(hkey, NULL, NULL, RRF_RT_REG_SZ, NULL, guid, &size);
|
|
|
|
RegCloseKey(hkey);
|
|
|
|
if (ret) return HRESULT_FROM_WIN32(ret);
|
|
|
|
|
|
|
|
return ASSOC_ReturnString(pszOut, pcchOut, guid, size / sizeof(WCHAR));
|
|
|
|
}
|
2009-08-25 09:13:26 +00:00
|
|
|
|
|
|
|
default:
|
|
|
|
FIXME("assocstr %d unimplemented!\n", str);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
2012-01-11 22:58:09 +00:00
|
|
|
* IQueryAssociations_GetKey
|
2009-08-25 09:13:26 +00:00
|
|
|
*
|
|
|
|
* Get a file association key from the registry.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* iface [I] IQueryAssociations interface to query
|
|
|
|
* cfFlags [I] ASSOCF_ flags from "shlwapi.h"
|
|
|
|
* assockey [I] Type of key to get (ASSOCKEY enum from "shlwapi.h")
|
|
|
|
* pszExtra [I] Extra information about the key location
|
|
|
|
* phkeyOut [O] Destination for the association key
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: S_OK. phkeyOut contains a handle to the key.
|
|
|
|
* Failure: An HRESULT error code indicating the error.
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI IQueryAssociations_fnGetKey(
|
|
|
|
IQueryAssociations *iface,
|
|
|
|
ASSOCF cfFlags,
|
|
|
|
ASSOCKEY assockey,
|
|
|
|
LPCWSTR pszExtra,
|
|
|
|
HKEY *phkeyOut)
|
|
|
|
{
|
2010-12-04 21:16:32 +00:00
|
|
|
IQueryAssociationsImpl *This = impl_from_IQueryAssociations(iface);
|
2009-08-25 09:13:26 +00:00
|
|
|
|
|
|
|
FIXME("(%p,0x%8x,0x%8x,%s,%p)-stub!\n", This, cfFlags, assockey,
|
|
|
|
debugstr_w(pszExtra), phkeyOut);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
2012-01-11 22:58:09 +00:00
|
|
|
* IQueryAssociations_GetData
|
2009-08-25 09:13:26 +00:00
|
|
|
*
|
|
|
|
* Get the data for a file association key from the registry.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* iface [I] IQueryAssociations interface to query
|
|
|
|
* cfFlags [I] ASSOCF_ flags from "shlwapi.h"
|
|
|
|
* assocdata [I] Type of data to get (ASSOCDATA enum from "shlwapi.h")
|
|
|
|
* pszExtra [I] Extra information about the data location
|
|
|
|
* pvOut [O] Destination for the association key
|
|
|
|
* pcbOut [I/O] Size of pvOut
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: S_OK. pszOut contains the data, pcbOut contains its length.
|
|
|
|
* Failure: An HRESULT error code indicating the error.
|
|
|
|
*/
|
2012-03-27 10:05:38 +00:00
|
|
|
static HRESULT WINAPI IQueryAssociations_fnGetData(IQueryAssociations *iface,
|
|
|
|
ASSOCF cfFlags, ASSOCDATA assocdata, LPCWSTR pszExtra, LPVOID pvOut,
|
|
|
|
DWORD *pcbOut)
|
2009-08-25 09:13:26 +00:00
|
|
|
{
|
2012-03-27 10:05:38 +00:00
|
|
|
static const WCHAR edit_flags[] = {'E','d','i','t','F','l','a','g','s',0};
|
2009-08-25 09:13:26 +00:00
|
|
|
|
2012-03-27 10:05:38 +00:00
|
|
|
IQueryAssociationsImpl *This = impl_from_IQueryAssociations(iface);
|
|
|
|
void *data;
|
|
|
|
DWORD size;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
TRACE("(%p,0x%8x,0x%8x,%s,%p,%p)\n", This, cfFlags, assocdata,
|
|
|
|
debugstr_w(pszExtra), pvOut, pcbOut);
|
|
|
|
|
|
|
|
if(cfFlags)
|
|
|
|
FIXME("Unsupported flags: %x\n", cfFlags);
|
|
|
|
|
|
|
|
switch(assocdata) {
|
|
|
|
case ASSOCDATA_EDITFLAGS:
|
|
|
|
if(!This->hkeyProgID)
|
|
|
|
return HRESULT_FROM_WIN32(ERROR_NO_ASSOCIATION);
|
|
|
|
|
|
|
|
hres = ASSOC_GetValue(This->hkeyProgID, edit_flags, &data, &size);
|
|
|
|
if(FAILED(hres) || !pcbOut)
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
hres = ASSOC_ReturnData(pvOut, pcbOut, data, size);
|
|
|
|
HeapFree(GetProcessHeap(), 0, data);
|
|
|
|
return hres;
|
|
|
|
default:
|
|
|
|
FIXME("Unsupported ASSOCDATA value: %d\n", assocdata);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
2009-08-25 09:13:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
2012-01-11 22:58:09 +00:00
|
|
|
* IQueryAssociations_GetEnum
|
2009-08-25 09:13:26 +00:00
|
|
|
*
|
|
|
|
* Not yet implemented in native Win32.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* iface [I] IQueryAssociations interface to query
|
|
|
|
* cfFlags [I] ASSOCF_ flags from "shlwapi.h"
|
|
|
|
* assocenum [I] Type of enum to get (ASSOCENUM enum from "shlwapi.h")
|
|
|
|
* pszExtra [I] Extra information about the enum location
|
|
|
|
* riid [I] REFIID to look for
|
|
|
|
* ppvOut [O] Destination for the interface.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: S_OK.
|
|
|
|
* Failure: An HRESULT error code indicating the error.
|
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* Presumably this function returns an enumerator object.
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI IQueryAssociations_fnGetEnum(
|
|
|
|
IQueryAssociations *iface,
|
|
|
|
ASSOCF cfFlags,
|
|
|
|
ASSOCENUM assocenum,
|
|
|
|
LPCWSTR pszExtra,
|
|
|
|
REFIID riid,
|
|
|
|
LPVOID *ppvOut)
|
|
|
|
{
|
2010-12-04 21:16:32 +00:00
|
|
|
IQueryAssociationsImpl *This = impl_from_IQueryAssociations(iface);
|
2009-08-25 09:13:26 +00:00
|
|
|
|
|
|
|
FIXME("(%p,0x%8x,0x%8x,%s,%s,%p)-stub!\n", This, cfFlags, assocenum,
|
|
|
|
debugstr_w(pszExtra), debugstr_guid(riid), ppvOut);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IQueryAssociationsVtbl IQueryAssociations_vtbl =
|
|
|
|
{
|
|
|
|
IQueryAssociations_fnQueryInterface,
|
|
|
|
IQueryAssociations_fnAddRef,
|
|
|
|
IQueryAssociations_fnRelease,
|
|
|
|
IQueryAssociations_fnInit,
|
|
|
|
IQueryAssociations_fnGetString,
|
|
|
|
IQueryAssociations_fnGetKey,
|
|
|
|
IQueryAssociations_fnGetData,
|
|
|
|
IQueryAssociations_fnGetEnum
|
|
|
|
};
|
|
|
|
|
2012-01-15 23:06:15 +00:00
|
|
|
/**************************************************************************
|
|
|
|
* IApplicationAssociationRegistration implementation
|
|
|
|
*/
|
|
|
|
static inline IApplicationAssociationRegistrationImpl *impl_from_IApplicationAssociationRegistration(IApplicationAssociationRegistration *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, IApplicationAssociationRegistrationImpl, IApplicationAssociationRegistration_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ApplicationAssociationRegistration_QueryInterface(
|
|
|
|
IApplicationAssociationRegistration* iface, REFIID riid, LPVOID *ppv)
|
|
|
|
{
|
|
|
|
IApplicationAssociationRegistrationImpl *This = impl_from_IApplicationAssociationRegistration(iface);
|
|
|
|
|
|
|
|
TRACE("(%p, %s, %p)\n",This, debugstr_guid(riid), ppv);
|
|
|
|
|
|
|
|
if (ppv == NULL)
|
|
|
|
return E_POINTER;
|
|
|
|
|
|
|
|
if (IsEqualGUID(&IID_IUnknown, riid) ||
|
|
|
|
IsEqualGUID(&IID_IApplicationAssociationRegistration, riid)) {
|
|
|
|
*ppv = &This->IApplicationAssociationRegistration_iface;
|
|
|
|
IUnknown_AddRef((IUnknown*)*ppv);
|
|
|
|
TRACE("returning IApplicationAssociationRegistration: %p\n", *ppv);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
*ppv = NULL;
|
|
|
|
FIXME("(%p)->(%s %p) interface not supported\n", This, debugstr_guid(riid), ppv);
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI ApplicationAssociationRegistration_AddRef(IApplicationAssociationRegistration *iface)
|
|
|
|
{
|
|
|
|
IApplicationAssociationRegistrationImpl *This = impl_from_IApplicationAssociationRegistration(iface);
|
|
|
|
ULONG ref = InterlockedIncrement(&This->ref);
|
|
|
|
|
|
|
|
TRACE("(%p) ref=%d\n", This, ref);
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI ApplicationAssociationRegistration_Release(IApplicationAssociationRegistration *iface)
|
|
|
|
{
|
|
|
|
IApplicationAssociationRegistrationImpl *This = impl_from_IApplicationAssociationRegistration(iface);
|
|
|
|
ULONG ref = InterlockedDecrement(&This->ref);
|
|
|
|
|
|
|
|
TRACE("(%p) ref=%d\n", This, ref);
|
|
|
|
|
|
|
|
if (!ref) {
|
|
|
|
SHFree(This);
|
|
|
|
}
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ApplicationAssociationRegistration_QueryCurrentDefault(IApplicationAssociationRegistration* This, LPCWSTR query,
|
|
|
|
ASSOCIATIONTYPE type, ASSOCIATIONLEVEL level, LPWSTR *association)
|
|
|
|
{
|
|
|
|
FIXME("(%p)->(%s, %d, %d, %p)\n", This, debugstr_w(query), type, level, association);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ApplicationAssociationRegistration_QueryAppIsDefault(IApplicationAssociationRegistration* This, LPCWSTR query,
|
|
|
|
ASSOCIATIONTYPE type, ASSOCIATIONLEVEL level, LPCWSTR appname, BOOL *is_default)
|
|
|
|
{
|
|
|
|
FIXME("(%p)->(%s, %d, %d, %s, %p)\n", This, debugstr_w(query), type, level, debugstr_w(appname), is_default);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ApplicationAssociationRegistration_QueryAppIsDefaultAll(IApplicationAssociationRegistration* This, ASSOCIATIONLEVEL level,
|
|
|
|
LPCWSTR appname, BOOL *is_default)
|
|
|
|
{
|
|
|
|
FIXME("(%p)->(%d, %s, %p)\n", This, level, debugstr_w(appname), is_default);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ApplicationAssociationRegistration_SetAppAsDefault(IApplicationAssociationRegistration* This, LPCWSTR appname,
|
|
|
|
LPCWSTR set, ASSOCIATIONTYPE set_type)
|
|
|
|
{
|
|
|
|
FIXME("(%p)->(%s, %s, %d)\n", This, debugstr_w(appname), debugstr_w(set), set_type);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ApplicationAssociationRegistration_SetAppAsDefaultAll(IApplicationAssociationRegistration* This, LPCWSTR appname)
|
|
|
|
{
|
|
|
|
FIXME("(%p)->(%s)\n", This, debugstr_w(appname));
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI ApplicationAssociationRegistration_ClearUserAssociations(IApplicationAssociationRegistration* This)
|
|
|
|
{
|
|
|
|
FIXME("(%p)\n", This);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static const IApplicationAssociationRegistrationVtbl IApplicationAssociationRegistration_vtbl =
|
|
|
|
{
|
|
|
|
ApplicationAssociationRegistration_QueryInterface,
|
|
|
|
ApplicationAssociationRegistration_AddRef,
|
|
|
|
ApplicationAssociationRegistration_Release,
|
|
|
|
ApplicationAssociationRegistration_QueryCurrentDefault,
|
|
|
|
ApplicationAssociationRegistration_QueryAppIsDefault,
|
|
|
|
ApplicationAssociationRegistration_QueryAppIsDefaultAll,
|
|
|
|
ApplicationAssociationRegistration_SetAppAsDefault,
|
|
|
|
ApplicationAssociationRegistration_SetAppAsDefaultAll,
|
|
|
|
ApplicationAssociationRegistration_ClearUserAssociations
|
|
|
|
};
|
|
|
|
|
2009-08-25 09:13:26 +00:00
|
|
|
/**************************************************************************
|
|
|
|
* IQueryAssociations_Constructor [internal]
|
|
|
|
*
|
|
|
|
* Construct a new IQueryAssociations object.
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI QueryAssociations_Constructor(IUnknown *pUnkOuter, REFIID riid, LPVOID *ppOutput)
|
|
|
|
{
|
|
|
|
IQueryAssociationsImpl* this;
|
|
|
|
HRESULT ret;
|
|
|
|
|
|
|
|
if (pUnkOuter) return CLASS_E_NOAGGREGATION;
|
|
|
|
|
|
|
|
if (!(this = SHAlloc(sizeof(*this)))) return E_OUTOFMEMORY;
|
2010-12-04 21:16:32 +00:00
|
|
|
this->IQueryAssociations_iface.lpVtbl = &IQueryAssociations_vtbl;
|
2009-08-25 09:13:26 +00:00
|
|
|
this->ref = 0;
|
|
|
|
this->hkeySource = 0;
|
|
|
|
this->hkeyProgID = 0;
|
2013-09-03 13:09:07 +00:00
|
|
|
if (FAILED(ret = IQueryAssociations_QueryInterface(&this->IQueryAssociations_iface, riid, ppOutput))) SHFree( this );
|
2009-08-25 09:13:26 +00:00
|
|
|
TRACE("returning %p\n", *ppOutput);
|
|
|
|
return ret;
|
|
|
|
}
|
2012-01-15 23:06:15 +00:00
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* ApplicationAssociationRegistration_Constructor [internal]
|
|
|
|
*
|
|
|
|
* Construct a IApplicationAssociationRegistration object.
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI ApplicationAssociationRegistration_Constructor(IUnknown *outer, REFIID riid, LPVOID *ppv)
|
|
|
|
{
|
|
|
|
IApplicationAssociationRegistrationImpl *This;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
if (outer)
|
|
|
|
return CLASS_E_NOAGGREGATION;
|
|
|
|
|
|
|
|
if (!(This = SHAlloc(sizeof(*This))))
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
This->IApplicationAssociationRegistration_iface.lpVtbl = &IApplicationAssociationRegistration_vtbl;
|
|
|
|
This->ref = 0;
|
|
|
|
|
2012-07-29 08:51:05 +00:00
|
|
|
hr = IApplicationAssociationRegistration_QueryInterface(&This->IApplicationAssociationRegistration_iface, riid, ppv);
|
2012-01-15 23:06:15 +00:00
|
|
|
if (FAILED(hr))
|
|
|
|
SHFree(This);
|
|
|
|
|
|
|
|
TRACE("returning 0x%x with %p\n", hr, *ppv);
|
|
|
|
return hr;
|
|
|
|
}
|