2 * SHLWAPI ordinal functions
4 * Copyright 1997 Marcus Meissner
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 #include "wine/port.h"
38 #include "wine/unicode.h"
39 #include "wine/obj_base.h"
40 #include "wine/obj_inplace.h"
41 #include "wine/obj_serviceprovider.h"
42 #include "wine/obj_control.h"
43 #include "wine/obj_connection.h"
44 #include "wine/obj_property.h"
48 #include "wine/debug.h"
53 WINE_DEFAULT_DEBUG_CHANNEL(shell);
55 extern HINSTANCE shlwapi_hInstance;
56 extern HMODULE SHLWAPI_hshell32;
57 extern HMODULE SHLWAPI_hwinmm;
58 extern HMODULE SHLWAPI_hcomdlg32;
59 extern HMODULE SHLWAPI_hcomctl32;
60 extern HMODULE SHLWAPI_hmpr;
61 extern HMODULE SHLWAPI_hmlang;
62 extern HMODULE SHLWAPI_hversion;
64 extern DWORD SHLWAPI_ThreadRef_index;
66 typedef HANDLE HSHARED; /* Shared memory */
68 /* following is GUID for IObjectWithSite::SetSite -- see _174 */
69 static DWORD id1[4] = {0xfc4801a3, 0x11cf2ba9, 0xaa0029a2, 0x52733d00};
70 /* following is GUID for IPersistMoniker::GetClassID -- see _174 */
71 static DWORD id2[4] = {0x79eac9ee, 0x11cebaf9, 0xaa00828c, 0x0ba94b00};
73 /* The following schemes were identified in the native version of
74 * SHLWAPI.DLL version 5.50
77 URL_SCHEME_INVALID = -1,
78 URL_SCHEME_UNKNOWN = 0,
93 URL_SCHEME_JAVASCRIPT,
101 URL_SCHEME scheme_number;
105 static const SHL_2_inet_scheme shlwapi_schemes[] = {
106 {URL_SCHEME_FTP, "ftp"},
107 {URL_SCHEME_HTTP, "http"},
108 {URL_SCHEME_GOPHER, "gopher"},
109 {URL_SCHEME_MAILTO, "mailto"},
110 {URL_SCHEME_NEWS, "news"},
111 {URL_SCHEME_NNTP, "nntp"},
112 {URL_SCHEME_TELNET, "telnet"},
113 {URL_SCHEME_WAIS, "wais"},
114 {URL_SCHEME_FILE, "file"},
115 {URL_SCHEME_MK, "mk"},
116 {URL_SCHEME_HTTPS, "https"},
117 {URL_SCHEME_SHELL, "shell"},
118 {URL_SCHEME_SNEWS, "snews"},
119 {URL_SCHEME_LOCAL, "local"},
120 {URL_SCHEME_JAVASCRIPT, "javascript"},
121 {URL_SCHEME_VBSCRIPT, "vbscript"},
122 {URL_SCHEME_ABOUT, "about"},
123 {URL_SCHEME_RES, "res"},
127 /* function pointers for GET_FUNC macro; these need to be global because of gcc bug */
128 static LPITEMIDLIST (WINAPI *pSHBrowseForFolderW)(LPBROWSEINFOW);
129 static HRESULT (WINAPI *pConvertINetUnicodeToMultiByte)(LPDWORD,DWORD,LPCWSTR,LPINT,LPSTR,LPINT);
130 static BOOL (WINAPI *pPlaySoundW)(LPCWSTR, HMODULE, DWORD);
131 static DWORD (WINAPI *pSHGetFileInfoW)(LPCWSTR,DWORD,SHFILEINFOW*,UINT,UINT);
132 static UINT (WINAPI *pDragQueryFileW)(HDROP, UINT, LPWSTR, UINT);
133 static BOOL (WINAPI *pSHGetPathFromIDListW)(LPCITEMIDLIST, LPWSTR);
134 static BOOL (WINAPI *pShellExecuteExW)(LPSHELLEXECUTEINFOW);
135 static HICON (WINAPI *pSHFileOperationW)(LPSHFILEOPSTRUCTW);
136 static HICON (WINAPI *pExtractIconExW)(LPCWSTR, INT,HICON *,HICON *, UINT);
137 static BOOL (WINAPI *pSHGetNewLinkInfoW)(LPCWSTR, LPCWSTR, LPCWSTR, BOOL*, UINT);
138 static DWORD (WINAPI *pSHDefExtractIconW)(LPVOID, LPVOID, LPVOID, LPVOID, LPVOID, LPVOID); /* FIXME: Correct args */
139 static HICON (WINAPI *pExtractIconW)(HINSTANCE, LPCWSTR, UINT);
140 static BOOL (WINAPI *pGetSaveFileNameW)(LPOPENFILENAMEW);
141 static DWORD (WINAPI *pWNetRestoreConnectionW)(LPVOID, LPVOID); /* FIXME: Correct args */
142 static DWORD (WINAPI *pWNetGetLastErrorW)(LPVOID, LPVOID, LPVOID, LPVOID, LPVOID); /* FIXME: Correct args */
143 static BOOL (WINAPI *pPageSetupDlgW)(LPPAGESETUPDLGW);
144 static BOOL (WINAPI *pPrintDlgW)(LPPRINTDLGW);
145 static BOOL (WINAPI *pGetOpenFileNameW)(LPOPENFILENAMEW);
146 static DWORD (WINAPI *pGetFileVersionInfoSizeW)(LPCWSTR,LPDWORD);
147 static BOOL (WINAPI *pGetFileVersionInfoW)(LPCWSTR,DWORD,DWORD,LPVOID);
148 static WORD (WINAPI *pVerQueryValueW)(LPVOID,LPCWSTR,LPVOID*,UINT*);
149 static BOOL (WINAPI *pCOMCTL32_417)(HDC,INT,INT,UINT,const RECT*,LPCWSTR,UINT,const INT*);
150 static HRESULT (WINAPI *pDllGetVersion)(DLLVERSIONINFO*);
153 NOTES: Most functions exported by ordinal seem to be superflous.
154 The reason for these functions to be there is to provide a wrapper
155 for unicode functions to provide these functions on systems without
156 unicode functions eg. win95/win98. Since we have such functions we just
157 call these. If running Wine with native DLL's, some late bound calls may
158 fail. However, its better to implement the functions in the forward DLL
159 and recommend the builtin rather than reimplementing the calls here!
162 /*************************************************************************
165 * Identifies the Internet "scheme" in the passed string. ASCII based.
166 * Also determines start and length of item after the ':'
168 DWORD WINAPI SHLWAPI_1 (LPCSTR x, UNKNOWN_SHLWAPI_1 *y)
171 const SHL_2_inet_scheme *inet_pro;
173 y->fcncde = URL_SCHEME_INVALID;
174 if (y->size != 0x18) return E_INVALIDARG;
175 /* FIXME: leading white space generates error of 0x80041001 which
178 if (*x <= ' ') return 0x80041001;
193 /* check for no scheme in string start */
194 /* (apparently schemes *must* be larger than a single character) */
195 if ((*x == '\0') || (y->sizep1 <= 1)) {
200 /* found scheme, set length of remainder */
201 y->sizep2 = lstrlenA(y->ap2);
203 /* see if known scheme and return indicator number */
204 y->fcncde = URL_SCHEME_UNKNOWN;
205 inet_pro = shlwapi_schemes;
206 while (inet_pro->scheme_name) {
207 if (!strncasecmp(inet_pro->scheme_name, y->ap1,
208 min(y->sizep1, lstrlenA(inet_pro->scheme_name)))) {
209 y->fcncde = inet_pro->scheme_number;
217 /*************************************************************************
220 * Identifies the Internet "scheme" in the passed string. UNICODE based.
221 * Also determines start and length of item after the ':'
223 DWORD WINAPI SHLWAPI_2 (LPCWSTR x, UNKNOWN_SHLWAPI_2 *y)
226 const SHL_2_inet_scheme *inet_pro;
230 y->fcncde = URL_SCHEME_INVALID;
231 if (y->size != 0x18) return E_INVALIDARG;
232 /* FIXME: leading white space generates error of 0x80041001 which
235 if (*x <= L' ') return 0x80041001;
250 /* check for no scheme in string start */
251 /* (apparently schemes *must* be larger than a single character) */
252 if ((*x == L'\0') || (y->sizep1 <= 1)) {
257 /* found scheme, set length of remainder */
258 y->sizep2 = lstrlenW(y->ap2);
260 /* see if known scheme and return indicator number */
261 len = WideCharToMultiByte(0, 0, y->ap1, y->sizep1, 0, 0, 0, 0);
262 cmpstr = (LPSTR)HeapAlloc(GetProcessHeap(), 0, len+1);
263 WideCharToMultiByte(0, 0, y->ap1, y->sizep1, cmpstr, len+1, 0, 0);
264 y->fcncde = URL_SCHEME_UNKNOWN;
265 inet_pro = shlwapi_schemes;
266 while (inet_pro->scheme_name) {
267 if (!strncasecmp(inet_pro->scheme_name, cmpstr,
268 min(len, lstrlenA(inet_pro->scheme_name)))) {
269 y->fcncde = inet_pro->scheme_number;
274 HeapFree(GetProcessHeap(), 0, cmpstr);
278 /*************************************************************************
281 * Determine if a file exists locally and is of an executable type.
284 * lpszFile [O] File to search for
285 * dwWhich [I] Type of executable to search for
288 * TRUE If the file was found. lpszFile contains the file name.
292 * lpszPath is modified in place and must be at least MAX_PATH in length.
293 * If the function returns FALSE, the path is modified to its orginal state.
294 * If the given path contains an extension or dwWhich is 0, executable
295 * extensions are not checked.
297 * Ordinals 3-6 are a classic case of MS exposing limited functionality to
298 * users (here through PathFindOnPath) and keeping advanced functionality for
299 * their own developers exclusive use. Monopoly, anyone?
301 BOOL WINAPI SHLWAPI_3(LPSTR lpszFile,DWORD dwWhich)
303 return SHLWAPI_PathFindLocalExeA(lpszFile,dwWhich);
306 /*************************************************************************
309 * Unicode version of SHLWAPI_3.
311 BOOL WINAPI SHLWAPI_4(LPWSTR lpszFile,DWORD dwWhich)
313 return SHLWAPI_PathFindLocalExeW(lpszFile,dwWhich);
316 /*************************************************************************
319 * Search a range of paths for a specific type of executable.
322 * lpszFile [O] File to search for
323 * lppszOtherDirs [I] Other directories to look in
324 * dwWhich [I] Type of executable to search for
327 * Success: TRUE. The path to the executable is stored in sFile.
328 * Failure: FALSE. The path to the executable is unchanged.
330 BOOL WINAPI SHLWAPI_5(LPSTR lpszFile,LPCSTR *lppszOtherDirs,DWORD dwWhich)
332 return SHLWAPI_PathFindOnPathExA(lpszFile,lppszOtherDirs,dwWhich);
335 /*************************************************************************
338 * Unicode version of SHLWAPI_5.
340 BOOL WINAPI SHLWAPI_6(LPWSTR lpszFile,LPCWSTR *lppszOtherDirs,DWORD dwWhich)
342 return SHLWAPI_PathFindOnPathExW(lpszFile,lppszOtherDirs,dwWhich);
345 /*************************************************************************
346 * SHLWAPI_DupSharedHandle
348 * Internal implemetation of SHLWAPI_11.
351 HSHARED WINAPI SHLWAPI_DupSharedHandle(HSHARED hShared, DWORD dwDstProcId,
352 DWORD dwSrcProcId, DWORD dwAccess,
356 DWORD dwMyProcId = GetCurrentProcessId();
357 HSHARED hRet = (HSHARED)NULL;
359 TRACE("(%p,%ld,%ld,%08lx,%08lx)\n", (PVOID)hShared, dwDstProcId, dwSrcProcId,
360 dwAccess, dwOptions);
362 /* Get dest process handle */
363 if (dwDstProcId == dwMyProcId)
364 hDst = GetCurrentProcess();
366 hDst = OpenProcess(PROCESS_DUP_HANDLE, 0, dwDstProcId);
370 /* Get src process handle */
371 if (dwSrcProcId == dwMyProcId)
372 hSrc = GetCurrentProcess();
374 hSrc = OpenProcess(PROCESS_DUP_HANDLE, 0, dwSrcProcId);
378 /* Make handle available to dest process */
379 if (!DuplicateHandle(hDst, (HANDLE)hShared, hSrc, &hRet,
380 dwAccess, 0, dwOptions | DUPLICATE_SAME_ACCESS))
381 hRet = (HSHARED)NULL;
383 if (dwSrcProcId != dwMyProcId)
387 if (dwDstProcId != dwMyProcId)
391 TRACE("Returning handle %p\n", (PVOID)hRet);
395 /*************************************************************************
398 * Create a block of sharable memory and initialise it with data.
401 * dwProcId [I] ID of process owning data
402 * lpvData [I] Pointer to data to write
403 * dwSize [I] Size of data
406 * Success: A shared memory handle
410 * Ordinals 7-11 provide a set of calls to create shared memory between a
411 * group of processes. The shared memory is treated opaquely in that its size
412 * is not exposed to clients who map it. This is accomplished by storing
413 * the size of the map as the first DWORD of mapped data, and then offsetting
414 * the view pointer returned by this size.
416 * SHLWAPI_7/SHLWAPI_10 - Create/Destroy the shared memory handle
417 * SHLWAPI_8/SHLWAPI_9 - Get/Release a pointer to the shared data
418 * SHLWAPI_11 - Helper function; Duplicate cross-process handles
420 HSHARED WINAPI SHLWAPI_7 (DWORD dwProcId, DWORD dwSize, LPCVOID lpvData)
424 HSHARED hRet = (HSHARED)NULL;
426 TRACE("(%ld,%p,%ld)\n", dwProcId, lpvData, dwSize);
428 /* Create file mapping of the correct length */
429 hMap = CreateFileMappingA(INVALID_HANDLE_VALUE, NULL, FILE_MAP_READ, 0,
430 dwSize + sizeof(dwSize), NULL);
434 /* Get a view in our process address space */
435 pMapped = MapViewOfFile(hMap, FILE_MAP_READ | FILE_MAP_WRITE, 0, 0, 0);
439 /* Write size of data, followed by the data, to the view */
440 *((DWORD*)pMapped) = dwSize;
442 memcpy((char *) pMapped + sizeof(dwSize), lpvData, dwSize);
444 /* Release view. All further views mapped will be opaque */
445 UnmapViewOfFile(pMapped);
446 hRet = SHLWAPI_DupSharedHandle((HSHARED)hMap, dwProcId,
447 GetCurrentProcessId(), FILE_MAP_ALL_ACCESS,
448 DUPLICATE_SAME_ACCESS);
455 /*************************************************************************
458 * Get a pointer to a block of shared memory from a shared memory handle.
461 * hShared [I] Shared memory handle
462 * dwProcId [I] ID of process owning hShared
465 * Success: A pointer to the shared memory
471 PVOID WINAPI SHLWAPI_8 (HSHARED hShared, DWORD dwProcId)
476 TRACE("(%p %ld)\n", (PVOID)hShared, dwProcId);
478 /* Get handle to shared memory for current process */
479 hDup = SHLWAPI_DupSharedHandle(hShared, dwProcId, GetCurrentProcessId(),
480 FILE_MAP_ALL_ACCESS, 0);
482 pMapped = MapViewOfFile((HANDLE)hDup, FILE_MAP_READ | FILE_MAP_WRITE, 0, 0, 0);
486 return (char *) pMapped + sizeof(DWORD); /* Hide size */
490 /*************************************************************************
493 * Release a pointer to a block of shared memory.
496 * lpView [I] Shared memory pointer
505 BOOL WINAPI SHLWAPI_9 (LPVOID lpView)
507 TRACE("(%p)\n", lpView);
508 return UnmapViewOfFile((char *) lpView - sizeof(DWORD)); /* Include size */
511 /*************************************************************************
514 * Destroy a block of sharable memory.
517 * hShared [I] Shared memory handle
518 * dwProcId [I] ID of process owning hShared
527 BOOL WINAPI SHLWAPI_10 (HSHARED hShared, DWORD dwProcId)
531 TRACE("(%p %ld)\n", (PVOID)hShared, dwProcId);
533 /* Get a copy of the handle for our process, closing the source handle */
534 hClose = SHLWAPI_DupSharedHandle(hShared, dwProcId, GetCurrentProcessId(),
535 FILE_MAP_ALL_ACCESS,DUPLICATE_CLOSE_SOURCE);
536 /* Close local copy */
537 return CloseHandle((HANDLE)hClose);
540 /*************************************************************************
543 * Copy a sharable memory handle from one process to another.
546 * hShared [I] Shared memory handle to duplicate
547 * dwDstProcId [I] ID of the process wanting the duplicated handle
548 * dwSrcProcId [I] ID of the process owning hShared
549 * dwAccess [I] Desired DuplicateHandle access
550 * dwOptions [I] Desired DuplicateHandle options
553 * Success: A handle suitable for use by the dwDstProcId process.
554 * Failure: A NULL handle.
559 HSHARED WINAPI SHLWAPI_11(HSHARED hShared, DWORD dwDstProcId, DWORD dwSrcProcId,
560 DWORD dwAccess, DWORD dwOptions)
564 hRet = SHLWAPI_DupSharedHandle(hShared, dwDstProcId, dwSrcProcId,
565 dwAccess, dwOptions);
569 /*************************************************************************
572 * Create and register a clipboard enumerator for a web browser.
575 * lpBC [I] Binding context
576 * lpUnknown [I] An object exposing the IWebBrowserApp interface
580 * Failure: An HRESULT error code.
583 * The enumerator is stored as a property of the web browser. If it does not
584 * yet exist, it is created and set before being registered.
589 HRESULT WINAPI SHLWAPI_13(LPBC lpBC, IUnknown *lpUnknown)
591 FIXME("(%p,%p) stub\n", lpBC, lpUnknown);
594 /* pseudo code extracted from relay trace */
595 RegOpenKeyA(HKLM, "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\Accepted Documents", &newkey);
600 ret = RegEnumValueA(newkey, i, a1, a2, 0, a3, 0, 0);
604 b1 = LocalAlloc(0x40, size);
608 ret = RegEnumValueA(newkey, i, a1, a2, 0, a3, a4, a5);
609 RegisterClipBoardFormatA(a4);
612 hmod1 = GetModuleHandleA("URLMON.DLL");
613 proc = GetProcAddress(hmod1, "CreateFormatEnumerator");
614 HeapAlloc(??, 0, 0x14);
615 HeapAlloc(??, 0, 0x50);
616 LocalAlloc(0x40, 0x78);
617 /* FIXME: bad string below */
618 lstrlenW(L"{D0FCA420-D3F5-11CF-B211-00AA004AE837}");
619 StrCpyW(a6, L"{D0FCA420-D3F5-11CF-B211-00AA004AE837}");
622 IsBadReadPtr(c1 = 0x403fd210,4);
623 InterlockedIncrement(c1+4);
626 IsBadReadPtr(c1 = 0x403fd210,4);
627 InterlockedIncrement(c1+4);
629 HeapAlloc(40350000,00000000,00000014) retval=403fd0a8;
630 HeapAlloc(40350000,00000000,00000050) retval=403feb44;
631 hmod1 = GetModuleHandleA("URLMON.DLL");
632 proc = GetProcAddress(hmod1, "RegisterFormatEnumerator");
633 /* 0x1a40c88c is in URLMON.DLL just before above proc
634 * content is L"_EnumFORMATETC_"
637 IsBadReadPtr(d1 = 0x1a40c88c,00000002);
640 HeapAlloc(40350000,00000000,0000001e) retval=403fed44;
641 IsBadReadPtr(d2 = 0x403fd0a8,00000004);
642 InterlockedIncrement(d2+4);
643 IsBadReadPtr(d2 = 0x403fd0a8,00000004);
644 InterlockedDecrement(d2+4);
645 IsBadReadPtr(c1,00000004);
646 InterlockedDecrement(c1+4);
647 IsBadReadPtr(c1,00000004);
648 InterlockedDecrement(c1+4);
653 /*************************************************************************
656 * Get Explorers "AcceptLanguage" setting.
659 * langbuf [O] Destination for language string
660 * buflen [I] Length of langbuf
663 * Success: S_OK. langbuf is set to the language string found.
664 * Failure: E_FAIL, If any arguments are invalid, error occurred, or Explorer
665 * does not contain the setting.
667 HRESULT WINAPI SHLWAPI_14 (
672 DWORD mystrlen, mytype;
676 mystrlen = (*buflen > 6) ? *buflen : 6;
677 mystr = (CHAR*)HeapAlloc(GetProcessHeap(),
678 HEAP_ZERO_MEMORY, mystrlen);
679 RegOpenKeyA(HKEY_CURRENT_USER,
680 "Software\\Microsoft\\Internet Explorer\\International",
682 if (RegQueryValueExA(mykey, "AcceptLanguage",
683 0, &mytype, mystr, &mystrlen)) {
684 /* Did not find value */
685 mylcid = GetUserDefaultLCID();
686 /* somehow the mylcid translates into "en-us"
687 * this is similar to "LOCALE_SABBREVLANGNAME"
688 * which could be gotten via GetLocaleInfo.
689 * The only problem is LOCALE_SABBREVLANGUAGE" is
690 * a 3 char string (first 2 are country code and third is
691 * letter for "sublanguage", which does not come close to
694 lstrcpyA(mystr, "en-us");
695 mystrlen = lstrlenA(mystr);
698 /* handle returned string */
699 FIXME("missing code\n");
701 if (mystrlen > *buflen)
702 lstrcpynA(langbuf, mystr, *buflen);
704 lstrcpyA(langbuf, mystr);
705 *buflen = lstrlenA(langbuf);
708 HeapFree(GetProcessHeap(), 0, mystr);
709 TRACE("language is %s\n", debugstr_a(langbuf));
713 /*************************************************************************
716 * Unicode version of SHLWAPI_14.
718 HRESULT WINAPI SHLWAPI_15 (
723 DWORD mystrlen, mytype;
727 mystrlen = (*buflen > 6) ? *buflen : 6;
728 mystr = (CHAR*)HeapAlloc(GetProcessHeap(),
729 HEAP_ZERO_MEMORY, mystrlen);
730 RegOpenKeyA(HKEY_CURRENT_USER,
731 "Software\\Microsoft\\Internet Explorer\\International",
733 if (RegQueryValueExA(mykey, "AcceptLanguage",
734 0, &mytype, mystr, &mystrlen)) {
735 /* Did not find value */
736 mylcid = GetUserDefaultLCID();
737 /* somehow the mylcid translates into "en-us"
738 * this is similar to "LOCALE_SABBREVLANGNAME"
739 * which could be gotten via GetLocaleInfo.
740 * The only problem is LOCALE_SABBREVLANGUAGE" is
741 * a 3 char string (first 2 are country code and third is
742 * letter for "sublanguage", which does not come close to
745 lstrcpyA(mystr, "en-us");
746 mystrlen = lstrlenA(mystr);
749 /* handle returned string */
750 FIXME("missing code\n");
753 *buflen = MultiByteToWideChar(0, 0, mystr, -1, langbuf, (*buflen)-1);
754 HeapFree(GetProcessHeap(), 0, mystr);
755 TRACE("language is %s\n", debugstr_w(langbuf));
759 /*************************************************************************
763 * converts a guid to a string
764 * returns strlen(str)
766 DWORD WINAPI SHLWAPI_23 (
767 REFGUID guid, /* [in] clsid */
768 LPSTR str, /* [out] buffer */
769 INT cmax) /* [in] size of buffer */
773 sprintf( xguid, "{%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
774 guid->Data1, guid->Data2, guid->Data3,
775 guid->Data4[0], guid->Data4[1], guid->Data4[2], guid->Data4[3],
776 guid->Data4[4], guid->Data4[5], guid->Data4[6], guid->Data4[7] );
777 TRACE("(%s %p 0x%08x)stub\n", xguid, str, cmax);
778 if (strlen(xguid)>=cmax) return 0;
780 return strlen(xguid) + 1;
783 /*************************************************************************
787 * converts a guid to a string
788 * returns strlen(str)
790 DWORD WINAPI SHLWAPI_24 (
791 REFGUID guid, /* [in] clsid */
792 LPWSTR str, /* [out] buffer */
793 INT cmax) /* [in] size of buffer */
797 sprintf( xguid, "{%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
798 guid->Data1, guid->Data2, guid->Data3,
799 guid->Data4[0], guid->Data4[1], guid->Data4[2], guid->Data4[3],
800 guid->Data4[4], guid->Data4[5], guid->Data4[6], guid->Data4[7] );
801 return MultiByteToWideChar( CP_ACP, 0, xguid, -1, str, cmax );
804 /*************************************************************************
807 * Seems to be iswalpha
809 BOOL WINAPI SHLWAPI_25(WCHAR wc)
811 return (get_char_typeW(wc) & C1_ALPHA) != 0;
814 /*************************************************************************
817 * Seems to be iswupper
819 BOOL WINAPI SHLWAPI_26(WCHAR wc)
821 return (get_char_typeW(wc) & C1_UPPER) != 0;
824 /*************************************************************************
827 * Seems to be iswlower
829 BOOL WINAPI SHLWAPI_27(WCHAR wc)
831 return (get_char_typeW(wc) & C1_LOWER) != 0;
834 /*************************************************************************
837 * Seems to be iswalnum
839 BOOL WINAPI SHLWAPI_28(WCHAR wc)
841 return (get_char_typeW(wc) & (C1_ALPHA|C1_DIGIT)) != 0;
844 /*************************************************************************
847 * Seems to be iswspace
849 BOOL WINAPI SHLWAPI_29(WCHAR wc)
851 return (get_char_typeW(wc) & C1_SPACE) != 0;
854 /*************************************************************************
857 * Seems to be iswblank
859 BOOL WINAPI SHLWAPI_30(WCHAR wc)
861 return (get_char_typeW(wc) & C1_BLANK) != 0;
864 /*************************************************************************
867 * Seems to be iswpunct
869 BOOL WINAPI SHLWAPI_31(WCHAR wc)
871 return (get_char_typeW(wc) & C1_PUNCT) != 0;
874 /*************************************************************************
877 * Seems to be iswcntrl
879 BOOL WINAPI SHLWAPI_32(WCHAR wc)
881 return (get_char_typeW(wc) & C1_CNTRL) != 0;
884 /*************************************************************************
887 * Seems to be iswdigit
889 BOOL WINAPI SHLWAPI_33(WCHAR wc)
891 return (get_char_typeW(wc) & C1_DIGIT) != 0;
894 /*************************************************************************
897 * Seems to be iswxdigit
899 BOOL WINAPI SHLWAPI_34(WCHAR wc)
901 return (get_char_typeW(wc) & C1_XDIGIT) != 0;
904 /*************************************************************************
908 BOOL WINAPI SHLWAPI_35(LPVOID p1, DWORD dw2, LPVOID p3)
910 FIXME("(%p, 0x%08lx, %p): stub\n", p1, dw2, p3);
914 /*************************************************************************
917 * Insert a bitmap menu item at the bottom of a menu.
920 * hMenu [I] Menu to insert into
921 * flags [I] Flags for insertion
922 * id [I] Menu ID of the item
923 * str [I] Menu text for the item
926 * Success: TRUE, the item is inserted into the menu
927 * Failure: FALSE, if any parameter is invalid
929 BOOL WINAPI SHLWAPI_36(HMENU hMenu, UINT flags, UINT id, LPCWSTR str)
931 TRACE("(0x%08x,0x%08x,0x%08x,%s)\n",hMenu, flags, id, debugstr_w(str));
932 return InsertMenuW(hMenu, -1, flags | MF_BITMAP, id, str);
935 /*************************************************************************
938 * Get the text from a given dialog item.
941 * hWnd [I] Handle of dialog
942 * nItem [I] Index of item
943 * lpsDest [O] Buffer for receiving window text
944 * nDestLen [I] Length of buffer.
947 * Success: The length of the returned text.
950 INT WINAPI SHLWAPI_74(HWND hWnd, INT nItem, LPWSTR lpsDest,INT nDestLen)
952 HWND hItem = GetDlgItem(hWnd, nItem);
955 return GetWindowTextW(hItem, lpsDest, nDestLen);
957 *lpsDest = (WCHAR)'\0';
961 /*************************************************************************
964 * Set the text of a given dialog item.
967 * hWnd [I] Handle of dialog
968 * iItem [I] Index of item
969 * lpszText [O] Text to set
972 * Success: TRUE. The text of the dialog is set to lpszText.
973 * Failure: FALSE, Otherwise.
975 BOOL WINAPI SHLWAPI_138(HWND hWnd, INT iItem, LPCWSTR lpszText)
977 HWND hWndItem = GetDlgItem(hWnd, iItem);
979 return SetWindowTextW(hWndItem, lpszText);
983 /*************************************************************************
985 * Function: Compare two ASCII strings for "len" bytes.
986 * Returns: *str1-*str2 (case sensitive)
988 DWORD WINAPI SHLWAPI_151(LPCSTR str1, LPCSTR str2, INT len)
990 return strncmp( str1, str2, len );
993 /*************************************************************************
996 * Function: Compare two WIDE strings for "len" bytes.
997 * Returns: *str1-*str2 (case sensitive)
999 DWORD WINAPI SHLWAPI_152(LPCWSTR str1, LPCWSTR str2, INT len)
1001 return strncmpW( str1, str2, len );
1004 /*************************************************************************
1006 * Function: Compare two ASCII strings for "len" bytes via caseless compare.
1007 * Returns: *str1-*str2 (case insensitive)
1009 DWORD WINAPI SHLWAPI_153(LPCSTR str1, LPCSTR str2, DWORD len)
1011 return strncasecmp( str1, str2, len );
1014 /*************************************************************************
1017 * Function: Compare two WIDE strings for "len" bytes via caseless compare.
1018 * Returns: *str1-*str2 (case insensitive)
1020 DWORD WINAPI SHLWAPI_154(LPCWSTR str1, LPCWSTR str2, DWORD len)
1022 return strncmpiW( str1, str2, len );
1025 /*************************************************************************
1028 * Case sensitive string compare (ASCII). Does not SetLastError().
1030 DWORD WINAPI SHLWAPI_155(LPCSTR str1, LPCSTR str2)
1032 return strcmp(str1, str2);
1035 /*************************************************************************
1038 * Case sensitive string compare. Does not SetLastError().
1040 DWORD WINAPI SHLWAPI_156(LPCWSTR str1, LPCWSTR str2)
1042 return strcmpW( str1, str2 );
1045 /*************************************************************************
1048 * Case insensitive string compare (ASCII). Does not SetLastError().
1050 DWORD WINAPI SHLWAPI_157(LPCSTR str1, LPCSTR str2)
1052 return strcasecmp(str1, str2);
1054 /*************************************************************************
1057 * Case insensitive string compare. Does not SetLastError(). ??
1059 DWORD WINAPI SHLWAPI_158 (LPCWSTR str1, LPCWSTR str2)
1061 return strcmpiW( str1, str2 );
1064 /*************************************************************************
1067 * Remove a hanging lead byte from the end of a string, if present.
1070 * lpStr [I] String to check for a hanging lead byte
1071 * size [I] Length of lpszStr
1074 * Success: The new size of the string. Any hanging lead bytes are removed.
1075 * Failure: 0, if any parameters are invalid.
1077 DWORD WINAPI SHLWAPI_162(LPSTR lpStr, DWORD size)
1081 LPSTR lastByte = lpStr + size - 1;
1083 while(lpStr < lastByte)
1084 lpStr += IsDBCSLeadByte(*lpStr) ? 2 : 1;
1086 if(lpStr == lastByte && IsDBCSLeadByte(*lpStr))
1096 /*************************************************************************
1099 * Call IOleCommandTarget::QueryStatus() on an object.
1102 * lpUnknown [I] Object supporting the IOleCommandTarget interface
1103 * pguidCmdGroup [I] GUID for the command group
1105 * prgCmds [O] Commands
1106 * pCmdText [O] Command text
1110 * Failure: E_FAIL, if lpUnknown is NULL.
1111 * E_NOINTERFACE, if lpUnknown does not support IOleCommandTarget.
1112 * Otherwise, an error code from IOleCommandTarget::QueryStatus().
1114 HRESULT WINAPI SHLWAPI_163(IUnknown* lpUnknown, REFGUID pguidCmdGroup,
1115 ULONG cCmds, OLECMD *prgCmds, OLECMDTEXT* pCmdText)
1117 HRESULT hRet = E_FAIL;
1119 TRACE("(%p,%p,%ld,%p,%p)\n",lpUnknown, pguidCmdGroup, cCmds, prgCmds, pCmdText);
1123 IOleCommandTarget* lpOle;
1125 hRet = IUnknown_QueryInterface(lpUnknown, &IID_IOleCommandTarget,
1128 if (SUCCEEDED(hRet) && lpOle)
1130 hRet = IOleCommandTarget_QueryStatus(lpOle, pguidCmdGroup, cCmds,
1132 IOleCommandTarget_Release(lpOle);
1138 /*************************************************************************
1141 * Call IOleCommandTarget::Exec() on an object.
1144 * lpUnknown [I] Object supporting the IOleCommandTarget interface
1145 * pguidCmdGroup [I] GUID for the command group
1149 * Failure: E_FAIL, if lpUnknown is NULL.
1150 * E_NOINTERFACE, if lpUnknown does not support IOleCommandTarget.
1151 * Otherwise, an error code from IOleCommandTarget::Exec().
1153 HRESULT WINAPI SHLWAPI_164(IUnknown* lpUnknown, REFGUID pguidCmdGroup,
1154 DWORD nCmdID, DWORD nCmdexecopt, VARIANT* pvaIn,
1157 HRESULT hRet = E_FAIL;
1159 TRACE("(%p,%p,%ld,%ld,%p,%p)\n",lpUnknown, pguidCmdGroup, nCmdID,
1160 nCmdexecopt, pvaIn, pvaOut);
1164 IOleCommandTarget* lpOle;
1166 hRet = IUnknown_QueryInterface(lpUnknown, &IID_IOleCommandTarget,
1168 if (SUCCEEDED(hRet) && lpOle)
1170 hRet = IOleCommandTarget_Exec(lpOle, pguidCmdGroup, nCmdID,
1171 nCmdexecopt, pvaIn, pvaOut);
1172 IOleCommandTarget_Release(lpOle);
1178 /*************************************************************************
1181 * Retrieve, modify, and re-set a value from a window.
1184 * hWnd [I] Windows to get value from
1185 * offset [I] Offset of value
1186 * wMask [I] Mask for uiFlags
1187 * wFlags [I] Bits to set in window value
1190 * The new value as it was set, or 0 if any parameter is invalid.
1193 * Any bits set in uiMask are cleared from the value, then any bits set in
1194 * uiFlags are set in the value.
1196 LONG WINAPI SHLWAPI_165(HWND hwnd, INT offset, UINT wMask, UINT wFlags)
1198 LONG ret = GetWindowLongA(hwnd, offset);
1199 UINT newFlags = (wFlags & wMask) | (ret & ~wFlags);
1201 if (newFlags != ret)
1202 ret = SetWindowLongA(hwnd, offset, newFlags);
1206 /*************************************************************************
1209 * Change a windows parent.
1212 * hWnd [I] Window to change parent of
1213 * hWndParent [I] New parent window
1219 * If hWndParent is NULL (desktop), the window style is changed to WS_POPUP.
1221 DWORD WINAPI SHLWAPI_167(HWND hWnd, HWND hWndParent)
1223 FIXME("0x%08x,0x%08x\n", hWnd, hWndParent);
1227 /*************************************************************************
1230 * Locate and advise a connection point in an IConnectionPointContainer.
1233 * lpUnkSink [I] Sink for the connection point advise call
1234 * riid [I] REFIID of connection point to advise
1235 * bAdviseOnly [I] TRUE = Advise only, FALSE = Unadvise first
1236 * lpUnknown [I] Object supporting the IConnectionPointContainer interface
1237 * lpCookie [O] Pointer to connection point cookie
1238 * lppCP [O] Destination for the IConnectionPoint found
1241 * Success: S_OK. If lppCP is non-NULL, it is filled with the IConnectionPoint
1242 * that was advised. The caller is responsable for releasing it.
1243 * Failure: E_FAIL, if any arguments are invalid.
1244 * E_NOINTERFACE, if lpUnknown isn't an IConnectionPointContainer,
1245 * Or an HRESULT error code if any call fails.
1247 HRESULT WINAPI SHLWAPI_168(IUnknown* lpUnkSink, REFIID riid, BOOL bAdviseOnly,
1248 IUnknown* lpUnknown, LPDWORD lpCookie,
1249 IConnectionPoint **lppCP)
1252 IConnectionPointContainer* lpContainer;
1253 IConnectionPoint *lpCP;
1255 if(!lpUnknown || (bAdviseOnly && !lpUnkSink))
1261 hRet = IUnknown_QueryInterface(lpUnknown, &IID_IConnectionPointContainer,
1262 (void**)&lpContainer);
1263 if (SUCCEEDED(hRet))
1265 hRet = IConnectionPointContainer_FindConnectionPoint(lpContainer, riid, &lpCP);
1267 if (SUCCEEDED(hRet))
1270 hRet = IConnectionPoint_Unadvise(lpCP, *lpCookie);
1271 hRet = IConnectionPoint_Advise(lpCP, lpUnkSink, lpCookie);
1276 if (lppCP && SUCCEEDED(hRet))
1277 *lppCP = lpCP; /* Caller keeps the interface */
1279 IConnectionPoint_Release(lpCP); /* Release it */
1282 IUnknown_Release(lpContainer);
1287 /*************************************************************************
1291 * Release an interface.
1294 * lpUnknown [I] Object to release
1299 DWORD WINAPI SHLWAPI_169 (IUnknown ** lpUnknown)
1303 TRACE("(%p)\n",lpUnknown);
1304 if(!lpUnknown || !*((LPDWORD)lpUnknown)) return 0;
1307 TRACE("doing Release\n");
1308 return IUnknown_Release(temp);
1311 /*************************************************************************
1314 * Skip '//' if present in a string.
1317 * lpszSrc [I] String to check for '//'
1320 * Success: The next character after the '//' or the string if not present
1321 * Failure: NULL, if lpszStr is NULL.
1323 LPCSTR WINAPI SHLWAPI_170(LPCSTR lpszSrc)
1325 if (lpszSrc && lpszSrc[0] == '/' && lpszSrc[1] == '/')
1330 /*************************************************************************
1335 BOOL WINAPI SHLWAPI_171(LPVOID x, LPVOID y)
1337 FIXME("%p %p\n",x,y);
1341 /*************************************************************************
1344 * Get the window handle of an object.
1347 * lpUnknown [I] Object to get the window handle of
1348 * lphWnd [O] Destination for window handle
1351 * Success: S_OK. lphWnd contains the objects window handle.
1352 * Failure: An HRESULT error code.
1355 * lpUnknown is expected to support one of the following interfaces:
1357 * IInternetSecurityMgrSite
1360 HRESULT WINAPI SHLWAPI_172(IUnknown *lpUnknown, LPHWND lphWnd)
1362 /* FIXME: Wine has no header for this object */
1363 static const GUID IID_IInternetSecurityMgrSite = { 0x79eac9ed,
1364 0xbaf9, 0x11ce, { 0x8c, 0x82, 0x00, 0xaa, 0x00, 0x4b, 0xa9, 0x0b }};
1366 HRESULT hRet = E_FAIL;
1368 TRACE("(%p,%p)\n", lpUnknown, lphWnd);
1373 hRet = IUnknown_QueryInterface(lpUnknown, &IID_IOleWindow, (void**)&lpOle);
1377 hRet = IUnknown_QueryInterface(lpUnknown,&IID_IShellView, (void**)&lpOle);
1381 hRet = IUnknown_QueryInterface(lpUnknown, &IID_IInternetSecurityMgrSite,
1386 if (SUCCEEDED(hRet))
1388 /* Lazyness here - Since GetWindow() is the first method for the above 3
1389 * interfaces, we use the same call for them all.
1391 hRet = IOleWindow_GetWindow((IOleWindow*)lpOle, lphWnd);
1392 IUnknown_Release(lpOle);
1394 TRACE("Returning HWND=%08x\n", *lphWnd);
1400 /*************************************************************************
1403 * Seems to do call either IObjectWithSite::SetSite or
1404 * IPersistMoniker::GetClassID. But since we do not implement either
1405 * of those classes in our headers, we will fake it out.
1407 DWORD WINAPI SHLWAPI_174(
1408 IUnknown *p1, /* [in] OLE object */
1409 LPVOID *p2) /* [out] ptr to result of either GetClassID
1414 if (!p1) return E_FAIL;
1416 /* see if SetSite interface exists for IObjectWithSite object */
1417 ret = IUnknown_QueryInterface((IUnknown *)p1, (REFIID)id1, (LPVOID *)&p1);
1418 TRACE("first IU_QI ret=%08lx, p1=%p\n", ret, p1);
1421 /* see if GetClassId interface exists for IPersistMoniker object */
1422 ret = IUnknown_QueryInterface((IUnknown *)p1, (REFIID)id2, (LPVOID *)&aa);
1423 TRACE("second IU_QI ret=%08lx, aa=%08lx\n", ret, aa);
1424 if (ret) return ret;
1426 /* fake a GetClassId call */
1427 ret = IOleWindow_GetWindow((IOleWindow *)aa, (HWND*)p2);
1428 TRACE("second IU_QI doing 0x0c ret=%08lx, *p2=%08lx\n", ret,
1430 IUnknown_Release((IUnknown *)aa);
1433 /* fake a SetSite call */
1434 ret = IOleWindow_GetWindow((IOleWindow *)p1, (HWND*)p2);
1435 TRACE("first IU_QI doing 0x0c ret=%08lx, *p2=%08lx\n", ret,
1437 IUnknown_Release((IUnknown *)p1);
1442 /*************************************************************************
1445 * Call IPersist::GetClassID on an object.
1448 * lpUnknown [I] Object supporting the IPersist interface
1449 * lpClassId [O] Destination for Class Id
1452 * Success: S_OK. lpClassId contains the Class Id requested.
1453 * Failure: E_FAIL, If lpUnknown is NULL,
1454 * E_NOINTERFACE If lpUnknown does not support IPersist,
1455 * Or an HRESULT error code.
1457 HRESULT WINAPI SHLWAPI_175 (IUnknown *lpUnknown, CLSID* lpClassId)
1459 IPersist* lpPersist;
1460 HRESULT hRet = E_FAIL;
1462 TRACE("(%p,%p)\n", lpUnknown, debugstr_guid(lpClassId));
1466 hRet = IUnknown_QueryInterface(lpUnknown,&IID_IPersist,(void**)&lpPersist);
1467 if (SUCCEEDED(hRet))
1469 IPersist_GetClassID(lpPersist, lpClassId);
1470 IPersist_Release(lpPersist);
1476 /*************************************************************************
1479 * Retrieve a Service Interface from an object.
1482 * lpUnknown [I] Object to get an IServiceProvider interface from
1483 * sid [I] Service ID for QueryService call
1484 * riid [I] Function requested for QueryService call
1485 * lppOut [O] Destination for the service interface pointer
1487 * Function appears to be interface to IServiceProvider::QueryService
1490 * Success: S_OK. lppOut contains an object providing the requested service
1491 * Failure: An HRESULT error code
1494 * lpUnknown is expected to support the IServiceProvider interface.
1496 HRESULT WINAPI SHLWAPI_176(IUnknown* lpUnknown, REFGUID sid, REFIID riid,
1499 IServiceProvider* pService = NULL;
1510 /* Get an IServiceProvider interface from the object */
1511 hRet = IUnknown_QueryInterface(lpUnknown, &IID_IServiceProvider,
1512 (LPVOID*)&pService);
1514 if (!hRet && pService)
1516 TRACE("QueryInterface returned (IServiceProvider*)%p\n", pService);
1518 /* Get a Service interface from the object */
1519 hRet = IServiceProvider_QueryService(pService, sid, riid, lppOut);
1521 TRACE("(IServiceProvider*)%p returned (IUnknown*)%p\n", pService, *lppOut);
1523 /* Release the IServiceProvider interface */
1524 IUnknown_Release(pService);
1529 /*************************************************************************
1532 * Remove all sub-menus from a menu.
1535 * hMenu [I] Menu to remove sub-menus from
1538 * Success: 0. All sub-menus under hMenu are removed
1539 * Failure: -1, if any parameter is invalid
1541 DWORD WINAPI SHLWAPI_180(HMENU hMenu)
1543 int iItemCount = GetMenuItemCount(hMenu) - 1;
1544 while (iItemCount >= 0)
1546 HMENU hSubMenu = GetSubMenu(hMenu, iItemCount);
1548 RemoveMenu(hMenu, iItemCount, 0x400);
1554 /*************************************************************************
1557 * Enable or disable a menu item.
1560 * hMenu [I] Menu holding menu item
1561 * uID [I] ID of menu item to enable/disable
1562 * bEnable [I] Whether to enable (TRUE) or disable (FALSE) the item.
1565 * The return code from CheckMenuItem.
1567 UINT WINAPI SHLWAPI_181(HMENU hMenu, UINT wItemID, BOOL bEnable)
1569 return EnableMenuItem(hMenu, wItemID, bEnable ? MF_ENABLED : MF_GRAYED);
1572 /*************************************************************************
1575 * Check or uncheck a menu item.
1578 * hMenu [I] Menu holding menu item
1579 * uID [I] ID of menu item to check/uncheck
1580 * bCheck [I] Whether to check (TRUE) or uncheck (FALSE) the item.
1583 * The return code from CheckMenuItem.
1585 DWORD WINAPI SHLWAPI_182(HMENU hMenu, UINT uID, BOOL bCheck)
1587 return CheckMenuItem(hMenu, uID, bCheck ? MF_CHECKED : 0);
1590 /*************************************************************************
1593 * Register a window class if it isn't already.
1596 * lpWndClass [I] Window class to register
1599 * The result of the RegisterClassA call.
1601 DWORD WINAPI SHLWAPI_183(WNDCLASSA *wndclass)
1604 if (GetClassInfoA(wndclass->hInstance, wndclass->lpszClassName, &wca))
1606 return (DWORD)RegisterClassA(wndclass);
1609 /*************************************************************************
1612 * Call IPersistPropertyBag::Load on an object.
1615 * lpUnknown [I] Object supporting the IPersistPropertyBag interface
1616 * lpPropBag [O] Destination for loaded IPropertyBag
1620 * Failure: An HRESULT error code, or E_FAIL if lpUnknown is NULL.
1622 DWORD WINAPI SHLWAPI_187(IUnknown *lpUnknown, IPropertyBag* lpPropBag)
1624 IPersistPropertyBag* lpPPBag;
1625 HRESULT hRet = E_FAIL;
1627 TRACE("(%p,%p)\n", lpUnknown, lpPropBag);
1631 hRet = IUnknown_QueryInterface(lpUnknown, &IID_IPersistPropertyBag,
1633 if (SUCCEEDED(hRet) && lpPPBag)
1635 hRet = IPersistPropertyBag_Load(lpPPBag, lpPropBag, NULL);
1636 IPersistPropertyBag_Release(lpPPBag);
1642 /*************************************************************************
1645 * _IUnknown_OnFocusOCS
1647 DWORD WINAPI SHLWAPI_189(LPVOID x, LPVOID y)
1649 FIXME("%p %p\n", x, y);
1653 /*************************************************************************
1656 * Get the color depth of the primary display.
1662 * The color depth of the primary display.
1664 DWORD WINAPI SHLWAPI_193 ()
1672 ret = GetDeviceCaps(hdc, BITSPIXEL) * GetDeviceCaps(hdc, PLANES);
1677 /*************************************************************************
1680 * Blank out a region of text by drawing the background only.
1683 * hDC [I] Device context to draw in
1684 * pRect [I] Area to draw in
1685 * cRef [I] Color to draw in
1690 DWORD WINAPI SHLWAPI_197(HDC hDC, LPCRECT pRect, COLORREF cRef)
1692 COLORREF cOldColor = SetBkColor(hDC, cRef);
1693 ExtTextOutA(hDC, 0, 0, ETO_OPAQUE, pRect, 0, 0, 0);
1694 SetBkColor(hDC, cOldColor);
1698 /*************************************************************************
1701 * Copy interface pointer
1704 * lppDest [O] Destination for copy
1705 * lpUnknown [I] Source for copy
1710 VOID WINAPI SHLWAPI_199(IUnknown **lppDest, IUnknown *lpUnknown)
1712 TRACE("(%p,%p)\n", lppDest, lpUnknown);
1715 SHLWAPI_169(lppDest); /* Release existing interface */
1720 IUnknown_AddRef(lpUnknown);
1721 *lppDest = lpUnknown;
1725 /*************************************************************************
1729 HRESULT WINAPI SHLWAPI_201(IUnknown* lpUnknown, INT iUnk, REFGUID pguidCmdGroup,
1730 DWORD nCmdID, DWORD nCmdexecopt, VARIANT* pvaIn,
1733 FIXME("(%p,%d,%p,%ld,%ld,%p,%p) - stub!\n", lpUnknown, iUnk, pguidCmdGroup,
1734 nCmdID, nCmdexecopt, pvaIn, pvaOut);
1735 return DRAGDROP_E_NOTREGISTERED;
1738 /*************************************************************************
1742 HRESULT WINAPI SHLWAPI_202(REFGUID pguidCmdGroup,ULONG cCmds, OLECMD *prgCmds)
1744 FIXME("(%p,%ld,%p) - stub!\n", pguidCmdGroup, cCmds, prgCmds);
1745 return DRAGDROP_E_NOTREGISTERED;
1748 /*************************************************************************
1752 VOID WINAPI SHLWAPI_203(LPCSTR lpszStr)
1754 FIXME("(%s) - stub!\n", debugstr_a(lpszStr));
1757 /*************************************************************************
1760 * Determine if a window is not a child of another window.
1763 * hParent [I] Suspected parent window
1764 * hChild [I] Suspected child window
1767 * TRUE: If hChild is a child window of hParent
1768 * FALSE: If hChild is not a child window of hParent, or they are equal
1770 BOOL WINAPI SHLWAPI_204(HWND hParent, HWND hChild)
1772 TRACE("(%08x,%08x)\n", hParent, hChild);
1774 if (!hParent || !hChild)
1776 else if(hParent == hChild)
1778 return !IsChild(hParent, hChild);
1781 /*************************************************************************
1784 * Some sort of memory management process - associated with _210
1786 DWORD WINAPI SHLWAPI_208 (
1793 FIXME("(0x%08lx 0x%08lx %p %p 0x%08lx) stub\n",
1798 /*************************************************************************
1801 * Some sort of memory management process - associated with _208
1803 DWORD WINAPI SHLWAPI_209 (
1806 FIXME("(%p) stub\n",
1811 /*************************************************************************
1814 * Some sort of memory management process - associated with _208
1816 DWORD WINAPI SHLWAPI_210 (
1821 FIXME("(%p 0x%08lx %p) stub\n",
1826 /*************************************************************************
1829 DWORD WINAPI SHLWAPI_211 (
1833 FIXME("(%p 0x%08lx) stub\n",
1838 /*************************************************************************
1844 DWORD WINAPI SHLWAPI_215 (
1851 len_a = lstrlenA(lpStrSrc);
1852 ret = MultiByteToWideChar(0, 0, lpStrSrc, len_a, lpwStrDest, len);
1853 TRACE("%s %s %d, ret=%d\n",
1854 debugstr_a(lpStrSrc), debugstr_w(lpwStrDest), len, ret);
1858 /*************************************************************************
1861 * WideCharToMultiByte with multi language support.
1863 INT WINAPI SHLWAPI_218(UINT CodePage, LPCWSTR lpSrcStr, LPSTR lpDstStr,
1864 LPINT lpnMultiCharCount)
1866 WCHAR emptyW[] = { '\0' };
1870 if (!lpDstStr || !lpnMultiCharCount)
1878 len = strlenW(lpSrcStr) + 1;
1883 CodePage = CP_UTF8; /* Fall through... */
1884 case 0x0000C350: /* FIXME: CP_ #define */
1889 INT nWideCharCount = len - 1;
1891 GET_FUNC(pConvertINetUnicodeToMultiByte, mlang, "ConvertINetUnicodeToMultiByte", 0);
1892 if (!pConvertINetUnicodeToMultiByte(&dwMode, CodePage, lpSrcStr, &nWideCharCount, lpDstStr,
1896 if (nWideCharCount < len - 1)
1898 mem = (LPSTR)HeapAlloc(GetProcessHeap(), 0, *lpnMultiCharCount);
1902 *lpnMultiCharCount = 0;
1904 if (pConvertINetUnicodeToMultiByte(&dwMode, CodePage, lpSrcStr, &len, mem, lpnMultiCharCount))
1906 SHLWAPI_162 (mem, *lpnMultiCharCount);
1907 lstrcpynA(lpDstStr, mem, *lpnMultiCharCount + 1);
1908 return *lpnMultiCharCount + 1;
1910 HeapFree(GetProcessHeap(), 0, mem);
1911 return *lpnMultiCharCount;
1913 lpDstStr[*lpnMultiCharCount] = '\0';
1914 return *lpnMultiCharCount;
1921 reqLen = WideCharToMultiByte(CodePage, 0, lpSrcStr, len, lpDstStr,
1922 *lpnMultiCharCount, NULL, NULL);
1924 if (!reqLen && GetLastError() == ERROR_INSUFFICIENT_BUFFER)
1926 reqLen = WideCharToMultiByte(CodePage, 0, lpSrcStr, len, NULL, 0, NULL, NULL);
1929 mem = (LPSTR)HeapAlloc(GetProcessHeap(), 0, reqLen);
1932 reqLen = WideCharToMultiByte(CodePage, 0, lpSrcStr, len, mem,
1933 reqLen, NULL, NULL);
1935 reqLen = SHLWAPI_162(mem, *lpnMultiCharCount);
1938 lstrcpynA(lpDstStr, mem, *lpnMultiCharCount);
1940 HeapFree(GetProcessHeap(), 0, mem);
1947 /*************************************************************************
1950 * Hmm, some program used lpnMultiCharCount == 0x3 (and lpSrcStr was "C")
1951 * --> Crash. Something wrong here.
1953 * It seems from OE v5 that the third param is the count. (GA 11/2001)
1955 INT WINAPI SHLWAPI_217(LPCWSTR lpSrcStr, LPSTR lpDstStr, INT MultiCharCount)
1957 INT myint = MultiCharCount;
1959 return SHLWAPI_218(CP_ACP, lpSrcStr, lpDstStr, &myint);
1962 /*************************************************************************
1965 * Seems to be "super" QueryInterface. Supplied with a table of interfaces
1966 * and an array of IIDs and offsets into the table.
1969 * error codes: E_POINTER, E_NOINTERFACE
1976 HRESULT WINAPI SHLWAPI_219 (
1977 LPVOID w, /* [in] table of interfaces */
1978 IFACE_INDEX_TBL *x, /* [in] array of REFIIDs and indexes to above */
1979 REFIID riid, /* [in] REFIID to get interface for */
1980 LPVOID *ppv) /* [out] location to get interface pointer */
1984 IFACE_INDEX_TBL *xmove;
1986 TRACE("(%p %p %s %p)\n", w,x,debugstr_guid(riid),ppv);
1989 while (xmove->refid) {
1990 TRACE("trying (indx %ld) %s\n", xmove->indx, debugstr_guid(xmove->refid));
1991 if (IsEqualIID(riid, xmove->refid)) {
1992 a_vtbl = (IUnknown*)(xmove->indx + (LPBYTE)w);
1993 TRACE("matched, returning (%p)\n", a_vtbl);
1994 *ppv = (LPVOID)a_vtbl;
1995 IUnknown_AddRef(a_vtbl);
2001 if (IsEqualIID(riid, &IID_IUnknown)) {
2002 a_vtbl = (IUnknown*)(x->indx + (LPBYTE)w);
2003 TRACE("returning first for IUnknown (%p)\n", a_vtbl);
2004 *ppv = (LPVOID)a_vtbl;
2005 IUnknown_AddRef(a_vtbl);
2009 ret = E_NOINTERFACE;
2013 TRACE("-- 0x%08lx\n", ret);
2017 /*************************************************************************
2020 HMODULE WINAPI SHLWAPI_236 (REFIID lpUnknown)
2024 CHAR value[MAX_PATH], string[MAX_PATH];
2026 strcpy(string, "CLSID\\");
2027 strcat(string, debugstr_guid(lpUnknown));
2028 strcat(string, "\\InProcServer32");
2031 RegOpenKeyExA(HKEY_CLASSES_ROOT, string, 0, 1, &newkey);
2032 RegQueryValueExA(newkey, 0, 0, &type, value, &count);
2033 RegCloseKey(newkey);
2034 return LoadLibraryExA(value, 0, 0);
2037 /*************************************************************************
2040 * Unicode version of SHLWAPI_183.
2042 DWORD WINAPI SHLWAPI_237 (WNDCLASSW * lpWndClass)
2046 TRACE("(0x%08x %s)\n",lpWndClass->hInstance, debugstr_w(lpWndClass->lpszClassName));
2048 if (GetClassInfoW(lpWndClass->hInstance, lpWndClass->lpszClassName, &WndClass))
2050 return RegisterClassW(lpWndClass);
2053 /*************************************************************************
2056 DWORD WINAPI SHLWAPI_239(HINSTANCE hInstance, LPVOID p2, DWORD dw3)
2058 FIXME("(0x%08x %p 0x%08lx) stub\n",
2059 hInstance, p2, dw3);
2062 /* pseudo code from relay trace */
2063 WideCharToMultiByte(0, 0, L"Shell DocObject View", -1, &aa, 0x0207, 0, 0);
2064 GetClassInfoA(70fe0000,405868ec "Shell DocObject View",40586b14);
2065 /* above pair repeated for:
2066 TridentThicketUrlDlClass
2075 /*************************************************************************
2078 * Call The correct (ASCII/Unicode) default window procedure for a window.
2081 * hWnd [I] Window to call the default proceedure for
2082 * uMessage [I] Message ID
2083 * wParam [I] WPARAM of message
2084 * lParam [I] LPARAM of message
2087 * The result of calling the window proceedure.
2089 LRESULT CALLBACK SHLWAPI_240(HWND hWnd, UINT uMessage, WPARAM wParam, LPARAM lParam)
2091 if (IsWindowUnicode(hWnd))
2092 return DefWindowProcW(hWnd, uMessage, wParam, lParam);
2093 return DefWindowProcA(hWnd, uMessage, wParam, lParam);
2096 /*************************************************************************
2100 DWORD WINAPI SHLWAPI_241 ()
2103 return /* 0xabba1243 */ 0;
2106 /*************************************************************************
2109 * native does at least approximately:
2110 * strcpyW(newstr, x);
2111 * strcatW(newstr, "\\Restrictions");
2112 * if (RegOpenKeyExA(80000001, newstr, 00000000,00000001,40520b78))
2116 DWORD WINAPI SHLWAPI_266 (
2118 LPVOID x, /* [in] partial registry key */
2122 FIXME("(%p %p %p %p)stub\n",w,x,y,z);
2123 return /* 0xabba1248 */ 0;
2126 /*************************************************************************
2130 * This QueryInterface asks the inner object for a interface. In case
2131 * of aggregation this request would be forwarded by the inner to the
2132 * outer object. This function asks the inner object directly for the
2133 * interface circumventing the forwarding to the outer object.
2135 HRESULT WINAPI SHLWAPI_267 (
2136 IUnknown * pUnk, /* [in] outer object */
2137 IUnknown * pInner, /* [in] inner object */
2141 HRESULT hret = E_NOINTERFACE;
2142 TRACE("(pUnk=%p pInner=%p\n\tIID: %s %p)\n",pUnk,pInner,debugstr_guid(riid), ppv);
2145 if(pUnk && pInner) {
2146 hret = IUnknown_QueryInterface(pInner, riid, (LPVOID*)ppv);
2147 if (SUCCEEDED(hret)) IUnknown_Release(pUnk);
2149 TRACE("-- 0x%08lx\n", hret);
2153 /*************************************************************************
2156 * Move a reference from one interface to another.
2159 * lpDest [O] Destination to receive the reference
2160 * lppUnknown [O] Source to give up the reference to lpDest
2165 VOID WINAPI SHLWAPI_268(IUnknown *lpDest, IUnknown **lppUnknown)
2167 TRACE("(%p,%p)\n", lpDest, lppUnknown);
2172 IUnknown_AddRef(lpDest);
2173 SHLWAPI_169(lppUnknown); /* Release existing interface */
2177 /*************************************************************************
2180 * Determine if the browser is integrated into the shell, and set a registry
2187 * 1, If the browser is not integrated.
2188 * 2, If the browser is integrated.
2191 * The key HKLM\Software\Microsoft\Internet Explorer\IntegratedBrowser is
2192 * either set to TRUE, or removed depending on whether the browser is deemed
2195 DWORD WINAPI SHLWAPI_276()
2197 static LPCSTR szIntegratedBrowser = "IntegratedBrowser";
2198 static DWORD dwState = 0;
2200 DWORD dwRet, dwData, dwSize;
2205 /* If shell32 exports DllGetVersion(), the browser is integrated */
2206 GET_FUNC(pDllGetVersion, shell32, "DllGetVersion", 1);
2207 dwState = pDllGetVersion ? 2 : 1;
2209 /* Set or delete the key accordinly */
2210 dwRet = RegOpenKeyExA(HKEY_LOCAL_MACHINE,
2211 "Software\\Microsoft\\Internet Explorer", 0,
2212 KEY_ALL_ACCESS, &hKey);
2215 dwRet = RegQueryValueExA(hKey, szIntegratedBrowser, 0, 0,
2216 (LPBYTE)&dwData, &dwSize);
2218 if (!dwRet && dwState == 1)
2220 /* Value exists but browser is not integrated */
2221 RegDeleteValueA(hKey, szIntegratedBrowser);
2223 else if (dwRet && dwState == 2)
2225 /* Browser is integrated but value does not exist */
2227 RegSetValueExA(hKey, szIntegratedBrowser, 0, REG_DWORD,
2228 (LPBYTE)&dwData, sizeof(dwData));
2235 /*************************************************************************
2239 HWND WINAPI SHLWAPI_278 (
2250 char * clsname = "WorkerA";
2252 FIXME("(0x%08lx 0x%08x 0x%08lx 0x%08lx 0x%08x 0x%08lx) partial stub\n",
2253 wndProc,hWndParent,dwExStyle,dwStyle,hMenu,z);
2255 hCursor = LoadCursorA(0x00000000,IDC_ARROWA);
2257 if(!GetClassInfoA(shlwapi_hInstance, clsname, &wndclass))
2259 RtlZeroMemory(&wndclass, sizeof(WNDCLASSA));
2260 wndclass.lpfnWndProc = DefWindowProcW;
2261 wndclass.cbWndExtra = 4;
2262 wndclass.hInstance = shlwapi_hInstance;
2263 wndclass.hCursor = hCursor;
2264 wndclass.hbrBackground = COLOR_BTNSHADOW;
2265 wndclass.lpszMenuName = NULL;
2266 wndclass.lpszClassName = clsname;
2267 RegisterClassA (&wndclass);
2269 hwnd = CreateWindowExA(dwExStyle, clsname, 0,dwStyle,0,0,0,0,hWndParent,
2270 hMenu,shlwapi_hInstance,0);
2271 SetWindowLongA(hwnd, 0, z);
2272 SetWindowLongA(hwnd, GWL_WNDPROC, wndProc);
2276 /*************************************************************************
2279 * _SHPackDispParamsV
2281 HRESULT WINAPI SHLWAPI_281(LPVOID w, LPVOID x, LPVOID y, LPVOID z)
2283 FIXME("%p %p %p %p\n",w,x,y,z);
2287 /*************************************************************************
2290 * _IConnectionPoint_SimpleInvoke
2292 DWORD WINAPI SHLWAPI_284 (
2297 TRACE("(%p %p %p) stub\n",x,y,z);
2301 /*************************************************************************
2304 * _IUnknown_CPContainerOnChanged
2306 HRESULT WINAPI SHLWAPI_287(LPVOID x, LPVOID y)
2308 FIXME("%p %p\n", x,y);
2312 /*************************************************************************
2315 * Late bound call to winmm.PlaySoundW
2317 BOOL WINAPI SHLWAPI_289(LPCWSTR pszSound, HMODULE hmod, DWORD fdwSound)
2319 GET_FUNC(pPlaySoundW, winmm, "PlaySoundW", FALSE);
2320 return pPlaySoundW(pszSound, hmod, fdwSound);
2323 /*************************************************************************
2326 BOOL WINAPI SHLWAPI_294(LPSTR str1, LPSTR str2, LPSTR pStr, DWORD some_len, LPCSTR lpStr2)
2329 * str1: "I" "I" pushl esp+0x20
2330 * str2: "U" "I" pushl 0x77c93810
2331 * (is "I" and "U" "integer" and "unsigned" ??)
2333 * pStr: "" "" pushl eax
2334 * some_len: 0x824 0x104 pushl 0x824
2335 * lpStr2: "%l" "%l" pushl esp+0xc
2337 * shlwapi. StrCpyNW(lpStr2, irrelevant_var, 0x104);
2338 * LocalAlloc(0x00, some_len) -> irrelevant_var
2339 * LocalAlloc(0x40, irrelevant_len) -> pStr
2340 * shlwapi.294(str1, str2, pStr, some_len, lpStr2);
2341 * shlwapi.PathRemoveBlanksW(pStr);
2343 FIXME("('%s', '%s', '%s', %08lx, '%s'): stub!\n", str1, str2, pStr, some_len, lpStr2);
2347 /*************************************************************************
2350 * Called by ICQ2000b install via SHDOCVW:
2351 * str1: "InternetShortcut"
2352 * x: some unknown pointer
2353 * str2: "http://free.aol.com/tryaolfree/index.adp?139269"
2354 * str3: "C:\\WINDOWS\\Desktop.new2\\Free AOL & Unlimited Internet.url"
2356 * In short: this one maybe creates a desktop link :-)
2358 BOOL WINAPI SHLWAPI_295(LPWSTR str1, LPVOID x, LPWSTR str2, LPWSTR str3)
2360 FIXME("('%s', %p, '%s', '%s'), stub.\n", debugstr_w(str1), x, debugstr_w(str2), debugstr_w(str3));
2364 /*************************************************************************
2367 * Late bound call to comctl32.417
2369 BOOL WINAPI SHLWAPI_299(HDC hdc, INT x, INT y, UINT flags, const RECT *lprect,
2370 LPCWSTR str, UINT count, const INT *lpDx)
2372 GET_FUNC(pCOMCTL32_417, comctl32, (LPCSTR)417, FALSE);
2373 return pCOMCTL32_417(hdc, x, y, flags, lprect, str, count, lpDx);
2376 /*************************************************************************
2379 * Late bound call to shell32.SHGetFileInfoW
2381 DWORD WINAPI SHLWAPI_313(LPCWSTR path, DWORD dwFileAttributes,
2382 SHFILEINFOW *psfi, UINT sizeofpsfi, UINT flags)
2384 GET_FUNC(pSHGetFileInfoW, shell32, "SHGetFileInfoW", 0);
2385 return pSHGetFileInfoW(path, dwFileAttributes, psfi, sizeofpsfi, flags);
2388 /*************************************************************************
2391 * Late bound call to shell32.DragQueryFileW
2393 UINT WINAPI SHLWAPI_318(HDROP hDrop, UINT lFile, LPWSTR lpszFile, UINT lLength)
2395 GET_FUNC(pDragQueryFileW, shell32, "DragQueryFileW", 0);
2396 return pDragQueryFileW(hDrop, lFile, lpszFile, lLength);
2399 /*************************************************************************
2402 * Late bound call to shell32.SHBrowseForFolderW
2404 LPITEMIDLIST WINAPI SHLWAPI_333(LPBROWSEINFOW lpBi)
2406 GET_FUNC(pSHBrowseForFolderW, shell32, "SHBrowseForFolderW", NULL);
2407 return pSHBrowseForFolderW(lpBi);
2410 /*************************************************************************
2413 * Late bound call to shell32.SHGetPathFromIDListW
2415 BOOL WINAPI SHLWAPI_334(LPCITEMIDLIST pidl,LPWSTR pszPath)
2417 GET_FUNC(pSHGetPathFromIDListW, shell32, "SHGetPathFromIDListW", 0);
2418 return pSHGetPathFromIDListW(pidl, pszPath);
2421 /*************************************************************************
2424 * Late bound call to shell32.ShellExecuteExW
2426 BOOL WINAPI SHLWAPI_335(LPSHELLEXECUTEINFOW lpExecInfo)
2428 GET_FUNC(pShellExecuteExW, shell32, "ShellExecuteExW", FALSE);
2429 return pShellExecuteExW(lpExecInfo);
2432 /*************************************************************************
2435 * Late bound call to shell32.SHFileOperationW.
2437 DWORD WINAPI SHLWAPI_336(LPSHFILEOPSTRUCTW lpFileOp)
2439 GET_FUNC(pSHFileOperationW, shell32, "SHFileOperationW", 0);
2440 return pSHFileOperationW(lpFileOp);
2443 /*************************************************************************
2446 * Late bound call to shell32.ExtractIconExW.
2448 HICON WINAPI SHLWAPI_337(LPCWSTR lpszFile, INT nIconIndex, HICON *phiconLarge,
2449 HICON *phiconSmall, UINT nIcons)
2451 GET_FUNC(pExtractIconExW, shell32, "ExtractIconExW", (HICON)0);
2452 return pExtractIconExW(lpszFile, nIconIndex, phiconLarge, phiconSmall, nIcons);
2455 /*************************************************************************
2459 LONG WINAPI SHInterlockedCompareExchange( PLONG dest, LONG xchg, LONG compare)
2461 return InterlockedCompareExchange(dest, xchg, compare);
2464 /*************************************************************************
2467 DWORD WINAPI SHLWAPI_346 (
2472 FIXME("(%s %p 0x%08x)stub\n",debugstr_w(src),dest,len);
2473 lstrcpynW(dest, src, len);
2474 return lstrlenW(dest)+1;
2477 /*************************************************************************
2480 * seems to be late bound call to GetFileVersionInfoSizeW
2482 DWORD WINAPI SHLWAPI_350 (
2488 GET_FUNC(pGetFileVersionInfoSizeW, version, "GetFileVersionInfoSizeW", 0);
2489 ret = pGetFileVersionInfoSizeW(x, y);
2493 /*************************************************************************
2496 * seems to be late bound call to GetFileVersionInfoW
2498 BOOL WINAPI SHLWAPI_351 (
2499 LPWSTR w, /* [in] path to dll */
2500 DWORD x, /* [in] parm 2 to GetFileVersionInfoA */
2501 DWORD y, /* [in] return value from .350 - assume length */
2502 LPVOID z) /* [in/out] buffer (+0x208 sent to GetFileVersionInfoA) */
2504 GET_FUNC(pGetFileVersionInfoW, version, "GetFileVersionInfoW", 0);
2505 return pGetFileVersionInfoW(w, x, y-0x208, (char*)z+0x208);
2508 /*************************************************************************
2511 * seems to be late bound call to VerQueryValueW
2513 WORD WINAPI SHLWAPI_352 (
2514 LPVOID w, /* [in] buffer from _351 */
2515 LPWSTR x, /* [in] value to retrieve -
2516 converted and passed to VerQueryValueA as #2 */
2517 LPVOID y, /* [out] ver buffer - passed to VerQueryValueA as #3 */
2518 UINT* z) /* [in] ver length - passed to VerQueryValueA as #4 */
2520 GET_FUNC(pVerQueryValueW, version, "VerQueryValueW", 0);
2521 return pVerQueryValueW((char*)w+0x208, x, y, z);
2524 /*************************************************************************
2527 * Late bound call to shell32.SHGetNewLinkInfoW
2529 BOOL WINAPI SHLWAPI_357(LPCWSTR pszLinkTo, LPCWSTR pszDir, LPWSTR pszName,
2530 BOOL *pfMustCopy, UINT uFlags)
2532 GET_FUNC(pSHGetNewLinkInfoW, shell32, "SHGetNewLinkInfoW", FALSE);
2533 return pSHGetNewLinkInfoW(pszLinkTo, pszDir, pszName, pfMustCopy, uFlags);
2536 /*************************************************************************
2539 * Late bound call to shell32.SHDefExtractIconW
2541 DWORD WINAPI SHLWAPI_358(LPVOID arg1, LPVOID arg2, LPVOID arg3, LPVOID arg4,
2542 LPVOID arg5, LPVOID arg6)
2544 GET_FUNC(pSHDefExtractIconW, shell32, "SHDefExtractIconW", 0);
2545 return pSHDefExtractIconW(arg1, arg2, arg3, arg4, arg5, arg6);
2548 /*************************************************************************
2551 * Wrapper for lstrcpynA with src and dst swapped.
2553 DWORD WINAPI SHLWAPI_364(LPCSTR src, LPSTR dst, INT n)
2555 lstrcpynA(dst, src, n);
2559 /*************************************************************************
2562 * Late bound call to shell32.ExtractIconW
2564 HICON WINAPI SHLWAPI_370(HINSTANCE hInstance, LPCWSTR lpszExeFileName,
2567 GET_FUNC(pExtractIconW, shell32, "ExtractIconW", (HICON)0);
2568 return pExtractIconW(hInstance, lpszExeFileName, nIconIndex);
2571 /*************************************************************************
2574 LANGID WINAPI SHLWAPI_376 ()
2577 /* FIXME: This should be a forward in the .spec file to the win2k function
2578 * kernel32.GetUserDefaultUILanguage, however that function isn't there yet.
2580 return GetUserDefaultLangID();
2583 /*************************************************************************
2586 * FIXME: Native appears to do DPA_Create and a DPA_InsertPtr for
2588 * FIXME: Native shows calls to:
2589 * SHRegGetUSValue for "Software\Microsoft\Internet Explorer\International"
2591 * RegOpenKeyExA for "HKLM\Software\Microsoft\Internet Explorer"
2592 * RegQueryValueExA for "LPKInstalled"
2594 * RegOpenKeyExA for "HKCU\Software\Microsoft\Internet Explorer\International"
2595 * RegQueryValueExA for "ResourceLocale"
2597 * RegOpenKeyExA for "HKLM\Software\Microsoft\Active Setup\Installed Components\{guid}"
2598 * RegQueryValueExA for "Locale"
2600 * and then tests the Locale ("en" for me).
2602 * after the code then a DPA_Create (first time) and DPA_InsertPtr are done.
2604 DWORD WINAPI SHLWAPI_377 (LPCSTR new_mod, HMODULE inst_hwnd, LPVOID z)
2606 CHAR mod_path[2*MAX_PATH];
2609 GetModuleFileNameA(inst_hwnd, mod_path, 2*MAX_PATH);
2610 ptr = strrchr(mod_path, '\\');
2612 strcpy(ptr+1, new_mod);
2613 TRACE("loading %s\n", debugstr_a(mod_path));
2614 return (DWORD)LoadLibraryA(mod_path);
2619 /*************************************************************************
2622 * This is Unicode version of .377
2624 DWORD WINAPI SHLWAPI_378 (
2625 LPCWSTR new_mod, /* [in] new module name */
2626 HMODULE inst_hwnd, /* [in] calling module handle */
2627 LPVOID z) /* [???] 4 */
2629 WCHAR mod_path[2*MAX_PATH];
2632 GetModuleFileNameW(inst_hwnd, mod_path, 2*MAX_PATH);
2633 ptr = strrchrW(mod_path, '\\');
2635 strcpyW(ptr+1, new_mod);
2636 TRACE("loading %s\n", debugstr_w(mod_path));
2637 return (DWORD)LoadLibraryW(mod_path);
2642 /*************************************************************************
2645 * Late bound call to comdlg32.GetSaveFileNameW
2647 BOOL WINAPI SHLWAPI_389(LPOPENFILENAMEW ofn)
2649 GET_FUNC(pGetSaveFileNameW, comdlg32, "GetSaveFileNameW", FALSE);
2650 return pGetSaveFileNameW(ofn);
2653 /*************************************************************************
2656 * Late bound call to mpr.WNetRestoreConnectionW
2658 DWORD WINAPI SHLWAPI_390(LPVOID arg1, LPVOID arg2)
2660 GET_FUNC(pWNetRestoreConnectionW, mpr, "WNetRestoreConnectionW", 0);
2661 return pWNetRestoreConnectionW(arg1, arg2);
2664 /*************************************************************************
2667 * Late bound call to mpr.WNetGetLastErrorW
2669 DWORD WINAPI SHLWAPI_391(LPVOID arg1, LPVOID arg2, LPVOID arg3, LPVOID arg4,
2672 GET_FUNC(pWNetGetLastErrorW, mpr, "WNetGetLastErrorW", 0);
2673 return pWNetGetLastErrorW(arg1, arg2, arg3, arg4, arg5);
2676 /*************************************************************************
2679 * Late bound call to comdlg32.PageSetupDlgW
2681 BOOL WINAPI SHLWAPI_401(LPPAGESETUPDLGW pagedlg)
2683 GET_FUNC(pPageSetupDlgW, comdlg32, "PageSetupDlgW", FALSE);
2684 return pPageSetupDlgW(pagedlg);
2687 /*************************************************************************
2690 * Late bound call to comdlg32.PrintDlgW
2692 BOOL WINAPI SHLWAPI_402(LPPRINTDLGW printdlg)
2694 GET_FUNC(pPrintDlgW, comdlg32, "PrintDlgW", FALSE);
2695 return pPrintDlgW(printdlg);
2698 /*************************************************************************
2701 * Late bound call to comdlg32.GetOpenFileNameW
2703 BOOL WINAPI SHLWAPI_403(LPOPENFILENAMEW ofn)
2705 GET_FUNC(pGetOpenFileNameW, comdlg32, "GetOpenFileNameW", FALSE);
2706 return pGetOpenFileNameW(ofn);
2709 /* INTERNAL: Map from HLS color space to RGB */
2710 static WORD ConvertHue(int wHue, WORD wMid1, WORD wMid2)
2712 wHue = wHue > 240 ? wHue - 240 : wHue < 0 ? wHue + 240 : wHue;
2716 else if (wHue > 120)
2721 return ((wHue * (wMid2 - wMid1) + 20) / 40) + wMid1;
2724 /* Convert to RGB and scale into RGB range (0..255) */
2725 #define GET_RGB(h) (ConvertHue(h, wMid1, wMid2) * 255 + 120) / 240
2727 /*************************************************************************
2728 * ColorHLSToRGB [SHLWAPI.404]
2730 * Convert from HLS color space into an RGB COLORREF.
2733 * Input HLS values are constrained to the range (0..240).
2735 COLORREF WINAPI ColorHLSToRGB(WORD wHue, WORD wLuminosity, WORD wSaturation)
2741 WORD wGreen, wBlue, wMid1, wMid2;
2743 if (wLuminosity > 120)
2744 wMid2 = wSaturation + wLuminosity - (wSaturation * wLuminosity + 120) / 240;
2746 wMid2 = ((wSaturation + 240) * wLuminosity + 120) / 240;
2748 wMid1 = wLuminosity * 2 - wMid2;
2750 wRed = GET_RGB(wHue + 80);
2751 wGreen = GET_RGB(wHue);
2752 wBlue = GET_RGB(wHue - 80);
2754 return RGB(wRed, wGreen, wBlue);
2757 wRed = wLuminosity * 255 / 240;
2758 return RGB(wRed, wRed, wRed);
2761 /*************************************************************************
2764 * Function unknown seems to always to return 0
2767 DWORD WINAPI SHLWAPI_413 (DWORD x)
2769 FIXME("(0x%08lx)stub\n", x);
2773 /*************************************************************************
2776 * Function seems to do FreeLibrary plus other things.
2778 * FIXME native shows the following calls:
2779 * RtlEnterCriticalSection
2781 * GetProcAddress(Comctl32??, 150L)
2783 * RtlLeaveCriticalSection
2784 * followed by the FreeLibrary.
2785 * The above code may be related to .377 above.
2787 BOOL WINAPI SHLWAPI_418 (HMODULE x)
2789 FIXME("(0x%08lx) partial stub\n", (LONG)x);
2790 return FreeLibrary(x);
2793 /*************************************************************************
2796 DWORD WINAPI SHLWAPI_430 (HINSTANCE hModule, HANDLE heap)
2798 FIXME("(0x%08lx 0x%08lx) stub\n", (DWORD)hModule, (DWORD)heap);
2799 return E_FAIL; /* This is what is used if shlwapi not loaded */
2802 /*************************************************************************
2805 DWORD WINAPI SHLWAPI_431 (DWORD x)
2807 FIXME("(0x%08lx)stub\n", x);
2811 /*************************************************************************
2814 * This is really CLSIDFromString which is exported by ole32.dll,
2815 * however the native shlwapi.dll does *not* import ole32. Nor does
2816 * ole32.dll import this ordinal from shlwapi. Therefore we must conclude
2817 * that MS duplicated the code for CLSIDFromString.
2819 * This is a duplicate (with changes for UNICODE) of CLSIDFromString16
2820 * in dlls/ole32/compobj.c
2822 DWORD WINAPI SHLWAPI_436 (LPWSTR idstr, CLSID *id)
2830 memset(s, 0, sizeof(CLSID));
2833 else { /* validate the CLSID string */
2835 if (strlenW(s) != 38)
2836 return CO_E_CLASSSTRING;
2838 if ((s[0]!=L'{') || (s[9]!=L'-') || (s[14]!=L'-') || (s[19]!=L'-') || (s[24]!=L'-') || (s[37]!=L'}'))
2839 return CO_E_CLASSSTRING;
2841 for (i=1; i<37; i++)
2843 if ((i == 9)||(i == 14)||(i == 19)||(i == 24)) continue;
2844 if (!(((s[i] >= L'0') && (s[i] <= L'9')) ||
2845 ((s[i] >= L'a') && (s[i] <= L'f')) ||
2846 ((s[i] >= L'A') && (s[i] <= L'F')))
2848 return CO_E_CLASSSTRING;
2852 TRACE("%s -> %p\n", debugstr_w(s), id);
2854 /* quick lookup table */
2855 memset(table, 0, 256*sizeof(WCHAR));
2857 for (i = 0; i < 10; i++) {
2860 for (i = 0; i < 6; i++) {
2861 table['A' + i] = i+10;
2862 table['a' + i] = i+10;
2865 /* in form {XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX} */
2869 s++; /* skip leading brace */
2870 for (i = 0; i < 4; i++) {
2871 p[3 - i] = table[*s]<<4 | table[*(s+1)];
2877 for (i = 0; i < 2; i++) {
2878 p[1-i] = table[*s]<<4 | table[*(s+1)];
2884 for (i = 0; i < 2; i++) {
2885 p[1-i] = table[*s]<<4 | table[*(s+1)];
2891 /* these are just sequential bytes */
2892 for (i = 0; i < 2; i++) {
2893 *p++ = table[*s]<<4 | table[*(s+1)];
2898 for (i = 0; i < 6; i++) {
2899 *p++ = table[*s]<<4 | table[*(s+1)];
2906 /*************************************************************************
2909 * Determine if the OS supports a given feature.
2912 * dwFeature [I] Feature requested (undocumented)
2915 * TRUE If the feature is available.
2916 * FALSE If the feature is not available.
2918 DWORD WINAPI SHLWAPI_437 (DWORD feature)
2920 FIXME("(0x%08lx) stub\n", feature);
2924 /*************************************************************************
2925 * ColorRGBToHLS [SHLWAPI.445]
2927 * Convert from RGB COLORREF into the HLS color space.
2930 * Input HLS values are constrained to the range (0..240).
2932 VOID WINAPI ColorRGBToHLS(COLORREF drRGB, LPWORD pwHue,
2933 LPWORD wLuminance, LPWORD pwSaturation)
2939 /*************************************************************************
2940 * SHCreateShellPalette [SHLWAPI.@]
2942 HPALETTE WINAPI SHCreateShellPalette(HDC hdc)
2945 return CreateHalftonePalette(hdc);
2948 /*************************************************************************
2949 * SHGetInverseCMAP (SHLWAPI.@)
2951 DWORD WINAPI SHGetInverseCMAP (LPDWORD* x, DWORD why)
2954 FIXME(" - returning bogus address for SHGetInverseCMAP\n");
2955 *x = (LPDWORD)0xabba1249;
2958 FIXME("(%p, %#lx)stub\n", x, why);
2962 /*************************************************************************
2963 * SHIsLowMemoryMachine [SHLWAPI.@]
2965 DWORD WINAPI SHIsLowMemoryMachine (DWORD x)
2967 FIXME("0x%08lx\n", x);
2971 /*************************************************************************
2972 * GetMenuPosFromID [SHLWAPI.@]
2974 INT WINAPI GetMenuPosFromID(HMENU hMenu, UINT wID)
2977 INT nCount = GetMenuItemCount(hMenu), nIter = 0;
2979 while (nIter < nCount)
2982 if (!GetMenuItemInfoA(hMenu, nIter, TRUE, &mi) && mi.wID == wID)
2989 /*************************************************************************
2990 * SHSkipJunction [SHLWAPI.@]
2992 * Determine if a bind context can be bound to an object
2995 * pbc [I] Bind context to check
2996 * pclsid [I] CLSID of object to be bound to
2999 * TRUE: If it is safe to bind
3000 * FALSE: If pbc is invalid or binding would not be safe
3003 BOOL WINAPI SHSkipJunction(IBindCtx *pbc, const CLSID *pclsid)
3005 static WCHAR szSkipBinding[] = { 'S','k','i','p',' ',
3006 'B','i','n','d','i','n','g',' ','C','L','S','I','D','\0' };
3013 if (SUCCEEDED(IBindCtx_GetObjectParam(pbc, szSkipBinding, &lpUnk)))
3017 if (SUCCEEDED(SHLWAPI_175(lpUnk, &clsid)) &&
3018 IsEqualGUID(pclsid, &clsid))
3021 IUnknown_Release(lpUnk);