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
31 #define NO_SHLWAPI_STREAM
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.
48 * hwndEdit [I] Handle of control to enable auto-completion for
49 * dwFlags [I] SHACF_ flags from "shlwapi.h"
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
)
61 /*************************************************************************
62 * MLBuildResURLA [SHLWAPI.405]
64 * Create a Url pointing to a resource in a module.
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
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
];
86 MultiByteToWideChar(CP_ACP
, 0, lpszLibName
, -1, szLibName
, ARRAY_SIZE(szLibName
));
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
);
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))
121 if (dwDestLen
>= szResLen
+ 1)
123 dwDestLen
-= (szResLen
+ 1);
124 memcpy(lpszDest
, szRes
, sizeof(szRes
));
126 hMod
= MLLoadLibraryW(lpszLibName
, hMod
, dwFlags
);
130 WCHAR szBuff
[MAX_PATH
];
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
)
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
));