2002-09-05 01:32:19 +02:00
|
|
|
/*
|
2009-08-25 11:13:26 +02:00
|
|
|
* IQueryAssociations helper functions
|
2002-09-05 01:32:19 +02:00
|
|
|
*
|
|
|
|
* 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
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2002-09-05 01:32:19 +02:00
|
|
|
*/
|
2003-09-06 01:08:26 +02:00
|
|
|
#include <stdarg.h>
|
2008-10-11 08:34:04 +02:00
|
|
|
#include <assert.h>
|
2003-09-06 01:08:26 +02:00
|
|
|
|
2002-09-05 01:32:19 +02:00
|
|
|
#include "windef.h"
|
2003-08-20 20:22:31 +02:00
|
|
|
#include "winbase.h"
|
2002-09-05 01:32:19 +02:00
|
|
|
#include "winnls.h"
|
|
|
|
#include "winreg.h"
|
2003-09-06 01:08:26 +02:00
|
|
|
#include "objbase.h"
|
2002-09-05 01:32:19 +02:00
|
|
|
#include "shlguid.h"
|
2009-08-25 11:13:26 +02:00
|
|
|
#include "shlobj.h"
|
2002-09-05 01:32:19 +02:00
|
|
|
#include "shlwapi.h"
|
2008-10-11 08:34:04 +02:00
|
|
|
#include "wine/unicode.h"
|
2002-09-05 01:32:19 +02:00
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(shell);
|
|
|
|
|
|
|
|
/* Default IQueryAssociations::Init() flags */
|
|
|
|
#define SHLWAPI_DEF_ASSOCF (ASSOCF_INIT_BYEXENAME|ASSOCF_INIT_DEFAULTTOSTAR| \
|
|
|
|
ASSOCF_INIT_DEFAULTTOFOLDER)
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
* SHLWAPI_ParamAToW
|
|
|
|
*
|
|
|
|
* Internal helper function: Convert ASCII parameter to Unicode.
|
|
|
|
*/
|
|
|
|
static BOOL SHLWAPI_ParamAToW(LPCSTR lpszParam, LPWSTR lpszBuff, DWORD dwLen,
|
|
|
|
LPWSTR* lpszOut)
|
|
|
|
{
|
|
|
|
if (lpszParam)
|
|
|
|
{
|
2004-07-04 02:06:29 +02:00
|
|
|
DWORD dwStrLen = MultiByteToWideChar(CP_ACP, 0, lpszParam, -1, NULL, 0);
|
2002-09-05 01:32:19 +02:00
|
|
|
|
|
|
|
if (dwStrLen < dwLen)
|
|
|
|
{
|
|
|
|
*lpszOut = lpszBuff; /* Use Buffer, it is big enough */
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Create a new buffer big enough for the string */
|
2004-07-04 02:06:29 +02:00
|
|
|
*lpszOut = HeapAlloc(GetProcessHeap(), 0,
|
|
|
|
dwStrLen * sizeof(WCHAR));
|
2002-09-05 01:32:19 +02:00
|
|
|
if (!*lpszOut)
|
|
|
|
return FALSE;
|
|
|
|
}
|
2004-07-04 02:06:29 +02:00
|
|
|
MultiByteToWideChar(CP_ACP, 0, lpszParam, -1, *lpszOut, dwStrLen);
|
2002-09-05 01:32:19 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
*lpszOut = NULL;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
2003-09-11 04:56:15 +02:00
|
|
|
* AssocCreate [SHLWAPI.@]
|
2002-09-05 01:32:19 +02:00
|
|
|
*
|
|
|
|
* Create a new IQueryAssociations object.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* clsid [I] CLSID of object
|
|
|
|
* refiid [I] REFIID of interface
|
|
|
|
* lpInterface [O] Destination for the created IQueryAssociations object
|
|
|
|
*
|
|
|
|
* RETURNS
|
2003-07-19 05:07:41 +02:00
|
|
|
* Success: S_OK. lpInterface contains the new object.
|
|
|
|
* Failure: An HRESULT error code indicating the error.
|
|
|
|
*
|
|
|
|
* NOTES
|
2009-07-30 03:30:22 +02:00
|
|
|
* clsid must be equal to CLSID_QueryAssociations and
|
|
|
|
* refiid must be equal to IID_IQueryAssociations, IID_IUnknown or this function will fail
|
2002-09-05 01:32:19 +02:00
|
|
|
*/
|
|
|
|
HRESULT WINAPI AssocCreate(CLSID clsid, REFIID refiid, void **lpInterface)
|
|
|
|
{
|
|
|
|
TRACE("(%s,%s,%p)\n", debugstr_guid(&clsid), debugstr_guid(refiid),
|
|
|
|
lpInterface);
|
|
|
|
|
|
|
|
if (!lpInterface)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
*(DWORD*)lpInterface = 0;
|
|
|
|
|
2009-07-30 03:30:22 +02:00
|
|
|
if (!IsEqualGUID(&clsid, &CLSID_QueryAssociations))
|
|
|
|
return CLASS_E_CLASSNOTAVAILABLE;
|
2002-09-05 01:32:19 +02:00
|
|
|
|
2009-08-25 11:13:26 +02:00
|
|
|
return SHCoCreateInstance( NULL, &clsid, NULL, refiid, lpInterface );
|
2002-09-05 01:32:19 +02:00
|
|
|
}
|
|
|
|
|
2012-04-08 15:22:25 +02:00
|
|
|
/*************************************************************************
|
|
|
|
* AssocGetPerceivedType [SHLWAPI.@]
|
|
|
|
*
|
|
|
|
* Detect the type of a file by inspecting its extension
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* lpszExt [I] File extension to evaluate.
|
|
|
|
* lpType [O] Pointer to perceived type
|
|
|
|
* lpFlag [O] Pointer to perceived type flag
|
|
|
|
* lppszType [O] Address to pointer for perceived type text
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: S_OK. lpType and lpFlag contain the perceived type and
|
|
|
|
* its informations. If lppszType is not NULL, it will point
|
|
|
|
* to a string with perceived type text.
|
|
|
|
* Failure: An HRESULT error code indicating the error.
|
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* lppszType is optional and it can be NULL.
|
|
|
|
* if lpType or lpFlag are NULL, the function will crash.
|
|
|
|
* if lpszExt is NULL, an error is returned.
|
|
|
|
*
|
|
|
|
* BUGS
|
|
|
|
* Unimplemented.
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI AssocGetPerceivedType(LPCWSTR lpszExt, PERCEIVED *lpType,
|
|
|
|
INT *lpFlag, LPWSTR *lppszType)
|
|
|
|
{
|
|
|
|
FIXME("(%s, %p, %p, %p) not supported\n", debugstr_w(lpszExt), lpType, lpFlag, lppszType);
|
|
|
|
|
|
|
|
if (lpszExt == NULL)
|
|
|
|
return HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2002-09-05 01:32:19 +02:00
|
|
|
/*************************************************************************
|
2003-09-11 04:56:15 +02:00
|
|
|
* AssocQueryKeyW [SHLWAPI.@]
|
2002-09-05 01:32:19 +02:00
|
|
|
*
|
|
|
|
* See AssocQueryKeyA.
|
|
|
|
*/
|
2003-07-19 05:07:41 +02:00
|
|
|
HRESULT WINAPI AssocQueryKeyW(ASSOCF cfFlags, ASSOCKEY assockey, LPCWSTR pszAssoc,
|
2002-09-05 01:32:19 +02:00
|
|
|
LPCWSTR pszExtra, HKEY *phkeyOut)
|
|
|
|
{
|
|
|
|
HRESULT hRet;
|
|
|
|
IQueryAssociations* lpAssoc;
|
|
|
|
|
2010-10-12 20:23:46 +02:00
|
|
|
TRACE("(0x%x,%d,%s,%s,%p)\n", cfFlags, assockey, debugstr_w(pszAssoc),
|
2003-07-19 05:07:41 +02:00
|
|
|
debugstr_w(pszExtra), phkeyOut);
|
|
|
|
|
2009-08-25 11:13:26 +02:00
|
|
|
hRet = AssocCreate( CLSID_QueryAssociations, &IID_IQueryAssociations, (void **)&lpAssoc );
|
|
|
|
if (FAILED(hRet)) return hRet;
|
2002-09-05 01:32:19 +02:00
|
|
|
|
2003-07-19 05:07:41 +02:00
|
|
|
cfFlags &= SHLWAPI_DEF_ASSOCF;
|
|
|
|
hRet = IQueryAssociations_Init(lpAssoc, cfFlags, pszAssoc, NULL, NULL);
|
2002-09-05 01:32:19 +02:00
|
|
|
|
|
|
|
if (SUCCEEDED(hRet))
|
2003-07-19 05:07:41 +02:00
|
|
|
hRet = IQueryAssociations_GetKey(lpAssoc, cfFlags, assockey, pszExtra, phkeyOut);
|
2002-09-05 01:32:19 +02:00
|
|
|
|
|
|
|
IQueryAssociations_Release(lpAssoc);
|
|
|
|
return hRet;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
2003-09-11 04:56:15 +02:00
|
|
|
* AssocQueryKeyA [SHLWAPI.@]
|
2002-09-05 01:32:19 +02:00
|
|
|
*
|
|
|
|
* Get a file association key from the registry.
|
|
|
|
*
|
|
|
|
* PARAMS
|
2003-07-19 05:07:41 +02:00
|
|
|
* cfFlags [I] ASSOCF_ flags from "shlwapi.h"
|
|
|
|
* assockey [I] Type of key to get
|
2002-09-05 01:32:19 +02:00
|
|
|
* pszAssoc [I] Key name to search below
|
|
|
|
* pszExtra [I] Extra information about the key location
|
|
|
|
* phkeyOut [O] Destination for the association key
|
|
|
|
*
|
|
|
|
* RETURNS
|
2003-07-19 05:07:41 +02:00
|
|
|
* Success: S_OK. phkeyOut contains the key.
|
|
|
|
* Failure: An HRESULT error code indicating the error.
|
2002-09-05 01:32:19 +02:00
|
|
|
*/
|
2003-07-19 05:07:41 +02:00
|
|
|
HRESULT WINAPI AssocQueryKeyA(ASSOCF cfFlags, ASSOCKEY assockey, LPCSTR pszAssoc,
|
2002-09-05 01:32:19 +02:00
|
|
|
LPCSTR pszExtra, HKEY *phkeyOut)
|
|
|
|
{
|
|
|
|
WCHAR szAssocW[MAX_PATH], *lpszAssocW = NULL;
|
|
|
|
WCHAR szExtraW[MAX_PATH], *lpszExtraW = NULL;
|
|
|
|
HRESULT hRet = E_OUTOFMEMORY;
|
|
|
|
|
2010-10-12 20:23:46 +02:00
|
|
|
TRACE("(0x%x,%d,%s,%s,%p)\n", cfFlags, assockey, debugstr_a(pszAssoc),
|
2003-07-19 05:07:41 +02:00
|
|
|
debugstr_a(pszExtra), phkeyOut);
|
|
|
|
|
2002-09-05 01:32:19 +02:00
|
|
|
if (SHLWAPI_ParamAToW(pszAssoc, szAssocW, MAX_PATH, &lpszAssocW) &&
|
|
|
|
SHLWAPI_ParamAToW(pszExtra, szExtraW, MAX_PATH, &lpszExtraW))
|
|
|
|
{
|
2003-07-19 05:07:41 +02:00
|
|
|
hRet = AssocQueryKeyW(cfFlags, assockey, lpszAssocW, lpszExtraW, phkeyOut);
|
2002-09-05 01:32:19 +02:00
|
|
|
}
|
|
|
|
|
2006-06-07 10:55:33 +02:00
|
|
|
if (lpszAssocW != szAssocW)
|
2002-09-05 01:32:19 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, lpszAssocW);
|
|
|
|
|
2006-06-07 10:55:33 +02:00
|
|
|
if (lpszExtraW != szExtraW)
|
2002-09-05 01:32:19 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, lpszExtraW);
|
|
|
|
|
|
|
|
return hRet;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
2003-09-11 04:56:15 +02:00
|
|
|
* AssocQueryStringW [SHLWAPI.@]
|
2002-09-05 01:32:19 +02:00
|
|
|
*
|
|
|
|
* See AssocQueryStringA.
|
|
|
|
*/
|
2003-07-19 05:07:41 +02:00
|
|
|
HRESULT WINAPI AssocQueryStringW(ASSOCF cfFlags, ASSOCSTR str, LPCWSTR pszAssoc,
|
2002-09-05 01:32:19 +02:00
|
|
|
LPCWSTR pszExtra, LPWSTR pszOut, DWORD *pcchOut)
|
|
|
|
{
|
|
|
|
HRESULT hRet;
|
|
|
|
IQueryAssociations* lpAssoc;
|
|
|
|
|
2010-10-12 20:23:46 +02:00
|
|
|
TRACE("(0x%x,%d,%s,%s,%p,%p)\n", cfFlags, str, debugstr_w(pszAssoc),
|
2003-07-19 05:07:41 +02:00
|
|
|
debugstr_w(pszExtra), pszOut, pcchOut);
|
|
|
|
|
2002-09-05 01:32:19 +02:00
|
|
|
if (!pcchOut)
|
2008-10-11 07:21:25 +02:00
|
|
|
return E_UNEXPECTED;
|
2002-09-05 01:32:19 +02:00
|
|
|
|
2009-08-25 11:13:26 +02:00
|
|
|
hRet = AssocCreate( CLSID_QueryAssociations, &IID_IQueryAssociations, (void **)&lpAssoc );
|
|
|
|
if (FAILED(hRet)) return hRet;
|
2002-09-05 01:32:19 +02:00
|
|
|
|
2003-07-19 05:07:41 +02:00
|
|
|
hRet = IQueryAssociations_Init(lpAssoc, cfFlags & SHLWAPI_DEF_ASSOCF,
|
2002-12-02 19:10:57 +01:00
|
|
|
pszAssoc, NULL, NULL);
|
2002-09-05 01:32:19 +02:00
|
|
|
|
|
|
|
if (SUCCEEDED(hRet))
|
2003-07-19 05:07:41 +02:00
|
|
|
hRet = IQueryAssociations_GetString(lpAssoc, cfFlags, str, pszExtra,
|
2002-09-05 01:32:19 +02:00
|
|
|
pszOut, pcchOut);
|
|
|
|
|
|
|
|
IQueryAssociations_Release(lpAssoc);
|
|
|
|
return hRet;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
2003-09-11 04:56:15 +02:00
|
|
|
* AssocQueryStringA [SHLWAPI.@]
|
2002-09-05 01:32:19 +02:00
|
|
|
*
|
|
|
|
* Get a file association string from the registry.
|
|
|
|
*
|
|
|
|
* PARAMS
|
2003-07-19 05:07:41 +02:00
|
|
|
* cfFlags [I] ASSOCF_ flags from "shlwapi.h"
|
|
|
|
* str [I] Type of string to get (ASSOCSTR enum from "shlwapi.h")
|
2002-09-05 01:32:19 +02:00
|
|
|
* pszAssoc [I] Key name to search below
|
|
|
|
* pszExtra [I] Extra information about the string location
|
|
|
|
* pszOut [O] Destination for the association string
|
|
|
|
* pcchOut [O] Length of pszOut
|
|
|
|
*
|
|
|
|
* RETURNS
|
2003-07-19 05:07:41 +02:00
|
|
|
* Success: S_OK. pszOut contains the string, pcchOut contains its length.
|
|
|
|
* Failure: An HRESULT error code indicating the error.
|
2002-09-05 01:32:19 +02:00
|
|
|
*/
|
2003-07-19 05:07:41 +02:00
|
|
|
HRESULT WINAPI AssocQueryStringA(ASSOCF cfFlags, ASSOCSTR str, LPCSTR pszAssoc,
|
2002-09-05 01:32:19 +02:00
|
|
|
LPCSTR pszExtra, LPSTR pszOut, DWORD *pcchOut)
|
|
|
|
{
|
|
|
|
WCHAR szAssocW[MAX_PATH], *lpszAssocW = NULL;
|
|
|
|
WCHAR szExtraW[MAX_PATH], *lpszExtraW = NULL;
|
|
|
|
HRESULT hRet = E_OUTOFMEMORY;
|
|
|
|
|
2010-10-12 20:23:46 +02:00
|
|
|
TRACE("(0x%x,0x%d,%s,%s,%p,%p)\n", cfFlags, str, debugstr_a(pszAssoc),
|
2003-07-19 05:07:41 +02:00
|
|
|
debugstr_a(pszExtra), pszOut, pcchOut);
|
|
|
|
|
2002-09-05 01:32:19 +02:00
|
|
|
if (!pcchOut)
|
2008-10-11 07:21:25 +02:00
|
|
|
hRet = E_UNEXPECTED;
|
2002-09-05 01:32:19 +02:00
|
|
|
else if (SHLWAPI_ParamAToW(pszAssoc, szAssocW, MAX_PATH, &lpszAssocW) &&
|
|
|
|
SHLWAPI_ParamAToW(pszExtra, szExtraW, MAX_PATH, &lpszExtraW))
|
|
|
|
{
|
|
|
|
WCHAR szReturnW[MAX_PATH], *lpszReturnW = szReturnW;
|
|
|
|
DWORD dwLenOut = *pcchOut;
|
|
|
|
|
|
|
|
if (dwLenOut >= MAX_PATH)
|
2004-07-04 02:06:29 +02:00
|
|
|
lpszReturnW = HeapAlloc(GetProcessHeap(), 0,
|
2002-09-05 01:32:19 +02:00
|
|
|
(dwLenOut + 1) * sizeof(WCHAR));
|
2008-10-17 16:36:59 +02:00
|
|
|
else
|
|
|
|
dwLenOut = sizeof(szReturnW) / sizeof(szReturnW[0]);
|
2002-09-05 01:32:19 +02:00
|
|
|
|
|
|
|
if (!lpszReturnW)
|
|
|
|
hRet = E_OUTOFMEMORY;
|
|
|
|
else
|
|
|
|
{
|
2003-07-19 05:07:41 +02:00
|
|
|
hRet = AssocQueryStringW(cfFlags, str, lpszAssocW, lpszExtraW,
|
2002-09-05 01:32:19 +02:00
|
|
|
lpszReturnW, &dwLenOut);
|
|
|
|
|
|
|
|
if (SUCCEEDED(hRet))
|
2008-10-17 16:36:59 +02:00
|
|
|
dwLenOut = WideCharToMultiByte(CP_ACP, 0, lpszReturnW, -1,
|
|
|
|
pszOut, *pcchOut, NULL, NULL);
|
2002-09-05 01:32:19 +02:00
|
|
|
|
2008-10-17 16:36:59 +02:00
|
|
|
*pcchOut = dwLenOut;
|
2006-06-07 10:55:33 +02:00
|
|
|
if (lpszReturnW != szReturnW)
|
2002-09-05 01:32:19 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, lpszReturnW);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-06-07 10:55:33 +02:00
|
|
|
if (lpszAssocW != szAssocW)
|
2002-09-05 01:32:19 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, lpszAssocW);
|
2006-06-07 10:55:33 +02:00
|
|
|
if (lpszExtraW != szExtraW)
|
2002-09-05 01:32:19 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, lpszExtraW);
|
|
|
|
return hRet;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
2003-09-11 04:56:15 +02:00
|
|
|
* AssocQueryStringByKeyW [SHLWAPI.@]
|
2002-09-05 01:32:19 +02:00
|
|
|
*
|
|
|
|
* See AssocQueryStringByKeyA.
|
|
|
|
*/
|
2003-07-19 05:07:41 +02:00
|
|
|
HRESULT WINAPI AssocQueryStringByKeyW(ASSOCF cfFlags, ASSOCSTR str, HKEY hkAssoc,
|
2002-09-05 01:32:19 +02:00
|
|
|
LPCWSTR pszExtra, LPWSTR pszOut,
|
|
|
|
DWORD *pcchOut)
|
|
|
|
{
|
|
|
|
HRESULT hRet;
|
|
|
|
IQueryAssociations* lpAssoc;
|
|
|
|
|
2010-10-12 20:23:46 +02:00
|
|
|
TRACE("(0x%x,0x%d,%p,%s,%p,%p)\n", cfFlags, str, hkAssoc,
|
2003-07-19 05:07:41 +02:00
|
|
|
debugstr_w(pszExtra), pszOut, pcchOut);
|
|
|
|
|
2009-08-25 11:13:26 +02:00
|
|
|
hRet = AssocCreate( CLSID_QueryAssociations, &IID_IQueryAssociations, (void **)&lpAssoc );
|
|
|
|
if (FAILED(hRet)) return hRet;
|
2002-09-05 01:32:19 +02:00
|
|
|
|
2003-07-19 05:07:41 +02:00
|
|
|
cfFlags &= SHLWAPI_DEF_ASSOCF;
|
|
|
|
hRet = IQueryAssociations_Init(lpAssoc, cfFlags, 0, hkAssoc, NULL);
|
2002-09-05 01:32:19 +02:00
|
|
|
|
|
|
|
if (SUCCEEDED(hRet))
|
2003-07-19 05:07:41 +02:00
|
|
|
hRet = IQueryAssociations_GetString(lpAssoc, cfFlags, str, pszExtra,
|
2002-09-05 01:32:19 +02:00
|
|
|
pszOut, pcchOut);
|
|
|
|
|
|
|
|
IQueryAssociations_Release(lpAssoc);
|
|
|
|
return hRet;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
2003-09-11 04:56:15 +02:00
|
|
|
* AssocQueryStringByKeyA [SHLWAPI.@]
|
2002-09-05 01:32:19 +02:00
|
|
|
*
|
|
|
|
* Get a file association string from the registry, given a starting key.
|
|
|
|
*
|
|
|
|
* PARAMS
|
2003-07-19 05:07:41 +02:00
|
|
|
* cfFlags [I] ASSOCF_ flags from "shlwapi.h"
|
2002-09-05 01:32:19 +02:00
|
|
|
* str [I] Type of string to get
|
|
|
|
* hkAssoc [I] Key to search below
|
|
|
|
* pszExtra [I] Extra information about the string location
|
|
|
|
* pszOut [O] Destination for the association string
|
|
|
|
* pcchOut [O] Length of pszOut
|
|
|
|
*
|
|
|
|
* RETURNS
|
2003-07-19 05:07:41 +02:00
|
|
|
* Success: S_OK. pszOut contains the string, pcchOut contains its length.
|
|
|
|
* Failure: An HRESULT error code indicating the error.
|
2002-09-05 01:32:19 +02:00
|
|
|
*/
|
2003-07-19 05:07:41 +02:00
|
|
|
HRESULT WINAPI AssocQueryStringByKeyA(ASSOCF cfFlags, ASSOCSTR str, HKEY hkAssoc,
|
2002-09-05 01:32:19 +02:00
|
|
|
LPCSTR pszExtra, LPSTR pszOut,
|
|
|
|
DWORD *pcchOut)
|
|
|
|
{
|
2007-01-20 18:29:29 +01:00
|
|
|
WCHAR szExtraW[MAX_PATH], *lpszExtraW = szExtraW;
|
2002-09-05 01:32:19 +02:00
|
|
|
WCHAR szReturnW[MAX_PATH], *lpszReturnW = szReturnW;
|
|
|
|
HRESULT hRet = E_OUTOFMEMORY;
|
|
|
|
|
2010-10-12 20:23:46 +02:00
|
|
|
TRACE("(0x%x,0x%d,%p,%s,%p,%p)\n", cfFlags, str, hkAssoc,
|
2003-07-19 05:07:41 +02:00
|
|
|
debugstr_a(pszExtra), pszOut, pcchOut);
|
|
|
|
|
2002-09-05 01:32:19 +02:00
|
|
|
if (!pcchOut)
|
|
|
|
hRet = E_INVALIDARG;
|
|
|
|
else if (SHLWAPI_ParamAToW(pszExtra, szExtraW, MAX_PATH, &lpszExtraW))
|
|
|
|
{
|
|
|
|
DWORD dwLenOut = *pcchOut;
|
|
|
|
if (dwLenOut >= MAX_PATH)
|
2004-07-04 02:06:29 +02:00
|
|
|
lpszReturnW = HeapAlloc(GetProcessHeap(), 0,
|
2002-09-05 01:32:19 +02:00
|
|
|
(dwLenOut + 1) * sizeof(WCHAR));
|
|
|
|
|
|
|
|
if (lpszReturnW)
|
|
|
|
{
|
2003-07-19 05:07:41 +02:00
|
|
|
hRet = AssocQueryStringByKeyW(cfFlags, str, hkAssoc, lpszExtraW,
|
2002-09-05 01:32:19 +02:00
|
|
|
lpszReturnW, &dwLenOut);
|
|
|
|
|
|
|
|
if (SUCCEEDED(hRet))
|
|
|
|
WideCharToMultiByte(CP_ACP,0,szReturnW,-1,pszOut,dwLenOut,0,0);
|
|
|
|
*pcchOut = dwLenOut;
|
|
|
|
|
|
|
|
if (lpszReturnW != szReturnW)
|
|
|
|
HeapFree(GetProcessHeap(), 0, lpszReturnW);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-06-07 10:55:33 +02:00
|
|
|
if (lpszExtraW != szExtraW)
|
2002-09-05 01:32:19 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, lpszExtraW);
|
|
|
|
return hRet;
|
|
|
|
}
|
2003-07-19 05:07:41 +02:00
|
|
|
|
2003-07-22 01:42:24 +02:00
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* AssocIsDangerous (SHLWAPI.@)
|
2004-02-10 03:22:17 +01:00
|
|
|
*
|
|
|
|
* Determine if a file association is dangerous (potentially malware).
|
|
|
|
*
|
|
|
|
* PARAMS
|
2004-03-02 21:55:57 +01:00
|
|
|
* lpszAssoc [I] Name of file or file extension to check.
|
2004-02-10 03:22:17 +01:00
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* TRUE, if lpszAssoc may potentially be malware (executable),
|
|
|
|
* FALSE, Otherwise.
|
2003-07-22 01:42:24 +02:00
|
|
|
*/
|
2004-02-10 03:22:17 +01:00
|
|
|
BOOL WINAPI AssocIsDangerous(LPCWSTR lpszAssoc)
|
2003-07-22 01:42:24 +02:00
|
|
|
{
|
2004-02-10 03:22:17 +01:00
|
|
|
FIXME("%s\n", debugstr_w(lpszAssoc));
|
|
|
|
return FALSE;
|
2003-07-22 01:42:24 +02:00
|
|
|
}
|