Fixed some issues found by winapi_check.
[wine/multimedia.git] / dlls / shlwapi / ordinal.c
blob2398e1c6a18ace7a1a36f65e5a65ccef8eb45057
1 /*
2 * SHLWAPI ordinal functions
4 * Copyright 1997 Marcus Meissner
5 * 1998 Jürgen Schmied
6 * 2001 Jon Griffiths
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #include <stdio.h>
24 #include <string.h>
26 #include "windef.h"
27 #include "winnls.h"
28 #include "winbase.h"
29 #include "ddeml.h"
30 #include "shlobj.h"
31 #include "shellapi.h"
32 #include "commdlg.h"
33 #include "wine/unicode.h"
34 #include "wine/obj_base.h"
35 #include "wine/obj_inplace.h"
36 #include "wine/obj_serviceprovider.h"
37 #include "wingdi.h"
38 #include "winreg.h"
39 #include "winuser.h"
40 #include "wine/debug.h"
41 #include "ordinal.h"
42 #include "shlwapi.h"
44 WINE_DEFAULT_DEBUG_CHANNEL(shell);
46 extern HINSTANCE shlwapi_hInstance;
47 extern HMODULE SHLWAPI_hshell32;
48 extern HMODULE SHLWAPI_hwinmm;
49 extern HMODULE SHLWAPI_hcomdlg32;
50 extern HMODULE SHLWAPI_hmpr;
51 extern HMODULE SHLWAPI_hmlang;
52 extern HMODULE SHLWAPI_hversion;
54 extern DWORD SHLWAPI_ThreadRef_index;
56 typedef HANDLE HSHARED; /* Shared memory */
58 /* following is GUID for IObjectWithSite::SetSite -- see _174 */
59 static DWORD id1[4] = {0xfc4801a3, 0x11cf2ba9, 0xaa0029a2, 0x52733d00};
60 /* following is GUID for IPersistMoniker::GetClassID -- see _174 */
61 static DWORD id2[4] = {0x79eac9ee, 0x11cebaf9, 0xaa00828c, 0x0ba94b00};
63 /* The following schemes were identified in the native version of
64 * SHLWAPI.DLL version 5.50
66 typedef enum {
67 URL_SCHEME_INVALID = -1,
68 URL_SCHEME_UNKNOWN = 0,
69 URL_SCHEME_FTP,
70 URL_SCHEME_HTTP,
71 URL_SCHEME_GOPHER,
72 URL_SCHEME_MAILTO,
73 URL_SCHEME_NEWS,
74 URL_SCHEME_NNTP,
75 URL_SCHEME_TELNET,
76 URL_SCHEME_WAIS,
77 URL_SCHEME_FILE,
78 URL_SCHEME_MK,
79 URL_SCHEME_HTTPS,
80 URL_SCHEME_SHELL,
81 URL_SCHEME_SNEWS,
82 URL_SCHEME_LOCAL,
83 URL_SCHEME_JAVASCRIPT,
84 URL_SCHEME_VBSCRIPT,
85 URL_SCHEME_ABOUT,
86 URL_SCHEME_RES,
87 URL_SCHEME_MAXVALUE
88 } URL_SCHEME;
90 typedef struct {
91 URL_SCHEME scheme_number;
92 LPCSTR scheme_name;
93 } SHL_2_inet_scheme;
95 static const SHL_2_inet_scheme shlwapi_schemes[] = {
96 {URL_SCHEME_FTP, "ftp"},
97 {URL_SCHEME_HTTP, "http"},
98 {URL_SCHEME_GOPHER, "gopher"},
99 {URL_SCHEME_MAILTO, "mailto"},
100 {URL_SCHEME_NEWS, "news"},
101 {URL_SCHEME_NNTP, "nntp"},
102 {URL_SCHEME_TELNET, "telnet"},
103 {URL_SCHEME_WAIS, "wais"},
104 {URL_SCHEME_FILE, "file"},
105 {URL_SCHEME_MK, "mk"},
106 {URL_SCHEME_HTTPS, "https"},
107 {URL_SCHEME_SHELL, "shell"},
108 {URL_SCHEME_SNEWS, "snews"},
109 {URL_SCHEME_LOCAL, "local"},
110 {URL_SCHEME_JAVASCRIPT, "javascript"},
111 {URL_SCHEME_VBSCRIPT, "vbscript"},
112 {URL_SCHEME_ABOUT, "about"},
113 {URL_SCHEME_RES, "res"},
114 {0, 0}
117 /* function pointers for GET_FUNC macro; these need to be global because of gcc bug */
118 static LPITEMIDLIST (WINAPI *pSHBrowseForFolderW)(LPBROWSEINFOW);
119 static HRESULT (WINAPI *pConvertINetUnicodeToMultiByte)(LPDWORD,DWORD,LPCWSTR,LPINT,LPSTR,LPINT);
120 static BOOL (WINAPI *pPlaySoundW)(LPCWSTR, HMODULE, DWORD);
121 static DWORD (WINAPI *pSHGetFileInfoW)(LPCWSTR,DWORD,SHFILEINFOW*,UINT,UINT);
122 static UINT (WINAPI *pDragQueryFileW)(HDROP, UINT, LPWSTR, UINT);
123 static BOOL (WINAPI *pSHGetPathFromIDListW)(LPCITEMIDLIST, LPWSTR);
124 static BOOL (WINAPI *pShellExecuteExW)(LPSHELLEXECUTEINFOW);
125 static HICON (WINAPI *pSHFileOperationW)(LPSHFILEOPSTRUCTW);
126 static HICON (WINAPI *pExtractIconExW)(LPCWSTR, INT,HICON *,HICON *, UINT);
127 static BOOL (WINAPI *pSHGetNewLinkInfoW)(LPCWSTR, LPCWSTR, LPCWSTR, BOOL*, UINT);
128 static DWORD (WINAPI *pSHDefExtractIconW)(LPVOID, LPVOID, LPVOID, LPVOID, LPVOID, LPVOID); /* FIXME: Correct args */
129 static HICON (WINAPI *pExtractIconW)(HINSTANCE, LPCWSTR, UINT);
130 static BOOL (WINAPI *pGetSaveFileNameW)(LPOPENFILENAMEW);
131 static DWORD (WINAPI *pWNetRestoreConnectionW)(LPVOID, LPVOID); /* FIXME: Correct args */
132 static DWORD (WINAPI *pWNetGetLastErrorW)(LPVOID, LPVOID, LPVOID, LPVOID, LPVOID); /* FIXME: Correct args */
133 static BOOL (WINAPI *pPageSetupDlgW)(LPPAGESETUPDLGW);
134 static BOOL (WINAPI *pPrintDlgW)(LPPRINTDLGW);
135 static BOOL (WINAPI *pGetOpenFileNameW)(LPOPENFILENAMEW);
136 static DWORD (WINAPI *pGetFileVersionInfoSizeW)(LPCWSTR,LPDWORD);
137 static BOOL (WINAPI *pGetFileVersionInfoW)(LPCWSTR,DWORD,DWORD,LPVOID);
138 static WORD (WINAPI *pVerQueryValueW)(LPVOID,LPCWSTR,LPVOID*,UINT*);
141 NOTES: Most functions exported by ordinal seem to be superflous.
142 The reason for these functions to be there is to provide a wrapper
143 for unicode functions to provide these functions on systems without
144 unicode functions eg. win95/win98. Since we have such functions we just
145 call these. If running Wine with native DLL's, some late bound calls may
146 fail. However, its better to implement the functions in the forward DLL
147 and recommend the builtin rather than reimplementing the calls here!
150 /*************************************************************************
151 * @ [SHLWAPI.1]
153 * Identifies the Internet "scheme" in the passed string. ASCII based.
154 * Also determines start and length of item after the ':'
156 DWORD WINAPI SHLWAPI_1 (LPCSTR x, UNKNOWN_SHLWAPI_1 *y)
158 DWORD cnt;
159 const SHL_2_inet_scheme *inet_pro;
161 if (y->size != 0x18) return E_INVALIDARG;
162 /* FIXME: leading white space generates error of 0x80041001 which
163 * is undefined
165 if (*x <= ' ') return 0x80041001;
166 cnt = 0;
167 y->sizep1 = 0;
168 y->ap1 = x;
169 while (*x) {
170 if (*x == ':') {
171 y->sizep1 = cnt;
172 cnt = -1;
173 y->ap2 = x+1;
174 break;
176 x++;
177 cnt++;
180 /* check for no scheme in string start */
181 /* (apparently schemes *must* be larger than a single character) */
182 if ((*x == '\0') || (y->sizep1 <= 1)) {
183 y->ap1 = 0;
184 return 0x80041001;
187 /* found scheme, set length of remainder */
188 y->sizep2 = lstrlenA(y->ap2);
190 /* see if known scheme and return indicator number */
191 y->fcncde = URL_SCHEME_UNKNOWN;
192 inet_pro = shlwapi_schemes;
193 while (inet_pro->scheme_name) {
194 if (!strncasecmp(inet_pro->scheme_name, y->ap1,
195 min(y->sizep1, lstrlenA(inet_pro->scheme_name)))) {
196 y->fcncde = inet_pro->scheme_number;
197 break;
199 inet_pro++;
201 return S_OK;
204 /*************************************************************************
205 * @ [SHLWAPI.2]
207 * Identifies the Internet "scheme" in the passed string. UNICODE based.
208 * Also determines start and length of item after the ':'
210 DWORD WINAPI SHLWAPI_2 (LPCWSTR x, UNKNOWN_SHLWAPI_2 *y)
212 DWORD cnt;
213 const SHL_2_inet_scheme *inet_pro;
214 LPSTR cmpstr;
215 INT len;
217 if (y->size != 0x18) return E_INVALIDARG;
218 /* FIXME: leading white space generates error of 0x80041001 which
219 * is undefined
221 if (*x <= L' ') return 0x80041001;
222 cnt = 0;
223 y->sizep1 = 0;
224 y->ap1 = x;
225 while (*x) {
226 if (*x == L':') {
227 y->sizep1 = cnt;
228 cnt = -1;
229 y->ap2 = x+1;
230 break;
232 x++;
233 cnt++;
236 /* check for no scheme in string start */
237 /* (apparently schemes *must* be larger than a single character) */
238 if ((*x == L'\0') || (y->sizep1 <= 1)) {
239 y->ap1 = 0;
240 return 0x80041001;
243 /* found scheme, set length of remainder */
244 y->sizep2 = lstrlenW(y->ap2);
246 /* see if known scheme and return indicator number */
247 len = WideCharToMultiByte(0, 0, y->ap1, y->sizep1, 0, 0, 0, 0);
248 cmpstr = (LPSTR)HeapAlloc(GetProcessHeap(), 0, len+1);
249 WideCharToMultiByte(0, 0, y->ap1, y->sizep1, cmpstr, len+1, 0, 0);
250 y->fcncde = URL_SCHEME_UNKNOWN;
251 inet_pro = shlwapi_schemes;
252 while (inet_pro->scheme_name) {
253 if (!strncasecmp(inet_pro->scheme_name, cmpstr,
254 min(len, lstrlenA(inet_pro->scheme_name)))) {
255 y->fcncde = inet_pro->scheme_number;
256 break;
258 inet_pro++;
260 HeapFree(GetProcessHeap(), 0, cmpstr);
261 return S_OK;
264 /*************************************************************************
265 * @ [SHLWAPI.3]
267 * Determine if a file exists locally and is of an executable type.
269 * PARAMS
270 * lpszFile [O] File to search for
271 * dwWhich [I] Type of executable to search for
273 * RETURNS
274 * TRUE If the file was found. lpszFile contains the file name.
275 * FALSE Otherwise.
277 * NOTES
278 * lpszPath is modified in place and must be at least MAX_PATH in length.
279 * If the function returns FALSE, the path is modified to its orginal state.
280 * If the given path contains an extension or dwWhich is 0, executable
281 * extensions are not checked.
283 * Ordinals 3-6 are a classic case of MS exposing limited functionality to
284 * users (here through PathFindOnPath) and keeping advanced functionality for
285 * their own developers exclusive use. Monopoly, anyone?
287 BOOL WINAPI SHLWAPI_3(LPSTR lpszFile,DWORD dwWhich)
289 return SHLWAPI_PathFindLocalExeA(lpszFile,dwWhich);
292 /*************************************************************************
293 * @ [SHLWAPI.4]
295 * Unicode version of SHLWAPI_3.
297 BOOL WINAPI SHLWAPI_4(LPWSTR lpszFile,DWORD dwWhich)
299 return SHLWAPI_PathFindLocalExeW(lpszFile,dwWhich);
302 /*************************************************************************
303 * @ [SHLWAPI.5]
305 * Search a range of paths for a specific type of executable.
307 * PARAMS
308 * lpszFile [O] File to search for
309 * lppszOtherDirs [I] Other directories to look in
310 * dwWhich [I] Type of executable to search for
312 * RETURNS
313 * Success: TRUE. The path to the executable is stored in sFile.
314 * Failure: FALSE. The path to the executable is unchanged.
316 BOOL WINAPI SHLWAPI_5(LPSTR lpszFile,LPCSTR *lppszOtherDirs,DWORD dwWhich)
318 return SHLWAPI_PathFindOnPathExA(lpszFile,lppszOtherDirs,dwWhich);
321 /*************************************************************************
322 * @ [SHLWAPI.6]
324 * Unicode version of SHLWAPI_5.
326 BOOL WINAPI SHLWAPI_6(LPWSTR lpszFile,LPCWSTR *lppszOtherDirs,DWORD dwWhich)
328 return SHLWAPI_PathFindOnPathExW(lpszFile,lppszOtherDirs,dwWhich);
331 /*************************************************************************
332 * SHLWAPI_DupSharedHandle
334 * Internal implemetation of SHLWAPI_11.
336 static
337 HSHARED WINAPI SHLWAPI_DupSharedHandle(HSHARED hShared, DWORD dwDstProcId,
338 DWORD dwSrcProcId, DWORD dwAccess,
339 DWORD dwOptions)
341 HANDLE hDst, hSrc;
342 DWORD dwMyProcId = GetCurrentProcessId();
343 HSHARED hRet = (HSHARED)NULL;
345 TRACE("(%p,%ld,%ld,%08lx,%08lx)\n", (PVOID)hShared, dwDstProcId, dwSrcProcId,
346 dwAccess, dwOptions);
348 /* Get dest process handle */
349 if (dwDstProcId == dwMyProcId)
350 hDst = GetCurrentProcess();
351 else
352 hDst = OpenProcess(PROCESS_DUP_HANDLE, 0, dwDstProcId);
354 if (hDst)
356 /* Get src process handle */
357 if (dwSrcProcId == dwMyProcId)
358 hSrc = GetCurrentProcess();
359 else
360 hSrc = OpenProcess(PROCESS_DUP_HANDLE, 0, dwSrcProcId);
362 if (hSrc)
364 /* Make handle available to dest process */
365 if (!DuplicateHandle(hDst, (HANDLE)hShared, hSrc, &hRet,
366 dwAccess, 0, dwOptions | DUPLICATE_SAME_ACCESS))
367 hRet = (HSHARED)NULL;
369 if (dwSrcProcId != dwMyProcId)
370 CloseHandle(hSrc);
373 if (dwDstProcId != dwMyProcId)
374 CloseHandle(hDst);
377 TRACE("Returning handle %p\n", (PVOID)hRet);
378 return hRet;
381 /*************************************************************************
382 * @ [SHLWAPI.7]
384 * Create a block of sharable memory and initialise it with data.
386 * PARAMS
387 * dwProcId [I] ID of process owning data
388 * lpvData [I] Pointer to data to write
389 * dwSize [I] Size of data
391 * RETURNS
392 * Success: A shared memory handle
393 * Failure: NULL
395 * NOTES
396 * Ordinals 7-11 provide a set of calls to create shared memory between a
397 * group of processes. The shared memory is treated opaquely in that its size
398 * is not exposed to clients who map it. This is accomplished by storing
399 * the size of the map as the first DWORD of mapped data, and then offsetting
400 * the view pointer returned by this size.
402 * SHLWAPI_7/SHLWAPI_10 - Create/Destroy the shared memory handle
403 * SHLWAPI_8/SHLWAPI_9 - Get/Release a pointer to the shared data
404 * SHLWAPI_11 - Helper function; Duplicate cross-process handles
406 HSHARED WINAPI SHLWAPI_7 (DWORD dwProcId, DWORD dwSize, LPCVOID lpvData)
408 HANDLE hMap;
409 LPVOID pMapped;
410 HSHARED hRet = (HSHARED)NULL;
412 TRACE("(%ld,%p,%ld)\n", dwProcId, lpvData, dwSize);
414 /* Create file mapping of the correct length */
415 hMap = CreateFileMappingA(INVALID_HANDLE_VALUE, NULL, FILE_MAP_READ, 0,
416 dwSize + sizeof(dwSize), NULL);
417 if (!hMap)
418 return hRet;
420 /* Get a view in our process address space */
421 pMapped = MapViewOfFile(hMap, FILE_MAP_READ | FILE_MAP_WRITE, 0, 0, 0);
423 if (pMapped)
425 /* Write size of data, followed by the data, to the view */
426 *((DWORD*)pMapped) = dwSize;
427 if (dwSize)
428 memcpy((char *) pMapped + sizeof(dwSize), lpvData, dwSize);
430 /* Release view. All further views mapped will be opaque */
431 UnmapViewOfFile(pMapped);
432 hRet = SHLWAPI_DupSharedHandle((HSHARED)hMap, dwProcId,
433 GetCurrentProcessId(), FILE_MAP_ALL_ACCESS,
434 DUPLICATE_SAME_ACCESS);
437 CloseHandle(hMap);
438 return hRet;
441 /*************************************************************************
442 * @ [SHLWAPI.8]
444 * Get a pointer to a block of shared memory from a shared memory handle.
446 * PARAMS
447 * hShared [I] Shared memory handle
448 * dwProcId [I] ID of process owning hShared
450 * RETURNS
451 * Success: A pointer to the shared memory
452 * Failure: NULL
454 * NOTES
455 * See SHLWAPI_7.
457 PVOID WINAPI SHLWAPI_8 (HSHARED hShared, DWORD dwProcId)
459 HSHARED hDup;
460 LPVOID pMapped;
462 TRACE("(%p %ld)\n", (PVOID)hShared, dwProcId);
464 /* Get handle to shared memory for current process */
465 hDup = SHLWAPI_DupSharedHandle(hShared, dwProcId, GetCurrentProcessId(),
466 FILE_MAP_ALL_ACCESS, 0);
467 /* Get View */
468 pMapped = MapViewOfFile((HANDLE)hDup, FILE_MAP_READ | FILE_MAP_WRITE, 0, 0, 0);
469 CloseHandle(hDup);
471 if (pMapped)
472 return (char *) pMapped + sizeof(DWORD); /* Hide size */
473 return NULL;
476 /*************************************************************************
477 * @ [SHLWAPI.9]
479 * Release a pointer to a block of shared memory.
481 * PARAMS
482 * lpView [I] Shared memory pointer
484 * RETURNS
485 * Success: TRUE
486 * Failure: FALSE
488 * NOTES
489 * See SHLWAPI_7.
491 BOOL WINAPI SHLWAPI_9 (LPVOID lpView)
493 TRACE("(%p)\n", lpView);
494 return UnmapViewOfFile((char *) lpView - sizeof(DWORD)); /* Include size */
497 /*************************************************************************
498 * @ [SHLWAPI.10]
500 * Destroy a block of sharable memory.
502 * PARAMS
503 * hShared [I] Shared memory handle
504 * dwProcId [I] ID of process owning hShared
506 * RETURNS
507 * Success: TRUE
508 * Failure: FALSE
510 * NOTES
511 * See SHLWAPI_7.
513 BOOL WINAPI SHLWAPI_10 (HSHARED hShared, DWORD dwProcId)
515 HSHARED hClose;
517 TRACE("(%p %ld)\n", (PVOID)hShared, dwProcId);
519 /* Get a copy of the handle for our process, closing the source handle */
520 hClose = SHLWAPI_DupSharedHandle(hShared, dwProcId, GetCurrentProcessId(),
521 FILE_MAP_ALL_ACCESS,DUPLICATE_CLOSE_SOURCE);
522 /* Close local copy */
523 return CloseHandle((HANDLE)hClose);
526 /*************************************************************************
527 * @ [SHLWAPI.11]
529 * Copy a sharable memory handle from one process to another.
531 * PARAMS
532 * hShared [I] Shared memory handle to duplicate
533 * dwDstProcId [I] ID of the process wanting the duplicated handle
534 * dwSrcProcId [I] ID of the process owning hShared
535 * dwAccess [I] Desired DuplicateHandle access
536 * dwOptions [I] Desired DuplicateHandle options
538 * RETURNS
539 * Success: A handle suitable for use by the dwDstProcId process.
540 * Failure: A NULL handle.
542 * NOTES
543 * See SHLWAPI_7.
545 HSHARED WINAPI SHLWAPI_11(HSHARED hShared, DWORD dwDstProcId, DWORD dwSrcProcId,
546 DWORD dwAccess, DWORD dwOptions)
548 HSHARED hRet;
550 hRet = SHLWAPI_DupSharedHandle(hShared, dwDstProcId, dwSrcProcId,
551 dwAccess, dwOptions);
552 return hRet;
555 /*************************************************************************
556 * @ [SHLWAPI.13]
557 * (Used by IE4 during startup)
559 HRESULT WINAPI SHLWAPI_13 (
560 LPVOID w,
561 LPVOID x)
563 FIXME("(%p %p)stub\n",w,x);
564 return 1;
565 #if 0
566 /* pseudo code extracted from relay trace */
567 RegOpenKeyA(HKLM, "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\Accepted Documents", &newkey);
568 ret = 0;
569 i = 0;
570 size = 0;
571 while(!ret) {
572 ret = RegEnumValueA(newkey, i, a1, a2, 0, a3, 0, 0);
573 size += ???;
574 i++;
576 b1 = LocalAlloc(0x40, size);
577 ret = 0;
578 i = 0;
579 while(!ret) {
580 ret = RegEnumValueA(newkey, i, a1, a2, 0, a3, a4, a5);
581 RegisterClipBoardFormatA(a4);
582 i++;
584 hmod1 = GetModuleHandleA("URLMON.DLL");
585 proc = GetProcAddress(hmod1, "CreateFormatEnumerator");
586 HeapAlloc(??, 0, 0x14);
587 HeapAlloc(??, 0, 0x50);
588 LocalAlloc(0x40, 0x78);
589 /* FIXME: bad string below */
590 lstrlenW(L"{D0FCA420-D3F5-11CF-B211-00AA004AE837}");
591 StrCpyW(a6, L"{D0FCA420-D3F5-11CF-B211-00AA004AE837}");
593 GetTickCount();
594 IsBadReadPtr(c1 = 0x403fd210,4);
595 InterlockedIncrement(c1+4);
596 LocalFree(b1);
597 RegCloseKey(newkey);
598 IsBadReadPtr(c1 = 0x403fd210,4);
599 InterlockedIncrement(c1+4);
601 HeapAlloc(40350000,00000000,00000014) retval=403fd0a8;
602 HeapAlloc(40350000,00000000,00000050) retval=403feb44;
603 hmod1 = GetModuleHandleA("URLMON.DLL");
604 proc = GetProcAddress(hmod1, "RegisterFormatEnumerator");
605 /* 0x1a40c88c is in URLMON.DLL just before above proc
606 * content is L"_EnumFORMATETC_"
607 * label is d1
609 IsBadReadPtr(d1 = 0x1a40c88c,00000002);
610 lstrlenW(d1);
611 lstrlenW(d1);
612 HeapAlloc(40350000,00000000,0000001e) retval=403fed44;
613 IsBadReadPtr(d2 = 0x403fd0a8,00000004);
614 InterlockedIncrement(d2+4);
615 IsBadReadPtr(d2 = 0x403fd0a8,00000004);
616 InterlockedDecrement(d2+4);
617 IsBadReadPtr(c1,00000004);
618 InterlockedDecrement(c1+4);
619 IsBadReadPtr(c1,00000004);
620 InterlockedDecrement(c1+4);
622 #endif
625 /*************************************************************************
626 * @ [SHLWAPI.14]
628 * Function:
629 * Retrieves IE "AcceptLanguage" value from registry. ASCII mode.
632 HRESULT WINAPI SHLWAPI_14 (
633 LPSTR langbuf,
634 LPDWORD buflen)
636 CHAR *mystr;
637 DWORD mystrlen, mytype;
638 HKEY mykey;
639 LCID mylcid;
641 mystrlen = (*buflen > 6) ? *buflen : 6;
642 mystr = (CHAR*)HeapAlloc(GetProcessHeap(),
643 HEAP_ZERO_MEMORY, mystrlen);
644 RegOpenKeyA(HKEY_CURRENT_USER,
645 "Software\\Microsoft\\Internet Explorer\\International",
646 &mykey);
647 if (RegQueryValueExA(mykey, "AcceptLanguage",
648 0, &mytype, mystr, &mystrlen)) {
649 /* Did not find value */
650 mylcid = GetUserDefaultLCID();
651 /* somehow the mylcid translates into "en-us"
652 * this is similar to "LOCALE_SABBREVLANGNAME"
653 * which could be gotten via GetLocaleInfo.
654 * The only problem is LOCALE_SABBREVLANGUAGE" is
655 * a 3 char string (first 2 are country code and third is
656 * letter for "sublanguage", which does not come close to
657 * "en-us"
659 lstrcpyA(mystr, "en-us");
660 mystrlen = lstrlenA(mystr);
662 else {
663 /* handle returned string */
664 FIXME("missing code\n");
666 if (mystrlen > *buflen)
667 lstrcpynA(langbuf, mystr, *buflen);
668 else {
669 lstrcpyA(langbuf, mystr);
670 *buflen = lstrlenA(langbuf);
672 RegCloseKey(mykey);
673 HeapFree(GetProcessHeap(), 0, mystr);
674 TRACE("language is %s\n", debugstr_a(langbuf));
675 return 0;
678 /*************************************************************************
679 * @ [SHLWAPI.15]
681 * Function:
682 * Retrieves IE "AcceptLanguage" value from registry. UNICODE mode.
685 HRESULT WINAPI SHLWAPI_15 (
686 LPWSTR langbuf,
687 LPDWORD buflen)
689 CHAR *mystr;
690 DWORD mystrlen, mytype;
691 HKEY mykey;
692 LCID mylcid;
694 mystrlen = (*buflen > 6) ? *buflen : 6;
695 mystr = (CHAR*)HeapAlloc(GetProcessHeap(),
696 HEAP_ZERO_MEMORY, mystrlen);
697 RegOpenKeyA(HKEY_CURRENT_USER,
698 "Software\\Microsoft\\Internet Explorer\\International",
699 &mykey);
700 if (RegQueryValueExA(mykey, "AcceptLanguage",
701 0, &mytype, mystr, &mystrlen)) {
702 /* Did not find value */
703 mylcid = GetUserDefaultLCID();
704 /* somehow the mylcid translates into "en-us"
705 * this is similar to "LOCALE_SABBREVLANGNAME"
706 * which could be gotten via GetLocaleInfo.
707 * The only problem is LOCALE_SABBREVLANGUAGE" is
708 * a 3 char string (first 2 are country code and third is
709 * letter for "sublanguage", which does not come close to
710 * "en-us"
712 lstrcpyA(mystr, "en-us");
713 mystrlen = lstrlenA(mystr);
715 else {
716 /* handle returned string */
717 FIXME("missing code\n");
719 RegCloseKey(mykey);
720 *buflen = MultiByteToWideChar(0, 0, mystr, -1, langbuf, (*buflen)-1);
721 HeapFree(GetProcessHeap(), 0, mystr);
722 TRACE("language is %s\n", debugstr_w(langbuf));
723 return 0;
726 /*************************************************************************
727 * @ [SHLWAPI.23]
729 * NOTES
730 * converts a guid to a string
731 * returns strlen(str)
733 DWORD WINAPI SHLWAPI_23 (
734 REFGUID guid, /* [in] clsid */
735 LPSTR str, /* [out] buffer */
736 INT cmax) /* [in] size of buffer */
738 char xguid[40];
740 sprintf( xguid, "{%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
741 guid->Data1, guid->Data2, guid->Data3,
742 guid->Data4[0], guid->Data4[1], guid->Data4[2], guid->Data4[3],
743 guid->Data4[4], guid->Data4[5], guid->Data4[6], guid->Data4[7] );
744 TRACE("(%s %p 0x%08x)stub\n", xguid, str, cmax);
745 if (strlen(xguid)>=cmax) return 0;
746 strcpy(str,xguid);
747 return strlen(xguid) + 1;
750 /*************************************************************************
751 * @ [SHLWAPI.24]
753 * NOTES
754 * converts a guid to a string
755 * returns strlen(str)
757 DWORD WINAPI SHLWAPI_24 (
758 REFGUID guid, /* [in] clsid */
759 LPWSTR str, /* [out] buffer */
760 INT cmax) /* [in] size of buffer */
762 char xguid[40];
764 sprintf( xguid, "{%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
765 guid->Data1, guid->Data2, guid->Data3,
766 guid->Data4[0], guid->Data4[1], guid->Data4[2], guid->Data4[3],
767 guid->Data4[4], guid->Data4[5], guid->Data4[6], guid->Data4[7] );
768 return MultiByteToWideChar( CP_ACP, 0, xguid, -1, str, cmax );
771 /*************************************************************************
772 * @ [SHLWAPI.25]
774 * Seems to be iswalpha
776 BOOL WINAPI SHLWAPI_25(WCHAR wc)
778 return (get_char_typeW(wc) & C1_ALPHA) != 0;
781 /*************************************************************************
782 * @ [SHLWAPI.26]
784 * Seems to be iswupper
786 BOOL WINAPI SHLWAPI_26(WCHAR wc)
788 return (get_char_typeW(wc) & C1_UPPER) != 0;
791 /*************************************************************************
792 * @ [SHLWAPI.27]
794 * Seems to be iswlower
796 BOOL WINAPI SHLWAPI_27(WCHAR wc)
798 return (get_char_typeW(wc) & C1_LOWER) != 0;
801 /*************************************************************************
802 * @ [SHLWAPI.28]
804 * Seems to be iswalnum
806 BOOL WINAPI SHLWAPI_28(WCHAR wc)
808 return (get_char_typeW(wc) & (C1_ALPHA|C1_DIGIT)) != 0;
811 /*************************************************************************
812 * @ [SHLWAPI.29]
814 * Seems to be iswspace
816 BOOL WINAPI SHLWAPI_29(WCHAR wc)
818 return (get_char_typeW(wc) & C1_SPACE) != 0;
821 /*************************************************************************
822 * @ [SHLWAPI.30]
824 * Seems to be iswblank
826 BOOL WINAPI SHLWAPI_30(WCHAR wc)
828 return (get_char_typeW(wc) & C1_BLANK) != 0;
831 /*************************************************************************
832 * @ [SHLWAPI.31]
834 * Seems to be iswpunct
836 BOOL WINAPI SHLWAPI_31(WCHAR wc)
838 return (get_char_typeW(wc) & C1_PUNCT) != 0;
841 /*************************************************************************
842 * @ [SHLWAPI.32]
844 * Seems to be iswcntrl
846 BOOL WINAPI SHLWAPI_32(WCHAR wc)
848 return (get_char_typeW(wc) & C1_CNTRL) != 0;
851 /*************************************************************************
852 * @ [SHLWAPI.33]
854 * Seems to be iswdigit
856 BOOL WINAPI SHLWAPI_33(WCHAR wc)
858 return (get_char_typeW(wc) & C1_DIGIT) != 0;
861 /*************************************************************************
862 * @ [SHLWAPI.34]
864 * Seems to be iswxdigit
866 BOOL WINAPI SHLWAPI_34(WCHAR wc)
868 return (get_char_typeW(wc) & C1_XDIGIT) != 0;
871 /*************************************************************************
872 * @ [SHLWAPI.35]
875 BOOL WINAPI SHLWAPI_35(LPVOID p1, DWORD dw2, LPVOID p3)
877 FIXME("(%p, 0x%08lx, %p): stub\n", p1, dw2, p3);
878 return TRUE;
881 /*************************************************************************
882 * @ [SHLWAPI.36]
885 BOOL WINAPI SHLWAPI_36(HMENU h1, UINT ui2, UINT h3, LPCWSTR p4)
887 TRACE("(0x%08x, 0x%08x, 0x%08x, %s): stub\n",
888 h1, ui2, h3, debugstr_w(p4));
889 return AppendMenuW(h1, ui2, h3, p4);
892 /*************************************************************************
893 * @ [SHLWAPI.74]
895 * Get the text from a given dialog item.
897 INT WINAPI SHLWAPI_74(HWND hWnd, INT nItem, LPWSTR lpsDest,INT nDestLen)
899 HWND hItem = GetDlgItem(hWnd, nItem);
901 if (hItem)
902 return GetWindowTextW(hItem, lpsDest, nDestLen);
903 if (nDestLen)
904 *lpsDest = (WCHAR)'\0';
905 return 0;
908 /*************************************************************************
909 * @ [SHLWAPI.151]
910 * Function: Compare two ASCII strings for "len" bytes.
911 * Returns: *str1-*str2 (case sensitive)
913 DWORD WINAPI SHLWAPI_151(LPSTR str1, LPSTR str2, INT len)
915 return strncmp( str1, str2, len );
918 /*************************************************************************
919 * @ [SHLWAPI.152]
921 * Function: Compare two WIDE strings for "len" bytes.
922 * Returns: *str1-*str2 (case sensitive)
924 DWORD WINAPI SHLWAPI_152(LPWSTR str1, LPWSTR str2, INT len)
926 return strncmpW( str1, str2, len );
929 /*************************************************************************
930 * @ [SHLWAPI.153]
931 * Function: Compare two ASCII strings for "len" bytes via caseless compare.
932 * Returns: *str1-*str2 (case insensitive)
934 DWORD WINAPI SHLWAPI_153(LPSTR str1, LPSTR str2, DWORD len)
936 return strncasecmp( str1, str2, len );
939 /*************************************************************************
940 * @ [SHLWAPI.154]
942 * Function: Compare two WIDE strings for "len" bytes via caseless compare.
943 * Returns: *str1-*str2 (case insensitive)
945 DWORD WINAPI SHLWAPI_154(LPWSTR str1, LPWSTR str2, DWORD len)
947 return strncmpiW( str1, str2, len );
950 /*************************************************************************
951 * @ [SHLWAPI.155]
953 * Case sensitive string compare (ASCII). Does not SetLastError().
955 DWORD WINAPI SHLWAPI_155 ( LPSTR str1, LPSTR str2)
957 return strcmp(str1, str2);
960 /*************************************************************************
961 * @ [SHLWAPI.156]
963 * Case sensitive string compare. Does not SetLastError().
965 DWORD WINAPI SHLWAPI_156 ( LPWSTR str1, LPWSTR str2)
967 return strcmpW( str1, str2 );
970 /*************************************************************************
971 * @ [SHLWAPI.158]
973 * Case insensitive string compare. Does not SetLastError(). ??
975 DWORD WINAPI SHLWAPI_158 ( LPWSTR str1, LPWSTR str2)
977 return strcmpiW( str1, str2 );
980 /*************************************************************************
981 * @ [SHLWAPI.162]
983 * Ensure a multibyte character string doesn't end in a hanging lead byte.
985 DWORD WINAPI SHLWAPI_162(LPSTR lpStr, DWORD size)
987 if (lpStr && size)
989 LPSTR lastByte = lpStr + size - 1;
991 while(lpStr < lastByte)
992 lpStr += IsDBCSLeadByte(*lpStr) ? 2 : 1;
994 if(lpStr == lastByte && IsDBCSLeadByte(*lpStr))
996 *lpStr = '\0';
997 size--;
999 return size;
1001 return 0;
1004 /*************************************************************************
1005 * @ [SHLWAPI.163]
1007 * _IUnknown_QueryStatus
1009 DWORD WINAPI SHLWAPI_163 (
1010 LPVOID v,
1011 LPVOID w,
1012 LPVOID x,
1013 LPVOID y,
1014 LPVOID z)
1016 TRACE("(%p %p %p %p %p) stub\n", v,w,x,y,z);
1017 return 0;
1021 /*************************************************************************
1022 * @ [SHLWAPI.164]
1024 * _IUnknown_Exec
1026 DWORD WINAPI SHLWAPI_164 (
1027 LPVOID u,
1028 LPVOID v,
1029 LPVOID w,
1030 LPVOID x,
1031 LPVOID y,
1032 LPVOID z)
1034 TRACE("(%p %p %p %p %p %p) stub\n",u,v,w,x,y,z);
1035 return 0x80004002; /* E_NOINTERFACE */
1038 /*************************************************************************
1039 * @ [SHLWAPI.165]
1041 * SetWindowLongA with mask.
1043 LONG WINAPI SHLWAPI_165(HWND hwnd, INT offset, UINT wFlags, UINT wMask)
1045 LONG ret = GetWindowLongA(hwnd, offset);
1046 UINT newFlags = (wFlags & wMask) | (ret & ~wFlags);
1048 if (newFlags != ret)
1049 ret = SetWindowLongA(hwnd, offset, newFlags);
1050 return ret;
1053 /*************************************************************************
1054 * @ [SHLWAPI.167]
1056 * _SHSetParentHwnd
1058 DWORD WINAPI SHLWAPI_167(HWND hWnd, LPVOID y)
1060 FIXME("0x%08x %p\n", hWnd,y);
1061 return 0;
1064 /*************************************************************************
1065 * @ [SHLWAPI.169]
1067 * _IUnknown_AtomicRelease
1069 * Do IUnknown::Release on passed object.
1071 DWORD WINAPI SHLWAPI_169 (IUnknown ** lpUnknown)
1073 IUnknown *temp;
1075 TRACE("(%p)\n",lpUnknown);
1076 if(!lpUnknown || !*((LPDWORD)lpUnknown)) return 0;
1077 temp = *lpUnknown;
1078 *lpUnknown = NULL;
1079 TRACE("doing Release\n");
1080 return IUnknown_Release(temp);
1083 /*************************************************************************
1084 * @ [SHLWAPI.170]
1086 * Skip URL '//' sequence.
1088 LPCSTR WINAPI SHLWAPI_170(LPCSTR lpszSrc)
1090 if (lpszSrc && lpszSrc[0] == '/' && lpszSrc[1] == '/')
1091 lpszSrc += 2;
1092 return lpszSrc;
1095 /*************************************************************************
1096 * @ [SHLWAPI.171]
1098 * _SHIsSameObject
1100 BOOL WINAPI SHLWAPI_171(LPVOID x, LPVOID y)
1102 FIXME("%p %p\n",x,y);
1103 return 0;
1106 /*************************************************************************
1107 * @ [SHLWAPI.172]
1109 * _IUnknown_GetWindow
1111 * Get window handle of OLE object
1113 DWORD WINAPI SHLWAPI_172 (
1114 IUnknown *pUnk, /* [in] OLE object interface */
1115 LPHWND hWnd) /* [out] location to put window handle */
1117 DWORD ret = E_FAIL;
1118 IOleWindow *pOleWnd;
1120 TRACE("(%p %p)\n",pUnk,hWnd);
1122 if (pUnk) {
1123 ret = IUnknown_QueryInterface(pUnk, &IID_IOleWindow,(LPVOID *)&pOleWnd);
1124 if (SUCCEEDED(ret)) {
1125 ret = IOleWindow_GetWindow(pOleWnd, hWnd);
1126 IOleWindow_Release(pOleWnd);
1127 TRACE("result hwnd=%08x\n", *hWnd);
1131 return ret;
1134 /*************************************************************************
1135 * @ [SHLWAPI.174]
1137 * Seems to do call either IObjectWithSite::SetSite or
1138 * IPersistMoniker::GetClassID. But since we do not implement either
1139 * of those classes in our headers, we will fake it out.
1141 DWORD WINAPI SHLWAPI_174(
1142 IUnknown *p1, /* [in] OLE object */
1143 LPVOID *p2) /* [out] ptr to result of either GetClassID
1144 or SetSite call. */
1146 DWORD ret, aa;
1148 if (!p1) return E_FAIL;
1150 /* see if SetSite interface exists for IObjectWithSite object */
1151 ret = IUnknown_QueryInterface((IUnknown *)p1, (REFIID)id1, (LPVOID *)&p1);
1152 TRACE("first IU_QI ret=%08lx, p1=%p\n", ret, p1);
1153 if (ret) {
1155 /* see if GetClassId interface exists for IPersistMoniker object */
1156 ret = IUnknown_QueryInterface((IUnknown *)p1, (REFIID)id2, (LPVOID *)&aa);
1157 TRACE("second IU_QI ret=%08lx, aa=%08lx\n", ret, aa);
1158 if (ret) return ret;
1160 /* fake a GetClassId call */
1161 ret = IOleWindow_GetWindow((IOleWindow *)aa, (HWND*)p2);
1162 TRACE("second IU_QI doing 0x0c ret=%08lx, *p2=%08lx\n", ret,
1163 *(LPDWORD)p2);
1164 IUnknown_Release((IUnknown *)aa);
1166 else {
1167 /* fake a SetSite call */
1168 ret = IOleWindow_GetWindow((IOleWindow *)p1, (HWND*)p2);
1169 TRACE("first IU_QI doing 0x0c ret=%08lx, *p2=%08lx\n", ret,
1170 *(LPDWORD)p2);
1171 IUnknown_Release((IUnknown *)p1);
1173 return ret;
1176 /*************************************************************************
1177 * @ [SHLWAPI.175]
1179 * NOTE:
1180 * Param1 can be an IShellFolder Object
1182 HRESULT WINAPI SHLWAPI_175 (LPVOID x, LPVOID y)
1184 FIXME("(%p %p) stub\n", x,y);
1185 return E_FAIL;
1187 /*************************************************************************
1188 * @ [SHLWAPI.176]
1190 * _IUnknown_QueryService
1192 * Function appears to be interface to IServiceProvider::QueryService
1194 * NOTE:
1195 * returns E_NOINTERFACE
1196 * E_FAIL if w == 0
1197 * S_OK if _219 called successfully
1199 DWORD WINAPI SHLWAPI_176 (
1200 IUnknown* unk, /* [in] object to give Service Provider */
1201 REFGUID sid, /* [in] Service ID */
1202 REFIID riid, /* [in] Function requested */
1203 LPVOID *ppv) /* [out] place to save interface pointer */
1205 HRESULT ret = E_FAIL;
1206 IServiceProvider *pSP;
1207 *ppv = 0;
1209 TRACE("%p, %s, %s, %p\n", unk, debugstr_guid(sid), debugstr_guid(riid), ppv);
1211 if (unk) {
1212 ret = IUnknown_QueryInterface(unk, &IID_IServiceProvider,(LPVOID*) &pSP);
1213 TRACE("did IU_QI retval=%08lx, aa=%p\n", ret, pSP);
1214 if (SUCCEEDED(ret)) {
1215 ret = IServiceProvider_QueryService(pSP, sid, riid, (LPVOID*)ppv);
1216 TRACE("did ISP_QS retval=%08lx, *z=%p\n", ret, *ppv);
1217 IServiceProvider_Release(pSP);
1220 return ret;
1223 /*************************************************************************
1224 * @ [SHLWAPI.181]
1226 * Enable or disable a menu item.
1228 UINT WINAPI SHLWAPI_181(HMENU hMenu, UINT wItemID, BOOL bEnable)
1230 return EnableMenuItem(hMenu, wItemID, bEnable ? MF_ENABLED : MF_GRAYED);
1233 /*************************************************************************
1234 * @ [SHLWAPI.183]
1236 * Register a window class if it isn't already.
1238 DWORD WINAPI SHLWAPI_183(WNDCLASSA *wndclass)
1240 WNDCLASSA wca;
1241 if (GetClassInfoA(wndclass->hInstance, wndclass->lpszClassName, &wca))
1242 return TRUE;
1243 return (DWORD)RegisterClassA(wndclass);
1246 /*************************************************************************
1247 * @ [SHLWAPI.189]
1249 * _IUnknown_OnFocusOCS
1251 DWORD WINAPI SHLWAPI_189(LPVOID x, LPVOID y)
1253 FIXME("%p %p\n", x, y);
1254 return 0;
1257 /*************************************************************************
1258 * @ [SHLWAPI.193]
1260 DWORD WINAPI SHLWAPI_193 ()
1262 HDC hdc;
1263 DWORD ret;
1265 TRACE("()\n");
1267 hdc = GetDC(0);
1268 ret = GetDeviceCaps(hdc, BITSPIXEL) * GetDeviceCaps(hdc, PLANES);
1269 ReleaseDC(0, hdc);
1270 return ret;
1273 /*************************************************************************
1274 * @ [SHLWAPI.199]
1276 * Copy interface pointer
1278 DWORD WINAPI SHLWAPI_199 (
1279 IUnknown **dest, /* [out] pointer to copy of interface ptr */
1280 IUnknown *src) /* [in] interface pointer */
1282 TRACE("(%p %p)\n",dest,src);
1283 if (*dest != src) {
1284 if (*dest)
1285 IUnknown_Release(*dest);
1286 if (src) {
1287 IUnknown_AddRef(src);
1288 *dest = src;
1291 return 4;
1294 /*************************************************************************
1295 * @ [SHLWAPI.208]
1297 * Some sort of memory management process - associated with _210
1299 DWORD WINAPI SHLWAPI_208 (
1300 DWORD a,
1301 DWORD b,
1302 LPVOID c,
1303 LPVOID d,
1304 DWORD e)
1306 FIXME("(0x%08lx 0x%08lx %p %p 0x%08lx) stub\n",
1307 a, b, c, d, e);
1308 return 1;
1311 /*************************************************************************
1312 * @ [SHLWAPI.209]
1314 * Some sort of memory management process - associated with _208
1316 DWORD WINAPI SHLWAPI_209 (
1317 LPVOID a)
1319 FIXME("(%p) stub\n",
1321 return 1;
1324 /*************************************************************************
1325 * @ [SHLWAPI.210]
1327 * Some sort of memory management process - associated with _208
1329 DWORD WINAPI SHLWAPI_210 (
1330 LPVOID a,
1331 DWORD b,
1332 LPVOID c)
1334 FIXME("(%p 0x%08lx %p) stub\n",
1335 a, b, c);
1336 return 0;
1339 /*************************************************************************
1340 * @ [SHLWAPI.211]
1342 DWORD WINAPI SHLWAPI_211 (
1343 LPVOID a,
1344 DWORD b)
1346 FIXME("(%p 0x%08lx) stub\n",
1347 a, b);
1348 return 1;
1351 /*************************************************************************
1352 * @ [SHLWAPI.215]
1354 * NOTES
1355 * check me!
1357 DWORD WINAPI SHLWAPI_215 (
1358 LPCSTR lpStrSrc,
1359 LPWSTR lpwStrDest,
1360 int len)
1362 INT len_a, ret;
1364 len_a = lstrlenA(lpStrSrc);
1365 ret = MultiByteToWideChar(0, 0, lpStrSrc, len_a, lpwStrDest, len);
1366 TRACE("%s %s %d, ret=%d\n",
1367 debugstr_a(lpStrSrc), debugstr_w(lpwStrDest), len, ret);
1368 return ret;
1371 /*************************************************************************
1372 * @ [SHLWAPI.218]
1374 * WideCharToMultiByte with multi language support.
1376 INT WINAPI SHLWAPI_218(UINT CodePage, LPCWSTR lpSrcStr, LPSTR lpDstStr,
1377 LPINT lpnMultiCharCount)
1379 WCHAR emptyW[] = { '\0' };
1380 int len , reqLen;
1381 LPSTR mem;
1383 if (!lpDstStr || !lpnMultiCharCount)
1384 return 0;
1386 if (!lpSrcStr)
1387 lpSrcStr = emptyW;
1389 *lpDstStr = '\0';
1391 len = strlenW(lpSrcStr) + 1;
1393 switch (CodePage)
1395 case CP_WINUNICODE:
1396 CodePage = CP_UTF8; /* Fall through... */
1397 case 0x0000C350: /* FIXME: CP_ #define */
1398 case CP_UTF7:
1399 case CP_UTF8:
1401 DWORD dwMode = 0;
1402 INT nWideCharCount = len - 1;
1404 GET_FUNC(pConvertINetUnicodeToMultiByte, mlang, "ConvertINetUnicodeToMultiByte", 0);
1405 if (!pConvertINetUnicodeToMultiByte(&dwMode, CodePage, lpSrcStr, &nWideCharCount, lpDstStr,
1406 lpnMultiCharCount))
1407 return 0;
1409 if (nWideCharCount < len - 1)
1411 mem = (LPSTR)HeapAlloc(GetProcessHeap(), 0, *lpnMultiCharCount);
1412 if (!mem)
1413 return 0;
1415 *lpnMultiCharCount = 0;
1417 if (pConvertINetUnicodeToMultiByte(&dwMode, CodePage, lpSrcStr, &len, mem, lpnMultiCharCount))
1419 SHLWAPI_162 (mem, *lpnMultiCharCount);
1420 lstrcpynA(lpDstStr, mem, *lpnMultiCharCount + 1);
1421 return *lpnMultiCharCount + 1;
1423 HeapFree(GetProcessHeap(), 0, mem);
1424 return *lpnMultiCharCount;
1426 lpDstStr[*lpnMultiCharCount] = '\0';
1427 return *lpnMultiCharCount;
1429 break;
1430 default:
1431 break;
1434 reqLen = WideCharToMultiByte(CodePage, 0, lpSrcStr, len, lpDstStr,
1435 *lpnMultiCharCount, NULL, NULL);
1437 if (!reqLen && GetLastError() == ERROR_INSUFFICIENT_BUFFER)
1439 reqLen = WideCharToMultiByte(CodePage, 0, lpSrcStr, len, NULL, 0, NULL, NULL);
1440 if (reqLen)
1442 mem = (LPSTR)HeapAlloc(GetProcessHeap(), 0, reqLen);
1443 if (mem)
1445 reqLen = WideCharToMultiByte(CodePage, 0, lpSrcStr, len, mem,
1446 reqLen, NULL, NULL);
1448 reqLen = SHLWAPI_162(mem, *lpnMultiCharCount);
1449 reqLen++;
1451 lstrcpynA(lpDstStr, mem, *lpnMultiCharCount);
1453 HeapFree(GetProcessHeap(), 0, mem);
1457 return reqLen;
1460 /*************************************************************************
1461 * @ [SHLWAPI.217]
1463 * Hmm, some program used lpnMultiCharCount == 0x3 (and lpSrcStr was "C")
1464 * --> Crash. Something wrong here.
1466 * It seems from OE v5 that the third param is the count. (GA 11/2001)
1468 INT WINAPI SHLWAPI_217(LPCWSTR lpSrcStr, LPSTR lpDstStr, INT MultiCharCount)
1470 INT myint = MultiCharCount;
1472 return SHLWAPI_218(CP_ACP, lpSrcStr, lpDstStr, &myint);
1475 /*************************************************************************
1476 * @ [SHLWAPI.219]
1478 * Seems to be "super" QueryInterface. Supplied with a table of interfaces
1479 * and an array of IIDs and offsets into the table.
1481 * NOTES
1482 * error codes: E_POINTER, E_NOINTERFACE
1484 typedef struct {
1485 REFIID refid;
1486 DWORD indx;
1487 } IFACE_INDEX_TBL;
1489 HRESULT WINAPI SHLWAPI_219 (
1490 LPVOID w, /* [in] table of interfaces */
1491 IFACE_INDEX_TBL *x, /* [in] array of REFIIDs and indexes to above */
1492 REFIID riid, /* [in] REFIID to get interface for */
1493 LPVOID *ppv) /* [out] location to get interface pointer */
1495 HRESULT ret;
1496 IUnknown *a_vtbl;
1497 IFACE_INDEX_TBL *xmove;
1499 TRACE("(%p %p %s %p)\n", w,x,debugstr_guid(riid),ppv);
1500 if (ppv) {
1501 xmove = x;
1502 while (xmove->refid) {
1503 TRACE("trying (indx %ld) %s\n", xmove->indx, debugstr_guid(xmove->refid));
1504 if (IsEqualIID(riid, xmove->refid)) {
1505 a_vtbl = (IUnknown*)(xmove->indx + (LPBYTE)w);
1506 TRACE("matched, returning (%p)\n", a_vtbl);
1507 *ppv = (LPVOID)a_vtbl;
1508 IUnknown_AddRef(a_vtbl);
1509 return S_OK;
1511 xmove++;
1514 if (IsEqualIID(riid, &IID_IUnknown)) {
1515 a_vtbl = (IUnknown*)(x->indx + (LPBYTE)w);
1516 TRACE("returning first for IUnknown (%p)\n", a_vtbl);
1517 *ppv = (LPVOID)a_vtbl;
1518 IUnknown_AddRef(a_vtbl);
1519 return S_OK;
1521 *ppv = 0;
1522 ret = E_NOINTERFACE;
1523 } else
1524 ret = E_POINTER;
1526 TRACE("-- 0x%08lx\n", ret);
1527 return ret;
1530 /*************************************************************************
1531 * @ [SHLWAPI.236]
1533 HMODULE WINAPI SHLWAPI_236 (REFIID lpUnknown)
1535 HKEY newkey;
1536 DWORD type, count;
1537 CHAR value[MAX_PATH], string[MAX_PATH];
1539 strcpy(string, "CLSID\\");
1540 strcat(string, debugstr_guid(lpUnknown));
1541 strcat(string, "\\InProcServer32");
1543 count = MAX_PATH;
1544 RegOpenKeyExA(HKEY_CLASSES_ROOT, string, 0, 1, &newkey);
1545 RegQueryValueExA(newkey, 0, 0, &type, value, &count);
1546 RegCloseKey(newkey);
1547 return LoadLibraryExA(value, 0, 0);
1550 /*************************************************************************
1551 * @ [SHLWAPI.237]
1553 * Unicode version of SHLWAPI_183.
1555 DWORD WINAPI SHLWAPI_237 (WNDCLASSW * lpWndClass)
1557 WNDCLASSW WndClass;
1559 TRACE("(0x%08x %s)\n",lpWndClass->hInstance, debugstr_w(lpWndClass->lpszClassName));
1561 if (GetClassInfoW(lpWndClass->hInstance, lpWndClass->lpszClassName, &WndClass))
1562 return TRUE;
1563 return RegisterClassW(lpWndClass);
1566 /*************************************************************************
1567 * @ [SHLWAPI.239]
1569 DWORD WINAPI SHLWAPI_239(HINSTANCE hInstance, LPVOID p2, DWORD dw3)
1571 FIXME("(0x%08x %p 0x%08lx) stub\n",
1572 hInstance, p2, dw3);
1573 return 0;
1574 #if 0
1575 /* pseudo code from relay trace */
1576 WideCharToMultiByte(0, 0, L"Shell DocObject View", -1, &aa, 0x0207, 0, 0);
1577 GetClassInfoA(70fe0000,405868ec "Shell DocObject View",40586b14);
1578 /* above pair repeated for:
1579 TridentThicketUrlDlClass
1580 Shell Embedding
1581 CIESplashScreen
1582 Inet Notify_Hidden
1583 OCHost
1585 #endif
1588 /*************************************************************************
1589 * @ [SHLWAPI.240]
1591 * Calls ASCII or Unicode WindowProc for the given window.
1593 LRESULT CALLBACK SHLWAPI_240(HWND hWnd, UINT uMessage, WPARAM wParam, LPARAM lParam)
1595 if (IsWindowUnicode(hWnd))
1596 return DefWindowProcW(hWnd, uMessage, wParam, lParam);
1597 return DefWindowProcA(hWnd, uMessage, wParam, lParam);
1600 /*************************************************************************
1601 * @ [SHLWAPI.241]
1604 DWORD WINAPI SHLWAPI_241 ()
1606 FIXME("()stub\n");
1607 return /* 0xabba1243 */ 0;
1610 /*************************************************************************
1611 * @ [SHLWAPI.266]
1613 * native does at least approximately:
1614 * strcpyW(newstr, x);
1615 * strcatW(newstr, "\\Restrictions");
1616 * if (RegOpenKeyExA(80000001, newstr, 00000000,00000001,40520b78))
1617 * return 0;
1618 * *unknown*
1620 DWORD WINAPI SHLWAPI_266 (
1621 LPVOID w,
1622 LPVOID x, /* [in] partial registry key */
1623 LPVOID y,
1624 LPVOID z)
1626 FIXME("(%p %p %p %p)stub\n",w,x,y,z);
1627 return /* 0xabba1248 */ 0;
1630 /*************************************************************************
1631 * @ [SHLWAPI.267]
1633 * NOTES:
1634 * This QueryInterface asks the inner object for a interface. In case
1635 * of aggregation this request would be forwarded by the inner to the
1636 * outer object. This function asks the inner object directly for the
1637 * interface circumventing the forwarding to the outer object.
1639 HRESULT WINAPI SHLWAPI_267 (
1640 IUnknown * pUnk, /* [in] outer object */
1641 IUnknown * pInner, /* [in] inner object */
1642 IID * riid,
1643 LPVOID* ppv)
1645 HRESULT hret = E_NOINTERFACE;
1646 TRACE("(pUnk=%p pInner=%p\n\tIID: %s %p)\n",pUnk,pInner,debugstr_guid(riid), ppv);
1648 *ppv = NULL;
1649 if(pUnk && pInner) {
1650 hret = IUnknown_QueryInterface(pInner, riid, (LPVOID*)ppv);
1651 if (SUCCEEDED(hret)) IUnknown_Release(pUnk);
1653 TRACE("-- 0x%08lx\n", hret);
1654 return hret;
1657 /*************************************************************************
1658 * @ [SHLWAPI.268]
1659 * NOTES
1660 * pInner is returned by SHLWAPI_267 as ppv
1662 DWORD WINAPI SHLWAPI_268 (
1663 IUnknown * pUnk,
1664 IUnknown ** pInner)
1666 DWORD ret = 0;
1668 TRACE("(pUnk=%p pInner=%p)\n",pUnk,pInner);
1670 IUnknown_AddRef(pUnk);
1671 if (pInner && *pInner) {
1672 ret = IUnknown_Release(*pInner);
1673 *pInner = NULL;
1675 TRACE("-- count=%lu\n",ret);
1676 return ret;
1679 /*************************************************************************
1680 * @ [SHLWAPI.276]
1682 * on first call process does following: other calls just returns 2
1683 * instance = LoadLibraryA("SHELL32.DLL");
1684 * func = GetProcAddress(instance, "DllGetVersion");
1685 * ret = RegOpenKeyExA(80000002, "Software\\Microsoft\\Internet Explorer",00000000,0002001f, newkey);
1686 * ret = RegQueryValueExA(newkey, "IntegratedBrowser",00000000,00000000,4052588c,40525890);
1687 * RegCloseKey(newkey);
1688 * FreeLibrary(instance);
1689 * return 2;
1691 DWORD WINAPI SHLWAPI_276 ()
1693 FIXME("()stub\n");
1694 return /* 0xabba1244 */ 2;
1697 /*************************************************************************
1698 * @ [SHLWAPI.278]
1701 HWND WINAPI SHLWAPI_278 (
1702 LONG wndProc,
1703 HWND hWndParent,
1704 DWORD dwExStyle,
1705 DWORD dwStyle,
1706 HMENU hMenu,
1707 LONG z)
1709 WNDCLASSA wndclass;
1710 HWND hwnd;
1711 HCURSOR hCursor;
1712 char * clsname = "WorkerA";
1714 FIXME("(0x%08lx 0x%08x 0x%08lx 0x%08lx 0x%08x 0x%08lx) partial stub\n",
1715 wndProc,hWndParent,dwExStyle,dwStyle,hMenu,z);
1717 hCursor = LoadCursorA(0x00000000,IDC_ARROWA);
1719 if(!GetClassInfoA(shlwapi_hInstance, clsname, &wndclass))
1721 RtlZeroMemory(&wndclass, sizeof(WNDCLASSA));
1722 wndclass.lpfnWndProc = DefWindowProcW;
1723 wndclass.cbWndExtra = 4;
1724 wndclass.hInstance = shlwapi_hInstance;
1725 wndclass.hCursor = hCursor;
1726 wndclass.hbrBackground = COLOR_BTNSHADOW;
1727 wndclass.lpszMenuName = NULL;
1728 wndclass.lpszClassName = clsname;
1729 RegisterClassA (&wndclass);
1731 hwnd = CreateWindowExA(dwExStyle, clsname, 0,dwStyle,0,0,0,0,hWndParent,
1732 hMenu,shlwapi_hInstance,0);
1733 SetWindowLongA(hwnd, 0, z);
1734 SetWindowLongA(hwnd, GWL_WNDPROC, wndProc);
1735 return hwnd;
1738 /*************************************************************************
1739 * @ [SHLWAPI.281]
1741 * _SHPackDispParamsV
1743 HRESULT WINAPI SHLWAPI_281(LPVOID w, LPVOID x, LPVOID y, LPVOID z)
1745 FIXME("%p %p %p %p\n",w,x,y,z);
1746 return E_FAIL;
1749 /*************************************************************************
1750 * @ [SHLWAPI.284]
1752 * _IConnectionPoint_SimpleInvoke
1754 DWORD WINAPI SHLWAPI_284 (
1755 LPVOID x,
1756 LPVOID y,
1757 LPVOID z)
1759 TRACE("(%p %p %p) stub\n",x,y,z);
1760 return 0;
1763 /*************************************************************************
1764 * @ [SHLWAPI.287]
1766 * _IUnknown_CPContainerOnChanged
1768 HRESULT WINAPI SHLWAPI_287(LPVOID x, LPVOID y)
1770 FIXME("%p %p\n", x,y);
1771 return E_FAIL;
1774 /*************************************************************************
1775 * @ [SHLWAPI.289]
1777 * Late bound call to winmm.PlaySoundW
1779 BOOL WINAPI SHLWAPI_289(LPCWSTR pszSound, HMODULE hmod, DWORD fdwSound)
1781 GET_FUNC(pPlaySoundW, winmm, "PlaySoundW", FALSE);
1782 return pPlaySoundW(pszSound, hmod, fdwSound);
1785 /*************************************************************************
1786 * @ [SHLWAPI.294]
1788 BOOL WINAPI SHLWAPI_294(LPSTR str1, LPSTR str2, LPSTR pStr, DWORD some_len, LPCSTR lpStr2)
1791 * str1: "I" "I" pushl esp+0x20
1792 * str2: "U" "I" pushl 0x77c93810
1793 * (is "I" and "U" "integer" and "unsigned" ??)
1795 * pStr: "" "" pushl eax
1796 * some_len: 0x824 0x104 pushl 0x824
1797 * lpStr2: "%l" "%l" pushl esp+0xc
1799 * shlwapi. StrCpyNW(lpStr2, irrelevant_var, 0x104);
1800 * LocalAlloc(0x00, some_len) -> irrelevant_var
1801 * LocalAlloc(0x40, irrelevant_len) -> pStr
1802 * shlwapi.294(str1, str2, pStr, some_len, lpStr2);
1803 * shlwapi.PathRemoveBlanksW(pStr);
1805 FIXME("('%s', '%s', '%s', %08lx, '%s'): stub!\n", str1, str2, pStr, some_len, lpStr2);
1806 return TRUE;
1809 /*************************************************************************
1810 * @ [SHLWAPI.295]
1812 * Called by ICQ2000b install via SHDOCVW:
1813 * str1: "InternetShortcut"
1814 * x: some unknown pointer
1815 * str2: "http://free.aol.com/tryaolfree/index.adp?139269"
1816 * str3: "C:\\WINDOWS\\Desktop.new2\\Free AOL & Unlimited Internet.url"
1818 * In short: this one maybe creates a desktop link :-)
1820 BOOL WINAPI SHLWAPI_295(LPWSTR str1, LPVOID x, LPWSTR str2, LPWSTR str3)
1822 FIXME("('%s', %p, '%s', '%s'), stub.\n", debugstr_w(str1), x, debugstr_w(str2), debugstr_w(str3));
1823 return TRUE;
1826 /*************************************************************************
1827 * @ [SHLWAPI.313]
1829 * Late bound call to shell32.SHGetFileInfoW
1831 DWORD WINAPI SHLWAPI_313(LPCWSTR path, DWORD dwFileAttributes,
1832 SHFILEINFOW *psfi, UINT sizeofpsfi, UINT flags)
1834 GET_FUNC(pSHGetFileInfoW, shell32, "SHGetFileInfoW", 0);
1835 return pSHGetFileInfoW(path, dwFileAttributes, psfi, sizeofpsfi, flags);
1838 /*************************************************************************
1839 * @ [SHLWAPI.318]
1841 * Late bound call to shell32.DragQueryFileW
1843 UINT WINAPI SHLWAPI_318(HDROP hDrop, UINT lFile, LPWSTR lpszFile, UINT lLength)
1845 GET_FUNC(pDragQueryFileW, shell32, "DragQueryFileW", 0);
1846 return pDragQueryFileW(hDrop, lFile, lpszFile, lLength);
1849 /*************************************************************************
1850 * @ [SHLWAPI.333]
1852 * Late bound call to shell32.SHBrowseForFolderW
1854 LPITEMIDLIST WINAPI SHLWAPI_333(LPBROWSEINFOW lpBi)
1856 GET_FUNC(pSHBrowseForFolderW, shell32, "SHBrowseForFolderW", NULL);
1857 return pSHBrowseForFolderW(lpBi);
1860 /*************************************************************************
1861 * @ [SHLWAPI.334]
1863 * Late bound call to shell32.SHGetPathFromIDListW
1865 BOOL WINAPI SHLWAPI_334(LPCITEMIDLIST pidl,LPWSTR pszPath)
1867 GET_FUNC(pSHGetPathFromIDListW, shell32, "SHGetPathFromIDListW", 0);
1868 return pSHGetPathFromIDListW(pidl, pszPath);
1871 /*************************************************************************
1872 * @ [SHLWAPI.335]
1874 * Late bound call to shell32.ShellExecuteExW
1876 BOOL WINAPI SHLWAPI_335(LPSHELLEXECUTEINFOW lpExecInfo)
1878 GET_FUNC(pShellExecuteExW, shell32, "ShellExecuteExW", FALSE);
1879 return pShellExecuteExW(lpExecInfo);
1882 /*************************************************************************
1883 * @ [SHLWAPI.336]
1885 * Late bound call to shell32.SHFileOperationW.
1887 DWORD WINAPI SHLWAPI_336(LPSHFILEOPSTRUCTW lpFileOp)
1889 GET_FUNC(pSHFileOperationW, shell32, "SHFileOperationW", 0);
1890 return pSHFileOperationW(lpFileOp);
1893 /*************************************************************************
1894 * @ [SHLWAPI.337]
1896 * Late bound call to shell32.ExtractIconExW.
1898 HICON WINAPI SHLWAPI_337(LPCWSTR lpszFile, INT nIconIndex, HICON *phiconLarge,
1899 HICON *phiconSmall, UINT nIcons)
1901 GET_FUNC(pExtractIconExW, shell32, "ExtractIconExW", (HICON)0);
1902 return pExtractIconExW(lpszFile, nIconIndex, phiconLarge, phiconSmall, nIcons);
1905 /*************************************************************************
1906 * @ [SHLWAPI.342]
1909 LONG WINAPI SHInterlockedCompareExchange( PLONG dest, LONG xchg, LONG compare)
1911 return InterlockedCompareExchange(dest, xchg, compare);
1914 /*************************************************************************
1915 * @ [SHLWAPI.346]
1917 DWORD WINAPI SHLWAPI_346 (
1918 LPCWSTR src,
1919 LPWSTR dest,
1920 int len)
1922 FIXME("(%s %p 0x%08x)stub\n",debugstr_w(src),dest,len);
1923 lstrcpynW(dest, src, len);
1924 return lstrlenW(dest)+1;
1927 /*************************************************************************
1928 * @ [SHLWAPI.350]
1930 * seems to be late bound call to GetFileVersionInfoSizeW
1932 DWORD WINAPI SHLWAPI_350 (
1933 LPWSTR x,
1934 LPVOID y)
1936 DWORD ret;
1938 GET_FUNC(pGetFileVersionInfoSizeW, version, "GetFileVersionInfoSizeW", 0);
1939 ret = pGetFileVersionInfoSizeW(x, y);
1940 return 0x208 + ret;
1943 /*************************************************************************
1944 * @ [SHLWAPI.351]
1946 * seems to be late bound call to GetFileVersionInfoW
1948 BOOL WINAPI SHLWAPI_351 (
1949 LPWSTR w, /* [in] path to dll */
1950 DWORD x, /* [in] parm 2 to GetFileVersionInfoA */
1951 DWORD y, /* [in] return value from .350 - assume length */
1952 LPVOID z) /* [in/out] buffer (+0x208 sent to GetFileVersionInfoA) */
1954 GET_FUNC(pGetFileVersionInfoW, version, "GetFileVersionInfoW", 0);
1955 return pGetFileVersionInfoW(w, x, y-0x208, (char*)z+0x208);
1958 /*************************************************************************
1959 * @ [SHLWAPI.352]
1961 * seems to be late bound call to VerQueryValueW
1963 WORD WINAPI SHLWAPI_352 (
1964 LPVOID w, /* [in] buffer from _351 */
1965 LPWSTR x, /* [in] value to retrieve -
1966 converted and passed to VerQueryValueA as #2 */
1967 LPVOID y, /* [out] ver buffer - passed to VerQueryValueA as #3 */
1968 UINT* z) /* [in] ver length - passed to VerQueryValueA as #4 */
1970 GET_FUNC(pVerQueryValueW, version, "VerQueryValueW", 0);
1971 return pVerQueryValueW((char*)w+0x208, x, y, z);
1974 /*************************************************************************
1975 * @ [SHLWAPI.357]
1977 * Late bound call to shell32.SHGetNewLinkInfoW
1979 BOOL WINAPI SHLWAPI_357(LPCWSTR pszLinkTo, LPCWSTR pszDir, LPWSTR pszName,
1980 BOOL *pfMustCopy, UINT uFlags)
1982 GET_FUNC(pSHGetNewLinkInfoW, shell32, "SHGetNewLinkInfoW", FALSE);
1983 return pSHGetNewLinkInfoW(pszLinkTo, pszDir, pszName, pfMustCopy, uFlags);
1986 /*************************************************************************
1987 * @ [SHLWAPI.358]
1989 * Late bound call to shell32.SHDefExtractIconW
1991 DWORD WINAPI SHLWAPI_358(LPVOID arg1, LPVOID arg2, LPVOID arg3, LPVOID arg4,
1992 LPVOID arg5, LPVOID arg6)
1994 GET_FUNC(pSHDefExtractIconW, shell32, "SHDefExtractIconW", 0);
1995 return pSHDefExtractIconW(arg1, arg2, arg3, arg4, arg5, arg6);
1998 /*************************************************************************
1999 * @ [SHLWAPI.364]
2001 * Wrapper for lstrcpynA with src and dst swapped.
2003 DWORD WINAPI SHLWAPI_364(LPCSTR src, LPSTR dst, INT n)
2005 lstrcpynA(dst, src, n);
2006 return TRUE;
2009 /*************************************************************************
2010 * @ [SHLWAPI.370]
2012 * Late bound call to shell32.ExtractIconW
2014 HICON WINAPI SHLWAPI_370(HINSTANCE hInstance, LPCWSTR lpszExeFileName,
2015 UINT nIconIndex)
2017 GET_FUNC(pExtractIconW, shell32, "ExtractIconW", (HICON)0);
2018 return pExtractIconW(hInstance, lpszExeFileName, nIconIndex);
2021 /*************************************************************************
2022 * @ [SHLWAPI.376]
2024 LANGID WINAPI SHLWAPI_376 ()
2026 FIXME("() stub\n");
2027 /* FIXME: This should be a forward in the .spec file to the win2k function
2028 * kernel32.GetUserDefaultUILanguage, however that function isn't there yet.
2030 return GetUserDefaultLangID();
2033 /*************************************************************************
2034 * @ [SHLWAPI.377]
2036 * FIXME: Native appears to do DPA_Create and a DPA_InsertPtr for
2037 * each call here.
2038 * FIXME: Native shows calls to:
2039 * SHRegGetUSValue for "Software\Microsoft\Internet Explorer\International"
2040 * CheckVersion
2041 * RegOpenKeyExA for "HKLM\Software\Microsoft\Internet Explorer"
2042 * RegQueryValueExA for "LPKInstalled"
2043 * RegCloseKey
2044 * RegOpenKeyExA for "HKCU\Software\Microsoft\Internet Explorer\International"
2045 * RegQueryValueExA for "ResourceLocale"
2046 * RegCloseKey
2047 * RegOpenKeyExA for "HKLM\Software\Microsoft\Active Setup\Installed Components\{guid}"
2048 * RegQueryValueExA for "Locale"
2049 * RegCloseKey
2050 * and then tests the Locale ("en" for me).
2051 * code below
2052 * after the code then a DPA_Create (first time) and DPA_InsertPtr are done.
2054 DWORD WINAPI SHLWAPI_377 (LPCSTR new_mod, HMODULE inst_hwnd, LPVOID z)
2056 CHAR mod_path[2*MAX_PATH];
2057 LPSTR ptr;
2059 GetModuleFileNameA(inst_hwnd, mod_path, 2*MAX_PATH);
2060 ptr = strrchr(mod_path, '\\');
2061 if (ptr) {
2062 strcpy(ptr+1, new_mod);
2063 TRACE("loading %s\n", debugstr_a(mod_path));
2064 return (DWORD)LoadLibraryA(mod_path);
2066 return 0;
2069 /*************************************************************************
2070 * @ [SHLWAPI.378]
2072 * This is Unicode version of .377
2074 DWORD WINAPI SHLWAPI_378 (
2075 LPCWSTR new_mod, /* [in] new module name */
2076 HMODULE inst_hwnd, /* [in] calling module handle */
2077 LPVOID z) /* [???] 4 */
2079 WCHAR mod_path[2*MAX_PATH];
2080 LPWSTR ptr;
2082 GetModuleFileNameW(inst_hwnd, mod_path, 2*MAX_PATH);
2083 ptr = strrchrW(mod_path, '\\');
2084 if (ptr) {
2085 strcpyW(ptr+1, new_mod);
2086 TRACE("loading %s\n", debugstr_w(mod_path));
2087 return (DWORD)LoadLibraryW(mod_path);
2089 return 0;
2092 /*************************************************************************
2093 * @ [SHLWAPI.389]
2095 * Late bound call to comdlg32.GetSaveFileNameW
2097 BOOL WINAPI SHLWAPI_389(LPOPENFILENAMEW ofn)
2099 GET_FUNC(pGetSaveFileNameW, comdlg32, "GetSaveFileNameW", FALSE);
2100 return pGetSaveFileNameW(ofn);
2103 /*************************************************************************
2104 * @ [SHLWAPI.390]
2106 * Late bound call to mpr.WNetRestoreConnectionW
2108 DWORD WINAPI SHLWAPI_390(LPVOID arg1, LPVOID arg2)
2110 GET_FUNC(pWNetRestoreConnectionW, mpr, "WNetRestoreConnectionW", 0);
2111 return pWNetRestoreConnectionW(arg1, arg2);
2114 /*************************************************************************
2115 * @ [SHLWAPI.391]
2117 * Late bound call to mpr.WNetGetLastErrorW
2119 DWORD WINAPI SHLWAPI_391(LPVOID arg1, LPVOID arg2, LPVOID arg3, LPVOID arg4,
2120 LPVOID arg5)
2122 GET_FUNC(pWNetGetLastErrorW, mpr, "WNetGetLastErrorW", 0);
2123 return pWNetGetLastErrorW(arg1, arg2, arg3, arg4, arg5);
2126 /*************************************************************************
2127 * @ [SHLWAPI.401]
2129 * Late bound call to comdlg32.PageSetupDlgW
2131 BOOL WINAPI SHLWAPI_401(LPPAGESETUPDLGW pagedlg)
2133 GET_FUNC(pPageSetupDlgW, comdlg32, "PageSetupDlgW", FALSE);
2134 return pPageSetupDlgW(pagedlg);
2137 /*************************************************************************
2138 * @ [SHLWAPI.402]
2140 * Late bound call to comdlg32.PrintDlgW
2142 BOOL WINAPI SHLWAPI_402(LPPRINTDLGW printdlg)
2144 GET_FUNC(pPrintDlgW, comdlg32, "PrintDlgW", FALSE);
2145 return pPrintDlgW(printdlg);
2148 /*************************************************************************
2149 * @ [SHLWAPI.403]
2151 * Late bound call to comdlg32.GetOpenFileNameW
2153 BOOL WINAPI SHLWAPI_403(LPOPENFILENAMEW ofn)
2155 GET_FUNC(pGetOpenFileNameW, comdlg32, "GetOpenFileNameW", FALSE);
2156 return pGetOpenFileNameW(ofn);
2159 /* INTERNAL: Map from HLS color space to RGB */
2160 static WORD ConvertHue(int wHue, WORD wMid1, WORD wMid2)
2162 wHue = wHue > 240 ? wHue - 240 : wHue < 0 ? wHue + 240 : wHue;
2164 if (wHue > 160)
2165 return wMid1;
2166 else if (wHue > 120)
2167 wHue = 160 - wHue;
2168 else if (wHue > 40)
2169 return wMid2;
2171 return ((wHue * (wMid2 - wMid1) + 20) / 40) + wMid1;
2174 /* Convert to RGB and scale into RGB range (0..255) */
2175 #define GET_RGB(h) (ConvertHue(h, wMid1, wMid2) * 255 + 120) / 240
2177 /*************************************************************************
2178 * ColorHLSToRGB [SHLWAPI.404]
2180 * Convert from HLS color space into an RGB COLORREF.
2182 * NOTES
2183 * Input HLS values are constrained to the range (0..240).
2185 COLORREF WINAPI ColorHLSToRGB(WORD wHue, WORD wLuminosity, WORD wSaturation)
2187 WORD wRed;
2189 if (wSaturation)
2191 WORD wGreen, wBlue, wMid1, wMid2;
2193 if (wLuminosity > 120)
2194 wMid2 = wSaturation + wLuminosity - (wSaturation * wLuminosity + 120) / 240;
2195 else
2196 wMid2 = ((wSaturation + 240) * wLuminosity + 120) / 240;
2198 wMid1 = wLuminosity * 2 - wMid2;
2200 wRed = GET_RGB(wHue + 80);
2201 wGreen = GET_RGB(wHue);
2202 wBlue = GET_RGB(wHue - 80);
2204 return RGB(wRed, wGreen, wBlue);
2207 wRed = wLuminosity * 255 / 240;
2208 return RGB(wRed, wRed, wRed);
2211 /*************************************************************************
2212 * @ [SHLWAPI.413]
2214 * Function unknown seems to always to return 0
2215 * x can be 0x3.
2217 DWORD WINAPI SHLWAPI_413 (DWORD x)
2219 FIXME("(0x%08lx)stub\n", x);
2220 return 0;
2223 /*************************************************************************
2224 * @ [SHLWAPI.418]
2226 * Function seems to do FreeLibrary plus other things.
2228 * FIXME native shows the following calls:
2229 * RtlEnterCriticalSection
2230 * LocalFree
2231 * GetProcAddress(Comctl32??, 150L)
2232 * DPA_DeletePtr
2233 * RtlLeaveCriticalSection
2234 * followed by the FreeLibrary.
2235 * The above code may be related to .377 above.
2237 BOOL WINAPI SHLWAPI_418 (HMODULE x)
2239 FIXME("(0x%08lx) partial stub\n", (LONG)x);
2240 return FreeLibrary(x);
2243 /*************************************************************************
2244 * @ [SHLWAPI.430]
2246 DWORD WINAPI SHLWAPI_430 (HINSTANCE hModule, HANDLE heap)
2248 FIXME("(0x%08lx 0x%08lx) stub\n", (DWORD)hModule, (DWORD)heap);
2249 return E_FAIL; /* This is what is used if shlwapi not loaded */
2252 /*************************************************************************
2253 * @ [SHLWAPI.431]
2255 DWORD WINAPI SHLWAPI_431 (DWORD x)
2257 FIXME("(0x%08lx)stub\n", x);
2258 return 0xabba1247;
2261 /*************************************************************************
2262 * @ [SHLWAPI.436]
2264 * This is really CLSIDFromString which is exported by ole32.dll,
2265 * however the native shlwapi.dll does *not* import ole32. Nor does
2266 * ole32.dll import this ordinal from shlwapi. Therefore we must conclude
2267 * that MS duplicated the code for CLSIDFromString.
2269 * This is a duplicate (with changes for UNICODE) of CLSIDFromString16
2270 * in dlls/ole32/compobj.c
2272 DWORD WINAPI SHLWAPI_436 (LPWSTR idstr, CLSID *id)
2274 LPWSTR s = idstr;
2275 BYTE *p;
2276 INT i;
2277 WCHAR table[256];
2279 if (!s) {
2280 memset(s, 0, sizeof(CLSID));
2281 return S_OK;
2283 else { /* validate the CLSID string */
2285 if (strlenW(s) != 38)
2286 return CO_E_CLASSSTRING;
2288 if ((s[0]!=L'{') || (s[9]!=L'-') || (s[14]!=L'-') || (s[19]!=L'-') || (s[24]!=L'-') || (s[37]!=L'}'))
2289 return CO_E_CLASSSTRING;
2291 for (i=1; i<37; i++)
2293 if ((i == 9)||(i == 14)||(i == 19)||(i == 24)) continue;
2294 if (!(((s[i] >= L'0') && (s[i] <= L'9')) ||
2295 ((s[i] >= L'a') && (s[i] <= L'f')) ||
2296 ((s[i] >= L'A') && (s[i] <= L'F')))
2298 return CO_E_CLASSSTRING;
2302 TRACE("%s -> %p\n", debugstr_w(s), id);
2304 /* quick lookup table */
2305 memset(table, 0, 256*sizeof(WCHAR));
2307 for (i = 0; i < 10; i++) {
2308 table['0' + i] = i;
2310 for (i = 0; i < 6; i++) {
2311 table['A' + i] = i+10;
2312 table['a' + i] = i+10;
2315 /* in form {XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX} */
2317 p = (BYTE *) id;
2319 s++; /* skip leading brace */
2320 for (i = 0; i < 4; i++) {
2321 p[3 - i] = table[*s]<<4 | table[*(s+1)];
2322 s += 2;
2324 p += 4;
2325 s++; /* skip - */
2327 for (i = 0; i < 2; i++) {
2328 p[1-i] = table[*s]<<4 | table[*(s+1)];
2329 s += 2;
2331 p += 2;
2332 s++; /* skip - */
2334 for (i = 0; i < 2; i++) {
2335 p[1-i] = table[*s]<<4 | table[*(s+1)];
2336 s += 2;
2338 p += 2;
2339 s++; /* skip - */
2341 /* these are just sequential bytes */
2342 for (i = 0; i < 2; i++) {
2343 *p++ = table[*s]<<4 | table[*(s+1)];
2344 s += 2;
2346 s++; /* skip - */
2348 for (i = 0; i < 6; i++) {
2349 *p++ = table[*s]<<4 | table[*(s+1)];
2350 s += 2;
2353 return S_OK;
2356 /*************************************************************************
2357 * @ [SHLWAPI.437]
2359 * NOTES
2360 * In the real shlwapi, One time initialisation calls GetVersionEx and reads
2361 * the registry to determine what O/S & Service Pack level is running, and
2362 * therefore which functions are available. Currently we always run as NT,
2363 * since this means that we don't need extra code to emulate Unicode calls,
2364 * they are forwarded directly to the appropriate API call instead.
2365 * Since the flags for whether to call or emulate Unicode are internal to
2366 * the dll, this function does not need a full implementation.
2368 DWORD WINAPI SHLWAPI_437 (DWORD functionToCall)
2370 FIXME("(0x%08lx)stub\n", functionToCall);
2371 return /* 0xabba1247 */ 0;
2374 /*************************************************************************
2375 * ColorRGBToHLS [SHLWAPI.445]
2377 * Convert from RGB COLORREF into the HLS color space.
2379 * NOTES
2380 * Input HLS values are constrained to the range (0..240).
2382 VOID WINAPI ColorRGBToHLS(COLORREF drRGB, LPWORD pwHue,
2383 LPWORD wLuminance, LPWORD pwSaturation)
2385 FIXME("stub\n");
2386 return;
2389 /*************************************************************************
2390 * SHCreateShellPalette [SHLWAPI.@]
2392 HPALETTE WINAPI SHCreateShellPalette(HDC hdc)
2394 FIXME("stub\n");
2395 return CreateHalftonePalette(hdc);
2398 /*************************************************************************
2399 * SHGetInverseCMAP (SHLWAPI.@)
2401 DWORD WINAPI SHGetInverseCMAP (LPDWORD* x, DWORD why)
2403 if (why == 4) {
2404 FIXME(" - returning bogus address for SHGetInverseCMAP\n");
2405 *x = (LPDWORD)0xabba1249;
2406 return 0;
2408 FIXME("(%p, %#lx)stub\n", x, why);
2409 return 0;
2412 /*************************************************************************
2413 * SHIsLowMemoryMachine [SHLWAPI.@]
2415 DWORD WINAPI SHIsLowMemoryMachine (DWORD x)
2417 FIXME("0x%08lx\n", x);
2418 return 0;
2421 /*************************************************************************
2422 * GetMenuPosFromID [SHLWAPI.@]
2424 INT WINAPI GetMenuPosFromID(HMENU hMenu, UINT wID)
2426 MENUITEMINFOA mi;
2427 INT nCount = GetMenuItemCount(hMenu), nIter = 0;
2429 while (nIter < nCount)
2431 mi.wID = 0;
2432 if (!GetMenuItemInfoA(hMenu, nIter, TRUE, &mi) && mi.wID == wID)
2433 return nIter;
2434 nIter++;
2436 return -1;