Add exclusion defs & remaining funcs, remove internal types &
[wine/hacks.git] / dlls / shlwapi / ordinal.c
blob2437099f69f1e8541f7a2bd9d25c0a8acd41c64c
1 /*
2 * SHLWAPI ordinal functions
4 * Copyright 1997 Marcus Meissner
5 * 1998 Jürgen Schmied
6 * 2001 Jon Griffiths
7 */
9 #include <stdio.h>
10 #include <string.h>
12 #include "windef.h"
13 #include "winnls.h"
14 #include "winbase.h"
15 #include "ddeml.h"
16 #include "shlobj.h"
17 #include "shellapi.h"
18 #include "commdlg.h"
19 #include "wine/unicode.h"
20 #include "wine/obj_base.h"
21 #include "wine/obj_inplace.h"
22 #include "wine/obj_serviceprovider.h"
23 #include "wingdi.h"
24 #include "winreg.h"
25 #include "winuser.h"
26 #include "debugtools.h"
27 #include "ordinal.h"
28 #include "shlwapi.h"
30 DEFAULT_DEBUG_CHANNEL(shell);
32 extern HINSTANCE shlwapi_hInstance;
33 extern HMODULE SHLWAPI_hshell32;
34 extern HMODULE SHLWAPI_hwinmm;
35 extern HMODULE SHLWAPI_hcomdlg32;
36 extern HMODULE SHLWAPI_hmpr;
37 extern HMODULE SHLWAPI_hmlang;
39 /* following is GUID for IObjectWithSite::SetSite -- see _174 */
40 static DWORD id1[4] = {0xfc4801a3, 0x11cf2ba9, 0xaa0029a2, 0x52733d00};
41 /* following is GUID for IPersistMoniker::GetClassID -- see _174 */
42 static DWORD id2[4] = {0x79eac9ee, 0x11cebaf9, 0xaa00828c, 0x0ba94b00};
44 /* The following schemes were identified in the native version of
45 * SHLWAPI.DLL version 5.50
47 typedef enum {
48 URL_SCHEME_INVALID = -1,
49 URL_SCHEME_UNKNOWN = 0,
50 URL_SCHEME_FTP,
51 URL_SCHEME_HTTP,
52 URL_SCHEME_GOPHER,
53 URL_SCHEME_MAILTO,
54 URL_SCHEME_NEWS,
55 URL_SCHEME_NNTP,
56 URL_SCHEME_TELNET,
57 URL_SCHEME_WAIS,
58 URL_SCHEME_FILE,
59 URL_SCHEME_MK,
60 URL_SCHEME_HTTPS,
61 URL_SCHEME_SHELL,
62 URL_SCHEME_SNEWS,
63 URL_SCHEME_LOCAL,
64 URL_SCHEME_JAVASCRIPT,
65 URL_SCHEME_VBSCRIPT,
66 URL_SCHEME_ABOUT,
67 URL_SCHEME_RES,
68 URL_SCHEME_MAXVALUE
69 } URL_SCHEME;
71 typedef struct {
72 URL_SCHEME scheme_number;
73 LPCSTR scheme_name;
74 } SHL_2_inet_scheme;
76 static const SHL_2_inet_scheme shlwapi_schemes[] = {
77 {URL_SCHEME_FTP, "ftp"},
78 {URL_SCHEME_HTTP, "http"},
79 {URL_SCHEME_GOPHER, "gopher"},
80 {URL_SCHEME_MAILTO, "mailto"},
81 {URL_SCHEME_NEWS, "news"},
82 {URL_SCHEME_NNTP, "nntp"},
83 {URL_SCHEME_TELNET, "telnet"},
84 {URL_SCHEME_WAIS, "wais"},
85 {URL_SCHEME_FILE, "file"},
86 {URL_SCHEME_MK, "mk"},
87 {URL_SCHEME_HTTPS, "https"},
88 {URL_SCHEME_SHELL, "shell"},
89 {URL_SCHEME_SNEWS, "snews"},
90 {URL_SCHEME_LOCAL, "local"},
91 {URL_SCHEME_JAVASCRIPT, "javascript"},
92 {URL_SCHEME_VBSCRIPT, "vbscript"},
93 {URL_SCHEME_ABOUT, "about"},
94 {URL_SCHEME_RES, "res"},
95 {0, 0}
98 /* Macro to get function pointer for a module*/
99 #define GET_FUNC(module, name, fail) \
100 if (!SHLWAPI_h##module) SHLWAPI_h##module = LoadLibraryA(#module ".dll"); \
101 if (!SHLWAPI_h##module) return fail; \
102 if (!pfnFunc) pfnFunc = (void*)GetProcAddress(SHLWAPI_h##module, name); \
103 if (!pfnFunc) return fail
106 NOTES: Most functions exported by ordinal seem to be superflous.
107 The reason for these functions to be there is to provide a wraper
108 for unicode functions to provide these functions on systems without
109 unicode functions eg. win95/win98. Since we have such functions we just
110 call these. If running Wine with native DLL's, some late bound calls may
111 fail. However, its better to implement the functions in the forward DLL
112 and recommend the builtin rather than reimplementing the calls here!
115 /*************************************************************************
116 * @ [SHLWAPI.1]
118 * Identifies the Internet "scheme" in the passed string. ASCII based.
119 * Also determines start and length of item after the ':'
121 DWORD WINAPI SHLWAPI_1 (LPCSTR x, UNKNOWN_SHLWAPI_1 *y)
123 DWORD cnt;
124 const SHL_2_inet_scheme *inet_pro;
126 if (y->size != 0x18) return E_INVALIDARG;
127 /* FIXME: leading white space generates error of 0x80041001 which
128 * is undefined
130 if (*x <= ' ') return 0x80041001;
131 cnt = 0;
132 y->sizep1 = 0;
133 y->ap1 = x;
134 while (*x) {
135 if (*x == ':') {
136 y->sizep1 = cnt;
137 cnt = -1;
138 y->ap2 = x+1;
139 break;
141 x++;
142 cnt++;
145 /* check for no scheme in string start */
146 /* (apparently schemes *must* be larger than a single character) */
147 if ((*x == '\0') || (y->sizep1 <= 1)) {
148 y->ap1 = 0;
149 return 0x80041001;
152 /* found scheme, set length of remainder */
153 y->sizep2 = lstrlenA(y->ap2);
155 /* see if known scheme and return indicator number */
156 y->fcncde = URL_SCHEME_UNKNOWN;
157 inet_pro = shlwapi_schemes;
158 while (inet_pro->scheme_name) {
159 if (!strncasecmp(inet_pro->scheme_name, y->ap1,
160 min(y->sizep1, lstrlenA(inet_pro->scheme_name)))) {
161 y->fcncde = inet_pro->scheme_number;
162 break;
164 inet_pro++;
166 return S_OK;
169 /*************************************************************************
170 * @ [SHLWAPI.2]
172 * Identifies the Internet "scheme" in the passed string. UNICODE based.
173 * Also determines start and length of item after the ':'
175 DWORD WINAPI SHLWAPI_2 (LPCWSTR x, UNKNOWN_SHLWAPI_2 *y)
177 DWORD cnt;
178 const SHL_2_inet_scheme *inet_pro;
179 LPSTR cmpstr;
180 INT len;
182 if (y->size != 0x18) return E_INVALIDARG;
183 /* FIXME: leading white space generates error of 0x80041001 which
184 * is undefined
186 if (*x <= L' ') return 0x80041001;
187 cnt = 0;
188 y->sizep1 = 0;
189 y->ap1 = x;
190 while (*x) {
191 if (*x == L':') {
192 y->sizep1 = cnt;
193 cnt = -1;
194 y->ap2 = x+1;
195 break;
197 x++;
198 cnt++;
201 /* check for no scheme in string start */
202 /* (apparently schemes *must* be larger than a single character) */
203 if ((*x == L'\0') || (y->sizep1 <= 1)) {
204 y->ap1 = 0;
205 return 0x80041001;
208 /* found scheme, set length of remainder */
209 y->sizep2 = lstrlenW(y->ap2);
211 /* see if known scheme and return indicator number */
212 len = WideCharToMultiByte(0, 0, y->ap1, y->sizep1, 0, 0, 0, 0);
213 cmpstr = (LPSTR)HeapAlloc(GetProcessHeap(), 0, len+1);
214 WideCharToMultiByte(0, 0, y->ap1, y->sizep1, cmpstr, len+1, 0, 0);
215 y->fcncde = URL_SCHEME_UNKNOWN;
216 inet_pro = shlwapi_schemes;
217 while (inet_pro->scheme_name) {
218 if (!strncasecmp(inet_pro->scheme_name, cmpstr,
219 min(len, lstrlenA(inet_pro->scheme_name)))) {
220 y->fcncde = inet_pro->scheme_number;
221 break;
223 inet_pro++;
225 HeapFree(GetProcessHeap(), 0, cmpstr);
226 return S_OK;
229 /*************************************************************************
230 * @ [SHLWAPI.7]
231 * (Used by IE4 during startup)
232 * appears to return HWND (used as input to 8 below)
234 HRESULT WINAPI SHLWAPI_7 (
235 LPVOID w,
236 LPVOID x,
237 LPVOID y) /* [???] appears to be result of GetCurrentProcessId() */
239 FIXME("(%p %p %p) stub\n", w, x, y);
240 return 0;
241 #if 0
242 /* pseudo code extracted from relay trace */
243 fhnd = CreateFileMappingA(-1, 0, 4, 0, 0x58, 0);
244 addr = MapViewOfFile(fhnd, 6, 0, 0, 0);
245 UnmapViewOfFile(addr);
246 GetCurrentProcessId();
247 GetCurrentProcessId();
248 sph = GetCurrentProcess();
249 GetCurrentProcessId();
250 dph = GetCurrentProcess();
251 DuplicateHandle(sph, fhnd, dph, &hoho, 0x000f001f, 0, 2);
252 GetCurrentProcessId();
253 GetCurrentProcessId();
254 CloseHandle(fhnd);
255 return hoho;
256 #endif
259 /*************************************************************************
260 * @ [SHLWAPI.8]
261 * (Used by IE4 during startup)
262 * appears to return MapViewOfFile+4 (used as input to 9 below)
264 LONG WINAPI SHLWAPI_8 (
265 LPVOID w, /* [???] possibly HANDLE */
266 LPVOID x) /* [???] appears to be result of GetCurrentProcessId() */
268 FIXME("(%p %p) stub\n", w, x);
269 return 0;
270 #if 0
271 /* pseudo code extracted from relay trace */
272 GetCurrentProcessId();
273 GetCurrentProcessId();
274 sph = GetCurrentProcess();
275 GetCurrentProcessId();
276 dph = GetCurrentProcess();
277 DuplicateHandle(sph, w, dph, &hoho, 0x000f001f, 0, 2);
278 GetCurrentProcessId();
279 GetCurrentProcessId();
280 addr = MapViewOfFile(hoho, 6, 0, 0, 0);
281 CloseHandle(hoho);
282 return (LONG)addr + 4;
283 #endif
286 /*************************************************************************
287 * @ [SHLWAPI.9]
288 * (Used by IE4 during startup)
290 HRESULT WINAPI SHLWAPI_9 (
291 LPVOID w)
293 FIXME("(%p) stub\n", w);
294 return 0;
295 #if 0
296 /* pseudo code extracted from relay trace */
297 return UnmapViewOfFile((LPVOID)((LONG)w-4));
298 #endif
301 /*************************************************************************
302 * @ [SHLWAPI.13]
303 * (Used by IE4 during startup)
305 HRESULT WINAPI SHLWAPI_13 (
306 LPVOID w,
307 LPVOID x)
309 FIXME("(%p %p)stub\n",w,x);
310 return 1;
311 #if 0
312 /* pseudo code extracted from relay trace */
313 RegOpenKeyA(HKLM, "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\Aceepted Documents", &newkey);
314 ret = 0;
315 i = 0;
316 size = 0;
317 while(!ret) {
318 ret = RegEnumValueA(newkey, i, a1, a2, 0, a3, 0, 0);
319 size += ???;
320 i++;
322 b1 = LocalAlloc(0x40, size);
323 ret = 0;
324 i = 0;
325 while(!ret) {
326 ret = RegEnumValueA(newkey, i, a1, a2, 0, a3, a4, a5);
327 RegisterClipBoardFormatA(a4);
328 i++;
330 hwnd1 = GetModuleHandleA("URLMON.DLL");
331 proc = GetProcAddress(hwnd1, "CreateFormatEnumerator");
332 HeapAlloc(??, 0, 0x14);
333 HeapAlloc(??, 0, 0x50);
334 LocalAlloc(0x40, 0x78);
335 /* FIXME: bad string below */
336 lstrlenW(L"{D0FCA420-D3F5-11CF-B211-00AA004AE837}");
337 StrCpyW(a6, L"{D0FCA420-D3F5-11CF-B211-00AA004AE837}");
339 GetTickCount();
340 IsBadReadPtr(c1 = 0x403fd210,4);
341 InterlockedIncrement(c1+4);
342 LocalFree(b1);
343 RegCloseKey(newkey);
344 IsBadReadPtr(c1 = 0x403fd210,4);
345 InterlockedIncrement(c1+4);
347 HeapAlloc(40350000,00000000,00000014) retval=403fd0a8;
348 HeapAlloc(40350000,00000000,00000050) retval=403feb44;
349 hwnd1 = GetModuleHandleA("URLMON.DLL");
350 proc = GetProcAddress(hwnd1, "RegisterFormatEnumerator");
351 /* 0x1a40c88c is in URLMON.DLL just before above proc
352 * content is L"_EnumFORMATETC_"
353 * label is d1
355 IsBadReadPtr(d1 = 0x1a40c88c,00000002);
356 lstrlenW(d1);
357 lstrlenW(d1);
358 HeapAlloc(40350000,00000000,0000001e) retval=403fed44;
359 IsBadReadPtr(d2 = 0x403fd0a8,00000004);
360 InterlockedIncrement(d2+4);
361 IsBadReadPtr(d2 = 0x403fd0a8,00000004);
362 InterlockedDecrement(d2+4);
363 IsBadReadPtr(c1,00000004);
364 InterlockedDecrement(c1+4);
365 IsBadReadPtr(c1,00000004);
366 InterlockedDecrement(c1+4);
368 #endif
371 /*************************************************************************
372 * @ [SHLWAPI.14]
374 * Function:
375 * Retrieves IE "AcceptLanguage" value from registry. ASCII mode.
378 HRESULT WINAPI SHLWAPI_14 (
379 LPSTR langbuf,
380 LPDWORD buflen)
382 CHAR *mystr;
383 DWORD mystrlen, mytype;
384 HKEY mykey;
385 LCID mylcid;
387 mystrlen = (*buflen > 6) ? *buflen : 6;
388 mystr = (CHAR*)HeapAlloc(GetProcessHeap(),
389 HEAP_ZERO_MEMORY, mystrlen);
390 RegOpenKeyA(HKEY_CURRENT_USER,
391 "Software\\Microsoft\\Internet Explorer\\International",
392 &mykey);
393 if (RegQueryValueExA(mykey, "AcceptLanguage",
394 0, &mytype, mystr, &mystrlen)) {
395 /* Did not find value */
396 mylcid = GetUserDefaultLCID();
397 /* somehow the mylcid translates into "en-us"
398 * this is similar to "LOCALE_SABBREVLANGNAME"
399 * which could be gotten via GetLocaleInfo.
400 * The only problem is LOCALE_SABBREVLANGUAGE" is
401 * a 3 char string (first 2 are country code and third is
402 * letter for "sublanguage", which does not come close to
403 * "en-us"
405 lstrcpyA(mystr, "en-us");
406 mystrlen = lstrlenA(mystr);
408 else {
409 /* handle returned string */
410 FIXME("missing code\n");
412 if (mystrlen > *buflen)
413 lstrcpynA(langbuf, mystr, *buflen);
414 else {
415 lstrcpyA(langbuf, mystr);
416 *buflen = lstrlenA(langbuf);
418 RegCloseKey(mykey);
419 HeapFree(GetProcessHeap(), 0, mystr);
420 TRACE("language is %s\n", debugstr_a(langbuf));
421 return 0;
424 /*************************************************************************
425 * @ [SHLWAPI.15]
427 * Function:
428 * Retrieves IE "AcceptLanguage" value from registry. UNICODE mode.
431 HRESULT WINAPI SHLWAPI_15 (
432 LPWSTR langbuf,
433 LPDWORD buflen)
435 CHAR *mystr;
436 DWORD mystrlen, mytype;
437 HKEY mykey;
438 LCID mylcid;
440 mystrlen = (*buflen > 6) ? *buflen : 6;
441 mystr = (CHAR*)HeapAlloc(GetProcessHeap(),
442 HEAP_ZERO_MEMORY, mystrlen);
443 RegOpenKeyA(HKEY_CURRENT_USER,
444 "Software\\Microsoft\\Internet Explorer\\International",
445 &mykey);
446 if (RegQueryValueExA(mykey, "AcceptLanguage",
447 0, &mytype, mystr, &mystrlen)) {
448 /* Did not find value */
449 mylcid = GetUserDefaultLCID();
450 /* somehow the mylcid translates into "en-us"
451 * this is similar to "LOCALE_SABBREVLANGNAME"
452 * which could be gotten via GetLocaleInfo.
453 * The only problem is LOCALE_SABBREVLANGUAGE" is
454 * a 3 char string (first 2 are country code and third is
455 * letter for "sublanguage", which does not come close to
456 * "en-us"
458 lstrcpyA(mystr, "en-us");
459 mystrlen = lstrlenA(mystr);
461 else {
462 /* handle returned string */
463 FIXME("missing code\n");
465 RegCloseKey(mykey);
466 *buflen = MultiByteToWideChar(0, 0, mystr, -1, langbuf, (*buflen)-1);
467 HeapFree(GetProcessHeap(), 0, mystr);
468 TRACE("language is %s\n", debugstr_w(langbuf));
469 return 0;
472 /*************************************************************************
473 * @ [SHLWAPI.16]
475 HRESULT WINAPI SHLWAPI_16 (
476 LPVOID w,
477 LPVOID x,
478 LPVOID y,
479 LPWSTR z)
481 FIXME("(%p %p %p %p)stub\n",w,x,y,z);
482 return 0xabba1252;
485 /*************************************************************************
486 * @ [SHLWAPI.18]
488 * w is pointer to address of callback routine
489 * x is pointer to LPVOID to receive address of locally allocated
490 * space size 0x14
491 * return is 0 (unless out of memory???)
493 * related to _19, _21 and _22 below
494 * only seen invoked by SHDOCVW
496 LONG WINAPI SHLWAPI_18 (
497 LPVOID *w,
498 LPVOID x)
500 FIXME("(%p %p)stub\n",w,x);
501 *((LPDWORD)x) = 0;
502 return 0;
505 /*************************************************************************
506 * @ [SHLWAPI.19]
508 * w is address of allocated memory from _21
509 * return is 0 (unless out of memory???)
511 * related to _18, _21 and _22 below
512 * only seen invoked by SHDOCVW
514 LONG WINAPI SHLWAPI_19 (
515 LPVOID w)
517 FIXME("(%p) stub\n",w);
518 return 0;
521 /*************************************************************************
522 * @ [SHLWAPI.21]
524 * w points to space allocated via .18 above
525 * LocalSize is done on it (retrieves 18)
526 * LocalReAlloc is done on it to size 8 with LMEM_MOVEABLE & LMEM_ZEROINIT
527 * x values seen 0xa0000005
528 * returns 1
530 * relates to _18, _19 and _22 above and below
531 * only seen invoked by SHDOCVW
533 LONG WINAPI SHLWAPI_21 (
534 LPVOID w,
535 DWORD x)
537 FIXME("(%p %lx)stub\n",w,x);
538 return 1;
541 /*************************************************************************
542 * @ [SHLWAPI.22]
544 * return is 'w' value seen in x is 0xa0000005
546 * relates to _18, _19 and _21 above
547 * only seen invoked by SHDOCVW
549 LPVOID WINAPI SHLWAPI_22 (
550 LPVOID w,
551 DWORD x)
553 FIXME("(%p %lx)stub\n",w,x);
554 return w;
557 /*************************************************************************
558 * @ [SHLWAPI.23]
560 * NOTES
561 * converts a guid to a string
562 * returns strlen(str)
564 DWORD WINAPI SHLWAPI_23 (
565 REFGUID guid, /* [in] clsid */
566 LPSTR str, /* [out] buffer */
567 INT cmax) /* [in] size of buffer */
569 char xguid[40];
571 sprintf( xguid, "{%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
572 guid->Data1, guid->Data2, guid->Data3,
573 guid->Data4[0], guid->Data4[1], guid->Data4[2], guid->Data4[3],
574 guid->Data4[4], guid->Data4[5], guid->Data4[6], guid->Data4[7] );
575 TRACE("(%s %p 0x%08x)stub\n", xguid, str, cmax);
576 if (strlen(xguid)>=cmax) return 0;
577 strcpy(str,xguid);
578 return strlen(xguid) + 1;
581 /*************************************************************************
582 * @ [SHLWAPI.24]
584 * NOTES
585 * converts a guid to a string
586 * returns strlen(str)
588 DWORD WINAPI SHLWAPI_24 (
589 REFGUID guid, /* [in] clsid */
590 LPWSTR str, /* [out] buffer */
591 INT cmax) /* [in] size of buffer */
593 char xguid[40];
595 sprintf( xguid, "{%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
596 guid->Data1, guid->Data2, guid->Data3,
597 guid->Data4[0], guid->Data4[1], guid->Data4[2], guid->Data4[3],
598 guid->Data4[4], guid->Data4[5], guid->Data4[6], guid->Data4[7] );
599 return MultiByteToWideChar( CP_ACP, 0, xguid, -1, str, cmax );
602 /*************************************************************************
603 * @ [SHLWAPI.25]
605 * Seems to be iswalpha
607 BOOL WINAPI SHLWAPI_25(WCHAR wc)
609 return (get_char_typeW(wc) & C1_ALPHA) != 0;
612 /*************************************************************************
613 * @ [SHLWAPI.26]
615 * Seems to be iswupper
617 BOOL WINAPI SHLWAPI_26(WCHAR wc)
619 return (get_char_typeW(wc) & C1_UPPER) != 0;
622 /*************************************************************************
623 * @ [SHLWAPI.27]
625 * Seems to be iswlower
627 BOOL WINAPI SHLWAPI_27(WCHAR wc)
629 return (get_char_typeW(wc) & C1_LOWER) != 0;
632 /*************************************************************************
633 * @ [SHLWAPI.28]
635 * Seems to be iswalnum
637 BOOL WINAPI SHLWAPI_28(WCHAR wc)
639 return (get_char_typeW(wc) & (C1_ALPHA|C1_DIGIT)) != 0;
642 /*************************************************************************
643 * @ [SHLWAPI.29]
645 * Seems to be iswspace
647 BOOL WINAPI SHLWAPI_29(WCHAR wc)
649 return (get_char_typeW(wc) & C1_SPACE) != 0;
652 /*************************************************************************
653 * @ [SHLWAPI.30]
655 * Seems to be iswblank
657 BOOL WINAPI SHLWAPI_30(WCHAR wc)
659 return (get_char_typeW(wc) & C1_BLANK) != 0;
662 /*************************************************************************
663 * @ [SHLWAPI.31]
665 * Seems to be iswpunct
667 BOOL WINAPI SHLWAPI_31(WCHAR wc)
669 return (get_char_typeW(wc) & C1_PUNCT) != 0;
672 /*************************************************************************
673 * @ [SHLWAPI.32]
675 * Seems to be iswcntrl
677 BOOL WINAPI SHLWAPI_32(WCHAR wc)
679 return (get_char_typeW(wc) & C1_CNTRL) != 0;
682 /*************************************************************************
683 * @ [SHLWAPI.33]
685 * Seems to be iswdigit
687 BOOL WINAPI SHLWAPI_33(WCHAR wc)
689 return (get_char_typeW(wc) & C1_DIGIT) != 0;
692 /*************************************************************************
693 * @ [SHLWAPI.34]
695 * Seems to be iswxdigit
697 BOOL WINAPI SHLWAPI_34(WCHAR wc)
699 return (get_char_typeW(wc) & C1_XDIGIT) != 0;
702 /*************************************************************************
703 * @ [SHLWAPI.35]
706 BOOL WINAPI SHLWAPI_35(LPVOID p1, DWORD dw2, LPVOID p3)
708 FIXME("(%p, 0x%08lx, %p): stub\n", p1, dw2, p3);
709 return TRUE;
712 /*************************************************************************
713 * @ [SHLWAPI.36]
716 BOOL WINAPI SHLWAPI_36(HMENU h1, UINT ui2, UINT h3, LPCWSTR p4)
718 TRACE("(0x%08x, 0x%08x, 0x%08x, %s): stub\n",
719 h1, ui2, h3, debugstr_w(p4));
720 return AppendMenuW(h1, ui2, h3, p4);
723 /*************************************************************************
724 * @ [SHLWAPI.40]
726 * Get pointer to next Unicode character.
728 LPCWSTR WINAPI SHLWAPI_40(LPCWSTR str)
730 return *str ? str + 1 : str;
733 /*************************************************************************
734 * @ [SHLWAPI.74]
736 * Get the text from a given dialog item.
738 INT WINAPI SHLWAPI_74(HWND hWnd, INT nItem, LPWSTR lpsDest,INT nDestLen)
740 HWND hItem = GetDlgItem(hWnd, nItem);
742 if (hItem)
743 return GetWindowTextW(hItem, lpsDest, nDestLen);
744 if (nDestLen)
745 *lpsDest = (WCHAR)'\0';
746 return 0;
749 /*************************************************************************
750 * @ [SHLWAPI.151]
751 * Function: Compare two ASCII strings for "len" bytes.
752 * Returns: *str1-*str2 (case sensitive)
754 DWORD WINAPI SHLWAPI_151(LPSTR str1, LPSTR str2, INT len)
756 return strncmp( str1, str2, len );
759 /*************************************************************************
760 * @ [SHLWAPI.152]
762 * Function: Compare two WIDE strings for "len" bytes.
763 * Returns: *str1-*str2 (case sensitive)
765 DWORD WINAPI SHLWAPI_152(LPWSTR str1, LPWSTR str2, INT len)
767 return strncmpW( str1, str2, len );
770 /*************************************************************************
771 * @ [SHLWAPI.153]
772 * Function: Compare two ASCII strings for "len" bytes via caseless compare.
773 * Returns: *str1-*str2 (case insensitive)
775 DWORD WINAPI SHLWAPI_153(LPSTR str1, LPSTR str2, DWORD len)
777 return strncasecmp( str1, str2, len );
780 /*************************************************************************
781 * @ [SHLWAPI.154]
783 * Function: Compare two WIDE strings for "len" bytes via caseless compare.
784 * Returns: *str1-*str2 (case insensitive)
786 DWORD WINAPI SHLWAPI_154(LPWSTR str1, LPWSTR str2, DWORD len)
788 return strncmpiW( str1, str2, len );
791 /*************************************************************************
792 * @ [SHLWAPI.156]
794 * Case sensitive string compare. Does not SetLastError().
796 DWORD WINAPI SHLWAPI_156 ( LPWSTR str1, LPWSTR str2)
798 return strcmpW( str1, str2 );
801 /*************************************************************************
802 * @ [SHLWAPI.158]
804 * Case insensitive string compare. Does not SetLastError(). ??
806 DWORD WINAPI SHLWAPI_158 ( LPWSTR str1, LPWSTR str2)
808 return strcmpiW( str1, str2 );
811 /*************************************************************************
812 * @ [SHLWAPI.162]
814 * Ensure a multibyte character string doesn't end in a hanging lead byte.
816 DWORD WINAPI SHLWAPI_162(LPSTR lpStr, DWORD size)
818 if (lpStr && size)
820 LPSTR lastByte = lpStr + size - 1;
822 while(lpStr < lastByte)
823 lpStr += IsDBCSLeadByte(*lpStr) ? 2 : 1;
825 if(lpStr == lastByte && IsDBCSLeadByte(*lpStr))
827 *lpStr = '\0';
828 size--;
830 return size;
832 return 0;
835 /*************************************************************************
836 * @ [SHLWAPI.164]
838 DWORD WINAPI SHLWAPI_164 (
839 LPVOID u,
840 LPVOID v,
841 LPVOID w,
842 LPVOID x,
843 LPVOID y,
844 LPVOID z)
846 TRACE("(%p %p %p %p %p %p) stub\n",u,v,w,x,y,z);
847 return 0x80004002; /* E_NOINTERFACE */
850 /*************************************************************************
851 * @ [SHLWAPI.165]
853 * SetWindowLongA with mask.
855 LONG WINAPI SHLWAPI_165(HWND hwnd, INT offset, UINT wFlags, UINT wMask)
857 LONG ret = GetWindowLongA(hwnd, offset);
858 UINT newFlags = (wFlags & wMask) | (ret & ~wFlags);
860 if (newFlags != ret)
861 ret = SetWindowLongA(hwnd, offset, newFlags);
862 return ret;
865 /*************************************************************************
866 * @ [SHLWAPI.169]
868 * Do IUnknown::Release on passed object.
870 DWORD WINAPI SHLWAPI_169 (IUnknown ** lpUnknown)
872 IUnknown *temp;
874 TRACE("(%p)\n",lpUnknown);
875 if(!lpUnknown || !*((LPDWORD)lpUnknown)) return 0;
876 temp = *lpUnknown;
877 *lpUnknown = NULL;
878 TRACE("doing Release\n");
879 return IUnknown_Release(temp);
882 /*************************************************************************
883 * @ [SHLWAPI.170]
885 * Skip URL '//' sequence.
887 LPCSTR WINAPI SHLWAPI_170(LPCSTR lpszSrc)
889 if (lpszSrc && lpszSrc[0] == '/' && lpszSrc[1] == '/')
890 lpszSrc += 2;
891 return lpszSrc;
894 /*************************************************************************
895 * @ [SHLWAPI.172]
896 * Get window handle of OLE object
898 DWORD WINAPI SHLWAPI_172 (
899 IUnknown *y, /* [in] OLE object interface */
900 LPHWND z) /* [out] location to put window handle */
902 DWORD ret;
903 IUnknown *pv;
905 TRACE("(%p %p)\n",y,z);
906 if (!y) return E_FAIL;
908 if ((ret = IUnknown_QueryInterface(y, &IID_IOleWindow,(LPVOID *)&pv)) < 0) {
909 /* error */
910 return ret;
912 ret = IOleWindow_GetWindow((IOleWindow *)pv, z);
913 IUnknown_Release(pv);
914 TRACE("result hwnd=%08x\n", *z);
915 return ret;
918 /*************************************************************************
919 * @ [SHLWAPI.174]
921 * Seems to do call either IObjectWithSite::SetSite or
922 * IPersistMoniker::GetClassID. But since we do not implement either
923 * of those classes in our headers, we will fake it out.
925 DWORD WINAPI SHLWAPI_174(
926 IUnknown *p1, /* [in] OLE object */
927 LPVOID *p2) /* [out] ptr to result of either GetClassID */
928 /* or SetSite call. */
930 DWORD ret, aa;
932 if (!p1) return E_FAIL;
934 /* see if SetSite interface exists for IObjectWithSite object */
935 ret = IUnknown_QueryInterface((IUnknown *)p1, (REFIID)id1, (LPVOID *)&p1);
936 TRACE("first IU_QI ret=%08lx, p1=%p\n", ret, p1);
937 if (ret) {
939 /* see if GetClassId interface exists for IPersistMoniker object */
940 ret = IUnknown_QueryInterface((IUnknown *)p1, (REFIID)id2, (LPVOID *)&aa);
941 TRACE("second IU_QI ret=%08lx, aa=%08lx\n", ret, aa);
942 if (ret) return ret;
944 /* fake a GetClassId call */
945 ret = IOleWindow_GetWindow((IOleWindow *)aa, (HWND*)p2);
946 TRACE("second IU_QI doing 0x0c ret=%08lx, *p2=%08lx\n", ret,
947 *(LPDWORD)p2);
948 IUnknown_Release((IUnknown *)aa);
950 else {
951 /* fake a SetSite call */
952 ret = IOleWindow_GetWindow((IOleWindow *)p1, (HWND*)p2);
953 TRACE("first IU_QI doing 0x0c ret=%08lx, *p2=%08lx\n", ret,
954 *(LPDWORD)p2);
955 IUnknown_Release((IUnknown *)p1);
957 return ret;
960 /*************************************************************************
961 * @ [SHLWAPI.176]
963 * Function appears to be interface to IServiceProvider::QueryService
965 * NOTE:
966 * returns E_NOINTERFACE
967 * E_FAIL if w == 0
968 * S_OK if _219 called successfully
970 DWORD WINAPI SHLWAPI_176 (
971 IUnknown* unk, /* [in] object to give Service Provider */
972 REFGUID sid, /* [in] Service ID */
973 REFIID riid, /* [in] Function requested */
974 LPVOID *z) /* [out] place to save interface pointer */
976 DWORD ret;
977 LPVOID aa;
978 *z = 0;
979 if (!unk) return E_FAIL;
980 ret = IUnknown_QueryInterface(unk, &IID_IServiceProvider, &aa);
981 TRACE("did IU_QI retval=%08lx, aa=%p\n", ret, aa);
982 if (ret) return ret;
983 ret = IServiceProvider_QueryService((IServiceProvider *)aa, sid, riid,
984 (void **)z);
985 TRACE("did ISP_QS retval=%08lx, *z=%p\n", ret, (LPVOID)*z);
986 IUnknown_Release((IUnknown*)aa);
987 return ret;
990 /*************************************************************************
991 * @ [SHLWAPI.181]
993 * Enable or disable a menu item.
995 UINT WINAPI SHLWAPI_181(HMENU hMenu, UINT wItemID, BOOL bEnable)
997 return EnableMenuItem(hMenu, wItemID, bEnable ? MF_ENABLED : MF_GRAYED);
1000 /*************************************************************************
1001 * @ [SHLWAPI.183]
1003 * Register a window class if it isn't already.
1005 DWORD WINAPI SHLWAPI_183(WNDCLASSA *wndclass)
1007 WNDCLASSA wca;
1008 if (GetClassInfoA(wndclass->hInstance, wndclass->lpszClassName, &wca))
1009 return TRUE;
1010 return (DWORD)RegisterClassA(wndclass);
1013 /*************************************************************************
1014 * @ [SHLWAPI.193]
1016 DWORD WINAPI SHLWAPI_193 ()
1018 HDC hdc;
1019 DWORD ret;
1021 TRACE("()\n");
1023 hdc = GetDC(0);
1024 ret = GetDeviceCaps(hdc, BITSPIXEL) * GetDeviceCaps(hdc, PLANES);
1025 ReleaseDC(0, hdc);
1026 return ret;
1029 /*************************************************************************
1030 * @ [SHLWAPI.199]
1032 * Copy interface pointer
1034 DWORD WINAPI SHLWAPI_199 (
1035 IUnknown **dest, /* [out] pointer to copy of interface ptr */
1036 IUnknown *src) /* [in] interface pointer */
1038 TRACE("(%p %p)\n",dest,src);
1039 if (*dest != src) {
1040 if (*dest)
1041 IUnknown_Release(*dest);
1042 if (src) {
1043 IUnknown_AddRef(src);
1044 *dest = src;
1047 return 4;
1050 /*************************************************************************
1051 * @ [SHLWAPI.208]
1053 * Some sort of memory management process - associated with _210
1055 DWORD WINAPI SHLWAPI_208 (
1056 DWORD a,
1057 DWORD b,
1058 LPVOID c,
1059 LPVOID d,
1060 DWORD e)
1062 FIXME("(0x%08lx 0x%08lx %p %p 0x%08lx) stub\n",
1063 a, b, c, d, e);
1064 return 1;
1067 /*************************************************************************
1068 * @ [SHLWAPI.210]
1070 * Some sort of memory management process - associated with _208
1072 DWORD WINAPI SHLWAPI_210 (
1073 LPVOID a,
1074 DWORD b,
1075 LPVOID c)
1077 FIXME("(%p 0x%08lx %p) stub\n",
1078 a, b, c);
1079 return 0;
1082 /*************************************************************************
1083 * @ [SHLWAPI.211]
1085 DWORD WINAPI SHLWAPI_211 (
1086 LPVOID a,
1087 DWORD b)
1089 FIXME("(%p 0x%08lx) stub\n",
1090 a, b);
1091 return 1;
1094 /*************************************************************************
1095 * @ [SHLWAPI.215]
1097 * NOTES
1098 * check me!
1100 DWORD WINAPI SHLWAPI_215 (
1101 LPCSTR lpStrSrc,
1102 LPWSTR lpwStrDest,
1103 int len)
1105 INT len_a, ret;
1107 len_a = lstrlenA(lpStrSrc);
1108 ret = MultiByteToWideChar(0, 0, lpStrSrc, len_a, lpwStrDest, len);
1109 TRACE("%s %s %d, ret=%d\n",
1110 debugstr_a(lpStrSrc), debugstr_w(lpwStrDest), len, ret);
1111 return ret;
1114 /*************************************************************************
1115 * @ [SHLWAPI.218]
1117 * WideCharToMultiByte with multi language support.
1119 INT WINAPI SHLWAPI_218(UINT CodePage, LPCWSTR lpSrcStr, LPSTR lpDstStr,
1120 LPINT lpnMultiCharCount)
1122 static HRESULT (WINAPI *pfnFunc)(LPDWORD,DWORD,LPCWSTR,LPINT,LPSTR,LPINT);
1123 WCHAR emptyW[] = { '\0' };
1124 int len , reqLen;
1125 LPSTR mem;
1127 if (!lpDstStr || !lpnMultiCharCount)
1128 return 0;
1130 if (!lpSrcStr)
1131 lpSrcStr = emptyW;
1133 *lpDstStr = '\0';
1135 len = strlenW(lpSrcStr) + 1;
1137 switch (CodePage)
1139 case CP_WINUNICODE:
1140 CodePage = CP_UTF8; /* Fall through... */
1141 case 0x0000C350: /* FIXME: CP_ #define */
1142 case CP_UTF7:
1143 case CP_UTF8:
1145 DWORD dwMode = 0;
1146 INT nWideCharCount = len - 1;
1148 GET_FUNC(mlang, "ConvertINetUnicodeToMultiByte", 0);
1149 if (!pfnFunc(&dwMode, CodePage, lpSrcStr, &nWideCharCount, lpDstStr,
1150 lpnMultiCharCount))
1151 return 0;
1153 if (nWideCharCount < len - 1)
1155 mem = (LPSTR)HeapAlloc(GetProcessHeap(), 0, *lpnMultiCharCount);
1156 if (!mem)
1157 return 0;
1159 *lpnMultiCharCount = 0;
1161 if (pfnFunc(&dwMode, CodePage, lpSrcStr, &len, mem, lpnMultiCharCount))
1163 SHLWAPI_162 (mem, *lpnMultiCharCount);
1164 lstrcpynA(lpDstStr, mem, *lpnMultiCharCount + 1);
1165 return *lpnMultiCharCount + 1;
1167 HeapFree(GetProcessHeap(), 0, mem);
1168 return *lpnMultiCharCount;
1170 lpDstStr[*lpnMultiCharCount] = '\0';
1171 return *lpnMultiCharCount;
1173 break;
1174 default:
1175 break;
1178 reqLen = WideCharToMultiByte(CodePage, 0, lpSrcStr, len, lpDstStr,
1179 *lpnMultiCharCount, NULL, NULL);
1181 if (!reqLen && GetLastError() == ERROR_INSUFFICIENT_BUFFER)
1183 reqLen = WideCharToMultiByte(CodePage, 0, lpSrcStr, len, NULL, 0, NULL, NULL);
1184 if (reqLen)
1186 mem = (LPSTR)HeapAlloc(GetProcessHeap(), 0, reqLen);
1187 if (mem)
1189 reqLen = WideCharToMultiByte(CodePage, 0, lpSrcStr, len, mem,
1190 reqLen, NULL, NULL);
1192 reqLen = SHLWAPI_162(mem, *lpnMultiCharCount);
1193 reqLen++;
1195 lstrcpynA(lpDstStr, mem, *lpnMultiCharCount);
1197 HeapFree(GetProcessHeap(), 0, mem);
1201 return reqLen;
1204 /*************************************************************************
1205 * @ [SHLWAPI.217]
1207 * Hmm, some program used lpnMultiCharCount == 0x3 (and lpSrcStr was "C")
1208 * --> Crash. Something wrong here.
1210 * It seems from OE v5 that the third param is the count. (GA 11/2001)
1212 INT WINAPI SHLWAPI_217(LPCWSTR lpSrcStr, LPSTR lpDstStr, INT MultiCharCount)
1214 INT myint = MultiCharCount;
1216 return SHLWAPI_218(CP_ACP, lpSrcStr, lpDstStr, &myint);
1219 /*************************************************************************
1220 * @ [SHLWAPI.219]
1222 * Seems to be "super" QueryInterface. Supplied with at table of interfaces
1223 * and an array of IIDs and offsets into the table.
1225 * NOTES
1226 * error codes: E_POINTER, E_NOINTERFACE
1228 typedef struct {
1229 REFIID refid;
1230 DWORD indx;
1231 } IFACE_INDEX_TBL;
1233 HRESULT WINAPI SHLWAPI_219 (
1234 LPVOID w, /* [in] table of interfaces */
1235 IFACE_INDEX_TBL *x, /* [in] array of REFIIDs and indexes to above */
1236 REFIID riid, /* [in] REFIID to get interface for */
1237 LPVOID *z) /* [out] location to get interface pointer */
1239 HRESULT ret;
1240 IUnknown *a_vtbl;
1241 IFACE_INDEX_TBL *xmove;
1243 TRACE("(%p %p %s %p)\n",
1244 w,x,debugstr_guid(riid),z);
1245 if (z) {
1246 xmove = x;
1247 while (xmove->refid) {
1248 TRACE("trying (indx %ld) %s\n", xmove->indx,
1249 debugstr_guid(xmove->refid));
1250 if (IsEqualIID(riid, xmove->refid)) {
1251 a_vtbl = (IUnknown*)(xmove->indx + (LPBYTE)w);
1252 TRACE("matched, returning (%p)\n", a_vtbl);
1253 *z = (LPVOID)a_vtbl;
1254 IUnknown_AddRef(a_vtbl);
1255 return S_OK;
1257 xmove++;
1260 if (IsEqualIID(riid, &IID_IUnknown)) {
1261 a_vtbl = (IUnknown*)(x->indx + (LPBYTE)w);
1262 TRACE("returning first for IUnknown (%p)\n", a_vtbl);
1263 *z = (LPVOID)a_vtbl;
1264 IUnknown_AddRef(a_vtbl);
1265 return S_OK;
1267 *z = 0;
1268 ret = E_NOINTERFACE;
1269 } else
1270 ret = E_POINTER;
1271 return ret;
1274 /*************************************************************************
1275 * @ [SHLWAPI.222]
1277 * NOTES
1278 * securityattributes missing
1280 HANDLE WINAPI SHLWAPI_222 (LPCLSID guid)
1282 char lpstrName[80];
1284 sprintf( lpstrName, "shell.{%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
1285 guid->Data1, guid->Data2, guid->Data3,
1286 guid->Data4[0], guid->Data4[1], guid->Data4[2], guid->Data4[3],
1287 guid->Data4[4], guid->Data4[5], guid->Data4[6], guid->Data4[7] );
1288 FIXME("(%s) stub\n", lpstrName);
1289 return CreateSemaphoreA(NULL,0, 0x7fffffff, lpstrName);
1292 /*************************************************************************
1293 * @ [SHLWAPI.223]
1295 * NOTES
1296 * get the count of the semaphore
1298 DWORD WINAPI SHLWAPI_223 (HANDLE handle)
1300 DWORD oldCount;
1302 FIXME("(0x%08x) stub\n",handle);
1304 ReleaseSemaphore( handle, 1, &oldCount); /* +1 */
1305 WaitForSingleObject( handle, 0 ); /* -1 */
1306 return oldCount;
1309 /*************************************************************************
1310 * @ [SHLWAPI.236]
1312 HMODULE WINAPI SHLWAPI_236 (REFIID lpUnknown)
1314 HKEY newkey;
1315 DWORD type, count;
1316 CHAR value[MAX_PATH], string[MAX_PATH];
1318 strcpy(string, "CLSID\\");
1319 strcat(string, debugstr_guid(lpUnknown));
1320 strcat(string, "\\InProcServer32");
1322 count = MAX_PATH;
1323 RegOpenKeyExA(HKEY_CLASSES_ROOT, string, 0, 1, &newkey);
1324 RegQueryValueExA(newkey, 0, 0, &type, value, &count);
1325 RegCloseKey(newkey);
1326 return LoadLibraryExA(value, 0, 0);
1329 /*************************************************************************
1330 * @ [SHLWAPI.237]
1332 * Unicode version of SHLWAPI_183.
1334 DWORD WINAPI SHLWAPI_237 (WNDCLASSW * lpWndClass)
1336 WNDCLASSW WndClass;
1338 TRACE("(0x%08x %s)\n",lpWndClass->hInstance, debugstr_w(lpWndClass->lpszClassName));
1340 if (GetClassInfoW(lpWndClass->hInstance, lpWndClass->lpszClassName, &WndClass))
1341 return TRUE;
1342 return RegisterClassW(lpWndClass);
1345 /*************************************************************************
1346 * @ [SHLWAPI.239]
1348 DWORD WINAPI SHLWAPI_239(HINSTANCE hInstance, LPVOID p2, DWORD dw3)
1350 FIXME("(0x%08x %p 0x%08lx) stub\n",
1351 hInstance, p2, dw3);
1352 return 0;
1353 #if 0
1354 /* pseudo code from relay trace */
1355 WideCharToMultiByte(0, 0, L"Shell DocObject View", -1, &aa, 0x0207, 0, 0);
1356 GetClassInfoA(70fe0000,405868ec "Shell DocObject View",40586b14);
1357 /* above pair repeated for:
1358 TridentThicketUrlDlClass
1359 Shell Embedding
1360 CIESplashScreen
1361 Inet Notify_Hidden
1362 OCHost
1364 #endif
1367 /*************************************************************************
1368 * @ [SHLWAPI.240]
1370 * Calls ASCII or Unicode WindowProc for the given window.
1372 LRESULT CALLBACK SHLWAPI_240(HWND hWnd, UINT uMessage, WPARAM wParam, LPARAM lParam)
1374 if (IsWindowUnicode(hWnd))
1375 return DefWindowProcW(hWnd, uMessage, wParam, lParam);
1376 return DefWindowProcA(hWnd, uMessage, wParam, lParam);
1379 /*************************************************************************
1380 * @ [SHLWAPI.241]
1383 DWORD WINAPI SHLWAPI_241 ()
1385 FIXME("()stub\n");
1386 return /* 0xabba1243 */ 0;
1389 /*************************************************************************
1390 * @ [SHLWAPI.266]
1392 DWORD WINAPI SHLWAPI_266 (
1393 LPVOID w,
1394 LPVOID x,
1395 LPVOID y,
1396 LPVOID z)
1398 FIXME("(%p %p %p %p)stub\n",w,x,y,z);
1399 return 0xabba1248;
1402 /*************************************************************************
1403 * @ [SHLWAPI.267]
1405 HRESULT WINAPI SHLWAPI_267 (
1406 LPVOID w, /* [???] NOTE: same as 1th parameter of SHLWAPI_219 */
1407 LPVOID x, /* [???] NOTE: same as 2nd parameter of SHLWAPI_219 */
1408 LPVOID y,
1409 LPVOID z)
1411 FIXME("(%p %p %p %p)stub\n",w,x,y,z);
1412 *((LPDWORD)z) = 0xabba1200;
1413 return 0xabba1254;
1416 /*************************************************************************
1417 * @ [SHLWAPI.268]
1419 DWORD WINAPI SHLWAPI_268 (
1420 LPVOID w,
1421 LPVOID x)
1423 FIXME("(%p %p)\n",w,x);
1424 return 0xabba1251; /* 0 = failure */
1427 /*************************************************************************
1428 * @ [SHLWAPI.276]
1431 DWORD WINAPI SHLWAPI_276 ()
1433 FIXME("()stub\n");
1434 return /* 0xabba1244 */ 0;
1437 /*************************************************************************
1438 * @ [SHLWAPI.278]
1441 HWND WINAPI SHLWAPI_278 (
1442 LONG wndProc,
1443 HWND hWndParent,
1444 DWORD dwExStyle,
1445 DWORD dwStyle,
1446 HMENU hMenu,
1447 LONG z)
1449 WNDCLASSA wndclass;
1450 HWND hwnd;
1451 HCURSOR hCursor;
1452 char * clsname = "WorkerA";
1454 FIXME("(0x%08lx 0x%08x 0x%08lx 0x%08lx 0x%08x 0x%08lx) partial stub\n",
1455 wndProc,hWndParent,dwExStyle,dwStyle,hMenu,z);
1457 hCursor = LoadCursorA(0x00000000,IDC_ARROWA);
1459 if(!GetClassInfoA(shlwapi_hInstance, clsname, &wndclass))
1461 RtlZeroMemory(&wndclass, sizeof(WNDCLASSA));
1462 wndclass.lpfnWndProc = DefWindowProcW;
1463 wndclass.cbWndExtra = 4;
1464 wndclass.hInstance = shlwapi_hInstance;
1465 wndclass.hCursor = hCursor;
1466 wndclass.hbrBackground = COLOR_BTNSHADOW;
1467 wndclass.lpszMenuName = NULL;
1468 wndclass.lpszClassName = clsname;
1469 RegisterClassA (&wndclass);
1471 hwnd = CreateWindowExA(dwExStyle, clsname, 0,dwStyle,0,0,0,0,hWndParent,
1472 hMenu,shlwapi_hInstance,0);
1473 SetWindowLongA(hwnd, 0, z);
1474 SetWindowLongA(hwnd, GWL_WNDPROC, wndProc);
1475 return hwnd;
1478 /*************************************************************************
1479 * @ [SHLWAPI.289]
1481 * Late bound call to winmm.PlaySoundW
1483 BOOL WINAPI SHLWAPI_289(LPCWSTR pszSound, HMODULE hmod, DWORD fdwSound)
1485 static BOOL (WINAPI *pfnFunc)(LPCWSTR, HMODULE, DWORD) = NULL;
1487 GET_FUNC(winmm, "PlaySoundW", FALSE);
1488 return pfnFunc(pszSound, hmod, fdwSound);
1491 /*************************************************************************
1492 * @ [SHLWAPI.294]
1494 BOOL WINAPI SHLWAPI_294(LPSTR str1, LPSTR str2, LPSTR pStr, DWORD some_len, LPCSTR lpStr2)
1497 * str1: "I" "I" pushl esp+0x20
1498 * str2: "U" "I" pushl 0x77c93810
1499 * (is "I" and "U" "integer" and "unsigned" ??)
1501 * pStr: "" "" pushl eax
1502 * some_len: 0x824 0x104 pushl 0x824
1503 * lpStr2: "%l" "%l" pushl esp+0xc
1505 * shlwapi. StrCpyNW(lpStr2, irrelevant_var, 0x104);
1506 * LocalAlloc(0x00, some_len) -> irrelevant_var
1507 * LocalAlloc(0x40, irrelevant_len) -> pStr
1508 * shlwapi.294(str1, str2, pStr, some_len, lpStr2);
1509 * shlwapi.PathRemoveBlanksW(pStr);
1511 ERR("('%s', '%s', '%s', %08lx, '%s'): stub!\n", str1, str2, pStr, some_len, lpStr2);
1512 return TRUE;
1515 /*************************************************************************
1516 * @ [SHLWAPI.313]
1518 * Late bound call to shell32.SHGetFileInfoW
1520 DWORD WINAPI SHLWAPI_313(LPCWSTR path, DWORD dwFileAttributes,
1521 SHFILEINFOW *psfi, UINT sizeofpsfi, UINT flags)
1523 static DWORD (WINAPI *pfnFunc)(LPCWSTR,DWORD,SHFILEINFOW*,UINT,UINT) = NULL;
1525 GET_FUNC(shell32, "SHGetFileInfoW", 0);
1526 return pfnFunc(path, dwFileAttributes, psfi, sizeofpsfi, flags);
1529 /*************************************************************************
1530 * @ [SHLWAPI.318]
1532 * Late bound call to shell32.DragQueryFileW
1534 UINT WINAPI SHLWAPI_318(HDROP hDrop, UINT lFile, LPWSTR lpszFile, UINT lLength)
1536 static UINT (WINAPI *pfnFunc)(HDROP, UINT, LPWSTR, UINT) = NULL;
1538 GET_FUNC(shell32, "DragQueryFileW", 0);
1539 return pfnFunc(hDrop, lFile, lpszFile, lLength);
1542 /*************************************************************************
1543 * @ [SHLWAPI.333]
1545 * Late bound call to shell32.SHBrowseForFolderW
1547 LPITEMIDLIST WINAPI SHLWAPI_333(LPBROWSEINFOW lpBi)
1549 static LPITEMIDLIST (WINAPI *pfnFunc)(LPBROWSEINFOW) = NULL;
1551 GET_FUNC(shell32, "SHBrowseForFolderW", NULL);
1552 return pfnFunc(lpBi);
1555 /*************************************************************************
1556 * @ [SHLWAPI.334]
1558 * Late bound call to shell32.SHGetPathFromIDListW
1560 BOOL WINAPI SHLWAPI_334(LPCITEMIDLIST pidl,LPWSTR pszPath)
1562 static BOOL (WINAPI *pfnFunc)(LPCITEMIDLIST, LPWSTR) = NULL;
1564 GET_FUNC(shell32, "SHGetPathFromIDListW", 0);
1565 return pfnFunc(pidl, pszPath);
1568 /*************************************************************************
1569 * @ [SHLWAPI.335]
1571 * Late bound call to shell32.ShellExecuteExW
1573 BOOL WINAPI SHLWAPI_335(LPSHELLEXECUTEINFOW lpExecInfo)
1575 static BOOL (WINAPI *pfnFunc)(LPSHELLEXECUTEINFOW) = NULL;
1577 GET_FUNC(shell32, "ShellExecuteExW", FALSE);
1578 return pfnFunc(lpExecInfo);
1581 /*************************************************************************
1582 * @ [SHLWAPI.336]
1584 * Late bound call to shell32.SHFileOperationW.
1586 DWORD WINAPI SHLWAPI_336(LPSHFILEOPSTRUCTW lpFileOp)
1588 static HICON (WINAPI *pfnFunc)(LPSHFILEOPSTRUCTW) = NULL;
1590 GET_FUNC(shell32, "SHFileOperationW", 0);
1591 return pfnFunc(lpFileOp);
1594 /*************************************************************************
1595 * @ [SHLWAPI.337]
1597 * Late bound call to shell32.ExtractIconExW.
1599 HICON WINAPI SHLWAPI_337(LPCWSTR lpszFile, INT nIconIndex, HICON *phiconLarge,
1600 HICON *phiconSmall, UINT nIcons)
1602 static HICON (WINAPI *pfnFunc)(LPCWSTR, INT,HICON *,HICON *, UINT) = NULL;
1604 GET_FUNC(shell32, "ExtractIconExW", (HICON)0);
1605 return pfnFunc(lpszFile, nIconIndex, phiconLarge, phiconSmall, nIcons);
1608 /*************************************************************************
1609 * @ [SHLWAPI.342]
1612 DWORD WINAPI SHLWAPI_342 (
1613 LPDWORD w, /* [out] location to put HKEY value??? */
1614 HKEY x, /* [in] appears to be HKEY_CURRENT_USER */
1615 LPVOID y)
1617 FIXME("(%p 0x%08x %p)stub\n", w,x,y);
1618 *w = (DWORD)x;
1619 return /* 0xabba1249 */ 0;
1622 /*************************************************************************
1623 * @ [SHLWAPI.346]
1625 DWORD WINAPI SHLWAPI_346 (
1626 LPCWSTR src,
1627 LPWSTR dest,
1628 int len)
1630 FIXME("(%s %p 0x%08x)stub\n",debugstr_w(src),dest,len);
1631 lstrcpynW(dest, src, len);
1632 return lstrlenW(dest)+1;
1635 /*************************************************************************
1636 * @ [SHLWAPI.356]
1638 DWORD WINAPI SHLWAPI_356 (
1639 LPVOID x,
1640 LPVOID y,
1641 LPVOID z)
1643 FIXME("(%p %p %p)stub\n", x,y,z);
1644 return 0;
1647 /*************************************************************************
1648 * @ [SHLWAPI.357]
1650 * Late bound call to shell32.SHGetNewLinkInfoW
1652 BOOL WINAPI SHLWAPI_357(LPCWSTR pszLinkTo, LPCWSTR pszDir, LPWSTR pszName,
1653 BOOL *pfMustCopy, UINT uFlags)
1655 static BOOL (WINAPI *pfnFunc)(LPCWSTR, LPCWSTR, LPCWSTR, BOOL*, UINT) = NULL;
1657 GET_FUNC(shell32, "SHGetNewLinkInfoW", FALSE);
1658 return pfnFunc(pszLinkTo, pszDir, pszName, pfMustCopy, uFlags);
1661 /*************************************************************************
1662 * @ [SHLWAPI.358]
1664 * Late bound call to shell32.SHDefExtractIconW
1666 DWORD WINAPI SHLWAPI_358(LPVOID arg1, LPVOID arg2, LPVOID arg3, LPVOID arg4,
1667 LPVOID arg5, LPVOID arg6)
1669 /* FIXME: Correct args */
1670 static DWORD (WINAPI *pfnFunc)(LPVOID, LPVOID, LPVOID, LPVOID, LPVOID, LPVOID) = NULL;
1672 GET_FUNC(shell32, "SHDefExtractIconW", 0);
1673 return pfnFunc(arg1, arg2, arg3, arg4, arg5, arg6);
1676 /*************************************************************************
1677 * @ [SHLWAPI.364]
1679 * Wrapper for lstrcpynA with src and dst swapped.
1681 DWORD WINAPI SHLWAPI_364(LPCSTR src, LPSTR dst, INT n)
1683 lstrcpynA(dst, src, n);
1684 return TRUE;
1687 /*************************************************************************
1688 * @ [SHLWAPI.370]
1690 * Late bound call to shell32.ExtractIconW
1692 HICON WINAPI SHLWAPI_370(HINSTANCE hInstance, LPCWSTR lpszExeFileName,
1693 UINT nIconIndex)
1695 static HICON (WINAPI *pfnFunc)(HINSTANCE, LPCWSTR, UINT) = NULL;
1697 GET_FUNC(shell32, "ExtractIconW", (HICON)0);
1698 return pfnFunc(hInstance, lpszExeFileName, nIconIndex);
1701 /*************************************************************************
1702 * @ [SHLWAPI.376]
1704 LANGID WINAPI SHLWAPI_376 ()
1706 FIXME("() stub\n");
1707 /* FIXME: This should be a forward in the .spec file to the win2k function
1708 * kernel32.GetUserDefaultUILanguage, however that function isn't there yet.
1710 return GetUserDefaultLangID();
1713 /*************************************************************************
1714 * @ [SHLWAPI.377]
1716 * FIXME: Native appears to do DPA_Create and a DPA_InsertPtr for
1717 * each call here.
1718 * FIXME: Native shows calls to:
1719 * SHRegGetUSValue for "Software\Microsoft\Internet Explorer\International"
1720 * CheckVersion
1721 * RegOpenKeyExA for "HKLM\Software\Microsoft\Internet Explorer"
1722 * RegQueryValueExA for "LPKInstalled"
1723 * RegCloseKey
1724 * RegOpenKeyExA for "HKCU\Software\Microsoft\Internet Explorer\International"
1725 * RegQueryValueExA for "ResourceLocale"
1726 * RegCloseKey
1727 * RegOpenKeyExA for "HKLM\Software\Microsoft\Active Setup\Installed Components\{guid}"
1728 * RegQueryValueExA for "Locale"
1729 * RegCloseKey
1730 * and then tests the Locale ("en" for me).
1731 * code below
1732 * after the code then a DPA_Create (first time) and DPA_InsertPtr are done.
1734 DWORD WINAPI SHLWAPI_377 (LPCSTR new_mod, HMODULE inst_hwnd, LPVOID z)
1736 CHAR mod_path[2*MAX_PATH];
1737 LPSTR ptr;
1739 GetModuleFileNameA(inst_hwnd, mod_path, 2*MAX_PATH);
1740 ptr = strrchr(mod_path, '\\');
1741 if (ptr) {
1742 strcpy(ptr+1, new_mod);
1743 TRACE("loading %s\n", debugstr_a(mod_path));
1744 return (DWORD)LoadLibraryA(mod_path);
1746 return 0;
1749 /*************************************************************************
1750 * @ [SHLWAPI.378]
1752 * This is Unicode version of .377
1754 DWORD WINAPI SHLWAPI_378 (
1755 LPCWSTR new_mod, /* [in] new module name */
1756 HMODULE inst_hwnd, /* [in] calling module handle */
1757 LPVOID z) /* [???] 4 */
1759 WCHAR mod_path[2*MAX_PATH];
1760 LPWSTR ptr;
1762 GetModuleFileNameW(inst_hwnd, mod_path, 2*MAX_PATH);
1763 ptr = strrchrW(mod_path, '\\');
1764 if (ptr) {
1765 strcpyW(ptr+1, new_mod);
1766 TRACE("loading %s\n", debugstr_w(mod_path));
1767 return (DWORD)LoadLibraryW(mod_path);
1769 return 0;
1772 /*************************************************************************
1773 * @ [SHLWAPI.389]
1775 * Late bound call to comdlg32.GetSaveFileNameW
1777 BOOL WINAPI SHLWAPI_389(LPOPENFILENAMEW ofn)
1779 static BOOL (WINAPI *pfnFunc)(LPOPENFILENAMEW) = NULL;
1781 GET_FUNC(comdlg32, "GetSaveFileNameW", FALSE);
1782 return pfnFunc(ofn);
1785 /*************************************************************************
1786 * @ [SHLWAPI.390]
1788 * Late bound call to mpr.WNetRestoreConnectionW
1790 DWORD WINAPI SHLWAPI_390(LPVOID arg1, LPVOID arg2)
1792 /* FIXME: Correct args */
1793 static DWORD (WINAPI *pfnFunc)(LPVOID, LPVOID) = NULL;
1795 GET_FUNC(mpr, "WNetRestoreConnectionW", 0);
1796 return pfnFunc(arg1, arg2);
1799 /*************************************************************************
1800 * @ [SHLWAPI.391]
1802 * Late bound call to mpr.WNetGetLastErrorW
1804 DWORD WINAPI SHLWAPI_391(LPVOID arg1, LPVOID arg2, LPVOID arg3, LPVOID arg4,
1805 LPVOID arg5)
1807 /* FIXME: Correct args */
1808 static DWORD (WINAPI *pfnFunc)(LPVOID, LPVOID, LPVOID, LPVOID, LPVOID) = NULL;
1810 GET_FUNC(mpr, "WNetGetLastErrorW", 0);
1811 return pfnFunc(arg1, arg2, arg3, arg4, arg5);
1814 /*************************************************************************
1815 * @ [SHLWAPI.401]
1817 * Late bound call to comdlg32.PageSetupDlgW
1819 BOOL WINAPI SHLWAPI_401(LPPAGESETUPDLGW pagedlg)
1821 static BOOL (WINAPI *pfnFunc)(LPPAGESETUPDLGW) = NULL;
1823 GET_FUNC(comdlg32, "PageSetupDlgW", FALSE);
1824 return pfnFunc(pagedlg);
1827 /*************************************************************************
1828 * @ [SHLWAPI.402]
1830 * Late bound call to comdlg32.PrintDlgW
1832 BOOL WINAPI SHLWAPI_402(LPPRINTDLGW printdlg)
1834 static BOOL (WINAPI *pfnFunc)(LPPRINTDLGW) = NULL;
1836 GET_FUNC(comdlg32, "PrintDlgW", FALSE);
1837 return pfnFunc(printdlg);
1840 /*************************************************************************
1841 * @ [SHLWAPI.403]
1843 * Late bound call to comdlg32.GetOpenFileNameW
1845 BOOL WINAPI SHLWAPI_403(LPOPENFILENAMEW ofn)
1847 static BOOL (WINAPI *pfnFunc)(LPOPENFILENAMEW) = NULL;
1849 GET_FUNC(comdlg32, "GetOpenFileNameW", FALSE);
1850 return pfnFunc(ofn);
1853 /* INTERNAL: Map from HLS color space to RGB */
1854 static WORD ConvertHue(int wHue, WORD wMid1, WORD wMid2)
1856 wHue = wHue > 240 ? wHue - 240 : wHue < 0 ? wHue + 240 : wHue;
1858 if (wHue > 160)
1859 return wMid1;
1860 else if (wHue > 120)
1861 wHue = 160 - wHue;
1862 else if (wHue > 40)
1863 return wMid2;
1865 return ((wHue * (wMid2 - wMid1) + 20) / 40) + wMid1;
1868 /* Convert to RGB and scale into RGB range (0..255) */
1869 #define GET_RGB(h) (ConvertHue(h, wMid1, wMid2) * 255 + 120) / 240
1871 /*************************************************************************
1872 * ColorHLSToRGB [SHLWAPI.404]
1874 * Convert from HLS color space into an RGB COLORREF.
1876 * NOTES
1877 * Input HLS values are constrained to the range (0..240).
1879 COLORREF WINAPI ColorHLSToRGB(WORD wHue, WORD wLuminosity, WORD wSaturation)
1881 WORD wRed;
1883 if (wSaturation)
1885 WORD wGreen, wBlue, wMid1, wMid2;
1887 if (wLuminosity > 120)
1888 wMid2 = wSaturation + wLuminosity - (wSaturation * wLuminosity + 120) / 240;
1889 else
1890 wMid2 = ((wSaturation + 240) * wLuminosity + 120) / 240;
1892 wMid1 = wLuminosity * 2 - wMid2;
1894 wRed = GET_RGB(wHue + 80);
1895 wGreen = GET_RGB(wHue);
1896 wBlue = GET_RGB(wHue - 80);
1898 return RGB(wRed, wGreen, wBlue);
1901 wRed = wLuminosity * 255 / 240;
1902 return RGB(wRed, wRed, wRed);
1905 /*************************************************************************
1906 * @ [SHLWAPI.413]
1908 * Function unknown seems to always to return 0
1910 DWORD WINAPI SHLWAPI_413 (DWORD x)
1912 FIXME("(0x%08lx)stub\n", x);
1913 return 0;
1916 /*************************************************************************
1917 * @ [SHLWAPI.431]
1919 DWORD WINAPI SHLWAPI_431 (DWORD x)
1921 FIXME("(0x%08lx)stub\n", x);
1922 return 0xabba1247;
1925 /*************************************************************************
1926 * @ [SHLWAPI.437]
1928 * NOTES
1929 * In the real shlwapi, One time initialisation calls GetVersionEx and reads
1930 * the registry to determine what O/S & Service Pack level is running, and
1931 * therefore which functions are available. Currently we always run as NT,
1932 * since this means that we don't need extra code to emulate Unicode calls,
1933 * they are forwarded directly to the appropriate API call instead.
1934 * Since the flags for whether to call or emulate Unicode are internal to
1935 * the dll, this function does not need a full implementation.
1937 DWORD WINAPI SHLWAPI_437 (DWORD functionToCall)
1939 FIXME("(0x%08lx)stub\n", functionToCall);
1940 return /* 0xabba1247 */ 0;
1943 /*************************************************************************
1944 * ColorRGBToHLS [SHLWAPI.445]
1946 * Convert from RGB COLORREF into the HLS color space.
1948 * NOTES
1949 * Input HLS values are constrained to the range (0..240).
1951 VOID WINAPI ColorRGBToHLS(COLORREF drRGB, LPWORD pwHue,
1952 LPWORD wLuminance, LPWORD pwSaturation)
1954 FIXME("stub\n");
1955 return;
1958 /*************************************************************************
1959 * SHCreateShellPalette [SHLWAPI.@]
1961 HPALETTE WINAPI SHCreateShellPalette(HDC hdc)
1963 FIXME("stub\n");
1964 return CreateHalftonePalette(hdc);
1967 /*************************************************************************
1968 * SHGetInverseCMAP (SHLWAPI.@)
1970 DWORD WINAPI SHGetInverseCMAP (LPVOID x, DWORD why)
1972 FIXME("(%p, %#lx)stub\n", x, why);
1973 return 0;
1976 /*************************************************************************
1977 * SHIsLowMemoryMachine [SHLWAPI.@]
1979 DWORD WINAPI SHIsLowMemoryMachine (DWORD x)
1981 FIXME("0x%08lx\n", x);
1982 return 0;
1985 /*************************************************************************
1986 * GetMenuPosFromID [SHLWAPI.@]
1988 INT WINAPI GetMenuPosFromID(HMENU hMenu, UINT wID)
1990 MENUITEMINFOA mi;
1991 INT nCount = GetMenuItemCount(hMenu), nIter = 0;
1993 while (nIter < nCount)
1995 mi.wID = 0;
1996 if (!GetMenuItemInfoA(hMenu, nIter, TRUE, &mi) && mi.wID == wID)
1997 return nIter;
1998 nIter++;
2000 return -1;
2003 /*************************************************************************
2004 * _SHGetInstanceExplorer@4 [SHLWAPI.@]
2006 * Late bound call to shell32.SHGetInstanceExplorer.
2008 HRESULT WINAPI _SHGetInstanceExplorer (LPUNKNOWN *lpUnknown)
2010 static HRESULT (WINAPI *pfnFunc)(LPUNKNOWN *) = NULL;
2012 GET_FUNC(shell32, "SHGetInstanceExplorer", E_FAIL);
2013 return pfnFunc(lpUnknown);