msvcrt: Remove non-needed function declarations from msvcrt.h.
[wine.git] / dlls / shlwapi / url.c
blob8318c5d7a6296923025cd169579c993bcb83f724
1 /*
2 * Url functions
4 * Copyright 2000 Huw D M Davies for CodeWeavers.
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
21 #include <stdarg.h>
22 #include <string.h>
23 #include <stdlib.h>
24 #include "windef.h"
25 #include "winbase.h"
26 #include "winnls.h"
27 #include "winerror.h"
28 #include "wininet.h"
29 #include "winreg.h"
30 #include "winternl.h"
31 #define NO_SHLWAPI_STREAM
32 #include "shlwapi.h"
33 #include "intshcut.h"
34 #include "wine/debug.h"
36 HMODULE WINAPI MLLoadLibraryW(LPCWSTR,HMODULE,DWORD);
37 BOOL WINAPI MLFreeLibrary(HMODULE);
38 HRESULT WINAPI MLBuildResURLW(LPCWSTR,HMODULE,DWORD,LPCWSTR,LPWSTR,DWORD);
40 WINE_DEFAULT_DEBUG_CHANNEL(shell);
42 /*************************************************************************
43 * SHAutoComplete [SHLWAPI.@]
45 * Enable auto-completion for an edit control.
47 * PARAMS
48 * hwndEdit [I] Handle of control to enable auto-completion for
49 * dwFlags [I] SHACF_ flags from "shlwapi.h"
51 * RETURNS
52 * Success: S_OK. Auto-completion is enabled for the control.
53 * Failure: An HRESULT error code indicating the error.
55 HRESULT WINAPI SHAutoComplete(HWND hwndEdit, DWORD dwFlags)
57 FIXME("stub\n");
58 return S_FALSE;
61 /*************************************************************************
62 * MLBuildResURLA [SHLWAPI.405]
64 * Create a Url pointing to a resource in a module.
66 * PARAMS
67 * lpszLibName [I] Name of the module containing the resource
68 * hMod [I] Callers module handle
69 * dwFlags [I] Undocumented flags for loading the module
70 * lpszRes [I] Resource name
71 * lpszDest [O] Destination for resulting Url
72 * dwDestLen [I] Length of lpszDest
74 * RETURNS
75 * Success: S_OK. lpszDest contains the resource Url.
76 * Failure: E_INVALIDARG, if any argument is invalid, or
77 * E_FAIL if dwDestLen is too small.
79 HRESULT WINAPI MLBuildResURLA(LPCSTR lpszLibName, HMODULE hMod, DWORD dwFlags,
80 LPCSTR lpszRes, LPSTR lpszDest, DWORD dwDestLen)
82 WCHAR szLibName[MAX_PATH], szRes[MAX_PATH], szDest[MAX_PATH];
83 HRESULT hRet;
85 if (lpszLibName)
86 MultiByteToWideChar(CP_ACP, 0, lpszLibName, -1, szLibName, ARRAY_SIZE(szLibName));
88 if (lpszRes)
89 MultiByteToWideChar(CP_ACP, 0, lpszRes, -1, szRes, ARRAY_SIZE(szRes));
91 if (dwDestLen > ARRAY_SIZE(szLibName))
92 dwDestLen = ARRAY_SIZE(szLibName);
94 hRet = MLBuildResURLW(lpszLibName ? szLibName : NULL, hMod, dwFlags,
95 lpszRes ? szRes : NULL, lpszDest ? szDest : NULL, dwDestLen);
96 if (SUCCEEDED(hRet) && lpszDest)
97 WideCharToMultiByte(CP_ACP, 0, szDest, -1, lpszDest, dwDestLen, NULL, NULL);
99 return hRet;
102 /*************************************************************************
103 * MLBuildResURLA [SHLWAPI.406]
105 * See MLBuildResURLA.
107 HRESULT WINAPI MLBuildResURLW(LPCWSTR lpszLibName, HMODULE hMod, DWORD dwFlags,
108 LPCWSTR lpszRes, LPWSTR lpszDest, DWORD dwDestLen)
110 static const WCHAR szRes[] = { 'r','e','s',':','/','/','\0' };
111 static const unsigned int szResLen = ARRAY_SIZE(szRes) - 1;
112 HRESULT hRet = E_FAIL;
114 TRACE("(%s,%p,0x%08x,%s,%p,%d)\n", debugstr_w(lpszLibName), hMod, dwFlags,
115 debugstr_w(lpszRes), lpszDest, dwDestLen);
117 if (!lpszLibName || !hMod || hMod == INVALID_HANDLE_VALUE || !lpszRes ||
118 !lpszDest || (dwFlags && dwFlags != 2))
119 return E_INVALIDARG;
121 if (dwDestLen >= szResLen + 1)
123 dwDestLen -= (szResLen + 1);
124 memcpy(lpszDest, szRes, sizeof(szRes));
126 hMod = MLLoadLibraryW(lpszLibName, hMod, dwFlags);
128 if (hMod)
130 WCHAR szBuff[MAX_PATH];
131 DWORD len;
133 len = GetModuleFileNameW(hMod, szBuff, ARRAY_SIZE(szBuff));
134 if (len && len < ARRAY_SIZE(szBuff))
136 DWORD dwPathLen = lstrlenW(szBuff) + 1;
138 if (dwDestLen >= dwPathLen)
140 DWORD dwResLen;
142 dwDestLen -= dwPathLen;
143 memcpy(lpszDest + szResLen, szBuff, dwPathLen * sizeof(WCHAR));
145 dwResLen = lstrlenW(lpszRes) + 1;
146 if (dwDestLen >= dwResLen + 1)
148 lpszDest[szResLen + dwPathLen-1] = '/';
149 memcpy(lpszDest + szResLen + dwPathLen, lpszRes, dwResLen * sizeof(WCHAR));
150 hRet = S_OK;
154 MLFreeLibrary(hMod);
157 return hRet;