- Reimplement functions 350, 351, 352 to use appropriate W functions
[wine/gsoc_dplay.git] / dlls / shlwapi / ordinal.c
blob5680faee035b15a483707f9e169392410b4b2a7a
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 /* Macro to get function pointer for a module*/
118 #define GET_FUNC(module, name, fail) \
119 if (!SHLWAPI_h##module) SHLWAPI_h##module = LoadLibraryA(#module ".dll"); \
120 if (!SHLWAPI_h##module) return fail; \
121 if (!pfnFunc) pfnFunc = (void*)GetProcAddress(SHLWAPI_h##module, name); \
122 if (!pfnFunc) return fail
125 NOTES: Most functions exported by ordinal seem to be superflous.
126 The reason for these functions to be there is to provide a wraper
127 for unicode functions to provide these functions on systems without
128 unicode functions eg. win95/win98. Since we have such functions we just
129 call these. If running Wine with native DLL's, some late bound calls may
130 fail. However, its better to implement the functions in the forward DLL
131 and recommend the builtin rather than reimplementing the calls here!
134 /*************************************************************************
135 * @ [SHLWAPI.1]
137 * Identifies the Internet "scheme" in the passed string. ASCII based.
138 * Also determines start and length of item after the ':'
140 DWORD WINAPI SHLWAPI_1 (LPCSTR x, UNKNOWN_SHLWAPI_1 *y)
142 DWORD cnt;
143 const SHL_2_inet_scheme *inet_pro;
145 if (y->size != 0x18) return E_INVALIDARG;
146 /* FIXME: leading white space generates error of 0x80041001 which
147 * is undefined
149 if (*x <= ' ') return 0x80041001;
150 cnt = 0;
151 y->sizep1 = 0;
152 y->ap1 = x;
153 while (*x) {
154 if (*x == ':') {
155 y->sizep1 = cnt;
156 cnt = -1;
157 y->ap2 = x+1;
158 break;
160 x++;
161 cnt++;
164 /* check for no scheme in string start */
165 /* (apparently schemes *must* be larger than a single character) */
166 if ((*x == '\0') || (y->sizep1 <= 1)) {
167 y->ap1 = 0;
168 return 0x80041001;
171 /* found scheme, set length of remainder */
172 y->sizep2 = lstrlenA(y->ap2);
174 /* see if known scheme and return indicator number */
175 y->fcncde = URL_SCHEME_UNKNOWN;
176 inet_pro = shlwapi_schemes;
177 while (inet_pro->scheme_name) {
178 if (!strncasecmp(inet_pro->scheme_name, y->ap1,
179 min(y->sizep1, lstrlenA(inet_pro->scheme_name)))) {
180 y->fcncde = inet_pro->scheme_number;
181 break;
183 inet_pro++;
185 return S_OK;
188 /*************************************************************************
189 * @ [SHLWAPI.2]
191 * Identifies the Internet "scheme" in the passed string. UNICODE based.
192 * Also determines start and length of item after the ':'
194 DWORD WINAPI SHLWAPI_2 (LPCWSTR x, UNKNOWN_SHLWAPI_2 *y)
196 DWORD cnt;
197 const SHL_2_inet_scheme *inet_pro;
198 LPSTR cmpstr;
199 INT len;
201 if (y->size != 0x18) return E_INVALIDARG;
202 /* FIXME: leading white space generates error of 0x80041001 which
203 * is undefined
205 if (*x <= L' ') return 0x80041001;
206 cnt = 0;
207 y->sizep1 = 0;
208 y->ap1 = x;
209 while (*x) {
210 if (*x == L':') {
211 y->sizep1 = cnt;
212 cnt = -1;
213 y->ap2 = x+1;
214 break;
216 x++;
217 cnt++;
220 /* check for no scheme in string start */
221 /* (apparently schemes *must* be larger than a single character) */
222 if ((*x == L'\0') || (y->sizep1 <= 1)) {
223 y->ap1 = 0;
224 return 0x80041001;
227 /* found scheme, set length of remainder */
228 y->sizep2 = lstrlenW(y->ap2);
230 /* see if known scheme and return indicator number */
231 len = WideCharToMultiByte(0, 0, y->ap1, y->sizep1, 0, 0, 0, 0);
232 cmpstr = (LPSTR)HeapAlloc(GetProcessHeap(), 0, len+1);
233 WideCharToMultiByte(0, 0, y->ap1, y->sizep1, cmpstr, len+1, 0, 0);
234 y->fcncde = URL_SCHEME_UNKNOWN;
235 inet_pro = shlwapi_schemes;
236 while (inet_pro->scheme_name) {
237 if (!strncasecmp(inet_pro->scheme_name, cmpstr,
238 min(len, lstrlenA(inet_pro->scheme_name)))) {
239 y->fcncde = inet_pro->scheme_number;
240 break;
242 inet_pro++;
244 HeapFree(GetProcessHeap(), 0, cmpstr);
245 return S_OK;
248 /*************************************************************************
249 * SHLWAPI_DupSharedHandle
251 * Internal implemetation of SHLWAPI_11.
253 static
254 HSHARED WINAPI SHLWAPI_DupSharedHandle(HSHARED hShared, DWORD dwDstProcId,
255 DWORD dwSrcProcId, DWORD dwAccess,
256 DWORD dwOptions)
258 HANDLE hDst, hSrc;
259 DWORD dwMyProcId = GetCurrentProcessId();
260 HSHARED hRet = (HSHARED)NULL;
262 TRACE("(%p,%ld,%ld,%08lx,%08lx)\n", (PVOID)hShared, dwDstProcId, dwSrcProcId,
263 dwAccess, dwOptions);
265 /* Get dest process handle */
266 if (dwDstProcId == dwMyProcId)
267 hDst = GetCurrentProcess();
268 else
269 hDst = OpenProcess(PROCESS_DUP_HANDLE, 0, dwDstProcId);
271 if (hDst)
273 /* Get src process handle */
274 if (dwSrcProcId == dwMyProcId)
275 hSrc = GetCurrentProcess();
276 else
277 hSrc = OpenProcess(PROCESS_DUP_HANDLE, 0, dwSrcProcId);
279 if (hSrc)
281 /* Make handle available to dest process */
282 if (!DuplicateHandle(hDst, (HANDLE)hShared, hSrc, &hRet,
283 dwAccess, 0, dwOptions | DUPLICATE_SAME_ACCESS))
284 hRet = (HSHARED)NULL;
286 if (dwSrcProcId != dwMyProcId)
287 CloseHandle(hSrc);
290 if (dwDstProcId != dwMyProcId)
291 CloseHandle(hDst);
294 TRACE("Returning handle %p\n", (PVOID)hRet);
295 return hRet;
298 /*************************************************************************
299 * @ [SHLWAPI.7]
301 * Create a block of sharable memory and initialise it with data.
303 * PARAMS
304 * dwProcId [I] ID of process owning data
305 * lpvData [I] Pointer to data to write
306 * dwSize [I] Size of data
308 * RETURNS
309 * Success: A shared memory handle
310 * Failure: NULL
312 * NOTES
313 * Ordinals 7-11 provide a set of calls to create shared memory between a
314 * group of processes. The shared memory is treated opaquely in that its size
315 * is not exposed to clients who map it. This is accomplished by storing
316 * the size of the map as the first DWORD of mapped data, and then offsetting
317 * the view pointer returned by this size.
319 * SHLWAPI_7/SHLWAPI_10 - Create/Destroy the shared memory handle
320 * SHLWAPI_8/SHLWAPI_9 - Get/Release a pointer to the shared data
321 * SHLWAPI_11 - Helper function; Duplicate cross-process handles
323 HSHARED WINAPI SHLWAPI_7 (DWORD dwProcId, DWORD dwSize, LPCVOID lpvData)
325 HANDLE hMap;
326 LPVOID pMapped;
327 HSHARED hRet = (HSHARED)NULL;
329 TRACE("(%ld,%p,%ld)\n", dwProcId, lpvData, dwSize);
331 /* Create file mapping of the correct length */
332 hMap = CreateFileMappingA(INVALID_HANDLE_VALUE, NULL, FILE_MAP_READ, 0,
333 dwSize + sizeof(dwSize), NULL);
334 if (!hMap)
335 return hRet;
337 /* Get a view in our process address space */
338 pMapped = MapViewOfFile(hMap, FILE_MAP_READ | FILE_MAP_WRITE, 0, 0, 0);
340 if (pMapped)
342 /* Write size of data, followed by the data, to the view */
343 *((DWORD*)pMapped) = dwSize;
344 if (dwSize)
345 memcpy((char *) pMapped + sizeof(dwSize), lpvData, dwSize);
347 /* Release view. All further views mapped will be opaque */
348 UnmapViewOfFile(pMapped);
349 hRet = SHLWAPI_DupSharedHandle((HSHARED)hMap, dwProcId,
350 GetCurrentProcessId(), FILE_MAP_ALL_ACCESS,
351 DUPLICATE_SAME_ACCESS);
354 CloseHandle(hMap);
355 return hRet;
358 /*************************************************************************
359 * @ [SHLWAPI.8]
361 * Get a pointer to a block of shared memory from a shared memory handle.
363 * PARAMS
364 * hShared [I] Shared memory handle
365 * dwProcId [I] ID of process owning hShared
367 * RETURNS
368 * Success: A pointer to the shared memory
369 * Failure: NULL
371 * NOTES
372 * See SHLWAPI_7.
374 PVOID WINAPI SHLWAPI_8 (HSHARED hShared, DWORD dwProcId)
376 HSHARED hDup;
377 LPVOID pMapped;
379 TRACE("(%p %ld)\n", (PVOID)hShared, dwProcId);
381 /* Get handle to shared memory for current process */
382 hDup = SHLWAPI_DupSharedHandle(hShared, dwProcId, GetCurrentProcessId(),
383 FILE_MAP_ALL_ACCESS, 0);
384 /* Get View */
385 pMapped = MapViewOfFile((HANDLE)hDup, FILE_MAP_READ | FILE_MAP_WRITE, 0, 0, 0);
386 CloseHandle(hDup);
388 if (pMapped)
389 return (char *) pMapped + sizeof(DWORD); /* Hide size */
390 return NULL;
393 /*************************************************************************
394 * @ [SHLWAPI.9]
396 * Release a pointer to a block of shared memory.
398 * PARAMS
399 * lpView [I] Shared memory pointer
401 * RETURNS
402 * Success: TRUE
403 * Failure: FALSE
405 * NOTES
406 * See SHLWAPI_7.
408 BOOL WINAPI SHLWAPI_9 (LPVOID lpView)
410 TRACE("(%p)\n", lpView);
411 return UnmapViewOfFile((char *) lpView - sizeof(DWORD)); /* Include size */
414 /*************************************************************************
415 * @ [SHLWAPI.10]
417 * Destroy a block of sharable memory.
419 * PARAMS
420 * hShared [I] Shared memory handle
421 * dwProcId [I] ID of process owning hShared
423 * RETURNS
424 * Success: TRUE
425 * Failure: FALSE
427 * NOTES
428 * See SHLWAPI_7.
430 BOOL WINAPI SHLWAPI_10 (HSHARED hShared, DWORD dwProcId)
432 HSHARED hClose;
434 TRACE("(%p %ld)\n", (PVOID)hShared, dwProcId);
436 /* Get a copy of the handle for our process, closing the source handle */
437 hClose = SHLWAPI_DupSharedHandle(hShared, dwProcId, GetCurrentProcessId(),
438 FILE_MAP_ALL_ACCESS,DUPLICATE_CLOSE_SOURCE);
439 /* Close local copy */
440 return CloseHandle((HANDLE)hClose);
443 /*************************************************************************
444 * @ [SHLWAPI.11]
446 * Copy a sharable memory handle from one process to another.
448 * PARAMS
449 * hShared [I] Shared memory handle to duplicate
450 * dwDstProcId [I] ID of the process wanting the duplicated handle
451 * dwSrcProcId [I] ID of the process owning hShared
452 * dwAccess [I] Desired DuplicateHandle access
453 * dwOptions [I] Desired DuplicateHandle options
455 * RETURNS
456 * Success: A handle suitable for use by the dwDstProcId process.
457 * Failure: A NULL handle.
459 * NOTES
460 * See SHLWAPI_7.
462 HSHARED WINAPI SHLWAPI_11(HSHARED hShared, DWORD dwDstProcId, DWORD dwSrcProcId,
463 DWORD dwAccess, DWORD dwOptions)
465 HSHARED hRet;
467 hRet = SHLWAPI_DupSharedHandle(hShared, dwDstProcId, dwSrcProcId,
468 dwAccess, dwOptions);
469 return hRet;
472 /*************************************************************************
473 * @ [SHLWAPI.13]
474 * (Used by IE4 during startup)
476 HRESULT WINAPI SHLWAPI_13 (
477 LPVOID w,
478 LPVOID x)
480 FIXME("(%p %p)stub\n",w,x);
481 return 1;
482 #if 0
483 /* pseudo code extracted from relay trace */
484 RegOpenKeyA(HKLM, "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\Aceepted Documents", &newkey);
485 ret = 0;
486 i = 0;
487 size = 0;
488 while(!ret) {
489 ret = RegEnumValueA(newkey, i, a1, a2, 0, a3, 0, 0);
490 size += ???;
491 i++;
493 b1 = LocalAlloc(0x40, size);
494 ret = 0;
495 i = 0;
496 while(!ret) {
497 ret = RegEnumValueA(newkey, i, a1, a2, 0, a3, a4, a5);
498 RegisterClipBoardFormatA(a4);
499 i++;
501 hwnd1 = GetModuleHandleA("URLMON.DLL");
502 proc = GetProcAddress(hwnd1, "CreateFormatEnumerator");
503 HeapAlloc(??, 0, 0x14);
504 HeapAlloc(??, 0, 0x50);
505 LocalAlloc(0x40, 0x78);
506 /* FIXME: bad string below */
507 lstrlenW(L"{D0FCA420-D3F5-11CF-B211-00AA004AE837}");
508 StrCpyW(a6, L"{D0FCA420-D3F5-11CF-B211-00AA004AE837}");
510 GetTickCount();
511 IsBadReadPtr(c1 = 0x403fd210,4);
512 InterlockedIncrement(c1+4);
513 LocalFree(b1);
514 RegCloseKey(newkey);
515 IsBadReadPtr(c1 = 0x403fd210,4);
516 InterlockedIncrement(c1+4);
518 HeapAlloc(40350000,00000000,00000014) retval=403fd0a8;
519 HeapAlloc(40350000,00000000,00000050) retval=403feb44;
520 hwnd1 = GetModuleHandleA("URLMON.DLL");
521 proc = GetProcAddress(hwnd1, "RegisterFormatEnumerator");
522 /* 0x1a40c88c is in URLMON.DLL just before above proc
523 * content is L"_EnumFORMATETC_"
524 * label is d1
526 IsBadReadPtr(d1 = 0x1a40c88c,00000002);
527 lstrlenW(d1);
528 lstrlenW(d1);
529 HeapAlloc(40350000,00000000,0000001e) retval=403fed44;
530 IsBadReadPtr(d2 = 0x403fd0a8,00000004);
531 InterlockedIncrement(d2+4);
532 IsBadReadPtr(d2 = 0x403fd0a8,00000004);
533 InterlockedDecrement(d2+4);
534 IsBadReadPtr(c1,00000004);
535 InterlockedDecrement(c1+4);
536 IsBadReadPtr(c1,00000004);
537 InterlockedDecrement(c1+4);
539 #endif
542 /*************************************************************************
543 * @ [SHLWAPI.14]
545 * Function:
546 * Retrieves IE "AcceptLanguage" value from registry. ASCII mode.
549 HRESULT WINAPI SHLWAPI_14 (
550 LPSTR langbuf,
551 LPDWORD buflen)
553 CHAR *mystr;
554 DWORD mystrlen, mytype;
555 HKEY mykey;
556 LCID mylcid;
558 mystrlen = (*buflen > 6) ? *buflen : 6;
559 mystr = (CHAR*)HeapAlloc(GetProcessHeap(),
560 HEAP_ZERO_MEMORY, mystrlen);
561 RegOpenKeyA(HKEY_CURRENT_USER,
562 "Software\\Microsoft\\Internet Explorer\\International",
563 &mykey);
564 if (RegQueryValueExA(mykey, "AcceptLanguage",
565 0, &mytype, mystr, &mystrlen)) {
566 /* Did not find value */
567 mylcid = GetUserDefaultLCID();
568 /* somehow the mylcid translates into "en-us"
569 * this is similar to "LOCALE_SABBREVLANGNAME"
570 * which could be gotten via GetLocaleInfo.
571 * The only problem is LOCALE_SABBREVLANGUAGE" is
572 * a 3 char string (first 2 are country code and third is
573 * letter for "sublanguage", which does not come close to
574 * "en-us"
576 lstrcpyA(mystr, "en-us");
577 mystrlen = lstrlenA(mystr);
579 else {
580 /* handle returned string */
581 FIXME("missing code\n");
583 if (mystrlen > *buflen)
584 lstrcpynA(langbuf, mystr, *buflen);
585 else {
586 lstrcpyA(langbuf, mystr);
587 *buflen = lstrlenA(langbuf);
589 RegCloseKey(mykey);
590 HeapFree(GetProcessHeap(), 0, mystr);
591 TRACE("language is %s\n", debugstr_a(langbuf));
592 return 0;
595 /*************************************************************************
596 * @ [SHLWAPI.15]
598 * Function:
599 * Retrieves IE "AcceptLanguage" value from registry. UNICODE mode.
602 HRESULT WINAPI SHLWAPI_15 (
603 LPWSTR langbuf,
604 LPDWORD buflen)
606 CHAR *mystr;
607 DWORD mystrlen, mytype;
608 HKEY mykey;
609 LCID mylcid;
611 mystrlen = (*buflen > 6) ? *buflen : 6;
612 mystr = (CHAR*)HeapAlloc(GetProcessHeap(),
613 HEAP_ZERO_MEMORY, mystrlen);
614 RegOpenKeyA(HKEY_CURRENT_USER,
615 "Software\\Microsoft\\Internet Explorer\\International",
616 &mykey);
617 if (RegQueryValueExA(mykey, "AcceptLanguage",
618 0, &mytype, mystr, &mystrlen)) {
619 /* Did not find value */
620 mylcid = GetUserDefaultLCID();
621 /* somehow the mylcid translates into "en-us"
622 * this is similar to "LOCALE_SABBREVLANGNAME"
623 * which could be gotten via GetLocaleInfo.
624 * The only problem is LOCALE_SABBREVLANGUAGE" is
625 * a 3 char string (first 2 are country code and third is
626 * letter for "sublanguage", which does not come close to
627 * "en-us"
629 lstrcpyA(mystr, "en-us");
630 mystrlen = lstrlenA(mystr);
632 else {
633 /* handle returned string */
634 FIXME("missing code\n");
636 RegCloseKey(mykey);
637 *buflen = MultiByteToWideChar(0, 0, mystr, -1, langbuf, (*buflen)-1);
638 HeapFree(GetProcessHeap(), 0, mystr);
639 TRACE("language is %s\n", debugstr_w(langbuf));
640 return 0;
643 /*************************************************************************
644 * @ [SHLWAPI.16]
646 HRESULT WINAPI SHLWAPI_16 (
647 LPVOID w,
648 LPVOID x,
649 LPVOID y,
650 LPWSTR z)
652 FIXME("(%p %p %p %p)stub\n",w,x,y,z);
653 return 0xabba1252;
656 /*************************************************************************
657 * @ [SHLWAPI.18]
659 * w is pointer to address of callback routine
660 * x is pointer to LPVOID to receive address of locally allocated
661 * space size 0x14
662 * return is 0 (unless out of memory???)
664 * related to _19, _21 and _22 below
665 * only seen invoked by SHDOCVW
667 LONG WINAPI SHLWAPI_18 (
668 LPVOID *w,
669 LPVOID x)
671 FIXME("(%p %p)stub\n",w,x);
672 *((LPDWORD)x) = 0;
673 return 0;
676 /*************************************************************************
677 * @ [SHLWAPI.19]
679 * w is address of allocated memory from _21
680 * return is 0 (unless out of memory???)
682 * related to _18, _21 and _22 below
683 * only seen invoked by SHDOCVW
685 LONG WINAPI SHLWAPI_19 (
686 LPVOID w)
688 FIXME("(%p) stub\n",w);
689 return 0;
692 /*************************************************************************
693 * @ [SHLWAPI.21]
695 * w points to space allocated via .18 above
696 * LocalSize is done on it (retrieves 18)
697 * LocalReAlloc is done on it to size 8 with LMEM_MOVEABLE & LMEM_ZEROINIT
698 * x values seen 0xa0000005
699 * returns 1
701 * relates to _18, _19 and _22 above and below
702 * only seen invoked by SHDOCVW
704 LONG WINAPI SHLWAPI_21 (
705 LPVOID w,
706 DWORD x)
708 FIXME("(%p %lx)stub\n",w,x);
709 return 1;
712 /*************************************************************************
713 * @ [SHLWAPI.22]
715 * return is 'w' value seen in x is 0xa0000005
717 * relates to _18, _19 and _21 above
718 * only seen invoked by SHDOCVW
720 LPVOID WINAPI SHLWAPI_22 (
721 LPVOID w,
722 DWORD x)
724 FIXME("(%p %lx)stub\n",w,x);
725 return w;
728 /*************************************************************************
729 * @ [SHLWAPI.23]
731 * NOTES
732 * converts a guid to a string
733 * returns strlen(str)
735 DWORD WINAPI SHLWAPI_23 (
736 REFGUID guid, /* [in] clsid */
737 LPSTR str, /* [out] buffer */
738 INT cmax) /* [in] size of buffer */
740 char xguid[40];
742 sprintf( xguid, "{%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
743 guid->Data1, guid->Data2, guid->Data3,
744 guid->Data4[0], guid->Data4[1], guid->Data4[2], guid->Data4[3],
745 guid->Data4[4], guid->Data4[5], guid->Data4[6], guid->Data4[7] );
746 TRACE("(%s %p 0x%08x)stub\n", xguid, str, cmax);
747 if (strlen(xguid)>=cmax) return 0;
748 strcpy(str,xguid);
749 return strlen(xguid) + 1;
752 /*************************************************************************
753 * @ [SHLWAPI.24]
755 * NOTES
756 * converts a guid to a string
757 * returns strlen(str)
759 DWORD WINAPI SHLWAPI_24 (
760 REFGUID guid, /* [in] clsid */
761 LPWSTR str, /* [out] buffer */
762 INT cmax) /* [in] size of buffer */
764 char xguid[40];
766 sprintf( xguid, "{%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
767 guid->Data1, guid->Data2, guid->Data3,
768 guid->Data4[0], guid->Data4[1], guid->Data4[2], guid->Data4[3],
769 guid->Data4[4], guid->Data4[5], guid->Data4[6], guid->Data4[7] );
770 return MultiByteToWideChar( CP_ACP, 0, xguid, -1, str, cmax );
773 /*************************************************************************
774 * @ [SHLWAPI.25]
776 * Seems to be iswalpha
778 BOOL WINAPI SHLWAPI_25(WCHAR wc)
780 return (get_char_typeW(wc) & C1_ALPHA) != 0;
783 /*************************************************************************
784 * @ [SHLWAPI.26]
786 * Seems to be iswupper
788 BOOL WINAPI SHLWAPI_26(WCHAR wc)
790 return (get_char_typeW(wc) & C1_UPPER) != 0;
793 /*************************************************************************
794 * @ [SHLWAPI.27]
796 * Seems to be iswlower
798 BOOL WINAPI SHLWAPI_27(WCHAR wc)
800 return (get_char_typeW(wc) & C1_LOWER) != 0;
803 /*************************************************************************
804 * @ [SHLWAPI.28]
806 * Seems to be iswalnum
808 BOOL WINAPI SHLWAPI_28(WCHAR wc)
810 return (get_char_typeW(wc) & (C1_ALPHA|C1_DIGIT)) != 0;
813 /*************************************************************************
814 * @ [SHLWAPI.29]
816 * Seems to be iswspace
818 BOOL WINAPI SHLWAPI_29(WCHAR wc)
820 return (get_char_typeW(wc) & C1_SPACE) != 0;
823 /*************************************************************************
824 * @ [SHLWAPI.30]
826 * Seems to be iswblank
828 BOOL WINAPI SHLWAPI_30(WCHAR wc)
830 return (get_char_typeW(wc) & C1_BLANK) != 0;
833 /*************************************************************************
834 * @ [SHLWAPI.31]
836 * Seems to be iswpunct
838 BOOL WINAPI SHLWAPI_31(WCHAR wc)
840 return (get_char_typeW(wc) & C1_PUNCT) != 0;
843 /*************************************************************************
844 * @ [SHLWAPI.32]
846 * Seems to be iswcntrl
848 BOOL WINAPI SHLWAPI_32(WCHAR wc)
850 return (get_char_typeW(wc) & C1_CNTRL) != 0;
853 /*************************************************************************
854 * @ [SHLWAPI.33]
856 * Seems to be iswdigit
858 BOOL WINAPI SHLWAPI_33(WCHAR wc)
860 return (get_char_typeW(wc) & C1_DIGIT) != 0;
863 /*************************************************************************
864 * @ [SHLWAPI.34]
866 * Seems to be iswxdigit
868 BOOL WINAPI SHLWAPI_34(WCHAR wc)
870 return (get_char_typeW(wc) & C1_XDIGIT) != 0;
873 /*************************************************************************
874 * @ [SHLWAPI.35]
877 BOOL WINAPI SHLWAPI_35(LPVOID p1, DWORD dw2, LPVOID p3)
879 FIXME("(%p, 0x%08lx, %p): stub\n", p1, dw2, p3);
880 return TRUE;
883 /*************************************************************************
884 * @ [SHLWAPI.36]
887 BOOL WINAPI SHLWAPI_36(HMENU h1, UINT ui2, UINT h3, LPCWSTR p4)
889 TRACE("(0x%08x, 0x%08x, 0x%08x, %s): stub\n",
890 h1, ui2, h3, debugstr_w(p4));
891 return AppendMenuW(h1, ui2, h3, p4);
894 /*************************************************************************
895 * @ [SHLWAPI.74]
897 * Get the text from a given dialog item.
899 INT WINAPI SHLWAPI_74(HWND hWnd, INT nItem, LPWSTR lpsDest,INT nDestLen)
901 HWND hItem = GetDlgItem(hWnd, nItem);
903 if (hItem)
904 return GetWindowTextW(hItem, lpsDest, nDestLen);
905 if (nDestLen)
906 *lpsDest = (WCHAR)'\0';
907 return 0;
910 /*************************************************************************
911 * @ [SHLWAPI.151]
912 * Function: Compare two ASCII strings for "len" bytes.
913 * Returns: *str1-*str2 (case sensitive)
915 DWORD WINAPI SHLWAPI_151(LPSTR str1, LPSTR str2, INT len)
917 return strncmp( str1, str2, len );
920 /*************************************************************************
921 * @ [SHLWAPI.152]
923 * Function: Compare two WIDE strings for "len" bytes.
924 * Returns: *str1-*str2 (case sensitive)
926 DWORD WINAPI SHLWAPI_152(LPWSTR str1, LPWSTR str2, INT len)
928 return strncmpW( str1, str2, len );
931 /*************************************************************************
932 * @ [SHLWAPI.153]
933 * Function: Compare two ASCII strings for "len" bytes via caseless compare.
934 * Returns: *str1-*str2 (case insensitive)
936 DWORD WINAPI SHLWAPI_153(LPSTR str1, LPSTR str2, DWORD len)
938 return strncasecmp( str1, str2, len );
941 /*************************************************************************
942 * @ [SHLWAPI.154]
944 * Function: Compare two WIDE strings for "len" bytes via caseless compare.
945 * Returns: *str1-*str2 (case insensitive)
947 DWORD WINAPI SHLWAPI_154(LPWSTR str1, LPWSTR str2, DWORD len)
949 return strncmpiW( str1, str2, len );
952 /*************************************************************************
953 * @ [SHLWAPI.155]
955 * Case sensitive string compare (ASCII). Does not SetLastError().
957 DWORD WINAPI SHLWAPI_155 ( LPSTR str1, LPSTR str2)
959 return strcmp(str1, str2);
962 /*************************************************************************
963 * @ [SHLWAPI.156]
965 * Case sensitive string compare. Does not SetLastError().
967 DWORD WINAPI SHLWAPI_156 ( LPWSTR str1, LPWSTR str2)
969 return strcmpW( str1, str2 );
972 /*************************************************************************
973 * @ [SHLWAPI.158]
975 * Case insensitive string compare. Does not SetLastError(). ??
977 DWORD WINAPI SHLWAPI_158 ( LPWSTR str1, LPWSTR str2)
979 return strcmpiW( str1, str2 );
982 /*************************************************************************
983 * @ [SHLWAPI.162]
985 * Ensure a multibyte character string doesn't end in a hanging lead byte.
987 DWORD WINAPI SHLWAPI_162(LPSTR lpStr, DWORD size)
989 if (lpStr && size)
991 LPSTR lastByte = lpStr + size - 1;
993 while(lpStr < lastByte)
994 lpStr += IsDBCSLeadByte(*lpStr) ? 2 : 1;
996 if(lpStr == lastByte && IsDBCSLeadByte(*lpStr))
998 *lpStr = '\0';
999 size--;
1001 return size;
1003 return 0;
1006 /*************************************************************************
1007 * @ [SHLWAPI.164]
1009 DWORD WINAPI SHLWAPI_164 (
1010 LPVOID u,
1011 LPVOID v,
1012 LPVOID w,
1013 LPVOID x,
1014 LPVOID y,
1015 LPVOID z)
1017 TRACE("(%p %p %p %p %p %p) stub\n",u,v,w,x,y,z);
1018 return 0x80004002; /* E_NOINTERFACE */
1021 /*************************************************************************
1022 * @ [SHLWAPI.165]
1024 * SetWindowLongA with mask.
1026 LONG WINAPI SHLWAPI_165(HWND hwnd, INT offset, UINT wFlags, UINT wMask)
1028 LONG ret = GetWindowLongA(hwnd, offset);
1029 UINT newFlags = (wFlags & wMask) | (ret & ~wFlags);
1031 if (newFlags != ret)
1032 ret = SetWindowLongA(hwnd, offset, newFlags);
1033 return ret;
1036 /*************************************************************************
1037 * @ [SHLWAPI.169]
1039 * Do IUnknown::Release on passed object.
1041 DWORD WINAPI SHLWAPI_169 (IUnknown ** lpUnknown)
1043 IUnknown *temp;
1045 TRACE("(%p)\n",lpUnknown);
1046 if(!lpUnknown || !*((LPDWORD)lpUnknown)) return 0;
1047 temp = *lpUnknown;
1048 *lpUnknown = NULL;
1049 TRACE("doing Release\n");
1050 return IUnknown_Release(temp);
1053 /*************************************************************************
1054 * @ [SHLWAPI.170]
1056 * Skip URL '//' sequence.
1058 LPCSTR WINAPI SHLWAPI_170(LPCSTR lpszSrc)
1060 if (lpszSrc && lpszSrc[0] == '/' && lpszSrc[1] == '/')
1061 lpszSrc += 2;
1062 return lpszSrc;
1065 /*************************************************************************
1066 * @ [SHLWAPI.172]
1067 * Get window handle of OLE object
1069 DWORD WINAPI SHLWAPI_172 (
1070 IUnknown *y, /* [in] OLE object interface */
1071 LPHWND z) /* [out] location to put window handle */
1073 DWORD ret;
1074 IUnknown *pv;
1076 TRACE("(%p %p)\n",y,z);
1077 if (!y) return E_FAIL;
1079 if ((ret = IUnknown_QueryInterface(y, &IID_IOleWindow,(LPVOID *)&pv)) < 0) {
1080 /* error */
1081 return ret;
1083 ret = IOleWindow_GetWindow((IOleWindow *)pv, z);
1084 IUnknown_Release(pv);
1085 TRACE("result hwnd=%08x\n", *z);
1086 return ret;
1089 /*************************************************************************
1090 * @ [SHLWAPI.174]
1092 * Seems to do call either IObjectWithSite::SetSite or
1093 * IPersistMoniker::GetClassID. But since we do not implement either
1094 * of those classes in our headers, we will fake it out.
1096 DWORD WINAPI SHLWAPI_174(
1097 IUnknown *p1, /* [in] OLE object */
1098 LPVOID *p2) /* [out] ptr to result of either GetClassID
1099 or SetSite call. */
1101 DWORD ret, aa;
1103 if (!p1) return E_FAIL;
1105 /* see if SetSite interface exists for IObjectWithSite object */
1106 ret = IUnknown_QueryInterface((IUnknown *)p1, (REFIID)id1, (LPVOID *)&p1);
1107 TRACE("first IU_QI ret=%08lx, p1=%p\n", ret, p1);
1108 if (ret) {
1110 /* see if GetClassId interface exists for IPersistMoniker object */
1111 ret = IUnknown_QueryInterface((IUnknown *)p1, (REFIID)id2, (LPVOID *)&aa);
1112 TRACE("second IU_QI ret=%08lx, aa=%08lx\n", ret, aa);
1113 if (ret) return ret;
1115 /* fake a GetClassId call */
1116 ret = IOleWindow_GetWindow((IOleWindow *)aa, (HWND*)p2);
1117 TRACE("second IU_QI doing 0x0c ret=%08lx, *p2=%08lx\n", ret,
1118 *(LPDWORD)p2);
1119 IUnknown_Release((IUnknown *)aa);
1121 else {
1122 /* fake a SetSite call */
1123 ret = IOleWindow_GetWindow((IOleWindow *)p1, (HWND*)p2);
1124 TRACE("first IU_QI doing 0x0c ret=%08lx, *p2=%08lx\n", ret,
1125 *(LPDWORD)p2);
1126 IUnknown_Release((IUnknown *)p1);
1128 return ret;
1131 /*************************************************************************
1132 * @ [SHLWAPI.176]
1134 * Function appears to be interface to IServiceProvider::QueryService
1136 * NOTE:
1137 * returns E_NOINTERFACE
1138 * E_FAIL if w == 0
1139 * S_OK if _219 called successfully
1141 DWORD WINAPI SHLWAPI_176 (
1142 IUnknown* unk, /* [in] object to give Service Provider */
1143 REFGUID sid, /* [in] Service ID */
1144 REFIID riid, /* [in] Function requested */
1145 LPVOID *z) /* [out] place to save interface pointer */
1147 DWORD ret;
1148 LPVOID aa;
1149 *z = 0;
1150 if (!unk) return E_FAIL;
1151 ret = IUnknown_QueryInterface(unk, &IID_IServiceProvider, &aa);
1152 TRACE("did IU_QI retval=%08lx, aa=%p\n", ret, aa);
1153 if (ret) return ret;
1154 ret = IServiceProvider_QueryService((IServiceProvider *)aa, sid, riid,
1155 (void **)z);
1156 TRACE("did ISP_QS retval=%08lx, *z=%p\n", ret, (LPVOID)*z);
1157 IUnknown_Release((IUnknown*)aa);
1158 return ret;
1161 /*************************************************************************
1162 * @ [SHLWAPI.181]
1164 * Enable or disable a menu item.
1166 UINT WINAPI SHLWAPI_181(HMENU hMenu, UINT wItemID, BOOL bEnable)
1168 return EnableMenuItem(hMenu, wItemID, bEnable ? MF_ENABLED : MF_GRAYED);
1171 /*************************************************************************
1172 * @ [SHLWAPI.183]
1174 * Register a window class if it isn't already.
1176 DWORD WINAPI SHLWAPI_183(WNDCLASSA *wndclass)
1178 WNDCLASSA wca;
1179 if (GetClassInfoA(wndclass->hInstance, wndclass->lpszClassName, &wca))
1180 return TRUE;
1181 return (DWORD)RegisterClassA(wndclass);
1184 /*************************************************************************
1185 * @ [SHLWAPI.193]
1187 DWORD WINAPI SHLWAPI_193 ()
1189 HDC hdc;
1190 DWORD ret;
1192 TRACE("()\n");
1194 hdc = GetDC(0);
1195 ret = GetDeviceCaps(hdc, BITSPIXEL) * GetDeviceCaps(hdc, PLANES);
1196 ReleaseDC(0, hdc);
1197 return ret;
1200 /*************************************************************************
1201 * @ [SHLWAPI.199]
1203 * Copy interface pointer
1205 DWORD WINAPI SHLWAPI_199 (
1206 IUnknown **dest, /* [out] pointer to copy of interface ptr */
1207 IUnknown *src) /* [in] interface pointer */
1209 TRACE("(%p %p)\n",dest,src);
1210 if (*dest != src) {
1211 if (*dest)
1212 IUnknown_Release(*dest);
1213 if (src) {
1214 IUnknown_AddRef(src);
1215 *dest = src;
1218 return 4;
1221 /*************************************************************************
1222 * @ [SHLWAPI.208]
1224 * Some sort of memory management process - associated with _210
1226 DWORD WINAPI SHLWAPI_208 (
1227 DWORD a,
1228 DWORD b,
1229 LPVOID c,
1230 LPVOID d,
1231 DWORD e)
1233 FIXME("(0x%08lx 0x%08lx %p %p 0x%08lx) stub\n",
1234 a, b, c, d, e);
1235 return 1;
1238 /*************************************************************************
1239 * @ [SHLWAPI.209]
1241 * Some sort of memory management process - associated with _208
1243 DWORD WINAPI SHLWAPI_209 (
1244 LPVOID a)
1246 FIXME("(%p) stub\n",
1248 return 1;
1251 /*************************************************************************
1252 * @ [SHLWAPI.210]
1254 * Some sort of memory management process - associated with _208
1256 DWORD WINAPI SHLWAPI_210 (
1257 LPVOID a,
1258 DWORD b,
1259 LPVOID c)
1261 FIXME("(%p 0x%08lx %p) stub\n",
1262 a, b, c);
1263 return 0;
1266 /*************************************************************************
1267 * @ [SHLWAPI.211]
1269 DWORD WINAPI SHLWAPI_211 (
1270 LPVOID a,
1271 DWORD b)
1273 FIXME("(%p 0x%08lx) stub\n",
1274 a, b);
1275 return 1;
1278 /*************************************************************************
1279 * @ [SHLWAPI.215]
1281 * NOTES
1282 * check me!
1284 DWORD WINAPI SHLWAPI_215 (
1285 LPCSTR lpStrSrc,
1286 LPWSTR lpwStrDest,
1287 int len)
1289 INT len_a, ret;
1291 len_a = lstrlenA(lpStrSrc);
1292 ret = MultiByteToWideChar(0, 0, lpStrSrc, len_a, lpwStrDest, len);
1293 TRACE("%s %s %d, ret=%d\n",
1294 debugstr_a(lpStrSrc), debugstr_w(lpwStrDest), len, ret);
1295 return ret;
1298 /*************************************************************************
1299 * @ [SHLWAPI.218]
1301 * WideCharToMultiByte with multi language support.
1303 INT WINAPI SHLWAPI_218(UINT CodePage, LPCWSTR lpSrcStr, LPSTR lpDstStr,
1304 LPINT lpnMultiCharCount)
1306 static HRESULT (WINAPI *pfnFunc)(LPDWORD,DWORD,LPCWSTR,LPINT,LPSTR,LPINT);
1307 WCHAR emptyW[] = { '\0' };
1308 int len , reqLen;
1309 LPSTR mem;
1311 if (!lpDstStr || !lpnMultiCharCount)
1312 return 0;
1314 if (!lpSrcStr)
1315 lpSrcStr = emptyW;
1317 *lpDstStr = '\0';
1319 len = strlenW(lpSrcStr) + 1;
1321 switch (CodePage)
1323 case CP_WINUNICODE:
1324 CodePage = CP_UTF8; /* Fall through... */
1325 case 0x0000C350: /* FIXME: CP_ #define */
1326 case CP_UTF7:
1327 case CP_UTF8:
1329 DWORD dwMode = 0;
1330 INT nWideCharCount = len - 1;
1332 GET_FUNC(mlang, "ConvertINetUnicodeToMultiByte", 0);
1333 if (!pfnFunc(&dwMode, CodePage, lpSrcStr, &nWideCharCount, lpDstStr,
1334 lpnMultiCharCount))
1335 return 0;
1337 if (nWideCharCount < len - 1)
1339 mem = (LPSTR)HeapAlloc(GetProcessHeap(), 0, *lpnMultiCharCount);
1340 if (!mem)
1341 return 0;
1343 *lpnMultiCharCount = 0;
1345 if (pfnFunc(&dwMode, CodePage, lpSrcStr, &len, mem, lpnMultiCharCount))
1347 SHLWAPI_162 (mem, *lpnMultiCharCount);
1348 lstrcpynA(lpDstStr, mem, *lpnMultiCharCount + 1);
1349 return *lpnMultiCharCount + 1;
1351 HeapFree(GetProcessHeap(), 0, mem);
1352 return *lpnMultiCharCount;
1354 lpDstStr[*lpnMultiCharCount] = '\0';
1355 return *lpnMultiCharCount;
1357 break;
1358 default:
1359 break;
1362 reqLen = WideCharToMultiByte(CodePage, 0, lpSrcStr, len, lpDstStr,
1363 *lpnMultiCharCount, NULL, NULL);
1365 if (!reqLen && GetLastError() == ERROR_INSUFFICIENT_BUFFER)
1367 reqLen = WideCharToMultiByte(CodePage, 0, lpSrcStr, len, NULL, 0, NULL, NULL);
1368 if (reqLen)
1370 mem = (LPSTR)HeapAlloc(GetProcessHeap(), 0, reqLen);
1371 if (mem)
1373 reqLen = WideCharToMultiByte(CodePage, 0, lpSrcStr, len, mem,
1374 reqLen, NULL, NULL);
1376 reqLen = SHLWAPI_162(mem, *lpnMultiCharCount);
1377 reqLen++;
1379 lstrcpynA(lpDstStr, mem, *lpnMultiCharCount);
1381 HeapFree(GetProcessHeap(), 0, mem);
1385 return reqLen;
1388 /*************************************************************************
1389 * @ [SHLWAPI.217]
1391 * Hmm, some program used lpnMultiCharCount == 0x3 (and lpSrcStr was "C")
1392 * --> Crash. Something wrong here.
1394 * It seems from OE v5 that the third param is the count. (GA 11/2001)
1396 INT WINAPI SHLWAPI_217(LPCWSTR lpSrcStr, LPSTR lpDstStr, INT MultiCharCount)
1398 INT myint = MultiCharCount;
1400 return SHLWAPI_218(CP_ACP, lpSrcStr, lpDstStr, &myint);
1403 /*************************************************************************
1404 * @ [SHLWAPI.219]
1406 * Seems to be "super" QueryInterface. Supplied with at table of interfaces
1407 * and an array of IIDs and offsets into the table.
1409 * NOTES
1410 * error codes: E_POINTER, E_NOINTERFACE
1412 typedef struct {
1413 REFIID refid;
1414 DWORD indx;
1415 } IFACE_INDEX_TBL;
1417 HRESULT WINAPI SHLWAPI_219 (
1418 LPVOID w, /* [in] table of interfaces */
1419 IFACE_INDEX_TBL *x, /* [in] array of REFIIDs and indexes to above */
1420 REFIID riid, /* [in] REFIID to get interface for */
1421 LPVOID *z) /* [out] location to get interface pointer */
1423 HRESULT ret;
1424 IUnknown *a_vtbl;
1425 IFACE_INDEX_TBL *xmove;
1427 TRACE("(%p %p %s %p)\n",
1428 w,x,debugstr_guid(riid),z);
1429 if (z) {
1430 xmove = x;
1431 while (xmove->refid) {
1432 TRACE("trying (indx %ld) %s\n", xmove->indx,
1433 debugstr_guid(xmove->refid));
1434 if (IsEqualIID(riid, xmove->refid)) {
1435 a_vtbl = (IUnknown*)(xmove->indx + (LPBYTE)w);
1436 TRACE("matched, returning (%p)\n", a_vtbl);
1437 *z = (LPVOID)a_vtbl;
1438 IUnknown_AddRef(a_vtbl);
1439 return S_OK;
1441 xmove++;
1444 if (IsEqualIID(riid, &IID_IUnknown)) {
1445 a_vtbl = (IUnknown*)(x->indx + (LPBYTE)w);
1446 TRACE("returning first for IUnknown (%p)\n", a_vtbl);
1447 *z = (LPVOID)a_vtbl;
1448 IUnknown_AddRef(a_vtbl);
1449 return S_OK;
1451 *z = 0;
1452 ret = E_NOINTERFACE;
1453 } else
1454 ret = E_POINTER;
1455 return ret;
1458 /*************************************************************************
1459 * @ [SHLWAPI.222]
1461 * NOTES
1462 * securityattributes missing
1464 HANDLE WINAPI SHLWAPI_222 (LPCLSID guid)
1466 char lpstrName[80];
1468 sprintf( lpstrName, "shell.{%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
1469 guid->Data1, guid->Data2, guid->Data3,
1470 guid->Data4[0], guid->Data4[1], guid->Data4[2], guid->Data4[3],
1471 guid->Data4[4], guid->Data4[5], guid->Data4[6], guid->Data4[7] );
1472 FIXME("(%s) stub\n", lpstrName);
1473 return CreateSemaphoreA(NULL,0, 0x7fffffff, lpstrName);
1476 /*************************************************************************
1477 * @ [SHLWAPI.223]
1479 * NOTES
1480 * get the count of the semaphore
1482 DWORD WINAPI SHLWAPI_223 (HANDLE handle)
1484 DWORD oldCount;
1486 FIXME("(0x%08x) stub\n",handle);
1488 ReleaseSemaphore( handle, 1, &oldCount); /* +1 */
1489 WaitForSingleObject( handle, 0 ); /* -1 */
1490 return oldCount;
1493 /*************************************************************************
1494 * @ [SHLWAPI.236]
1496 HMODULE WINAPI SHLWAPI_236 (REFIID lpUnknown)
1498 HKEY newkey;
1499 DWORD type, count;
1500 CHAR value[MAX_PATH], string[MAX_PATH];
1502 strcpy(string, "CLSID\\");
1503 strcat(string, debugstr_guid(lpUnknown));
1504 strcat(string, "\\InProcServer32");
1506 count = MAX_PATH;
1507 RegOpenKeyExA(HKEY_CLASSES_ROOT, string, 0, 1, &newkey);
1508 RegQueryValueExA(newkey, 0, 0, &type, value, &count);
1509 RegCloseKey(newkey);
1510 return LoadLibraryExA(value, 0, 0);
1513 /*************************************************************************
1514 * @ [SHLWAPI.237]
1516 * Unicode version of SHLWAPI_183.
1518 DWORD WINAPI SHLWAPI_237 (WNDCLASSW * lpWndClass)
1520 WNDCLASSW WndClass;
1522 TRACE("(0x%08x %s)\n",lpWndClass->hInstance, debugstr_w(lpWndClass->lpszClassName));
1524 if (GetClassInfoW(lpWndClass->hInstance, lpWndClass->lpszClassName, &WndClass))
1525 return TRUE;
1526 return RegisterClassW(lpWndClass);
1529 /*************************************************************************
1530 * @ [SHLWAPI.239]
1532 DWORD WINAPI SHLWAPI_239(HINSTANCE hInstance, LPVOID p2, DWORD dw3)
1534 FIXME("(0x%08x %p 0x%08lx) stub\n",
1535 hInstance, p2, dw3);
1536 return 0;
1537 #if 0
1538 /* pseudo code from relay trace */
1539 WideCharToMultiByte(0, 0, L"Shell DocObject View", -1, &aa, 0x0207, 0, 0);
1540 GetClassInfoA(70fe0000,405868ec "Shell DocObject View",40586b14);
1541 /* above pair repeated for:
1542 TridentThicketUrlDlClass
1543 Shell Embedding
1544 CIESplashScreen
1545 Inet Notify_Hidden
1546 OCHost
1548 #endif
1551 /*************************************************************************
1552 * @ [SHLWAPI.240]
1554 * Calls ASCII or Unicode WindowProc for the given window.
1556 LRESULT CALLBACK SHLWAPI_240(HWND hWnd, UINT uMessage, WPARAM wParam, LPARAM lParam)
1558 if (IsWindowUnicode(hWnd))
1559 return DefWindowProcW(hWnd, uMessage, wParam, lParam);
1560 return DefWindowProcA(hWnd, uMessage, wParam, lParam);
1563 /*************************************************************************
1564 * @ [SHLWAPI.241]
1567 DWORD WINAPI SHLWAPI_241 ()
1569 FIXME("()stub\n");
1570 return /* 0xabba1243 */ 0;
1573 /*************************************************************************
1574 * @ [SHLWAPI.266]
1576 * native does at least approximately:
1577 * strcpyW(newstr, x);
1578 * strcatW(newstr, "\\Restrictions");
1579 * if (RegOpenKeyExA(80000001, newstr, 00000000,00000001,40520b78))
1580 * return 0;
1581 * *unknown*
1583 DWORD WINAPI SHLWAPI_266 (
1584 LPVOID w,
1585 LPVOID x, /* [in] partial registry key */
1586 LPVOID y,
1587 LPVOID z)
1589 FIXME("(%p %p %p %p)stub\n",w,x,y,z);
1590 return /* 0xabba1248 */ 0;
1593 /*************************************************************************
1594 * @ [SHLWAPI.267]
1596 HRESULT WINAPI SHLWAPI_267 (
1597 LPVOID w,
1598 LPVOID x,
1599 LPVOID y, /* [???] NOTE: same as 3rd parameter of SHLWAPI_219 */
1600 LPVOID z) /* [???] NOTE: same as 4th parameter of SHLWAPI_219 */
1602 FIXME("(%p %p %p %p)stub\n",w,x,y,z);
1604 /* native seems to do:
1605 * SHLWAPI_219 ((LPVOID)(((LPSTR)x)-4), ???, (REFIID) y, (LPVOID*) z);
1608 *((LPDWORD)z) = 0xabba1200;
1609 return /* 0xabba1254 */ 0;
1612 /*************************************************************************
1613 * @ [SHLWAPI.268]
1615 DWORD WINAPI SHLWAPI_268 (
1616 LPVOID w,
1617 LPVOID x)
1619 FIXME("(%p %p)\n",w,x);
1620 return 0xabba1251; /* 0 = failure */
1623 /*************************************************************************
1624 * @ [SHLWAPI.276]
1626 * on first call process does following: other calls just returns 2
1627 * instance = LoadLibraryA("SHELL32.DLL");
1628 * func = GetProcAddress(instance, "DllGetVersion");
1629 * ret = RegOpenKeyExA(80000002, "Software\\Microsoft\\Internet Explorer",00000000,0002001f, newkey);
1630 * ret = RegQueryValueExA(newkey, "IntegratedBrowser",00000000,00000000,4052588c,40525890);
1631 * RegCloseKey(newkey);
1632 * FreeLibrary(instance);
1633 * return 2;
1635 DWORD WINAPI SHLWAPI_276 ()
1637 FIXME("()stub\n");
1638 return /* 0xabba1244 */ 2;
1641 /*************************************************************************
1642 * @ [SHLWAPI.278]
1645 HWND WINAPI SHLWAPI_278 (
1646 LONG wndProc,
1647 HWND hWndParent,
1648 DWORD dwExStyle,
1649 DWORD dwStyle,
1650 HMENU hMenu,
1651 LONG z)
1653 WNDCLASSA wndclass;
1654 HWND hwnd;
1655 HCURSOR hCursor;
1656 char * clsname = "WorkerA";
1658 FIXME("(0x%08lx 0x%08x 0x%08lx 0x%08lx 0x%08x 0x%08lx) partial stub\n",
1659 wndProc,hWndParent,dwExStyle,dwStyle,hMenu,z);
1661 hCursor = LoadCursorA(0x00000000,IDC_ARROWA);
1663 if(!GetClassInfoA(shlwapi_hInstance, clsname, &wndclass))
1665 RtlZeroMemory(&wndclass, sizeof(WNDCLASSA));
1666 wndclass.lpfnWndProc = DefWindowProcW;
1667 wndclass.cbWndExtra = 4;
1668 wndclass.hInstance = shlwapi_hInstance;
1669 wndclass.hCursor = hCursor;
1670 wndclass.hbrBackground = COLOR_BTNSHADOW;
1671 wndclass.lpszMenuName = NULL;
1672 wndclass.lpszClassName = clsname;
1673 RegisterClassA (&wndclass);
1675 hwnd = CreateWindowExA(dwExStyle, clsname, 0,dwStyle,0,0,0,0,hWndParent,
1676 hMenu,shlwapi_hInstance,0);
1677 SetWindowLongA(hwnd, 0, z);
1678 SetWindowLongA(hwnd, GWL_WNDPROC, wndProc);
1679 return hwnd;
1682 /*************************************************************************
1683 * @ [SHLWAPI.289]
1685 * Late bound call to winmm.PlaySoundW
1687 BOOL WINAPI SHLWAPI_289(LPCWSTR pszSound, HMODULE hmod, DWORD fdwSound)
1689 static BOOL (WINAPI *pfnFunc)(LPCWSTR, HMODULE, DWORD) = NULL;
1691 GET_FUNC(winmm, "PlaySoundW", FALSE);
1692 return pfnFunc(pszSound, hmod, fdwSound);
1695 /*************************************************************************
1696 * @ [SHLWAPI.294]
1698 BOOL WINAPI SHLWAPI_294(LPSTR str1, LPSTR str2, LPSTR pStr, DWORD some_len, LPCSTR lpStr2)
1701 * str1: "I" "I" pushl esp+0x20
1702 * str2: "U" "I" pushl 0x77c93810
1703 * (is "I" and "U" "integer" and "unsigned" ??)
1705 * pStr: "" "" pushl eax
1706 * some_len: 0x824 0x104 pushl 0x824
1707 * lpStr2: "%l" "%l" pushl esp+0xc
1709 * shlwapi. StrCpyNW(lpStr2, irrelevant_var, 0x104);
1710 * LocalAlloc(0x00, some_len) -> irrelevant_var
1711 * LocalAlloc(0x40, irrelevant_len) -> pStr
1712 * shlwapi.294(str1, str2, pStr, some_len, lpStr2);
1713 * shlwapi.PathRemoveBlanksW(pStr);
1715 ERR("('%s', '%s', '%s', %08lx, '%s'): stub!\n", str1, str2, pStr, some_len, lpStr2);
1716 return TRUE;
1719 /*************************************************************************
1720 * @ [SHLWAPI.313]
1722 * Late bound call to shell32.SHGetFileInfoW
1724 DWORD WINAPI SHLWAPI_313(LPCWSTR path, DWORD dwFileAttributes,
1725 SHFILEINFOW *psfi, UINT sizeofpsfi, UINT flags)
1727 static DWORD (WINAPI *pfnFunc)(LPCWSTR,DWORD,SHFILEINFOW*,UINT,UINT) = NULL;
1729 GET_FUNC(shell32, "SHGetFileInfoW", 0);
1730 return pfnFunc(path, dwFileAttributes, psfi, sizeofpsfi, flags);
1733 /*************************************************************************
1734 * @ [SHLWAPI.318]
1736 * Late bound call to shell32.DragQueryFileW
1738 UINT WINAPI SHLWAPI_318(HDROP hDrop, UINT lFile, LPWSTR lpszFile, UINT lLength)
1740 static UINT (WINAPI *pfnFunc)(HDROP, UINT, LPWSTR, UINT) = NULL;
1742 GET_FUNC(shell32, "DragQueryFileW", 0);
1743 return pfnFunc(hDrop, lFile, lpszFile, lLength);
1746 /*************************************************************************
1747 * @ [SHLWAPI.333]
1749 * Late bound call to shell32.SHBrowseForFolderW
1751 LPITEMIDLIST WINAPI SHLWAPI_333(LPBROWSEINFOW lpBi)
1753 static LPITEMIDLIST (WINAPI *pfnFunc)(LPBROWSEINFOW) = NULL;
1755 GET_FUNC(shell32, "SHBrowseForFolderW", NULL);
1756 return pfnFunc(lpBi);
1759 /*************************************************************************
1760 * @ [SHLWAPI.334]
1762 * Late bound call to shell32.SHGetPathFromIDListW
1764 BOOL WINAPI SHLWAPI_334(LPCITEMIDLIST pidl,LPWSTR pszPath)
1766 static BOOL (WINAPI *pfnFunc)(LPCITEMIDLIST, LPWSTR) = NULL;
1768 GET_FUNC(shell32, "SHGetPathFromIDListW", 0);
1769 return pfnFunc(pidl, pszPath);
1772 /*************************************************************************
1773 * @ [SHLWAPI.335]
1775 * Late bound call to shell32.ShellExecuteExW
1777 BOOL WINAPI SHLWAPI_335(LPSHELLEXECUTEINFOW lpExecInfo)
1779 static BOOL (WINAPI *pfnFunc)(LPSHELLEXECUTEINFOW) = NULL;
1781 GET_FUNC(shell32, "ShellExecuteExW", FALSE);
1782 return pfnFunc(lpExecInfo);
1785 /*************************************************************************
1786 * @ [SHLWAPI.336]
1788 * Late bound call to shell32.SHFileOperationW.
1790 DWORD WINAPI SHLWAPI_336(LPSHFILEOPSTRUCTW lpFileOp)
1792 static HICON (WINAPI *pfnFunc)(LPSHFILEOPSTRUCTW) = NULL;
1794 GET_FUNC(shell32, "SHFileOperationW", 0);
1795 return pfnFunc(lpFileOp);
1798 /*************************************************************************
1799 * @ [SHLWAPI.337]
1801 * Late bound call to shell32.ExtractIconExW.
1803 HICON WINAPI SHLWAPI_337(LPCWSTR lpszFile, INT nIconIndex, HICON *phiconLarge,
1804 HICON *phiconSmall, UINT nIcons)
1806 static HICON (WINAPI *pfnFunc)(LPCWSTR, INT,HICON *,HICON *, UINT) = NULL;
1808 GET_FUNC(shell32, "ExtractIconExW", (HICON)0);
1809 return pfnFunc(lpszFile, nIconIndex, phiconLarge, phiconSmall, nIcons);
1812 /*************************************************************************
1813 * @ [SHLWAPI.342]
1816 LONG WINAPI SHInterlockedCompareExchange( PLONG dest, LONG xchg, LONG compare)
1818 return InterlockedCompareExchange(dest, xchg, compare);
1821 /*************************************************************************
1822 * @ [SHLWAPI.346]
1824 DWORD WINAPI SHLWAPI_346 (
1825 LPCWSTR src,
1826 LPWSTR dest,
1827 int len)
1829 FIXME("(%s %p 0x%08x)stub\n",debugstr_w(src),dest,len);
1830 lstrcpynW(dest, src, len);
1831 return lstrlenW(dest)+1;
1834 /*************************************************************************
1835 * @ [SHLWAPI.350]
1837 * seems to be late bound call to GetFileVersionInfoSizeW
1839 DWORD WINAPI SHLWAPI_350 (
1840 LPWSTR x,
1841 LPVOID y)
1843 static DWORD WINAPI (*pfnFunc)(LPCWSTR,LPDWORD) = NULL;
1844 DWORD ret;
1846 GET_FUNC(version, "GetFileVersionInfoSizeW", 0);
1847 ret = pfnFunc(x, y);
1848 return 0x208 + ret;
1851 /*************************************************************************
1852 * @ [SHLWAPI.351]
1854 * seems to be late bound call to GetFileVersionInfoW
1856 BOOL WINAPI SHLWAPI_351 (
1857 LPWSTR w, /* [in] path to dll */
1858 DWORD x, /* [in] parm 2 to GetFileVersionInfoA */
1859 DWORD y, /* [in] return value from .350 - assume length */
1860 LPVOID z) /* [in/out] buffer (+0x208 sent to GetFileVersionInfoA) */
1862 static BOOL WINAPI (*pfnFunc)(LPCWSTR,DWORD,DWORD,LPVOID) = NULL;
1864 GET_FUNC(version, "GetFileVersionInfoW", 0);
1865 return pfnFunc(w, x, y-0x208, z+0x208);
1868 /*************************************************************************
1869 * @ [SHLWAPI.352]
1871 * seems to be late bound call to VerQueryValueW
1873 WORD WINAPI SHLWAPI_352 (
1874 LPVOID w, /* [in] buffer from _351 */
1875 LPWSTR x, /* [in] value to retrieve -
1876 converted and passed to VerQueryValueA as #2 */
1877 LPVOID y, /* [out] ver buffer - passed to VerQueryValueA as #3 */
1878 UINT* z) /* [in] ver length - passed to VerQueryValueA as #4 */
1880 static WORD WINAPI (*pfnFunc)(LPVOID,LPCWSTR,LPVOID*,UINT*) = NULL;
1882 GET_FUNC(version, "VerQueryValueW", 0);
1883 return pfnFunc(w+0x208, x, y, z);
1886 /**************************************************************************
1887 * @ [SHLWAPI.356]
1889 * mbc - this function is undocumented, The parameters are correct and
1890 * the calls to InitializeSecurityDescriptor and
1891 * SetSecurityDescriptorDacl are correct, but apparently some
1892 * apps call this function with all zero parameters.
1895 DWORD WINAPI SHLWAPI_356(PACL pDacl, PSECURITY_DESCRIPTOR pSD, LPCSTR *str)
1897 if(str != 0){
1898 *str = 0;
1901 if(!pDacl){
1902 return 0;
1905 if (!InitializeSecurityDescriptor(pSD, 1)) return 0;
1906 return SetSecurityDescriptorDacl(pSD, 1, pDacl, 0);
1910 /*************************************************************************
1911 * @ [SHLWAPI.357]
1913 * Late bound call to shell32.SHGetNewLinkInfoW
1915 BOOL WINAPI SHLWAPI_357(LPCWSTR pszLinkTo, LPCWSTR pszDir, LPWSTR pszName,
1916 BOOL *pfMustCopy, UINT uFlags)
1918 static BOOL (WINAPI *pfnFunc)(LPCWSTR, LPCWSTR, LPCWSTR, BOOL*, UINT) = NULL;
1920 GET_FUNC(shell32, "SHGetNewLinkInfoW", FALSE);
1921 return pfnFunc(pszLinkTo, pszDir, pszName, pfMustCopy, uFlags);
1924 /*************************************************************************
1925 * @ [SHLWAPI.358]
1927 * Late bound call to shell32.SHDefExtractIconW
1929 DWORD WINAPI SHLWAPI_358(LPVOID arg1, LPVOID arg2, LPVOID arg3, LPVOID arg4,
1930 LPVOID arg5, LPVOID arg6)
1932 /* FIXME: Correct args */
1933 static DWORD (WINAPI *pfnFunc)(LPVOID, LPVOID, LPVOID, LPVOID, LPVOID, LPVOID) = NULL;
1935 GET_FUNC(shell32, "SHDefExtractIconW", 0);
1936 return pfnFunc(arg1, arg2, arg3, arg4, arg5, arg6);
1939 /*************************************************************************
1940 * @ [SHLWAPI.364]
1942 * Wrapper for lstrcpynA with src and dst swapped.
1944 DWORD WINAPI SHLWAPI_364(LPCSTR src, LPSTR dst, INT n)
1946 lstrcpynA(dst, src, n);
1947 return TRUE;
1950 /*************************************************************************
1951 * @ [SHLWAPI.370]
1953 * Late bound call to shell32.ExtractIconW
1955 HICON WINAPI SHLWAPI_370(HINSTANCE hInstance, LPCWSTR lpszExeFileName,
1956 UINT nIconIndex)
1958 static HICON (WINAPI *pfnFunc)(HINSTANCE, LPCWSTR, UINT) = NULL;
1960 GET_FUNC(shell32, "ExtractIconW", (HICON)0);
1961 return pfnFunc(hInstance, lpszExeFileName, nIconIndex);
1964 /*************************************************************************
1965 * @ [SHLWAPI.376]
1967 LANGID WINAPI SHLWAPI_376 ()
1969 FIXME("() stub\n");
1970 /* FIXME: This should be a forward in the .spec file to the win2k function
1971 * kernel32.GetUserDefaultUILanguage, however that function isn't there yet.
1973 return GetUserDefaultLangID();
1976 /*************************************************************************
1977 * @ [SHLWAPI.377]
1979 * FIXME: Native appears to do DPA_Create and a DPA_InsertPtr for
1980 * each call here.
1981 * FIXME: Native shows calls to:
1982 * SHRegGetUSValue for "Software\Microsoft\Internet Explorer\International"
1983 * CheckVersion
1984 * RegOpenKeyExA for "HKLM\Software\Microsoft\Internet Explorer"
1985 * RegQueryValueExA for "LPKInstalled"
1986 * RegCloseKey
1987 * RegOpenKeyExA for "HKCU\Software\Microsoft\Internet Explorer\International"
1988 * RegQueryValueExA for "ResourceLocale"
1989 * RegCloseKey
1990 * RegOpenKeyExA for "HKLM\Software\Microsoft\Active Setup\Installed Components\{guid}"
1991 * RegQueryValueExA for "Locale"
1992 * RegCloseKey
1993 * and then tests the Locale ("en" for me).
1994 * code below
1995 * after the code then a DPA_Create (first time) and DPA_InsertPtr are done.
1997 DWORD WINAPI SHLWAPI_377 (LPCSTR new_mod, HMODULE inst_hwnd, LPVOID z)
1999 CHAR mod_path[2*MAX_PATH];
2000 LPSTR ptr;
2002 GetModuleFileNameA(inst_hwnd, mod_path, 2*MAX_PATH);
2003 ptr = strrchr(mod_path, '\\');
2004 if (ptr) {
2005 strcpy(ptr+1, new_mod);
2006 TRACE("loading %s\n", debugstr_a(mod_path));
2007 return (DWORD)LoadLibraryA(mod_path);
2009 return 0;
2012 /*************************************************************************
2013 * @ [SHLWAPI.378]
2015 * This is Unicode version of .377
2017 DWORD WINAPI SHLWAPI_378 (
2018 LPCWSTR new_mod, /* [in] new module name */
2019 HMODULE inst_hwnd, /* [in] calling module handle */
2020 LPVOID z) /* [???] 4 */
2022 WCHAR mod_path[2*MAX_PATH];
2023 LPWSTR ptr;
2025 GetModuleFileNameW(inst_hwnd, mod_path, 2*MAX_PATH);
2026 ptr = strrchrW(mod_path, '\\');
2027 if (ptr) {
2028 strcpyW(ptr+1, new_mod);
2029 TRACE("loading %s\n", debugstr_w(mod_path));
2030 return (DWORD)LoadLibraryW(mod_path);
2032 return 0;
2035 /*************************************************************************
2036 * @ [SHLWAPI.389]
2038 * Late bound call to comdlg32.GetSaveFileNameW
2040 BOOL WINAPI SHLWAPI_389(LPOPENFILENAMEW ofn)
2042 static BOOL (WINAPI *pfnFunc)(LPOPENFILENAMEW) = NULL;
2044 GET_FUNC(comdlg32, "GetSaveFileNameW", FALSE);
2045 return pfnFunc(ofn);
2048 /*************************************************************************
2049 * @ [SHLWAPI.390]
2051 * Late bound call to mpr.WNetRestoreConnectionW
2053 DWORD WINAPI SHLWAPI_390(LPVOID arg1, LPVOID arg2)
2055 /* FIXME: Correct args */
2056 static DWORD (WINAPI *pfnFunc)(LPVOID, LPVOID) = NULL;
2058 GET_FUNC(mpr, "WNetRestoreConnectionW", 0);
2059 return pfnFunc(arg1, arg2);
2062 /*************************************************************************
2063 * @ [SHLWAPI.391]
2065 * Late bound call to mpr.WNetGetLastErrorW
2067 DWORD WINAPI SHLWAPI_391(LPVOID arg1, LPVOID arg2, LPVOID arg3, LPVOID arg4,
2068 LPVOID arg5)
2070 /* FIXME: Correct args */
2071 static DWORD (WINAPI *pfnFunc)(LPVOID, LPVOID, LPVOID, LPVOID, LPVOID) = NULL;
2073 GET_FUNC(mpr, "WNetGetLastErrorW", 0);
2074 return pfnFunc(arg1, arg2, arg3, arg4, arg5);
2077 /*************************************************************************
2078 * @ [SHLWAPI.401]
2080 * Late bound call to comdlg32.PageSetupDlgW
2082 BOOL WINAPI SHLWAPI_401(LPPAGESETUPDLGW pagedlg)
2084 static BOOL (WINAPI *pfnFunc)(LPPAGESETUPDLGW) = NULL;
2086 GET_FUNC(comdlg32, "PageSetupDlgW", FALSE);
2087 return pfnFunc(pagedlg);
2090 /*************************************************************************
2091 * @ [SHLWAPI.402]
2093 * Late bound call to comdlg32.PrintDlgW
2095 BOOL WINAPI SHLWAPI_402(LPPRINTDLGW printdlg)
2097 static BOOL (WINAPI *pfnFunc)(LPPRINTDLGW) = NULL;
2099 GET_FUNC(comdlg32, "PrintDlgW", FALSE);
2100 return pfnFunc(printdlg);
2103 /*************************************************************************
2104 * @ [SHLWAPI.403]
2106 * Late bound call to comdlg32.GetOpenFileNameW
2108 BOOL WINAPI SHLWAPI_403(LPOPENFILENAMEW ofn)
2110 static BOOL (WINAPI *pfnFunc)(LPOPENFILENAMEW) = NULL;
2112 GET_FUNC(comdlg32, "GetOpenFileNameW", FALSE);
2113 return pfnFunc(ofn);
2116 /* INTERNAL: Map from HLS color space to RGB */
2117 static WORD ConvertHue(int wHue, WORD wMid1, WORD wMid2)
2119 wHue = wHue > 240 ? wHue - 240 : wHue < 0 ? wHue + 240 : wHue;
2121 if (wHue > 160)
2122 return wMid1;
2123 else if (wHue > 120)
2124 wHue = 160 - wHue;
2125 else if (wHue > 40)
2126 return wMid2;
2128 return ((wHue * (wMid2 - wMid1) + 20) / 40) + wMid1;
2131 /* Convert to RGB and scale into RGB range (0..255) */
2132 #define GET_RGB(h) (ConvertHue(h, wMid1, wMid2) * 255 + 120) / 240
2134 /*************************************************************************
2135 * ColorHLSToRGB [SHLWAPI.404]
2137 * Convert from HLS color space into an RGB COLORREF.
2139 * NOTES
2140 * Input HLS values are constrained to the range (0..240).
2142 COLORREF WINAPI ColorHLSToRGB(WORD wHue, WORD wLuminosity, WORD wSaturation)
2144 WORD wRed;
2146 if (wSaturation)
2148 WORD wGreen, wBlue, wMid1, wMid2;
2150 if (wLuminosity > 120)
2151 wMid2 = wSaturation + wLuminosity - (wSaturation * wLuminosity + 120) / 240;
2152 else
2153 wMid2 = ((wSaturation + 240) * wLuminosity + 120) / 240;
2155 wMid1 = wLuminosity * 2 - wMid2;
2157 wRed = GET_RGB(wHue + 80);
2158 wGreen = GET_RGB(wHue);
2159 wBlue = GET_RGB(wHue - 80);
2161 return RGB(wRed, wGreen, wBlue);
2164 wRed = wLuminosity * 255 / 240;
2165 return RGB(wRed, wRed, wRed);
2168 /*************************************************************************
2169 * @ [SHLWAPI.413]
2171 * Function unknown seems to always to return 0
2173 DWORD WINAPI SHLWAPI_413 (DWORD x)
2175 FIXME("(0x%08lx)stub\n", x);
2176 return 0;
2179 /*************************************************************************
2180 * @ [SHLWAPI.418]
2182 * Function seems to do FreeLibrary plus other things.
2184 * FIXME native shows the following calls:
2185 * RtlEnterCriticalSection
2186 * LocalFree
2187 * GetProcAddress(Comctl32??, 150L)
2188 * DPA_DeletePtr
2189 * RtlLeaveCriticalSection
2190 * followed by the FreeLibrary.
2191 * The above code may be related to .377 above.
2193 BOOL WINAPI SHLWAPI_418 (HMODULE x)
2195 FIXME("(0x%08lx) partial stub\n", (LONG)x);
2196 return FreeLibrary(x);
2199 /*************************************************************************
2200 * @ [SHLWAPI.431]
2202 DWORD WINAPI SHLWAPI_431 (DWORD x)
2204 FIXME("(0x%08lx)stub\n", x);
2205 return 0xabba1247;
2208 /*************************************************************************
2209 * @ [SHLWAPI.436]
2211 * This is really CLSIDFromString which is exported by ole32.dll,
2212 * however the native shlwapi.dll does *not* import ole32. Nor does
2213 * ole32.dll import this ordinal from shlwapi. Therefore we must conclude
2214 * that MS duplicated the code for CLSIDFromString.
2216 * This is a duplicate (with changes for UNICODE) of CLSIDFromString16
2217 * in dlls/ole32/compobj.c
2219 DWORD WINAPI SHLWAPI_436 (LPWSTR idstr, CLSID *id)
2221 LPWSTR s = idstr;
2222 BYTE *p;
2223 INT i;
2224 WCHAR table[256];
2226 if (!s) {
2227 memset(s, 0, sizeof(CLSID));
2228 return S_OK;
2230 else { /* validate the CLSID string */
2232 if (strlenW(s) != 38)
2233 return CO_E_CLASSSTRING;
2235 if ((s[0]!=L'{') || (s[9]!=L'-') || (s[14]!=L'-') || (s[19]!=L'-') || (s[24]!=L'-') || (s[37]!=L'}'))
2236 return CO_E_CLASSSTRING;
2238 for (i=1; i<37; i++)
2240 if ((i == 9)||(i == 14)||(i == 19)||(i == 24)) continue;
2241 if (!(((s[i] >= L'0') && (s[i] <= L'9')) ||
2242 ((s[i] >= L'a') && (s[i] <= L'f')) ||
2243 ((s[i] >= L'A') && (s[i] <= L'F')))
2245 return CO_E_CLASSSTRING;
2249 TRACE("%s -> %p\n", debugstr_w(s), id);
2251 /* quick lookup table */
2252 memset(table, 0, 256*sizeof(WCHAR));
2254 for (i = 0; i < 10; i++) {
2255 table['0' + i] = i;
2257 for (i = 0; i < 6; i++) {
2258 table['A' + i] = i+10;
2259 table['a' + i] = i+10;
2262 /* in form {XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX} */
2264 p = (BYTE *) id;
2266 s++; /* skip leading brace */
2267 for (i = 0; i < 4; i++) {
2268 p[3 - i] = table[*s]<<4 | table[*(s+1)];
2269 s += 2;
2271 p += 4;
2272 s++; /* skip - */
2274 for (i = 0; i < 2; i++) {
2275 p[1-i] = table[*s]<<4 | table[*(s+1)];
2276 s += 2;
2278 p += 2;
2279 s++; /* skip - */
2281 for (i = 0; i < 2; i++) {
2282 p[1-i] = table[*s]<<4 | table[*(s+1)];
2283 s += 2;
2285 p += 2;
2286 s++; /* skip - */
2288 /* these are just sequential bytes */
2289 for (i = 0; i < 2; i++) {
2290 *p++ = table[*s]<<4 | table[*(s+1)];
2291 s += 2;
2293 s++; /* skip - */
2295 for (i = 0; i < 6; i++) {
2296 *p++ = table[*s]<<4 | table[*(s+1)];
2297 s += 2;
2300 return S_OK;
2303 /*************************************************************************
2304 * @ [SHLWAPI.437]
2306 * NOTES
2307 * In the real shlwapi, One time initialisation calls GetVersionEx and reads
2308 * the registry to determine what O/S & Service Pack level is running, and
2309 * therefore which functions are available. Currently we always run as NT,
2310 * since this means that we don't need extra code to emulate Unicode calls,
2311 * they are forwarded directly to the appropriate API call instead.
2312 * Since the flags for whether to call or emulate Unicode are internal to
2313 * the dll, this function does not need a full implementation.
2315 DWORD WINAPI SHLWAPI_437 (DWORD functionToCall)
2317 FIXME("(0x%08lx)stub\n", functionToCall);
2318 return /* 0xabba1247 */ 0;
2321 /*************************************************************************
2322 * ColorRGBToHLS [SHLWAPI.445]
2324 * Convert from RGB COLORREF into the HLS color space.
2326 * NOTES
2327 * Input HLS values are constrained to the range (0..240).
2329 VOID WINAPI ColorRGBToHLS(COLORREF drRGB, LPWORD pwHue,
2330 LPWORD wLuminance, LPWORD pwSaturation)
2332 FIXME("stub\n");
2333 return;
2336 /*************************************************************************
2337 * SHCreateShellPalette [SHLWAPI.@]
2339 HPALETTE WINAPI SHCreateShellPalette(HDC hdc)
2341 FIXME("stub\n");
2342 return CreateHalftonePalette(hdc);
2345 /*************************************************************************
2346 * SHGetInverseCMAP (SHLWAPI.@)
2348 DWORD WINAPI SHGetInverseCMAP (LPDWORD* x, DWORD why)
2350 if (why == 4) {
2351 FIXME(" - returning bogus address for SHGetInverseCMAP\n");
2352 *x = (LPDWORD)0xabba1249;
2353 return 0;
2355 FIXME("(%p, %#lx)stub\n", x, why);
2356 return 0;
2359 /*************************************************************************
2360 * SHIsLowMemoryMachine [SHLWAPI.@]
2362 DWORD WINAPI SHIsLowMemoryMachine (DWORD x)
2364 FIXME("0x%08lx\n", x);
2365 return 0;
2368 /*************************************************************************
2369 * GetMenuPosFromID [SHLWAPI.@]
2371 INT WINAPI GetMenuPosFromID(HMENU hMenu, UINT wID)
2373 MENUITEMINFOA mi;
2374 INT nCount = GetMenuItemCount(hMenu), nIter = 0;
2376 while (nIter < nCount)
2378 mi.wID = 0;
2379 if (!GetMenuItemInfoA(hMenu, nIter, TRUE, &mi) && mi.wID == wID)
2380 return nIter;
2381 nIter++;
2383 return -1;
2386 /*************************************************************************
2387 * _SHGetInstanceExplorer@4 [SHLWAPI.@]
2389 * Late bound call to shell32.SHGetInstanceExplorer.
2391 HRESULT WINAPI _SHGetInstanceExplorer (LPUNKNOWN *lpUnknown)
2393 static HRESULT (WINAPI *pfnFunc)(LPUNKNOWN *) = NULL;
2395 GET_FUNC(shell32, "SHGetInstanceExplorer", E_FAIL);
2396 return pfnFunc(lpUnknown);
2399 /*************************************************************************
2400 * SHGetThreadRef [SHLWAPI.@]
2402 * Retrieves the per-thread object reference set by SHSetThreadRef
2403 * "punk" - Address of a pointer to the IUnknown interface. Returns S_OK if
2404 * successful or E_NOINTERFACE otherwise.
2406 HRESULT WINAPI SHGetThreadRef (IUnknown ** ppunk)
2408 if (SHLWAPI_ThreadRef_index < 0) return E_NOINTERFACE;
2409 *ppunk = (IUnknown *)TlsGetValue(SHLWAPI_ThreadRef_index);
2410 return S_OK;
2413 /*************************************************************************
2414 * SHSetThreadRef [SHLWAPI.@]
2416 * Stores a per-thread reference to a COM object
2417 * "punk" - Pointer to the IUnknown interface of the object to
2418 * which you want to store a reference. Returns S_OK if successful
2419 * or an OLE error value.
2421 HRESULT WINAPI SHSetThreadRef (IUnknown * punk)
2423 if (SHLWAPI_ThreadRef_index < 0) return E_NOINTERFACE;
2424 TlsSetValue(SHLWAPI_ThreadRef_index, (LPVOID) punk);
2425 return S_OK;