2 * SHLWAPI ordinal functions
4 * Copyright 1997 Marcus Meissner
19 #include "wine/unicode.h"
20 #include "wine/obj_base.h"
21 #include "wine/obj_inplace.h"
22 #include "wine/obj_serviceprovider.h"
26 #include "debugtools.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 typedef HANDLE HSHARED; /* Shared memory */
41 /* following is GUID for IObjectWithSite::SetSite -- see _174 */
42 static DWORD id1[4] = {0xfc4801a3, 0x11cf2ba9, 0xaa0029a2, 0x52733d00};
43 /* following is GUID for IPersistMoniker::GetClassID -- see _174 */
44 static DWORD id2[4] = {0x79eac9ee, 0x11cebaf9, 0xaa00828c, 0x0ba94b00};
46 /* The following schemes were identified in the native version of
47 * SHLWAPI.DLL version 5.50
50 URL_SCHEME_INVALID = -1,
51 URL_SCHEME_UNKNOWN = 0,
66 URL_SCHEME_JAVASCRIPT,
74 URL_SCHEME scheme_number;
78 static const SHL_2_inet_scheme shlwapi_schemes[] = {
79 {URL_SCHEME_FTP, "ftp"},
80 {URL_SCHEME_HTTP, "http"},
81 {URL_SCHEME_GOPHER, "gopher"},
82 {URL_SCHEME_MAILTO, "mailto"},
83 {URL_SCHEME_NEWS, "news"},
84 {URL_SCHEME_NNTP, "nntp"},
85 {URL_SCHEME_TELNET, "telnet"},
86 {URL_SCHEME_WAIS, "wais"},
87 {URL_SCHEME_FILE, "file"},
88 {URL_SCHEME_MK, "mk"},
89 {URL_SCHEME_HTTPS, "https"},
90 {URL_SCHEME_SHELL, "shell"},
91 {URL_SCHEME_SNEWS, "snews"},
92 {URL_SCHEME_LOCAL, "local"},
93 {URL_SCHEME_JAVASCRIPT, "javascript"},
94 {URL_SCHEME_VBSCRIPT, "vbscript"},
95 {URL_SCHEME_ABOUT, "about"},
96 {URL_SCHEME_RES, "res"},
100 /* Macro to get function pointer for a module*/
101 #define GET_FUNC(module, name, fail) \
102 if (!SHLWAPI_h##module) SHLWAPI_h##module = LoadLibraryA(#module ".dll"); \
103 if (!SHLWAPI_h##module) return fail; \
104 if (!pfnFunc) pfnFunc = (void*)GetProcAddress(SHLWAPI_h##module, name); \
105 if (!pfnFunc) return fail
108 NOTES: Most functions exported by ordinal seem to be superflous.
109 The reason for these functions to be there is to provide a wraper
110 for unicode functions to provide these functions on systems without
111 unicode functions eg. win95/win98. Since we have such functions we just
112 call these. If running Wine with native DLL's, some late bound calls may
113 fail. However, its better to implement the functions in the forward DLL
114 and recommend the builtin rather than reimplementing the calls here!
117 /*************************************************************************
120 * Identifies the Internet "scheme" in the passed string. ASCII based.
121 * Also determines start and length of item after the ':'
123 DWORD WINAPI SHLWAPI_1 (LPCSTR x, UNKNOWN_SHLWAPI_1 *y)
126 const SHL_2_inet_scheme *inet_pro;
128 if (y->size != 0x18) return E_INVALIDARG;
129 /* FIXME: leading white space generates error of 0x80041001 which
132 if (*x <= ' ') return 0x80041001;
147 /* check for no scheme in string start */
148 /* (apparently schemes *must* be larger than a single character) */
149 if ((*x == '\0') || (y->sizep1 <= 1)) {
154 /* found scheme, set length of remainder */
155 y->sizep2 = lstrlenA(y->ap2);
157 /* see if known scheme and return indicator number */
158 y->fcncde = URL_SCHEME_UNKNOWN;
159 inet_pro = shlwapi_schemes;
160 while (inet_pro->scheme_name) {
161 if (!strncasecmp(inet_pro->scheme_name, y->ap1,
162 min(y->sizep1, lstrlenA(inet_pro->scheme_name)))) {
163 y->fcncde = inet_pro->scheme_number;
171 /*************************************************************************
174 * Identifies the Internet "scheme" in the passed string. UNICODE based.
175 * Also determines start and length of item after the ':'
177 DWORD WINAPI SHLWAPI_2 (LPCWSTR x, UNKNOWN_SHLWAPI_2 *y)
180 const SHL_2_inet_scheme *inet_pro;
184 if (y->size != 0x18) return E_INVALIDARG;
185 /* FIXME: leading white space generates error of 0x80041001 which
188 if (*x <= L' ') return 0x80041001;
203 /* check for no scheme in string start */
204 /* (apparently schemes *must* be larger than a single character) */
205 if ((*x == L'\0') || (y->sizep1 <= 1)) {
210 /* found scheme, set length of remainder */
211 y->sizep2 = lstrlenW(y->ap2);
213 /* see if known scheme and return indicator number */
214 len = WideCharToMultiByte(0, 0, y->ap1, y->sizep1, 0, 0, 0, 0);
215 cmpstr = (LPSTR)HeapAlloc(GetProcessHeap(), 0, len+1);
216 WideCharToMultiByte(0, 0, y->ap1, y->sizep1, cmpstr, len+1, 0, 0);
217 y->fcncde = URL_SCHEME_UNKNOWN;
218 inet_pro = shlwapi_schemes;
219 while (inet_pro->scheme_name) {
220 if (!strncasecmp(inet_pro->scheme_name, cmpstr,
221 min(len, lstrlenA(inet_pro->scheme_name)))) {
222 y->fcncde = inet_pro->scheme_number;
227 HeapFree(GetProcessHeap(), 0, cmpstr);
231 /*************************************************************************
232 * SHLWAPI_DupSharedHandle
234 * Internal implemetation of SHLWAPI_11.
237 HSHARED WINAPI SHLWAPI_DupSharedHandle(HSHARED hShared, DWORD dwDstProcId,
238 DWORD dwSrcProcId, DWORD dwAccess,
242 DWORD dwMyProcId = GetCurrentProcessId();
243 HSHARED hRet = (HSHARED)NULL;
245 TRACE("(%p,%ld,%ld,%08lx,%08lx)\n", (PVOID)hShared, dwDstProcId, dwSrcProcId,
246 dwAccess, dwOptions);
248 /* Get dest process handle */
249 if (dwDstProcId == dwMyProcId)
250 hDst = GetCurrentProcess();
252 hDst = OpenProcess(PROCESS_DUP_HANDLE, 0, dwDstProcId);
256 /* Get src process handle */
257 if (dwSrcProcId == dwMyProcId)
258 hSrc = GetCurrentProcess();
260 hSrc = OpenProcess(PROCESS_DUP_HANDLE, 0, dwSrcProcId);
264 /* Make handle available to dest process */
265 if (!DuplicateHandle(hDst, (HANDLE)hShared, hSrc, &hRet,
266 dwAccess, 0, dwOptions | DUPLICATE_SAME_ACCESS))
267 hRet = (HSHARED)NULL;
269 if (dwSrcProcId != dwMyProcId)
273 if (dwDstProcId != dwMyProcId)
277 TRACE("Returning handle %p\n", (PVOID)hRet);
281 /*************************************************************************
284 * Create a block of sharable memory and initialise it with data.
287 * dwProcId [I] ID of process owning data
288 * lpvData [I] Pointer to data to write
289 * dwSize [I] Size of data
292 * Success: A shared memory handle
296 * Ordinals 7-11 provide a set of calls to create shared memory between a
297 * group of processes. The shared memory is treated opaquely in that its size
298 * is not exposed to clients who map it. This is accomplished by storing
299 * the size of the map as the first DWORD of mapped data, and then offsetting
300 * the view pointer returned by this size.
302 * SHLWAPI_7/SHLWAPI_10 - Create/Destroy the shared memory handle
303 * SHLWAPI_8/SHLWAPI_9 - Get/Release a pointer to the shared data
304 * SHLWAPI_11 - Helper function; Duplicate cross-process handles
306 HSHARED WINAPI SHLWAPI_7 (DWORD dwProcId, LPCVOID lpvData, DWORD dwSize)
310 HSHARED hRet = (HSHARED)NULL;
312 TRACE("(%ld,%p,%ld)\n", dwProcId, lpvData, dwSize);
314 /* Create file mapping of the correct length */
315 hMap = CreateFileMappingA(INVALID_HANDLE_VALUE, NULL, FILE_MAP_READ, 0,
316 dwSize + sizeof(dwSize), NULL);
320 /* Get a view in our process address space */
321 pMapped = MapViewOfFile(hMap, FILE_MAP_READ | FILE_MAP_WRITE, 0, 0, 0);
325 /* Write size of data, followed by the data, to the view */
326 *((DWORD*)pMapped) = dwSize;
328 memcpy(pMapped + sizeof(dwSize), lpvData, dwSize);
330 /* Release view. All further views mapped will be opaque */
331 UnmapViewOfFile(pMapped);
332 hRet = SHLWAPI_DupSharedHandle((HSHARED)hMap, dwProcId,
333 GetCurrentProcessId(), FILE_MAP_ALL_ACCESS,
334 DUPLICATE_SAME_ACCESS);
341 /*************************************************************************
344 * Get a pointer to a block of shared memory from a shared memory handle.
347 * hShared [I] Shared memory handle
348 * dwProcId [I] ID of process owning hShared
351 * Success: A pointer to the shared memory
357 PVOID WINAPI SHLWAPI_8 (HSHARED hShared, DWORD dwProcId)
362 TRACE("(%p %ld)\n", (PVOID)hShared, dwProcId);
364 /* Get handle to shared memory for current process */
365 hDup = SHLWAPI_DupSharedHandle(hShared, dwProcId, GetCurrentProcessId(),
366 FILE_MAP_ALL_ACCESS, 0);
368 pMapped = MapViewOfFile((HANDLE)hDup, FILE_MAP_READ | FILE_MAP_WRITE, 0, 0, 0);
372 return pMapped + sizeof(DWORD); /* Hide size */
376 /*************************************************************************
379 * Release a pointer to a block of shared memory.
382 * lpView [I] Shared memory pointer
391 BOOL WINAPI SHLWAPI_9 (LPVOID lpView)
393 TRACE("(%p)\n", lpView);
394 return UnmapViewOfFile(lpView - sizeof(DWORD)); /* Include size */
397 /*************************************************************************
400 * Destroy a block of sharable memory.
403 * hShared [I] Shared memory handle
404 * dwProcId [I] ID of process owning hShared
413 BOOL WINAPI SHLWAPI_10 (HSHARED hShared, DWORD dwProcId)
417 TRACE("(%p %ld)\n", (PVOID)hShared, dwProcId);
419 /* Get a copy of the handle for our process, closing the source handle */
420 hClose = SHLWAPI_DupSharedHandle(hShared, dwProcId, GetCurrentProcessId(),
421 FILE_MAP_ALL_ACCESS,DUPLICATE_CLOSE_SOURCE);
422 /* Close local copy */
423 return CloseHandle((HANDLE)hClose);
426 /*************************************************************************
429 * Copy a sharable memory handle from one process to another.
432 * hShared [I] Shared memory handle to duplicate
433 * dwDstProcId [I] ID of the process wanting the duplicated handle
434 * dwSrcProcId [I] ID of the process owning hShared
435 * dwAccess [I] Desired DuplicateHandle access
436 * dwOptions [I] Desired DuplicateHandle options
439 * Success: A handle suitable for use by the dwDstProcId process.
440 * Failure: A NULL handle.
445 HSHARED WINAPI SHLWAPI_11(HSHARED hShared, DWORD dwDstProcId, DWORD dwSrcProcId,
446 DWORD dwAccess, DWORD dwOptions)
450 hRet = SHLWAPI_DupSharedHandle(hShared, dwDstProcId, dwSrcProcId,
451 dwAccess, dwOptions);
455 /*************************************************************************
457 * (Used by IE4 during startup)
459 HRESULT WINAPI SHLWAPI_13 (
463 FIXME("(%p %p)stub\n",w,x);
466 /* pseudo code extracted from relay trace */
467 RegOpenKeyA(HKLM, "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\Aceepted Documents", &newkey);
472 ret = RegEnumValueA(newkey, i, a1, a2, 0, a3, 0, 0);
476 b1 = LocalAlloc(0x40, size);
480 ret = RegEnumValueA(newkey, i, a1, a2, 0, a3, a4, a5);
481 RegisterClipBoardFormatA(a4);
484 hwnd1 = GetModuleHandleA("URLMON.DLL");
485 proc = GetProcAddress(hwnd1, "CreateFormatEnumerator");
486 HeapAlloc(??, 0, 0x14);
487 HeapAlloc(??, 0, 0x50);
488 LocalAlloc(0x40, 0x78);
489 /* FIXME: bad string below */
490 lstrlenW(L"{D0FCA420-D3F5-11CF-B211-00AA004AE837}");
491 StrCpyW(a6, L"{D0FCA420-D3F5-11CF-B211-00AA004AE837}");
494 IsBadReadPtr(c1 = 0x403fd210,4);
495 InterlockedIncrement(c1+4);
498 IsBadReadPtr(c1 = 0x403fd210,4);
499 InterlockedIncrement(c1+4);
501 HeapAlloc(40350000,00000000,00000014) retval=403fd0a8;
502 HeapAlloc(40350000,00000000,00000050) retval=403feb44;
503 hwnd1 = GetModuleHandleA("URLMON.DLL");
504 proc = GetProcAddress(hwnd1, "RegisterFormatEnumerator");
505 /* 0x1a40c88c is in URLMON.DLL just before above proc
506 * content is L"_EnumFORMATETC_"
509 IsBadReadPtr(d1 = 0x1a40c88c,00000002);
512 HeapAlloc(40350000,00000000,0000001e) retval=403fed44;
513 IsBadReadPtr(d2 = 0x403fd0a8,00000004);
514 InterlockedIncrement(d2+4);
515 IsBadReadPtr(d2 = 0x403fd0a8,00000004);
516 InterlockedDecrement(d2+4);
517 IsBadReadPtr(c1,00000004);
518 InterlockedDecrement(c1+4);
519 IsBadReadPtr(c1,00000004);
520 InterlockedDecrement(c1+4);
525 /*************************************************************************
529 * Retrieves IE "AcceptLanguage" value from registry. ASCII mode.
532 HRESULT WINAPI SHLWAPI_14 (
537 DWORD mystrlen, mytype;
541 mystrlen = (*buflen > 6) ? *buflen : 6;
542 mystr = (CHAR*)HeapAlloc(GetProcessHeap(),
543 HEAP_ZERO_MEMORY, mystrlen);
544 RegOpenKeyA(HKEY_CURRENT_USER,
545 "Software\\Microsoft\\Internet Explorer\\International",
547 if (RegQueryValueExA(mykey, "AcceptLanguage",
548 0, &mytype, mystr, &mystrlen)) {
549 /* Did not find value */
550 mylcid = GetUserDefaultLCID();
551 /* somehow the mylcid translates into "en-us"
552 * this is similar to "LOCALE_SABBREVLANGNAME"
553 * which could be gotten via GetLocaleInfo.
554 * The only problem is LOCALE_SABBREVLANGUAGE" is
555 * a 3 char string (first 2 are country code and third is
556 * letter for "sublanguage", which does not come close to
559 lstrcpyA(mystr, "en-us");
560 mystrlen = lstrlenA(mystr);
563 /* handle returned string */
564 FIXME("missing code\n");
566 if (mystrlen > *buflen)
567 lstrcpynA(langbuf, mystr, *buflen);
569 lstrcpyA(langbuf, mystr);
570 *buflen = lstrlenA(langbuf);
573 HeapFree(GetProcessHeap(), 0, mystr);
574 TRACE("language is %s\n", debugstr_a(langbuf));
578 /*************************************************************************
582 * Retrieves IE "AcceptLanguage" value from registry. UNICODE mode.
585 HRESULT WINAPI SHLWAPI_15 (
590 DWORD mystrlen, mytype;
594 mystrlen = (*buflen > 6) ? *buflen : 6;
595 mystr = (CHAR*)HeapAlloc(GetProcessHeap(),
596 HEAP_ZERO_MEMORY, mystrlen);
597 RegOpenKeyA(HKEY_CURRENT_USER,
598 "Software\\Microsoft\\Internet Explorer\\International",
600 if (RegQueryValueExA(mykey, "AcceptLanguage",
601 0, &mytype, mystr, &mystrlen)) {
602 /* Did not find value */
603 mylcid = GetUserDefaultLCID();
604 /* somehow the mylcid translates into "en-us"
605 * this is similar to "LOCALE_SABBREVLANGNAME"
606 * which could be gotten via GetLocaleInfo.
607 * The only problem is LOCALE_SABBREVLANGUAGE" is
608 * a 3 char string (first 2 are country code and third is
609 * letter for "sublanguage", which does not come close to
612 lstrcpyA(mystr, "en-us");
613 mystrlen = lstrlenA(mystr);
616 /* handle returned string */
617 FIXME("missing code\n");
620 *buflen = MultiByteToWideChar(0, 0, mystr, -1, langbuf, (*buflen)-1);
621 HeapFree(GetProcessHeap(), 0, mystr);
622 TRACE("language is %s\n", debugstr_w(langbuf));
626 /*************************************************************************
629 HRESULT WINAPI SHLWAPI_16 (
635 FIXME("(%p %p %p %p)stub\n",w,x,y,z);
639 /*************************************************************************
642 * w is pointer to address of callback routine
643 * x is pointer to LPVOID to receive address of locally allocated
645 * return is 0 (unless out of memory???)
647 * related to _19, _21 and _22 below
648 * only seen invoked by SHDOCVW
650 LONG WINAPI SHLWAPI_18 (
654 FIXME("(%p %p)stub\n",w,x);
659 /*************************************************************************
662 * w is address of allocated memory from _21
663 * return is 0 (unless out of memory???)
665 * related to _18, _21 and _22 below
666 * only seen invoked by SHDOCVW
668 LONG WINAPI SHLWAPI_19 (
671 FIXME("(%p) stub\n",w);
675 /*************************************************************************
678 * w points to space allocated via .18 above
679 * LocalSize is done on it (retrieves 18)
680 * LocalReAlloc is done on it to size 8 with LMEM_MOVEABLE & LMEM_ZEROINIT
681 * x values seen 0xa0000005
684 * relates to _18, _19 and _22 above and below
685 * only seen invoked by SHDOCVW
687 LONG WINAPI SHLWAPI_21 (
691 FIXME("(%p %lx)stub\n",w,x);
695 /*************************************************************************
698 * return is 'w' value seen in x is 0xa0000005
700 * relates to _18, _19 and _21 above
701 * only seen invoked by SHDOCVW
703 LPVOID WINAPI SHLWAPI_22 (
707 FIXME("(%p %lx)stub\n",w,x);
711 /*************************************************************************
715 * converts a guid to a string
716 * returns strlen(str)
718 DWORD WINAPI SHLWAPI_23 (
719 REFGUID guid, /* [in] clsid */
720 LPSTR str, /* [out] buffer */
721 INT cmax) /* [in] size of buffer */
725 sprintf( xguid, "{%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
726 guid->Data1, guid->Data2, guid->Data3,
727 guid->Data4[0], guid->Data4[1], guid->Data4[2], guid->Data4[3],
728 guid->Data4[4], guid->Data4[5], guid->Data4[6], guid->Data4[7] );
729 TRACE("(%s %p 0x%08x)stub\n", xguid, str, cmax);
730 if (strlen(xguid)>=cmax) return 0;
732 return strlen(xguid) + 1;
735 /*************************************************************************
739 * converts a guid to a string
740 * returns strlen(str)
742 DWORD WINAPI SHLWAPI_24 (
743 REFGUID guid, /* [in] clsid */
744 LPWSTR str, /* [out] buffer */
745 INT cmax) /* [in] size of buffer */
749 sprintf( xguid, "{%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
750 guid->Data1, guid->Data2, guid->Data3,
751 guid->Data4[0], guid->Data4[1], guid->Data4[2], guid->Data4[3],
752 guid->Data4[4], guid->Data4[5], guid->Data4[6], guid->Data4[7] );
753 return MultiByteToWideChar( CP_ACP, 0, xguid, -1, str, cmax );
756 /*************************************************************************
759 * Seems to be iswalpha
761 BOOL WINAPI SHLWAPI_25(WCHAR wc)
763 return (get_char_typeW(wc) & C1_ALPHA) != 0;
766 /*************************************************************************
769 * Seems to be iswupper
771 BOOL WINAPI SHLWAPI_26(WCHAR wc)
773 return (get_char_typeW(wc) & C1_UPPER) != 0;
776 /*************************************************************************
779 * Seems to be iswlower
781 BOOL WINAPI SHLWAPI_27(WCHAR wc)
783 return (get_char_typeW(wc) & C1_LOWER) != 0;
786 /*************************************************************************
789 * Seems to be iswalnum
791 BOOL WINAPI SHLWAPI_28(WCHAR wc)
793 return (get_char_typeW(wc) & (C1_ALPHA|C1_DIGIT)) != 0;
796 /*************************************************************************
799 * Seems to be iswspace
801 BOOL WINAPI SHLWAPI_29(WCHAR wc)
803 return (get_char_typeW(wc) & C1_SPACE) != 0;
806 /*************************************************************************
809 * Seems to be iswblank
811 BOOL WINAPI SHLWAPI_30(WCHAR wc)
813 return (get_char_typeW(wc) & C1_BLANK) != 0;
816 /*************************************************************************
819 * Seems to be iswpunct
821 BOOL WINAPI SHLWAPI_31(WCHAR wc)
823 return (get_char_typeW(wc) & C1_PUNCT) != 0;
826 /*************************************************************************
829 * Seems to be iswcntrl
831 BOOL WINAPI SHLWAPI_32(WCHAR wc)
833 return (get_char_typeW(wc) & C1_CNTRL) != 0;
836 /*************************************************************************
839 * Seems to be iswdigit
841 BOOL WINAPI SHLWAPI_33(WCHAR wc)
843 return (get_char_typeW(wc) & C1_DIGIT) != 0;
846 /*************************************************************************
849 * Seems to be iswxdigit
851 BOOL WINAPI SHLWAPI_34(WCHAR wc)
853 return (get_char_typeW(wc) & C1_XDIGIT) != 0;
856 /*************************************************************************
860 BOOL WINAPI SHLWAPI_35(LPVOID p1, DWORD dw2, LPVOID p3)
862 FIXME("(%p, 0x%08lx, %p): stub\n", p1, dw2, p3);
866 /*************************************************************************
870 BOOL WINAPI SHLWAPI_36(HMENU h1, UINT ui2, UINT h3, LPCWSTR p4)
872 TRACE("(0x%08x, 0x%08x, 0x%08x, %s): stub\n",
873 h1, ui2, h3, debugstr_w(p4));
874 return AppendMenuW(h1, ui2, h3, p4);
877 /*************************************************************************
880 * Get pointer to next Unicode character.
882 LPCWSTR WINAPI SHLWAPI_40(LPCWSTR str)
884 return *str ? str + 1 : str;
887 /*************************************************************************
890 * Get the text from a given dialog item.
892 INT WINAPI SHLWAPI_74(HWND hWnd, INT nItem, LPWSTR lpsDest,INT nDestLen)
894 HWND hItem = GetDlgItem(hWnd, nItem);
897 return GetWindowTextW(hItem, lpsDest, nDestLen);
899 *lpsDest = (WCHAR)'\0';
903 /*************************************************************************
905 * Function: Compare two ASCII strings for "len" bytes.
906 * Returns: *str1-*str2 (case sensitive)
908 DWORD WINAPI SHLWAPI_151(LPSTR str1, LPSTR str2, INT len)
910 return strncmp( str1, str2, len );
913 /*************************************************************************
916 * Function: Compare two WIDE strings for "len" bytes.
917 * Returns: *str1-*str2 (case sensitive)
919 DWORD WINAPI SHLWAPI_152(LPWSTR str1, LPWSTR str2, INT len)
921 return strncmpW( str1, str2, len );
924 /*************************************************************************
926 * Function: Compare two ASCII strings for "len" bytes via caseless compare.
927 * Returns: *str1-*str2 (case insensitive)
929 DWORD WINAPI SHLWAPI_153(LPSTR str1, LPSTR str2, DWORD len)
931 return strncasecmp( str1, str2, len );
934 /*************************************************************************
937 * Function: Compare two WIDE strings for "len" bytes via caseless compare.
938 * Returns: *str1-*str2 (case insensitive)
940 DWORD WINAPI SHLWAPI_154(LPWSTR str1, LPWSTR str2, DWORD len)
942 return strncmpiW( str1, str2, len );
945 /*************************************************************************
948 * Case sensitive string compare. Does not SetLastError().
950 DWORD WINAPI SHLWAPI_156 ( LPWSTR str1, LPWSTR str2)
952 return strcmpW( str1, str2 );
955 /*************************************************************************
958 * Case insensitive string compare. Does not SetLastError(). ??
960 DWORD WINAPI SHLWAPI_158 ( LPWSTR str1, LPWSTR str2)
962 return strcmpiW( str1, str2 );
965 /*************************************************************************
968 * Ensure a multibyte character string doesn't end in a hanging lead byte.
970 DWORD WINAPI SHLWAPI_162(LPSTR lpStr, DWORD size)
974 LPSTR lastByte = lpStr + size - 1;
976 while(lpStr < lastByte)
977 lpStr += IsDBCSLeadByte(*lpStr) ? 2 : 1;
979 if(lpStr == lastByte && IsDBCSLeadByte(*lpStr))
989 /*************************************************************************
992 DWORD WINAPI SHLWAPI_164 (
1000 TRACE("(%p %p %p %p %p %p) stub\n",u,v,w,x,y,z);
1001 return 0x80004002; /* E_NOINTERFACE */
1004 /*************************************************************************
1007 * SetWindowLongA with mask.
1009 LONG WINAPI SHLWAPI_165(HWND hwnd, INT offset, UINT wFlags, UINT wMask)
1011 LONG ret = GetWindowLongA(hwnd, offset);
1012 UINT newFlags = (wFlags & wMask) | (ret & ~wFlags);
1014 if (newFlags != ret)
1015 ret = SetWindowLongA(hwnd, offset, newFlags);
1019 /*************************************************************************
1022 * Do IUnknown::Release on passed object.
1024 DWORD WINAPI SHLWAPI_169 (IUnknown ** lpUnknown)
1028 TRACE("(%p)\n",lpUnknown);
1029 if(!lpUnknown || !*((LPDWORD)lpUnknown)) return 0;
1032 TRACE("doing Release\n");
1033 return IUnknown_Release(temp);
1036 /*************************************************************************
1039 * Skip URL '//' sequence.
1041 LPCSTR WINAPI SHLWAPI_170(LPCSTR lpszSrc)
1043 if (lpszSrc && lpszSrc[0] == '/' && lpszSrc[1] == '/')
1048 /*************************************************************************
1050 * Get window handle of OLE object
1052 DWORD WINAPI SHLWAPI_172 (
1053 IUnknown *y, /* [in] OLE object interface */
1054 LPHWND z) /* [out] location to put window handle */
1059 TRACE("(%p %p)\n",y,z);
1060 if (!y) return E_FAIL;
1062 if ((ret = IUnknown_QueryInterface(y, &IID_IOleWindow,(LPVOID *)&pv)) < 0) {
1066 ret = IOleWindow_GetWindow((IOleWindow *)pv, z);
1067 IUnknown_Release(pv);
1068 TRACE("result hwnd=%08x\n", *z);
1072 /*************************************************************************
1075 * Seems to do call either IObjectWithSite::SetSite or
1076 * IPersistMoniker::GetClassID. But since we do not implement either
1077 * of those classes in our headers, we will fake it out.
1079 DWORD WINAPI SHLWAPI_174(
1080 IUnknown *p1, /* [in] OLE object */
1081 LPVOID *p2) /* [out] ptr to result of either GetClassID */
1082 /* or SetSite call. */
1086 if (!p1) return E_FAIL;
1088 /* see if SetSite interface exists for IObjectWithSite object */
1089 ret = IUnknown_QueryInterface((IUnknown *)p1, (REFIID)id1, (LPVOID *)&p1);
1090 TRACE("first IU_QI ret=%08lx, p1=%p\n", ret, p1);
1093 /* see if GetClassId interface exists for IPersistMoniker object */
1094 ret = IUnknown_QueryInterface((IUnknown *)p1, (REFIID)id2, (LPVOID *)&aa);
1095 TRACE("second IU_QI ret=%08lx, aa=%08lx\n", ret, aa);
1096 if (ret) return ret;
1098 /* fake a GetClassId call */
1099 ret = IOleWindow_GetWindow((IOleWindow *)aa, (HWND*)p2);
1100 TRACE("second IU_QI doing 0x0c ret=%08lx, *p2=%08lx\n", ret,
1102 IUnknown_Release((IUnknown *)aa);
1105 /* fake a SetSite call */
1106 ret = IOleWindow_GetWindow((IOleWindow *)p1, (HWND*)p2);
1107 TRACE("first IU_QI doing 0x0c ret=%08lx, *p2=%08lx\n", ret,
1109 IUnknown_Release((IUnknown *)p1);
1114 /*************************************************************************
1117 * Function appears to be interface to IServiceProvider::QueryService
1120 * returns E_NOINTERFACE
1122 * S_OK if _219 called successfully
1124 DWORD WINAPI SHLWAPI_176 (
1125 IUnknown* unk, /* [in] object to give Service Provider */
1126 REFGUID sid, /* [in] Service ID */
1127 REFIID riid, /* [in] Function requested */
1128 LPVOID *z) /* [out] place to save interface pointer */
1133 if (!unk) return E_FAIL;
1134 ret = IUnknown_QueryInterface(unk, &IID_IServiceProvider, &aa);
1135 TRACE("did IU_QI retval=%08lx, aa=%p\n", ret, aa);
1136 if (ret) return ret;
1137 ret = IServiceProvider_QueryService((IServiceProvider *)aa, sid, riid,
1139 TRACE("did ISP_QS retval=%08lx, *z=%p\n", ret, (LPVOID)*z);
1140 IUnknown_Release((IUnknown*)aa);
1144 /*************************************************************************
1147 * Enable or disable a menu item.
1149 UINT WINAPI SHLWAPI_181(HMENU hMenu, UINT wItemID, BOOL bEnable)
1151 return EnableMenuItem(hMenu, wItemID, bEnable ? MF_ENABLED : MF_GRAYED);
1154 /*************************************************************************
1157 * Register a window class if it isn't already.
1159 DWORD WINAPI SHLWAPI_183(WNDCLASSA *wndclass)
1162 if (GetClassInfoA(wndclass->hInstance, wndclass->lpszClassName, &wca))
1164 return (DWORD)RegisterClassA(wndclass);
1167 /*************************************************************************
1170 DWORD WINAPI SHLWAPI_193 ()
1178 ret = GetDeviceCaps(hdc, BITSPIXEL) * GetDeviceCaps(hdc, PLANES);
1183 /*************************************************************************
1186 * Copy interface pointer
1188 DWORD WINAPI SHLWAPI_199 (
1189 IUnknown **dest, /* [out] pointer to copy of interface ptr */
1190 IUnknown *src) /* [in] interface pointer */
1192 TRACE("(%p %p)\n",dest,src);
1195 IUnknown_Release(*dest);
1197 IUnknown_AddRef(src);
1204 /*************************************************************************
1207 * Some sort of memory management process - associated with _210
1209 DWORD WINAPI SHLWAPI_208 (
1216 FIXME("(0x%08lx 0x%08lx %p %p 0x%08lx) stub\n",
1221 /*************************************************************************
1224 * Some sort of memory management process - associated with _208
1226 DWORD WINAPI SHLWAPI_210 (
1231 FIXME("(%p 0x%08lx %p) stub\n",
1236 /*************************************************************************
1239 DWORD WINAPI SHLWAPI_211 (
1243 FIXME("(%p 0x%08lx) stub\n",
1248 /*************************************************************************
1254 DWORD WINAPI SHLWAPI_215 (
1261 len_a = lstrlenA(lpStrSrc);
1262 ret = MultiByteToWideChar(0, 0, lpStrSrc, len_a, lpwStrDest, len);
1263 TRACE("%s %s %d, ret=%d\n",
1264 debugstr_a(lpStrSrc), debugstr_w(lpwStrDest), len, ret);
1268 /*************************************************************************
1271 * WideCharToMultiByte with multi language support.
1273 INT WINAPI SHLWAPI_218(UINT CodePage, LPCWSTR lpSrcStr, LPSTR lpDstStr,
1274 LPINT lpnMultiCharCount)
1276 static HRESULT (WINAPI *pfnFunc)(LPDWORD,DWORD,LPCWSTR,LPINT,LPSTR,LPINT);
1277 WCHAR emptyW[] = { '\0' };
1281 if (!lpDstStr || !lpnMultiCharCount)
1289 len = strlenW(lpSrcStr) + 1;
1294 CodePage = CP_UTF8; /* Fall through... */
1295 case 0x0000C350: /* FIXME: CP_ #define */
1300 INT nWideCharCount = len - 1;
1302 GET_FUNC(mlang, "ConvertINetUnicodeToMultiByte", 0);
1303 if (!pfnFunc(&dwMode, CodePage, lpSrcStr, &nWideCharCount, lpDstStr,
1307 if (nWideCharCount < len - 1)
1309 mem = (LPSTR)HeapAlloc(GetProcessHeap(), 0, *lpnMultiCharCount);
1313 *lpnMultiCharCount = 0;
1315 if (pfnFunc(&dwMode, CodePage, lpSrcStr, &len, mem, lpnMultiCharCount))
1317 SHLWAPI_162 (mem, *lpnMultiCharCount);
1318 lstrcpynA(lpDstStr, mem, *lpnMultiCharCount + 1);
1319 return *lpnMultiCharCount + 1;
1321 HeapFree(GetProcessHeap(), 0, mem);
1322 return *lpnMultiCharCount;
1324 lpDstStr[*lpnMultiCharCount] = '\0';
1325 return *lpnMultiCharCount;
1332 reqLen = WideCharToMultiByte(CodePage, 0, lpSrcStr, len, lpDstStr,
1333 *lpnMultiCharCount, NULL, NULL);
1335 if (!reqLen && GetLastError() == ERROR_INSUFFICIENT_BUFFER)
1337 reqLen = WideCharToMultiByte(CodePage, 0, lpSrcStr, len, NULL, 0, NULL, NULL);
1340 mem = (LPSTR)HeapAlloc(GetProcessHeap(), 0, reqLen);
1343 reqLen = WideCharToMultiByte(CodePage, 0, lpSrcStr, len, mem,
1344 reqLen, NULL, NULL);
1346 reqLen = SHLWAPI_162(mem, *lpnMultiCharCount);
1349 lstrcpynA(lpDstStr, mem, *lpnMultiCharCount);
1351 HeapFree(GetProcessHeap(), 0, mem);
1358 /*************************************************************************
1361 * Hmm, some program used lpnMultiCharCount == 0x3 (and lpSrcStr was "C")
1362 * --> Crash. Something wrong here.
1364 * It seems from OE v5 that the third param is the count. (GA 11/2001)
1366 INT WINAPI SHLWAPI_217(LPCWSTR lpSrcStr, LPSTR lpDstStr, INT MultiCharCount)
1368 INT myint = MultiCharCount;
1370 return SHLWAPI_218(CP_ACP, lpSrcStr, lpDstStr, &myint);
1373 /*************************************************************************
1376 * Seems to be "super" QueryInterface. Supplied with at table of interfaces
1377 * and an array of IIDs and offsets into the table.
1380 * error codes: E_POINTER, E_NOINTERFACE
1387 HRESULT WINAPI SHLWAPI_219 (
1388 LPVOID w, /* [in] table of interfaces */
1389 IFACE_INDEX_TBL *x, /* [in] array of REFIIDs and indexes to above */
1390 REFIID riid, /* [in] REFIID to get interface for */
1391 LPVOID *z) /* [out] location to get interface pointer */
1395 IFACE_INDEX_TBL *xmove;
1397 TRACE("(%p %p %s %p)\n",
1398 w,x,debugstr_guid(riid),z);
1401 while (xmove->refid) {
1402 TRACE("trying (indx %ld) %s\n", xmove->indx,
1403 debugstr_guid(xmove->refid));
1404 if (IsEqualIID(riid, xmove->refid)) {
1405 a_vtbl = (IUnknown*)(xmove->indx + (LPBYTE)w);
1406 TRACE("matched, returning (%p)\n", a_vtbl);
1407 *z = (LPVOID)a_vtbl;
1408 IUnknown_AddRef(a_vtbl);
1414 if (IsEqualIID(riid, &IID_IUnknown)) {
1415 a_vtbl = (IUnknown*)(x->indx + (LPBYTE)w);
1416 TRACE("returning first for IUnknown (%p)\n", a_vtbl);
1417 *z = (LPVOID)a_vtbl;
1418 IUnknown_AddRef(a_vtbl);
1422 ret = E_NOINTERFACE;
1428 /*************************************************************************
1432 * securityattributes missing
1434 HANDLE WINAPI SHLWAPI_222 (LPCLSID guid)
1438 sprintf( lpstrName, "shell.{%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
1439 guid->Data1, guid->Data2, guid->Data3,
1440 guid->Data4[0], guid->Data4[1], guid->Data4[2], guid->Data4[3],
1441 guid->Data4[4], guid->Data4[5], guid->Data4[6], guid->Data4[7] );
1442 FIXME("(%s) stub\n", lpstrName);
1443 return CreateSemaphoreA(NULL,0, 0x7fffffff, lpstrName);
1446 /*************************************************************************
1450 * get the count of the semaphore
1452 DWORD WINAPI SHLWAPI_223 (HANDLE handle)
1456 FIXME("(0x%08x) stub\n",handle);
1458 ReleaseSemaphore( handle, 1, &oldCount); /* +1 */
1459 WaitForSingleObject( handle, 0 ); /* -1 */
1463 /*************************************************************************
1466 HMODULE WINAPI SHLWAPI_236 (REFIID lpUnknown)
1470 CHAR value[MAX_PATH], string[MAX_PATH];
1472 strcpy(string, "CLSID\\");
1473 strcat(string, debugstr_guid(lpUnknown));
1474 strcat(string, "\\InProcServer32");
1477 RegOpenKeyExA(HKEY_CLASSES_ROOT, string, 0, 1, &newkey);
1478 RegQueryValueExA(newkey, 0, 0, &type, value, &count);
1479 RegCloseKey(newkey);
1480 return LoadLibraryExA(value, 0, 0);
1483 /*************************************************************************
1486 * Unicode version of SHLWAPI_183.
1488 DWORD WINAPI SHLWAPI_237 (WNDCLASSW * lpWndClass)
1492 TRACE("(0x%08x %s)\n",lpWndClass->hInstance, debugstr_w(lpWndClass->lpszClassName));
1494 if (GetClassInfoW(lpWndClass->hInstance, lpWndClass->lpszClassName, &WndClass))
1496 return RegisterClassW(lpWndClass);
1499 /*************************************************************************
1502 DWORD WINAPI SHLWAPI_239(HINSTANCE hInstance, LPVOID p2, DWORD dw3)
1504 FIXME("(0x%08x %p 0x%08lx) stub\n",
1505 hInstance, p2, dw3);
1508 /* pseudo code from relay trace */
1509 WideCharToMultiByte(0, 0, L"Shell DocObject View", -1, &aa, 0x0207, 0, 0);
1510 GetClassInfoA(70fe0000,405868ec "Shell DocObject View",40586b14);
1511 /* above pair repeated for:
1512 TridentThicketUrlDlClass
1521 /*************************************************************************
1524 * Calls ASCII or Unicode WindowProc for the given window.
1526 LRESULT CALLBACK SHLWAPI_240(HWND hWnd, UINT uMessage, WPARAM wParam, LPARAM lParam)
1528 if (IsWindowUnicode(hWnd))
1529 return DefWindowProcW(hWnd, uMessage, wParam, lParam);
1530 return DefWindowProcA(hWnd, uMessage, wParam, lParam);
1533 /*************************************************************************
1537 DWORD WINAPI SHLWAPI_241 ()
1540 return /* 0xabba1243 */ 0;
1543 /*************************************************************************
1546 DWORD WINAPI SHLWAPI_266 (
1552 FIXME("(%p %p %p %p)stub\n",w,x,y,z);
1556 /*************************************************************************
1559 HRESULT WINAPI SHLWAPI_267 (
1560 LPVOID w, /* [???] NOTE: same as 1th parameter of SHLWAPI_219 */
1561 LPVOID x, /* [???] NOTE: same as 2nd parameter of SHLWAPI_219 */
1565 FIXME("(%p %p %p %p)stub\n",w,x,y,z);
1566 *((LPDWORD)z) = 0xabba1200;
1570 /*************************************************************************
1573 DWORD WINAPI SHLWAPI_268 (
1577 FIXME("(%p %p)\n",w,x);
1578 return 0xabba1251; /* 0 = failure */
1581 /*************************************************************************
1585 DWORD WINAPI SHLWAPI_276 ()
1588 return /* 0xabba1244 */ 0;
1591 /*************************************************************************
1595 HWND WINAPI SHLWAPI_278 (
1606 char * clsname = "WorkerA";
1608 FIXME("(0x%08lx 0x%08x 0x%08lx 0x%08lx 0x%08x 0x%08lx) partial stub\n",
1609 wndProc,hWndParent,dwExStyle,dwStyle,hMenu,z);
1611 hCursor = LoadCursorA(0x00000000,IDC_ARROWA);
1613 if(!GetClassInfoA(shlwapi_hInstance, clsname, &wndclass))
1615 RtlZeroMemory(&wndclass, sizeof(WNDCLASSA));
1616 wndclass.lpfnWndProc = DefWindowProcW;
1617 wndclass.cbWndExtra = 4;
1618 wndclass.hInstance = shlwapi_hInstance;
1619 wndclass.hCursor = hCursor;
1620 wndclass.hbrBackground = COLOR_BTNSHADOW;
1621 wndclass.lpszMenuName = NULL;
1622 wndclass.lpszClassName = clsname;
1623 RegisterClassA (&wndclass);
1625 hwnd = CreateWindowExA(dwExStyle, clsname, 0,dwStyle,0,0,0,0,hWndParent,
1626 hMenu,shlwapi_hInstance,0);
1627 SetWindowLongA(hwnd, 0, z);
1628 SetWindowLongA(hwnd, GWL_WNDPROC, wndProc);
1632 /*************************************************************************
1635 * Late bound call to winmm.PlaySoundW
1637 BOOL WINAPI SHLWAPI_289(LPCWSTR pszSound, HMODULE hmod, DWORD fdwSound)
1639 static BOOL (WINAPI *pfnFunc)(LPCWSTR, HMODULE, DWORD) = NULL;
1641 GET_FUNC(winmm, "PlaySoundW", FALSE);
1642 return pfnFunc(pszSound, hmod, fdwSound);
1645 /*************************************************************************
1648 BOOL WINAPI SHLWAPI_294(LPSTR str1, LPSTR str2, LPSTR pStr, DWORD some_len, LPCSTR lpStr2)
1651 * str1: "I" "I" pushl esp+0x20
1652 * str2: "U" "I" pushl 0x77c93810
1653 * (is "I" and "U" "integer" and "unsigned" ??)
1655 * pStr: "" "" pushl eax
1656 * some_len: 0x824 0x104 pushl 0x824
1657 * lpStr2: "%l" "%l" pushl esp+0xc
1659 * shlwapi. StrCpyNW(lpStr2, irrelevant_var, 0x104);
1660 * LocalAlloc(0x00, some_len) -> irrelevant_var
1661 * LocalAlloc(0x40, irrelevant_len) -> pStr
1662 * shlwapi.294(str1, str2, pStr, some_len, lpStr2);
1663 * shlwapi.PathRemoveBlanksW(pStr);
1665 ERR("('%s', '%s', '%s', %08lx, '%s'): stub!\n", str1, str2, pStr, some_len, lpStr2);
1669 /*************************************************************************
1672 * Late bound call to shell32.SHGetFileInfoW
1674 DWORD WINAPI SHLWAPI_313(LPCWSTR path, DWORD dwFileAttributes,
1675 SHFILEINFOW *psfi, UINT sizeofpsfi, UINT flags)
1677 static DWORD (WINAPI *pfnFunc)(LPCWSTR,DWORD,SHFILEINFOW*,UINT,UINT) = NULL;
1679 GET_FUNC(shell32, "SHGetFileInfoW", 0);
1680 return pfnFunc(path, dwFileAttributes, psfi, sizeofpsfi, flags);
1683 /*************************************************************************
1686 * Late bound call to shell32.DragQueryFileW
1688 UINT WINAPI SHLWAPI_318(HDROP hDrop, UINT lFile, LPWSTR lpszFile, UINT lLength)
1690 static UINT (WINAPI *pfnFunc)(HDROP, UINT, LPWSTR, UINT) = NULL;
1692 GET_FUNC(shell32, "DragQueryFileW", 0);
1693 return pfnFunc(hDrop, lFile, lpszFile, lLength);
1696 /*************************************************************************
1699 * Late bound call to shell32.SHBrowseForFolderW
1701 LPITEMIDLIST WINAPI SHLWAPI_333(LPBROWSEINFOW lpBi)
1703 static LPITEMIDLIST (WINAPI *pfnFunc)(LPBROWSEINFOW) = NULL;
1705 GET_FUNC(shell32, "SHBrowseForFolderW", NULL);
1706 return pfnFunc(lpBi);
1709 /*************************************************************************
1712 * Late bound call to shell32.SHGetPathFromIDListW
1714 BOOL WINAPI SHLWAPI_334(LPCITEMIDLIST pidl,LPWSTR pszPath)
1716 static BOOL (WINAPI *pfnFunc)(LPCITEMIDLIST, LPWSTR) = NULL;
1718 GET_FUNC(shell32, "SHGetPathFromIDListW", 0);
1719 return pfnFunc(pidl, pszPath);
1722 /*************************************************************************
1725 * Late bound call to shell32.ShellExecuteExW
1727 BOOL WINAPI SHLWAPI_335(LPSHELLEXECUTEINFOW lpExecInfo)
1729 static BOOL (WINAPI *pfnFunc)(LPSHELLEXECUTEINFOW) = NULL;
1731 GET_FUNC(shell32, "ShellExecuteExW", FALSE);
1732 return pfnFunc(lpExecInfo);
1735 /*************************************************************************
1738 * Late bound call to shell32.SHFileOperationW.
1740 DWORD WINAPI SHLWAPI_336(LPSHFILEOPSTRUCTW lpFileOp)
1742 static HICON (WINAPI *pfnFunc)(LPSHFILEOPSTRUCTW) = NULL;
1744 GET_FUNC(shell32, "SHFileOperationW", 0);
1745 return pfnFunc(lpFileOp);
1748 /*************************************************************************
1751 * Late bound call to shell32.ExtractIconExW.
1753 HICON WINAPI SHLWAPI_337(LPCWSTR lpszFile, INT nIconIndex, HICON *phiconLarge,
1754 HICON *phiconSmall, UINT nIcons)
1756 static HICON (WINAPI *pfnFunc)(LPCWSTR, INT,HICON *,HICON *, UINT) = NULL;
1758 GET_FUNC(shell32, "ExtractIconExW", (HICON)0);
1759 return pfnFunc(lpszFile, nIconIndex, phiconLarge, phiconSmall, nIcons);
1762 /*************************************************************************
1766 DWORD WINAPI SHLWAPI_342 (
1767 LPDWORD w, /* [out] location to put HKEY value??? */
1768 HKEY x, /* [in] appears to be HKEY_CURRENT_USER */
1771 FIXME("(%p 0x%08x %p)stub\n", w,x,y);
1773 return /* 0xabba1249 */ 0;
1776 /*************************************************************************
1779 DWORD WINAPI SHLWAPI_346 (
1784 FIXME("(%s %p 0x%08x)stub\n",debugstr_w(src),dest,len);
1785 lstrcpynW(dest, src, len);
1786 return lstrlenW(dest)+1;
1789 /*************************************************************************
1792 DWORD WINAPI SHLWAPI_356 (
1797 FIXME("(%p %p %p)stub\n", x,y,z);
1801 /*************************************************************************
1804 * Late bound call to shell32.SHGetNewLinkInfoW
1806 BOOL WINAPI SHLWAPI_357(LPCWSTR pszLinkTo, LPCWSTR pszDir, LPWSTR pszName,
1807 BOOL *pfMustCopy, UINT uFlags)
1809 static BOOL (WINAPI *pfnFunc)(LPCWSTR, LPCWSTR, LPCWSTR, BOOL*, UINT) = NULL;
1811 GET_FUNC(shell32, "SHGetNewLinkInfoW", FALSE);
1812 return pfnFunc(pszLinkTo, pszDir, pszName, pfMustCopy, uFlags);
1815 /*************************************************************************
1818 * Late bound call to shell32.SHDefExtractIconW
1820 DWORD WINAPI SHLWAPI_358(LPVOID arg1, LPVOID arg2, LPVOID arg3, LPVOID arg4,
1821 LPVOID arg5, LPVOID arg6)
1823 /* FIXME: Correct args */
1824 static DWORD (WINAPI *pfnFunc)(LPVOID, LPVOID, LPVOID, LPVOID, LPVOID, LPVOID) = NULL;
1826 GET_FUNC(shell32, "SHDefExtractIconW", 0);
1827 return pfnFunc(arg1, arg2, arg3, arg4, arg5, arg6);
1830 /*************************************************************************
1833 * Wrapper for lstrcpynA with src and dst swapped.
1835 DWORD WINAPI SHLWAPI_364(LPCSTR src, LPSTR dst, INT n)
1837 lstrcpynA(dst, src, n);
1841 /*************************************************************************
1844 * Late bound call to shell32.ExtractIconW
1846 HICON WINAPI SHLWAPI_370(HINSTANCE hInstance, LPCWSTR lpszExeFileName,
1849 static HICON (WINAPI *pfnFunc)(HINSTANCE, LPCWSTR, UINT) = NULL;
1851 GET_FUNC(shell32, "ExtractIconW", (HICON)0);
1852 return pfnFunc(hInstance, lpszExeFileName, nIconIndex);
1855 /*************************************************************************
1858 LANGID WINAPI SHLWAPI_376 ()
1861 /* FIXME: This should be a forward in the .spec file to the win2k function
1862 * kernel32.GetUserDefaultUILanguage, however that function isn't there yet.
1864 return GetUserDefaultLangID();
1867 /*************************************************************************
1870 * FIXME: Native appears to do DPA_Create and a DPA_InsertPtr for
1872 * FIXME: Native shows calls to:
1873 * SHRegGetUSValue for "Software\Microsoft\Internet Explorer\International"
1875 * RegOpenKeyExA for "HKLM\Software\Microsoft\Internet Explorer"
1876 * RegQueryValueExA for "LPKInstalled"
1878 * RegOpenKeyExA for "HKCU\Software\Microsoft\Internet Explorer\International"
1879 * RegQueryValueExA for "ResourceLocale"
1881 * RegOpenKeyExA for "HKLM\Software\Microsoft\Active Setup\Installed Components\{guid}"
1882 * RegQueryValueExA for "Locale"
1884 * and then tests the Locale ("en" for me).
1886 * after the code then a DPA_Create (first time) and DPA_InsertPtr are done.
1888 DWORD WINAPI SHLWAPI_377 (LPCSTR new_mod, HMODULE inst_hwnd, LPVOID z)
1890 CHAR mod_path[2*MAX_PATH];
1893 GetModuleFileNameA(inst_hwnd, mod_path, 2*MAX_PATH);
1894 ptr = strrchr(mod_path, '\\');
1896 strcpy(ptr+1, new_mod);
1897 TRACE("loading %s\n", debugstr_a(mod_path));
1898 return (DWORD)LoadLibraryA(mod_path);
1903 /*************************************************************************
1906 * This is Unicode version of .377
1908 DWORD WINAPI SHLWAPI_378 (
1909 LPCWSTR new_mod, /* [in] new module name */
1910 HMODULE inst_hwnd, /* [in] calling module handle */
1911 LPVOID z) /* [???] 4 */
1913 WCHAR mod_path[2*MAX_PATH];
1916 GetModuleFileNameW(inst_hwnd, mod_path, 2*MAX_PATH);
1917 ptr = strrchrW(mod_path, '\\');
1919 strcpyW(ptr+1, new_mod);
1920 TRACE("loading %s\n", debugstr_w(mod_path));
1921 return (DWORD)LoadLibraryW(mod_path);
1926 /*************************************************************************
1929 * Late bound call to comdlg32.GetSaveFileNameW
1931 BOOL WINAPI SHLWAPI_389(LPOPENFILENAMEW ofn)
1933 static BOOL (WINAPI *pfnFunc)(LPOPENFILENAMEW) = NULL;
1935 GET_FUNC(comdlg32, "GetSaveFileNameW", FALSE);
1936 return pfnFunc(ofn);
1939 /*************************************************************************
1942 * Late bound call to mpr.WNetRestoreConnectionW
1944 DWORD WINAPI SHLWAPI_390(LPVOID arg1, LPVOID arg2)
1946 /* FIXME: Correct args */
1947 static DWORD (WINAPI *pfnFunc)(LPVOID, LPVOID) = NULL;
1949 GET_FUNC(mpr, "WNetRestoreConnectionW", 0);
1950 return pfnFunc(arg1, arg2);
1953 /*************************************************************************
1956 * Late bound call to mpr.WNetGetLastErrorW
1958 DWORD WINAPI SHLWAPI_391(LPVOID arg1, LPVOID arg2, LPVOID arg3, LPVOID arg4,
1961 /* FIXME: Correct args */
1962 static DWORD (WINAPI *pfnFunc)(LPVOID, LPVOID, LPVOID, LPVOID, LPVOID) = NULL;
1964 GET_FUNC(mpr, "WNetGetLastErrorW", 0);
1965 return pfnFunc(arg1, arg2, arg3, arg4, arg5);
1968 /*************************************************************************
1971 * Late bound call to comdlg32.PageSetupDlgW
1973 BOOL WINAPI SHLWAPI_401(LPPAGESETUPDLGW pagedlg)
1975 static BOOL (WINAPI *pfnFunc)(LPPAGESETUPDLGW) = NULL;
1977 GET_FUNC(comdlg32, "PageSetupDlgW", FALSE);
1978 return pfnFunc(pagedlg);
1981 /*************************************************************************
1984 * Late bound call to comdlg32.PrintDlgW
1986 BOOL WINAPI SHLWAPI_402(LPPRINTDLGW printdlg)
1988 static BOOL (WINAPI *pfnFunc)(LPPRINTDLGW) = NULL;
1990 GET_FUNC(comdlg32, "PrintDlgW", FALSE);
1991 return pfnFunc(printdlg);
1994 /*************************************************************************
1997 * Late bound call to comdlg32.GetOpenFileNameW
1999 BOOL WINAPI SHLWAPI_403(LPOPENFILENAMEW ofn)
2001 static BOOL (WINAPI *pfnFunc)(LPOPENFILENAMEW) = NULL;
2003 GET_FUNC(comdlg32, "GetOpenFileNameW", FALSE);
2004 return pfnFunc(ofn);
2007 /* INTERNAL: Map from HLS color space to RGB */
2008 static WORD ConvertHue(int wHue, WORD wMid1, WORD wMid2)
2010 wHue = wHue > 240 ? wHue - 240 : wHue < 0 ? wHue + 240 : wHue;
2014 else if (wHue > 120)
2019 return ((wHue * (wMid2 - wMid1) + 20) / 40) + wMid1;
2022 /* Convert to RGB and scale into RGB range (0..255) */
2023 #define GET_RGB(h) (ConvertHue(h, wMid1, wMid2) * 255 + 120) / 240
2025 /*************************************************************************
2026 * ColorHLSToRGB [SHLWAPI.404]
2028 * Convert from HLS color space into an RGB COLORREF.
2031 * Input HLS values are constrained to the range (0..240).
2033 COLORREF WINAPI ColorHLSToRGB(WORD wHue, WORD wLuminosity, WORD wSaturation)
2039 WORD wGreen, wBlue, wMid1, wMid2;
2041 if (wLuminosity > 120)
2042 wMid2 = wSaturation + wLuminosity - (wSaturation * wLuminosity + 120) / 240;
2044 wMid2 = ((wSaturation + 240) * wLuminosity + 120) / 240;
2046 wMid1 = wLuminosity * 2 - wMid2;
2048 wRed = GET_RGB(wHue + 80);
2049 wGreen = GET_RGB(wHue);
2050 wBlue = GET_RGB(wHue - 80);
2052 return RGB(wRed, wGreen, wBlue);
2055 wRed = wLuminosity * 255 / 240;
2056 return RGB(wRed, wRed, wRed);
2059 /*************************************************************************
2062 * Function unknown seems to always to return 0
2064 DWORD WINAPI SHLWAPI_413 (DWORD x)
2066 FIXME("(0x%08lx)stub\n", x);
2070 /*************************************************************************
2073 DWORD WINAPI SHLWAPI_431 (DWORD x)
2075 FIXME("(0x%08lx)stub\n", x);
2079 /*************************************************************************
2083 * In the real shlwapi, One time initialisation calls GetVersionEx and reads
2084 * the registry to determine what O/S & Service Pack level is running, and
2085 * therefore which functions are available. Currently we always run as NT,
2086 * since this means that we don't need extra code to emulate Unicode calls,
2087 * they are forwarded directly to the appropriate API call instead.
2088 * Since the flags for whether to call or emulate Unicode are internal to
2089 * the dll, this function does not need a full implementation.
2091 DWORD WINAPI SHLWAPI_437 (DWORD functionToCall)
2093 FIXME("(0x%08lx)stub\n", functionToCall);
2094 return /* 0xabba1247 */ 0;
2097 /*************************************************************************
2098 * ColorRGBToHLS [SHLWAPI.445]
2100 * Convert from RGB COLORREF into the HLS color space.
2103 * Input HLS values are constrained to the range (0..240).
2105 VOID WINAPI ColorRGBToHLS(COLORREF drRGB, LPWORD pwHue,
2106 LPWORD wLuminance, LPWORD pwSaturation)
2112 /*************************************************************************
2113 * SHCreateShellPalette [SHLWAPI.@]
2115 HPALETTE WINAPI SHCreateShellPalette(HDC hdc)
2118 return CreateHalftonePalette(hdc);
2121 /*************************************************************************
2122 * SHGetInverseCMAP (SHLWAPI.@)
2124 DWORD WINAPI SHGetInverseCMAP (LPVOID x, DWORD why)
2126 FIXME("(%p, %#lx)stub\n", x, why);
2130 /*************************************************************************
2131 * SHIsLowMemoryMachine [SHLWAPI.@]
2133 DWORD WINAPI SHIsLowMemoryMachine (DWORD x)
2135 FIXME("0x%08lx\n", x);
2139 /*************************************************************************
2140 * GetMenuPosFromID [SHLWAPI.@]
2142 INT WINAPI GetMenuPosFromID(HMENU hMenu, UINT wID)
2145 INT nCount = GetMenuItemCount(hMenu), nIter = 0;
2147 while (nIter < nCount)
2150 if (!GetMenuItemInfoA(hMenu, nIter, TRUE, &mi) && mi.wID == wID)
2157 /*************************************************************************
2158 * _SHGetInstanceExplorer@4 [SHLWAPI.@]
2160 * Late bound call to shell32.SHGetInstanceExplorer.
2162 HRESULT WINAPI _SHGetInstanceExplorer (LPUNKNOWN *lpUnknown)
2164 static HRESULT (WINAPI *pfnFunc)(LPUNKNOWN *) = NULL;
2166 GET_FUNC(shell32, "SHGetInstanceExplorer", E_FAIL);
2167 return pfnFunc(lpUnknown);