2001-01-05 22:22:57 +00:00
|
|
|
/*
|
|
|
|
* Url functions
|
|
|
|
*
|
|
|
|
* Copyright 2000 Huw D M Davies for CodeWeavers.
|
2002-03-09 23:29:33 +00:00
|
|
|
*
|
|
|
|
* 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 12:49:52 +00:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2001-01-05 22:22:57 +00:00
|
|
|
*/
|
|
|
|
|
2003-09-05 23:08:26 +00:00
|
|
|
#include <stdarg.h>
|
2001-01-26 20:43:40 +00:00
|
|
|
#include <string.h>
|
2001-12-11 00:30:17 +00:00
|
|
|
#include <stdlib.h>
|
2001-01-05 22:22:57 +00:00
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
2003-08-20 18:22:31 +00:00
|
|
|
#include "winnls.h"
|
2001-01-05 22:22:57 +00:00
|
|
|
#include "winerror.h"
|
2001-11-06 22:29:38 +00:00
|
|
|
#include "wininet.h"
|
|
|
|
#include "winreg.h"
|
2004-10-04 19:08:50 +00:00
|
|
|
#include "winternl.h"
|
2001-12-11 00:30:17 +00:00
|
|
|
#define NO_SHLWAPI_STREAM
|
2001-01-05 22:22:57 +00:00
|
|
|
#include "shlwapi.h"
|
2010-01-25 12:44:45 +00:00
|
|
|
#include "intshcut.h"
|
2002-03-09 23:29:33 +00:00
|
|
|
#include "wine/debug.h"
|
2001-01-05 22:22:57 +00:00
|
|
|
|
2003-10-01 03:10:42 +00:00
|
|
|
HMODULE WINAPI MLLoadLibraryW(LPCWSTR,HMODULE,DWORD);
|
|
|
|
BOOL WINAPI MLFreeLibrary(HMODULE);
|
|
|
|
HRESULT WINAPI MLBuildResURLW(LPCWSTR,HMODULE,DWORD,LPCWSTR,LPWSTR,DWORD);
|
|
|
|
|
2002-03-09 23:29:33 +00:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(shell);
|
2001-01-05 22:22:57 +00:00
|
|
|
|
2003-03-18 19:57:00 +00:00
|
|
|
/*************************************************************************
|
|
|
|
* SHAutoComplete [SHLWAPI.@]
|
2003-10-01 03:10:42 +00:00
|
|
|
*
|
|
|
|
* Enable auto-completion for an edit control.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* hwndEdit [I] Handle of control to enable auto-completion for
|
|
|
|
* dwFlags [I] SHACF_ flags from "shlwapi.h"
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: S_OK. Auto-completion is enabled for the control.
|
|
|
|
* Failure: An HRESULT error code indicating the error.
|
2003-03-18 19:57:00 +00:00
|
|
|
*/
|
|
|
|
HRESULT WINAPI SHAutoComplete(HWND hwndEdit, DWORD dwFlags)
|
|
|
|
{
|
2010-02-03 23:20:57 +00:00
|
|
|
FIXME("stub\n");
|
2003-03-18 19:57:00 +00:00
|
|
|
return S_FALSE;
|
|
|
|
}
|
2003-10-01 03:10:42 +00:00
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
* MLBuildResURLA [SHLWAPI.405]
|
|
|
|
*
|
|
|
|
* Create a Url pointing to a resource in a module.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* lpszLibName [I] Name of the module containing the resource
|
|
|
|
* hMod [I] Callers module handle
|
|
|
|
* dwFlags [I] Undocumented flags for loading the module
|
|
|
|
* lpszRes [I] Resource name
|
|
|
|
* lpszDest [O] Destination for resulting Url
|
|
|
|
* dwDestLen [I] Length of lpszDest
|
|
|
|
*
|
|
|
|
* RETURNS
|
2008-04-21 05:17:27 +00:00
|
|
|
* Success: S_OK. lpszDest contains the resource Url.
|
2003-10-01 03:10:42 +00:00
|
|
|
* Failure: E_INVALIDARG, if any argument is invalid, or
|
|
|
|
* E_FAIL if dwDestLen is too small.
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI MLBuildResURLA(LPCSTR lpszLibName, HMODULE hMod, DWORD dwFlags,
|
|
|
|
LPCSTR lpszRes, LPSTR lpszDest, DWORD dwDestLen)
|
|
|
|
{
|
|
|
|
WCHAR szLibName[MAX_PATH], szRes[MAX_PATH], szDest[MAX_PATH];
|
|
|
|
HRESULT hRet;
|
|
|
|
|
|
|
|
if (lpszLibName)
|
2018-09-14 22:10:31 +00:00
|
|
|
MultiByteToWideChar(CP_ACP, 0, lpszLibName, -1, szLibName, ARRAY_SIZE(szLibName));
|
2003-10-01 03:10:42 +00:00
|
|
|
|
|
|
|
if (lpszRes)
|
2018-09-14 22:10:31 +00:00
|
|
|
MultiByteToWideChar(CP_ACP, 0, lpszRes, -1, szRes, ARRAY_SIZE(szRes));
|
2003-10-01 03:10:42 +00:00
|
|
|
|
2018-09-14 22:10:31 +00:00
|
|
|
if (dwDestLen > ARRAY_SIZE(szLibName))
|
|
|
|
dwDestLen = ARRAY_SIZE(szLibName);
|
2003-10-01 03:10:42 +00:00
|
|
|
|
|
|
|
hRet = MLBuildResURLW(lpszLibName ? szLibName : NULL, hMod, dwFlags,
|
|
|
|
lpszRes ? szRes : NULL, lpszDest ? szDest : NULL, dwDestLen);
|
|
|
|
if (SUCCEEDED(hRet) && lpszDest)
|
2012-09-24 11:04:26 +00:00
|
|
|
WideCharToMultiByte(CP_ACP, 0, szDest, -1, lpszDest, dwDestLen, NULL, NULL);
|
2003-10-01 03:10:42 +00:00
|
|
|
|
|
|
|
return hRet;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
* MLBuildResURLA [SHLWAPI.406]
|
|
|
|
*
|
|
|
|
* See MLBuildResURLA.
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI MLBuildResURLW(LPCWSTR lpszLibName, HMODULE hMod, DWORD dwFlags,
|
|
|
|
LPCWSTR lpszRes, LPWSTR lpszDest, DWORD dwDestLen)
|
|
|
|
{
|
|
|
|
static const WCHAR szRes[] = { 'r','e','s',':','/','/','\0' };
|
2018-09-14 22:10:30 +00:00
|
|
|
static const unsigned int szResLen = ARRAY_SIZE(szRes) - 1;
|
2003-10-01 03:10:42 +00:00
|
|
|
HRESULT hRet = E_FAIL;
|
|
|
|
|
2022-02-18 08:16:21 +00:00
|
|
|
TRACE("(%s,%p,0x%08lx,%s,%p,%ld)\n", debugstr_w(lpszLibName), hMod, dwFlags,
|
2003-10-01 03:10:42 +00:00
|
|
|
debugstr_w(lpszRes), lpszDest, dwDestLen);
|
|
|
|
|
|
|
|
if (!lpszLibName || !hMod || hMod == INVALID_HANDLE_VALUE || !lpszRes ||
|
|
|
|
!lpszDest || (dwFlags && dwFlags != 2))
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
if (dwDestLen >= szResLen + 1)
|
|
|
|
{
|
|
|
|
dwDestLen -= (szResLen + 1);
|
|
|
|
memcpy(lpszDest, szRes, sizeof(szRes));
|
|
|
|
|
|
|
|
hMod = MLLoadLibraryW(lpszLibName, hMod, dwFlags);
|
|
|
|
|
|
|
|
if (hMod)
|
|
|
|
{
|
|
|
|
WCHAR szBuff[MAX_PATH];
|
2004-05-19 03:22:55 +00:00
|
|
|
DWORD len;
|
2003-10-01 03:10:42 +00:00
|
|
|
|
2018-09-14 22:10:31 +00:00
|
|
|
len = GetModuleFileNameW(hMod, szBuff, ARRAY_SIZE(szBuff));
|
|
|
|
if (len && len < ARRAY_SIZE(szBuff))
|
2003-10-01 03:10:42 +00:00
|
|
|
{
|
2019-06-20 07:13:05 +00:00
|
|
|
DWORD dwPathLen = lstrlenW(szBuff) + 1;
|
2003-10-01 03:10:42 +00:00
|
|
|
|
|
|
|
if (dwDestLen >= dwPathLen)
|
|
|
|
{
|
|
|
|
DWORD dwResLen;
|
|
|
|
|
|
|
|
dwDestLen -= dwPathLen;
|
|
|
|
memcpy(lpszDest + szResLen, szBuff, dwPathLen * sizeof(WCHAR));
|
|
|
|
|
2019-06-20 07:13:05 +00:00
|
|
|
dwResLen = lstrlenW(lpszRes) + 1;
|
2003-10-01 03:10:42 +00:00
|
|
|
if (dwDestLen >= dwResLen + 1)
|
|
|
|
{
|
2010-01-15 07:18:55 +00:00
|
|
|
lpszDest[szResLen + dwPathLen-1] = '/';
|
2003-10-01 03:10:42 +00:00
|
|
|
memcpy(lpszDest + szResLen + dwPathLen, lpszRes, dwResLen * sizeof(WCHAR));
|
|
|
|
hRet = S_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
MLFreeLibrary(hMod);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return hRet;
|
|
|
|
}
|