2 * SHLWAPI ordinal functions
4 * Copyright 1997 Marcus Meissner
19 #include "wine/unicode.h"
20 #include "wine/obj_base.h"
23 #include "debugtools.h"
25 DEFAULT_DEBUG_CHANNEL(shell);
27 extern HINSTANCE shlwapi_hInstance;
28 extern HMODULE SHLWAPI_hshell32;
29 extern HMODULE SHLWAPI_hwinmm;
30 extern HMODULE SHLWAPI_hcomdlg32;
31 extern HMODULE SHLWAPI_hmpr;
32 extern HMODULE SHLWAPI_hmlang;
34 /* Macro to get function pointer for a module*/
35 #define GET_FUNC(module, name, fail) \
36 if (!SHLWAPI_h##module) SHLWAPI_h##module = LoadLibraryA(#module ".dll"); \
37 if (!SHLWAPI_h##module) return fail; \
38 if (!pfnFunc) pfnFunc = (void*)GetProcAddress(SHLWAPI_h##module, name); \
39 if (!pfnFunc) return fail
42 NOTES: Most functions exported by ordinal seem to be superflous.
43 The reason for these functions to be there is to provide a wraper
44 for unicode functions to provide these functions on systems without
45 unicode functions eg. win95/win98. Since we have such functions we just
46 call these. If running Wine with native DLL's, some late bound calls may
47 fail. However, its better to implement the functions in the forward DLL
48 and recommend the builtin rather than reimplementing the calls here!
51 /*************************************************************************
54 DWORD WINAPI SHLWAPI_1 (
58 FIXME("(%p %s %p %s)\n",lpStr, debugstr_a(lpStr),x, debugstr_a(x));
62 /*************************************************************************
65 DWORD WINAPI SHLWAPI_2 (LPCWSTR x,LPVOID y)
67 FIXME("(%s,%p)\n",debugstr_w(x),y);
71 /*************************************************************************
74 HRESULT WINAPI SHLWAPI_16 (
80 FIXME("(%p %p %p %p)stub\n",w,x,y,z);
84 /*************************************************************************
88 * converts a guid to a string
91 DWORD WINAPI SHLWAPI_23 (
92 REFGUID guid, /* [in] clsid */
93 LPSTR str, /* [out] buffer */
94 INT cmax) /* [in] size of buffer */
98 sprintf( xguid, "{%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
99 guid->Data1, guid->Data2, guid->Data3,
100 guid->Data4[0], guid->Data4[1], guid->Data4[2], guid->Data4[3],
101 guid->Data4[4], guid->Data4[5], guid->Data4[6], guid->Data4[7] );
102 TRACE("(%s %p 0x%08x)stub\n", xguid, str, cmax);
103 if (strlen(xguid)>=cmax) return 0;
105 return strlen(xguid) + 1;
108 /*************************************************************************
112 * converts a guid to a string
113 * returns strlen(str)
115 DWORD WINAPI SHLWAPI_24 (
116 REFGUID guid, /* [in] clsid */
117 LPWSTR str, /* [out] buffer */
118 INT cmax) /* [in] size of buffer */
122 sprintf( xguid, "{%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
123 guid->Data1, guid->Data2, guid->Data3,
124 guid->Data4[0], guid->Data4[1], guid->Data4[2], guid->Data4[3],
125 guid->Data4[4], guid->Data4[5], guid->Data4[6], guid->Data4[7] );
126 return MultiByteToWideChar( CP_ACP, 0, xguid, -1, str, cmax );
129 /*************************************************************************
130 * SHLWAPI_30 [SHLWAPI.30]
132 * Seems to be an isspaceW.
134 BOOL WINAPI SHLWAPI_30(LPWSTR lpcChar)
148 /*************************************************************************
151 BOOL WINAPI SHLWAPI_32(LPCWSTR lpcChar)
153 if (*lpcChar < (WCHAR)' ')
156 /* This is probably a shlwapi bug, but we do it the same for compatability */
157 if (((DWORD)lpcChar & 0xffff) - 127 <= (WCHAR)' ')
162 /*************************************************************************
165 * Get pointer to next Unicode character.
167 LPCWSTR WINAPI SHLWAPI_40(LPCWSTR str)
169 return *str ? str + 1 : str;
172 /*************************************************************************
175 * Get the text from a given dialog item.
177 INT WINAPI SHLWAPI_74(HWND hWnd, INT nItem, LPWSTR lpsDest,INT nDestLen)
179 HWND hItem = GetDlgItem(hWnd, nItem);
182 return GetWindowTextW(hItem, lpsDest, nDestLen);
184 *lpsDest = (WCHAR)'\0';
188 /*************************************************************************
191 * pStr "HTTP/1.1", dw1 0x5
193 DWORD WINAPI SHLWAPI_151(LPSTR pStr, LPVOID ptr, DWORD dw1)
195 FIXME("('%s', %p, %08lx): stub\n", pStr, ptr, dw1);
199 /*************************************************************************
202 DWORD WINAPI SHLWAPI_152(LPWSTR str1, LPWSTR str2, INT len)
207 while (--len && *str1 && *str1 == *str2)
212 return *str1 - *str2;
215 /*************************************************************************
218 DWORD WINAPI SHLWAPI_153(LPSTR str1, LPSTR str2, DWORD dw3)
220 FIXME("'%s' '%s' %08lx - stub\n", str1, str2, dw3);
224 /*************************************************************************
227 * Case sensitive string compare. Does not SetLastError().
229 DWORD WINAPI SHLWAPI_156 ( LPWSTR str1, LPWSTR str2)
231 while (*str1 && (*str1 == *str2)) { str1++; str2++; }
232 return (INT)(*str1 - *str2);
235 /*************************************************************************
238 * Ensure a multibyte character string doesn't end in a hanging lead byte.
240 DWORD WINAPI SHLWAPI_162(LPSTR lpStr, DWORD size)
244 LPSTR lastByte = lpStr + size - 1;
246 while(lpStr < lastByte)
247 lpStr += IsDBCSLeadByte(*lpStr) ? 2 : 1;
249 if(lpStr == lastByte && IsDBCSLeadByte(*lpStr))
259 /*************************************************************************
262 * SetWindowLongA with mask.
264 LONG WINAPI SHLWAPI_165(HWND hwnd, INT offset, UINT wFlags, UINT wMask)
266 LONG ret = GetWindowLongA(hwnd, offset);
267 UINT newFlags = (wFlags & wMask) | (ret & ~wFlags);
270 ret = SetWindowLongA(hwnd, offset, newFlags);
274 /*************************************************************************
277 DWORD WINAPI SHLWAPI_169 (IUnknown * lpUnknown)
279 TRACE("(%p)\n",lpUnknown);
281 if(!lpUnknown || !*((LPDWORD)lpUnknown)) return 0;
282 return IUnknown_Release(lpUnknown);
287 /*************************************************************************
290 * Skip URL '//' sequence.
292 LPCSTR WINAPI SHLWAPI_170(LPCSTR lpszSrc)
294 if (lpszSrc && lpszSrc[0] == '/' && lpszSrc[1] == '/')
299 /*************************************************************************
302 * Enable or disable a menu item.
304 UINT WINAPI SHLWAPI_181(HMENU hMenu, UINT wItemID, BOOL bEnable)
306 return EnableMenuItem(hMenu, wItemID, bEnable ? MF_ENABLED : MF_GRAYED);
309 /*************************************************************************
312 * Register a window class if it isn't already.
314 DWORD WINAPI SHLWAPI_183(WNDCLASSA *wndclass)
317 if (GetClassInfoA(wndclass->hInstance, wndclass->lpszClassName, &wca))
319 return (DWORD)RegisterClassA(wndclass);
322 /*************************************************************************
325 DWORD WINAPI SHLWAPI_193 ()
333 ret = GetDeviceCaps(hdc, BITSPIXEL) * GetDeviceCaps(hdc, PLANES);
338 /*************************************************************************
344 LPWSTR WINAPI SHLWAPI_215 (
349 WARN("(%p %p %u)\n",lpStrSrc,lpwStrDest,len);
350 return strncpyW(lpwStrDest, lpStrSrc, len);
353 /*************************************************************************
356 * WideCharToMultiByte with multi language support.
358 INT WINAPI SHLWAPI_218(UINT CodePage, LPCWSTR lpSrcStr, LPSTR lpDstStr,
359 LPINT lpnMultiCharCount)
361 static HRESULT (WINAPI *pfnFunc)(LPDWORD,DWORD,LPCWSTR,LPINT,LPSTR,LPINT);
362 WCHAR emptyW[] = { '\0' };
366 if (!lpDstStr || !lpnMultiCharCount)
374 len = strlenW(lpSrcStr) + 1;
379 CodePage = CP_UTF8; /* Fall through... */
380 case 0x0000C350: /* FIXME: CP_ #define */
385 INT nWideCharCount = len - 1;
387 GET_FUNC(mlang, "ConvertINetUnicodeToMultiByte", 0);
388 if (!pfnFunc(&dwMode, CodePage, lpSrcStr, &nWideCharCount, lpDstStr,
392 if (nWideCharCount < len - 1)
394 mem = (LPSTR)HeapAlloc(GetProcessHeap(), 0, *lpnMultiCharCount);
398 *lpnMultiCharCount = 0;
400 if (pfnFunc(&dwMode, CodePage, lpSrcStr, &len, mem, lpnMultiCharCount))
402 SHLWAPI_162 (mem, *lpnMultiCharCount);
403 lstrcpynA(lpDstStr, mem, *lpnMultiCharCount + 1);
404 return *lpnMultiCharCount + 1;
406 HeapFree(GetProcessHeap(), 0, mem);
407 return *lpnMultiCharCount;
409 lpDstStr[*lpnMultiCharCount] = '\0';
410 return *lpnMultiCharCount;
417 reqLen = WideCharToMultiByte(CodePage, 0, lpSrcStr, len, lpDstStr,
418 *lpnMultiCharCount, NULL, NULL);
420 if (!reqLen && GetLastError() == ERROR_INSUFFICIENT_BUFFER)
422 reqLen = WideCharToMultiByte(CodePage, 0, lpSrcStr, len, NULL, 0, NULL, NULL);
425 mem = (LPSTR)HeapAlloc(GetProcessHeap(), 0, reqLen);
428 reqLen = WideCharToMultiByte(CodePage, 0, lpSrcStr, len, mem,
431 reqLen = SHLWAPI_162(mem, *lpnMultiCharCount);
434 lstrcpynA(lpDstStr, mem, *lpnMultiCharCount);
436 HeapFree(GetProcessHeap(), 0, mem);
443 /*************************************************************************
446 * Hmm, some program used lpnMultiCharCount == 0x3 (and lpSrcStr was "C")
447 * --> Crash. Something wrong here.
449 INT WINAPI SHLWAPI_217(LPCWSTR lpSrcStr, LPSTR lpDstStr, LPINT lpnMultiCharCount)
451 return SHLWAPI_218(CP_ACP, lpSrcStr, lpDstStr, lpnMultiCharCount);
454 /*************************************************************************
458 * error codes: E_POINTER, E_NOINTERFACE
460 HRESULT WINAPI SHLWAPI_219 (
461 LPVOID w, /* [???] NOTE: returned by LocalAlloc, 0x450 bytes, iface */
462 LPVOID x, /* [???] */
463 REFIID riid, /* [???] e.g. IWebBrowser2 */
464 LPWSTR z) /* [???] NOTE: OUT: path */
466 FIXME("(%p %s %s %p)stub\n",w,debugstr_a(x),debugstr_guid(riid),z);
470 /*************************************************************************
474 * securityattributes missing
476 HANDLE WINAPI SHLWAPI_222 (LPCLSID guid)
480 sprintf( lpstrName, "shell.{%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
481 guid->Data1, guid->Data2, guid->Data3,
482 guid->Data4[0], guid->Data4[1], guid->Data4[2], guid->Data4[3],
483 guid->Data4[4], guid->Data4[5], guid->Data4[6], guid->Data4[7] );
484 FIXME("(%s) stub\n", lpstrName);
485 return CreateSemaphoreA(NULL,0, 0x7fffffff, lpstrName);
488 /*************************************************************************
492 * get the count of the semaphore
494 DWORD WINAPI SHLWAPI_223 (HANDLE handle)
498 FIXME("(0x%08x) stub\n",handle);
500 ReleaseSemaphore( handle, 1, &oldCount); /* +1 */
501 WaitForSingleObject( handle, 0 ); /* -1 */
505 /*************************************************************************
508 * Unicode version of SHLWAPI_183.
510 DWORD WINAPI SHLWAPI_237 (WNDCLASSW * lpWndClass)
514 TRACE("(0x%08x %s)\n",lpWndClass->hInstance, debugstr_w(lpWndClass->lpszClassName));
516 if (GetClassInfoW(lpWndClass->hInstance, lpWndClass->lpszClassName, &WndClass))
518 return RegisterClassW(lpWndClass);
521 /*************************************************************************
524 * Calls ASCII or Unicode WindowProc for the given window.
526 LRESULT CALLBACK SHLWAPI_240(HWND hWnd, UINT uMessage, WPARAM wParam, LPARAM lParam)
528 if (IsWindowUnicode(hWnd))
529 return DefWindowProcW(hWnd, uMessage, wParam, lParam);
530 return DefWindowProcA(hWnd, uMessage, wParam, lParam);
533 /*************************************************************************
537 DWORD WINAPI SHLWAPI_241 ()
543 /*************************************************************************
546 DWORD WINAPI SHLWAPI_266 (
552 FIXME("(%p %p %p %p)stub\n",w,x,y,z);
556 /*************************************************************************
559 HRESULT WINAPI SHLWAPI_267 (
560 LPVOID w, /* [???] NOTE: same as 1th parameter of SHLWAPI_219 */
561 LPVOID x, /* [???] NOTE: same as 2nd parameter of SHLWAPI_219 */
565 FIXME("(%p %p %p %p)stub\n",w,x,y,z);
566 *((LPDWORD)z) = 0xabba1200;
570 /*************************************************************************
573 DWORD WINAPI SHLWAPI_268 (
577 FIXME("(%p %p)\n",w,x);
578 return 0xabba1251; /* 0 = failure */
581 /*************************************************************************
585 DWORD WINAPI SHLWAPI_276 ()
591 /*************************************************************************
595 HWND WINAPI SHLWAPI_278 (
606 char * clsname = "WorkerA";
608 FIXME("(0x%08lx 0x%08x 0x%08lx 0x%08lx 0x%08x 0x%08lx)stub\n",
609 wndProc,hWndParent,dwExStyle,dwStyle,hMenu,z);
611 hCursor = LoadCursorA(0x00000000,IDC_ARROWA);
613 if(!GetClassInfoA(shlwapi_hInstance, clsname, &wndclass))
615 RtlZeroMemory(&wndclass, sizeof(WNDCLASSA));
616 wndclass.lpfnWndProc = DefWindowProcW;
617 wndclass.cbWndExtra = 4;
618 wndclass.hInstance = shlwapi_hInstance;
619 wndclass.hCursor = hCursor;
620 wndclass.hbrBackground = COLOR_BTNSHADOW;
621 wndclass.lpszMenuName = NULL;
622 wndclass.lpszClassName = clsname;
623 RegisterClassA (&wndclass);
625 hwnd = CreateWindowExA(dwExStyle, clsname, 0,dwStyle,0,0,0,0,hWndParent,
626 hMenu,shlwapi_hInstance,0);
627 SetWindowLongA(hwnd, 0, z);
628 SetWindowLongA(hwnd, GWL_WNDPROC, wndProc);
632 /*************************************************************************
635 * Late bound call to winmm.PlaySoundW
637 BOOL WINAPI SHLWAPI_289(LPCWSTR pszSound, HMODULE hmod, DWORD fdwSound)
639 static BOOL (WINAPI *pfnFunc)(LPCWSTR, HMODULE, DWORD) = NULL;
641 GET_FUNC(winmm, "PlaySoundW", FALSE);
642 return pfnFunc(pszSound, hmod, fdwSound);
645 /*************************************************************************
648 BOOL WINAPI SHLWAPI_294(LPSTR str1, LPSTR str2, LPSTR pStr, DWORD some_len, LPCSTR lpStr2)
651 * str1: "I" "I" pushl esp+0x20
652 * str2: "U" "I" pushl 0x77c93810
653 * (is "I" and "U" "integer" and "unsigned" ??)
655 * pStr: "" "" pushl eax
656 * some_len: 0x824 0x104 pushl 0x824
657 * lpStr2: "%l" "%l" pushl esp+0xc
659 * shlwapi. StrCpyNW(lpStr2, irrelevant_var, 0x104);
660 * LocalAlloc(0x00, some_len) -> irrelevant_var
661 * LocalAlloc(0x40, irrelevant_len) -> pStr
662 * shlwapi.294(str1, str2, pStr, some_len, lpStr2);
663 * shlwapi.PathRemoveBlanksW(pStr);
665 ERR("('%s', '%s', '%s', %08lx, '%s'): stub!\n", str1, str2, pStr, some_len, lpStr2);
669 /*************************************************************************
672 * Late bound call to shell32.SHGetFileInfoW
674 DWORD WINAPI SHLWAPI_313(LPCWSTR path, DWORD dwFileAttributes,
675 SHFILEINFOW *psfi, UINT sizeofpsfi, UINT flags)
677 static DWORD (WINAPI *pfnFunc)(LPCWSTR,DWORD,SHFILEINFOW*,UINT,UINT) = NULL;
679 GET_FUNC(shell32, "SHGetFileInfoW", 0);
680 return pfnFunc(path, dwFileAttributes, psfi, sizeofpsfi, flags);
683 /*************************************************************************
686 * Late bound call to shell32.DragQueryFileW
688 UINT WINAPI SHLWAPI_318(HDROP hDrop, UINT lFile, LPWSTR lpszFile, UINT lLength)
690 static UINT (WINAPI *pfnFunc)(HDROP, UINT, LPWSTR, UINT) = NULL;
692 GET_FUNC(shell32, "DragQueryFileW", 0);
693 return pfnFunc(hDrop, lFile, lpszFile, lLength);
696 /*************************************************************************
699 * Late bound call to shell32.SHBrowseForFolderW
701 LPITEMIDLIST WINAPI SHLWAPI_333(LPBROWSEINFOW lpBi)
703 static LPITEMIDLIST (WINAPI *pfnFunc)(LPBROWSEINFOW) = NULL;
705 GET_FUNC(shell32, "SHBrowseForFolderW", NULL);
706 return pfnFunc(lpBi);
709 /*************************************************************************
712 * Late bound call to shell32.SHGetPathFromIDListW
714 BOOL WINAPI SHLWAPI_334(LPCITEMIDLIST pidl,LPWSTR pszPath)
716 static BOOL (WINAPI *pfnFunc)(LPCITEMIDLIST, LPWSTR) = NULL;
718 GET_FUNC(shell32, "SHGetPathFromIDListW", 0);
719 return pfnFunc(pidl, pszPath);
722 /*************************************************************************
725 * Late bound call to shell32.ShellExecuteExW
727 BOOL WINAPI SHLWAPI_335(LPSHELLEXECUTEINFOW lpExecInfo)
729 static BOOL (WINAPI *pfnFunc)(LPSHELLEXECUTEINFOW) = NULL;
731 GET_FUNC(shell32, "ShellExecuteExW", FALSE);
732 return pfnFunc(lpExecInfo);
735 /*************************************************************************
738 * Late bound call to shell32.SHFileOperationW.
740 DWORD WINAPI SHLWAPI_336(LPSHFILEOPSTRUCTW lpFileOp)
742 static HICON (WINAPI *pfnFunc)(LPSHFILEOPSTRUCTW) = NULL;
744 GET_FUNC(shell32, "SHFileOperationW", 0);
745 return pfnFunc(lpFileOp);
748 /*************************************************************************
751 * Late bound call to shell32.ExtractIconExW.
753 HICON WINAPI SHLWAPI_337(LPCWSTR lpszFile, INT nIconIndex, HICON *phiconLarge,
754 HICON *phiconSmall, UINT nIcons)
756 static HICON (WINAPI *pfnFunc)(LPCWSTR, INT,HICON *,HICON *, UINT) = NULL;
758 GET_FUNC(shell32, "ExtractIconExW", (HICON)0);
759 return pfnFunc(lpszFile, nIconIndex, phiconLarge, phiconSmall, nIcons);
762 /*************************************************************************
766 DWORD WINAPI SHLWAPI_342 (
772 FIXME("(%p %p %p %p)stub\n",w,x,y,z);
776 /*************************************************************************
779 DWORD WINAPI SHLWAPI_346 (
784 FIXME("(%s %p 0x%08x)stub\n",debugstr_w(src),dest,len);
785 lstrcpynW(dest, src, len);
786 return lstrlenW(dest)+1;
789 /*************************************************************************
792 * Late bound call to shell32.SHGetNewLinkInfoW
794 BOOL WINAPI SHLWAPI_357(LPCWSTR pszLinkTo, LPCWSTR pszDir, LPWSTR pszName,
795 BOOL *pfMustCopy, UINT uFlags)
797 static BOOL (WINAPI *pfnFunc)(LPCWSTR, LPCWSTR, LPCWSTR, BOOL*, UINT) = NULL;
799 GET_FUNC(shell32, "SHGetNewLinkInfoW", FALSE);
800 return pfnFunc(pszLinkTo, pszDir, pszName, pfMustCopy, uFlags);
803 /*************************************************************************
806 * Late bound call to shell32.SHDefExtractIconW
808 DWORD WINAPI SHLWAPI_358(LPVOID arg1, LPVOID arg2, LPVOID arg3, LPVOID arg4,
809 LPVOID arg5, LPVOID arg6)
811 /* FIXME: Correct args */
812 static DWORD (WINAPI *pfnFunc)(LPVOID, LPVOID, LPVOID, LPVOID, LPVOID, LPVOID) = NULL;
814 GET_FUNC(shell32, "SHDefExtractIconW", 0);
815 return pfnFunc(arg1, arg2, arg3, arg4, arg5, arg6);
818 /*************************************************************************
821 * Wrapper for lstrcpynA with src and dst swapped.
823 DWORD WINAPI SHLWAPI_364(LPCSTR src, LPSTR dst, INT n)
825 lstrcpynA(dst, src, n);
829 /*************************************************************************
832 * Late bound call to shell32.ExtractIconW
834 HICON WINAPI SHLWAPI_370(HINSTANCE hInstance, LPCWSTR lpszExeFileName,
837 static HICON (WINAPI *pfnFunc)(HINSTANCE, LPCWSTR, UINT) = NULL;
839 GET_FUNC(shell32, "ExtractIconW", (HICON)0);
840 return pfnFunc(hInstance, lpszExeFileName, nIconIndex);
843 /*************************************************************************
846 DWORD WINAPI SHLWAPI_376 (LONG x)
848 FIXME("(0x%08lx)stub\n", x );
849 /* FIXME: This should be a forward in the .spec file to the win2k function
850 * kernel32.GetUserDefaultUILanguage, however that function isn't there yet.
855 /*************************************************************************
858 DWORD WINAPI SHLWAPI_377 (LPVOID x, LPVOID y, LPVOID z)
860 FIXME("(%p %p %p)stub\n", x,y,z);
864 /*************************************************************************
867 DWORD WINAPI SHLWAPI_378 (
869 LPVOID y, /* [???] 0x50000000 */
870 LPVOID z) /* [???] 4 */
872 FIXME("(%s %p %p)stub\n", x,y,z);
873 return LoadLibraryA(x);
876 /*************************************************************************
879 * Late bound call to comdlg32.GetSaveFileNameW
881 BOOL WINAPI SHLWAPI_389(LPOPENFILENAMEW ofn)
883 static BOOL (WINAPI *pfnFunc)(LPOPENFILENAMEW) = NULL;
885 GET_FUNC(comdlg32, "GetSaveFileNameW", FALSE);
889 /*************************************************************************
892 * Late bound call to mpr.WNetRestoreConnectionW
894 DWORD WINAPI SHLWAPI_390(LPVOID arg1, LPVOID arg2)
896 /* FIXME: Correct args */
897 static DWORD (WINAPI *pfnFunc)(LPVOID, LPVOID) = NULL;
899 GET_FUNC(mpr, "WNetRestoreConnectionW", 0);
900 return pfnFunc(arg1, arg2);
903 /*************************************************************************
906 * Late bound call to mpr.WNetGetLastErrorW
908 DWORD WINAPI SHLWAPI_391(LPVOID arg1, LPVOID arg2, LPVOID arg3, LPVOID arg4,
911 /* FIXME: Correct args */
912 static DWORD (WINAPI *pfnFunc)(LPVOID, LPVOID, LPVOID, LPVOID, LPVOID) = NULL;
914 GET_FUNC(mpr, "WNetGetLastErrorW", 0);
915 return pfnFunc(arg1, arg2, arg3, arg4, arg5);
918 /*************************************************************************
921 * Late bound call to comdlg32.PageSetupDlgW
923 BOOL WINAPI SHLWAPI_401(LPPAGESETUPDLGW pagedlg)
925 static BOOL (WINAPI *pfnFunc)(LPPAGESETUPDLGW) = NULL;
927 GET_FUNC(comdlg32, "PageSetupDlgW", FALSE);
928 return pfnFunc(pagedlg);
931 /*************************************************************************
934 * Late bound call to comdlg32.PrintDlgW
936 BOOL WINAPI SHLWAPI_402(LPPRINTDLGW printdlg)
938 static BOOL (WINAPI *pfnFunc)(LPPRINTDLGW) = NULL;
940 GET_FUNC(comdlg32, "PrintDlgW", FALSE);
941 return pfnFunc(printdlg);
944 /*************************************************************************
947 * Late bound call to comdlg32.GetOpenFileNameW
949 BOOL WINAPI SHLWAPI_403(LPOPENFILENAMEW ofn)
951 static BOOL (WINAPI *pfnFunc)(LPOPENFILENAMEW) = NULL;
953 GET_FUNC(comdlg32, "GetOpenFileNameW", FALSE);
957 /* INTERNAL: Map from HLS color space to RGB */
958 static WORD ConvertHue(int wHue, WORD wMid1, WORD wMid2)
960 wHue = wHue > 240 ? wHue - 240 : wHue < 0 ? wHue + 240 : wHue;
969 return ((wHue * (wMid2 - wMid1) + 20) / 40) + wMid1;
972 /* Convert to RGB and scale into RGB range (0..255) */
973 #define GET_RGB(h) (ConvertHue(h, wMid1, wMid2) * 255 + 120) / 240
975 /*************************************************************************
976 * ColorHLSToRGB [SHLWAPI.404]
978 * Convert from HLS color space into an RGB COLORREF.
981 * Input HLS values are constrained to the range (0..240).
983 COLORREF WINAPI ColorHLSToRGB(WORD wHue, WORD wLuminosity, WORD wSaturation)
989 WORD wGreen, wBlue, wMid1, wMid2;
991 if (wLuminosity > 120)
992 wMid2 = wSaturation + wLuminosity - (wSaturation * wLuminosity + 120) / 240;
994 wMid2 = ((wSaturation + 240) * wLuminosity + 120) / 240;
996 wMid1 = wLuminosity * 2 - wMid2;
998 wRed = GET_RGB(wHue + 80);
999 wGreen = GET_RGB(wHue);
1000 wBlue = GET_RGB(wHue - 80);
1002 return RGB(wRed, wGreen, wBlue);
1005 wRed = wLuminosity * 255 / 240;
1006 return RGB(wRed, wRed, wRed);
1009 /*************************************************************************
1012 DWORD WINAPI SHLWAPI_431 (DWORD x)
1014 FIXME("(0x%08lx)stub\n", x);
1018 /*************************************************************************
1022 * In the real shlwapi, One time initialisation calls GetVersionEx and reads
1023 * the registry to determine what O/S & Service Pack level is running, and
1024 * therefore which functions are available. Currently we always run as NT,
1025 * since this means that we don't need extra code to emulate Unicode calls,
1026 * they are forwarded directly to the appropriate API call instead.
1027 * Since the flags for whether to call or emulate Unicode are internal to
1028 * the dll, this function does not need a full implementation.
1030 DWORD WINAPI SHLWAPI_437 (DWORD functionToCall)
1032 FIXME("(0x%08lx)stub\n", functionToCall);
1036 /*************************************************************************
1037 * SHCreateShellPalette [SHLWAPI.@]
1039 HPALETTE WINAPI SHCreateShellPalette(HDC hdc)
1042 return CreateHalftonePalette(hdc);
1045 /*************************************************************************
1046 * SHGetInverseCMAP (SHLWAPI.@)
1048 DWORD WINAPI SHGetInverseCMAP (LPVOID x, DWORD why)
1050 FIXME("(%p, %#lx)stub\n", x, why);
1054 /*************************************************************************
1055 * SHIsLowMemoryMachine [SHLWAPI.@]
1057 DWORD WINAPI SHIsLowMemoryMachine (DWORD x)
1059 FIXME("0x%08lx\n", x);
1063 /*************************************************************************
1064 * GetMenuPosFromID [SHLWAPI.@]
1066 INT WINAPI GetMenuPosFromID(HMENU hMenu, UINT wID)
1069 INT nCount = GetMenuItemCount(hMenu), nIter = 0;
1071 while (nIter < nCount)
1074 if (!GetMenuItemInfoA(hMenu, nIter, TRUE, &mi) && mi.wID == wID)
1081 /*************************************************************************
1082 * _SHGetInstanceExplorer@4 [SHLWAPI.@]
1084 * Late bound call to shell32.SHGetInstanceExplorer.
1086 HRESULT WINAPI _SHGetInstanceExplorer (LPUNKNOWN *lpUnknown)
1088 static HRESULT (WINAPI *pfnFunc)(LPUNKNOWN *) = NULL;
1090 GET_FUNC(shell32, "SHGetInstanceExplorer", E_FAIL);
1091 return pfnFunc(lpUnknown);