2 * SHLWAPI ordinal functions
4 * Copyright 1997 Marcus Meissner
6 * 2001-2003 Jon Griffiths
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #define COM_NO_WINDOWS_H
25 #include "wine/port.h"
32 #define NONAMELESSUNION
33 #define NONAMELESSSTRUCT
48 #include "wine/unicode.h"
51 #include "wine/debug.h"
56 WINE_DEFAULT_DEBUG_CHANNEL(shell);
58 /* Get a function pointer from a DLL handle */
59 #define GET_FUNC(func, module, name, fail) \
62 if (!SHLWAPI_h##module && !(SHLWAPI_h##module = LoadLibraryA(#module ".dll"))) return fail; \
63 func = (fn##func)GetProcAddress(SHLWAPI_h##module, name); \
64 if (!func) return fail; \
68 /* DLL handles for late bound calls */
69 extern HINSTANCE shlwapi_hInstance;
70 extern HMODULE SHLWAPI_hshell32;
71 extern HMODULE SHLWAPI_hwinmm;
72 extern HMODULE SHLWAPI_hcomdlg32;
73 extern HMODULE SHLWAPI_hcomctl32;
74 extern HMODULE SHLWAPI_hmpr;
75 extern HMODULE SHLWAPI_hurlmon;
76 extern HMODULE SHLWAPI_hversion;
78 extern DWORD SHLWAPI_ThreadRef_index;
80 /* following is GUID for IObjectWithSite::SetSite -- see _174 */
81 static DWORD id1[4] = {0xfc4801a3, 0x11cf2ba9, 0xaa0029a2, 0x52733d00};
82 /* following is GUID for IPersistMoniker::GetClassID -- see _174 */
83 static DWORD id2[4] = {0x79eac9ee, 0x11cebaf9, 0xaa00828c, 0x0ba94b00};
85 /* Function pointers for GET_FUNC macro; these need to be global because of gcc bug */
86 typedef LPITEMIDLIST (WINAPI *fnpSHBrowseForFolderW)(LPBROWSEINFOW);
87 static fnpSHBrowseForFolderW pSHBrowseForFolderW;
88 typedef BOOL (WINAPI *fnpPlaySoundW)(LPCWSTR, HMODULE, DWORD);
89 static fnpPlaySoundW pPlaySoundW;
90 typedef DWORD (WINAPI *fnpSHGetFileInfoW)(LPCWSTR,DWORD,SHFILEINFOW*,UINT,UINT);
91 static fnpSHGetFileInfoW pSHGetFileInfoW;
92 typedef UINT (WINAPI *fnpDragQueryFileW)(HDROP, UINT, LPWSTR, UINT);
93 static fnpDragQueryFileW pDragQueryFileW;
94 typedef BOOL (WINAPI *fnpSHGetPathFromIDListW)(LPCITEMIDLIST, LPWSTR);
95 static fnpSHGetPathFromIDListW pSHGetPathFromIDListW;
96 typedef BOOL (WINAPI *fnpShellExecuteExW)(LPSHELLEXECUTEINFOW);
97 static fnpShellExecuteExW pShellExecuteExW;
98 typedef HICON (WINAPI *fnpSHFileOperationW)(LPSHFILEOPSTRUCTW);
99 static fnpSHFileOperationW pSHFileOperationW;
100 typedef UINT (WINAPI *fnpExtractIconExW)(LPCWSTR, INT,HICON *,HICON *, UINT);
101 static fnpExtractIconExW pExtractIconExW;
102 typedef BOOL (WINAPI *fnpSHGetNewLinkInfoW)(LPCWSTR, LPCWSTR, LPCWSTR, BOOL*, UINT);
103 static fnpSHGetNewLinkInfoW pSHGetNewLinkInfoW;
104 typedef HRESULT (WINAPI *fnpSHDefExtractIconW)(LPCWSTR, int, UINT, HICON*, HICON*, UINT);
105 static fnpSHDefExtractIconW pSHDefExtractIconW;
106 typedef HICON (WINAPI *fnpExtractIconW)(HINSTANCE, LPCWSTR, UINT);
107 static fnpExtractIconW pExtractIconW;
108 typedef BOOL (WINAPI *fnpGetSaveFileNameW)(LPOPENFILENAMEW);
109 static fnpGetSaveFileNameW pGetSaveFileNameW;
110 typedef DWORD (WINAPI *fnpWNetRestoreConnectionW)(HWND, LPWSTR);
111 static fnpWNetRestoreConnectionW pWNetRestoreConnectionW;
112 typedef DWORD (WINAPI *fnpWNetGetLastErrorW)(LPDWORD, LPWSTR, DWORD, LPWSTR, DWORD);
113 static fnpWNetGetLastErrorW pWNetGetLastErrorW;
114 typedef BOOL (WINAPI *fnpPageSetupDlgW)(LPPAGESETUPDLGW);
115 static fnpPageSetupDlgW pPageSetupDlgW;
116 typedef BOOL (WINAPI *fnpPrintDlgW)(LPPRINTDLGW);
117 static fnpPrintDlgW pPrintDlgW;
118 typedef BOOL (WINAPI *fnpGetOpenFileNameW)(LPOPENFILENAMEW);
119 static fnpGetOpenFileNameW pGetOpenFileNameW;
120 typedef DWORD (WINAPI *fnpGetFileVersionInfoSizeW)(LPCWSTR,LPDWORD);
121 static fnpGetFileVersionInfoSizeW pGetFileVersionInfoSizeW;
122 typedef BOOL (WINAPI *fnpGetFileVersionInfoW)(LPCWSTR,DWORD,DWORD,LPVOID);
123 static fnpGetFileVersionInfoW pGetFileVersionInfoW;
124 typedef WORD (WINAPI *fnpVerQueryValueW)(LPVOID,LPCWSTR,LPVOID*,UINT*);
125 static fnpVerQueryValueW pVerQueryValueW;
126 typedef BOOL (WINAPI *fnpCOMCTL32_417)(HDC,INT,INT,UINT,const RECT*,LPCWSTR,UINT,const INT*);
127 static fnpCOMCTL32_417 pCOMCTL32_417;
128 typedef HRESULT (WINAPI *fnpDllGetVersion)(DLLVERSIONINFO*);
129 static fnpDllGetVersion pDllGetVersion;
130 typedef HRESULT (WINAPI *fnpCreateFormatEnumerator)(UINT,FORMATETC*,IEnumFORMATETC**);
131 static fnpCreateFormatEnumerator pCreateFormatEnumerator;
132 typedef HRESULT (WINAPI *fnpRegisterFormatEnumerator)(LPBC,IEnumFORMATETC*,DWORD);
133 static fnpRegisterFormatEnumerator pRegisterFormatEnumerator;
135 HRESULT WINAPI IUnknown_QueryService(IUnknown*,REFGUID,REFIID,LPVOID*);
136 HRESULT WINAPI SHInvokeCommand(HWND,IShellFolder*,LPCITEMIDLIST,BOOL);
137 HRESULT WINAPI CLSIDFromStringWrap(LPCWSTR,CLSID*);
138 BOOL WINAPI SHAboutInfoW(LPWSTR,DWORD);
141 NOTES: Most functions exported by ordinal seem to be superflous.
142 The reason for these functions to be there is to provide a wrapper
143 for unicode functions to provide these functions on systems without
144 unicode functions eg. win95/win98. Since we have such functions we just
145 call these. If running Wine with native DLL's, some late bound calls may
146 fail. However, it is better to implement the functions in the forward DLL
147 and recommend the builtin rather than reimplementing the calls here!
150 /*************************************************************************
151 * SHLWAPI_DupSharedHandle
153 * Internal implemetation of SHLWAPI_11.
156 HANDLE WINAPI SHLWAPI_DupSharedHandle(HANDLE hShared, DWORD dwDstProcId,
157 DWORD dwSrcProcId, DWORD dwAccess,
161 DWORD dwMyProcId = GetCurrentProcessId();
164 TRACE("(%p,%ld,%ld,%08lx,%08lx)\n", hShared, dwDstProcId, dwSrcProcId,
165 dwAccess, dwOptions);
167 /* Get dest process handle */
168 if (dwDstProcId == dwMyProcId)
169 hDst = GetCurrentProcess();
171 hDst = OpenProcess(PROCESS_DUP_HANDLE, 0, dwDstProcId);
175 /* Get src process handle */
176 if (dwSrcProcId == dwMyProcId)
177 hSrc = GetCurrentProcess();
179 hSrc = OpenProcess(PROCESS_DUP_HANDLE, 0, dwSrcProcId);
183 /* Make handle available to dest process */
184 if (!DuplicateHandle(hDst, hShared, hSrc, &hRet,
185 dwAccess, 0, dwOptions | DUPLICATE_SAME_ACCESS))
188 if (dwSrcProcId != dwMyProcId)
192 if (dwDstProcId != dwMyProcId)
196 TRACE("Returning handle %p\n", hRet);
200 /*************************************************************************
203 * Create a block of sharable memory and initialise it with data.
206 * lpvData [I] Pointer to data to write
207 * dwSize [I] Size of data
208 * dwProcId [I] ID of process owning data
211 * Success: A shared memory handle
215 * Ordinals 7-11 provide a set of calls to create shared memory between a
216 * group of processes. The shared memory is treated opaquely in that its size
217 * is not exposed to clients who map it. This is accomplished by storing
218 * the size of the map as the first DWORD of mapped data, and then offsetting
219 * the view pointer returned by this size.
222 HANDLE WINAPI SHAllocShared(LPCVOID lpvData, DWORD dwSize, DWORD dwProcId)
228 TRACE("(%p,%ld,%ld)\n", lpvData, dwSize, dwProcId);
230 /* Create file mapping of the correct length */
231 hMap = CreateFileMappingA(INVALID_HANDLE_VALUE, NULL, FILE_MAP_READ, 0,
232 dwSize + sizeof(dwSize), NULL);
236 /* Get a view in our process address space */
237 pMapped = MapViewOfFile(hMap, FILE_MAP_READ | FILE_MAP_WRITE, 0, 0, 0);
241 /* Write size of data, followed by the data, to the view */
242 *((DWORD*)pMapped) = dwSize;
244 memcpy((char *) pMapped + sizeof(dwSize), lpvData, dwSize);
246 /* Release view. All further views mapped will be opaque */
247 UnmapViewOfFile(pMapped);
248 hRet = SHLWAPI_DupSharedHandle(hMap, dwProcId,
249 GetCurrentProcessId(), FILE_MAP_ALL_ACCESS,
250 DUPLICATE_SAME_ACCESS);
257 /*************************************************************************
260 * Get a pointer to a block of shared memory from a shared memory handle.
263 * hShared [I] Shared memory handle
264 * dwProcId [I] ID of process owning hShared
267 * Success: A pointer to the shared memory
271 PVOID WINAPI SHLockShared(HANDLE hShared, DWORD dwProcId)
276 TRACE("(%p %ld)\n", hShared, dwProcId);
278 /* Get handle to shared memory for current process */
279 hDup = SHLWAPI_DupSharedHandle(hShared, dwProcId, GetCurrentProcessId(),
280 FILE_MAP_ALL_ACCESS, 0);
282 pMapped = MapViewOfFile(hDup, FILE_MAP_READ | FILE_MAP_WRITE, 0, 0, 0);
286 return (char *) pMapped + sizeof(DWORD); /* Hide size */
290 /*************************************************************************
293 * Release a pointer to a block of shared memory.
296 * lpView [I] Shared memory pointer
303 BOOL WINAPI SHUnlockShared(LPVOID lpView)
305 TRACE("(%p)\n", lpView);
306 return UnmapViewOfFile((char *) lpView - sizeof(DWORD)); /* Include size */
309 /*************************************************************************
312 * Destroy a block of sharable memory.
315 * hShared [I] Shared memory handle
316 * dwProcId [I] ID of process owning hShared
323 BOOL WINAPI SHFreeShared(HANDLE hShared, DWORD dwProcId)
327 TRACE("(%p %ld)\n", hShared, dwProcId);
329 /* Get a copy of the handle for our process, closing the source handle */
330 hClose = SHLWAPI_DupSharedHandle(hShared, dwProcId, GetCurrentProcessId(),
331 FILE_MAP_ALL_ACCESS,DUPLICATE_CLOSE_SOURCE);
332 /* Close local copy */
333 return CloseHandle(hClose);
336 /*************************************************************************
339 * Copy a sharable memory handle from one process to another.
342 * hShared [I] Shared memory handle to duplicate
343 * dwDstProcId [I] ID of the process wanting the duplicated handle
344 * dwSrcProcId [I] ID of the process owning hShared
345 * dwAccess [I] Desired DuplicateHandle() access
346 * dwOptions [I] Desired DuplicateHandle() options
349 * Success: A handle suitable for use by the dwDstProcId process.
350 * Failure: A NULL handle.
353 HANDLE WINAPI SHMapHandle(HANDLE hShared, DWORD dwDstProcId, DWORD dwSrcProcId,
354 DWORD dwAccess, DWORD dwOptions)
358 hRet = SHLWAPI_DupSharedHandle(hShared, dwDstProcId, dwSrcProcId,
359 dwAccess, dwOptions);
363 /*************************************************************************
366 * Create and register a clipboard enumerator for a web browser.
369 * lpBC [I] Binding context
370 * lpUnknown [I] An object exposing the IWebBrowserApp interface
374 * Failure: An HRESULT error code.
377 * The enumerator is stored as a property of the web browser. If it does not
378 * yet exist, it is created and set before being registered.
380 HRESULT WINAPI RegisterDefaultAcceptHeaders(LPBC lpBC, IUnknown *lpUnknown)
382 static const WCHAR szProperty[] = { '{','D','0','F','C','A','4','2','0',
383 '-','D','3','F','5','-','1','1','C','F', '-','B','2','1','1','-','0',
384 '0','A','A','0','0','4','A','E','8','3','7','}','\0' };
385 IEnumFORMATETC* pIEnumFormatEtc = NULL;
388 IWebBrowserApp* pBrowser = NULL;
390 TRACE("(%p, %p)\n", lpBC, lpUnknown);
392 /* Get An IWebBrowserApp interface from lpUnknown */
393 hRet = IUnknown_QueryService(lpUnknown, &IID_IWebBrowserApp, &IID_IWebBrowserApp, (PVOID)&pBrowser);
394 if (FAILED(hRet) || !pBrowser)
395 return E_NOINTERFACE;
397 V_VT(&var) = VT_EMPTY;
399 /* The property we get is the browsers clipboard enumerator */
400 hRet = IWebBrowserApp_GetProperty(pBrowser, (BSTR)szProperty, &var);
404 if (V_VT(&var) == VT_EMPTY)
406 /* Iterate through accepted documents and RegisterClipBoardFormatA() them */
407 char szKeyBuff[128], szValueBuff[128];
408 DWORD dwKeySize, dwValueSize, dwRet = 0, dwCount = 0, dwNumValues, dwType;
409 FORMATETC* formatList, *format;
412 TRACE("Registering formats and creating IEnumFORMATETC instance\n");
414 if (!RegOpenKeyA(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows\\Current"
415 "Version\\Internet Settings\\Accepted Documents", &hDocs))
418 /* Get count of values in key */
421 dwKeySize = sizeof(szKeyBuff);
422 dwRet = RegEnumValueA(hDocs,dwCount,szKeyBuff,&dwKeySize,0,&dwType,0,0);
426 dwNumValues = dwCount;
428 /* Note: dwCount = number of items + 1; The extra item is the end node */
429 format = formatList = HeapAlloc(GetProcessHeap(), 0, dwCount * sizeof(FORMATETC));
431 return E_OUTOFMEMORY;
440 /* Register clipboard formats for the values and populate format list */
441 while(!dwRet && dwCount < dwNumValues)
443 dwKeySize = sizeof(szKeyBuff);
444 dwValueSize = sizeof(szValueBuff);
445 dwRet = RegEnumValueA(hDocs, dwCount, szKeyBuff, &dwKeySize, 0, &dwType,
446 (PBYTE)szValueBuff, &dwValueSize);
450 format->cfFormat = RegisterClipboardFormatA(szValueBuff);
452 format->dwAspect = 1;
461 /* Terminate the (maybe empty) list, last entry has a cfFormat of 0 */
462 format->cfFormat = 0;
464 format->dwAspect = 1;
468 /* Create a clipboard enumerator */
469 GET_FUNC(pCreateFormatEnumerator, urlmon, "CreateFormatEnumerator", E_FAIL);
470 hRet = pCreateFormatEnumerator(dwNumValues, formatList, &pIEnumFormatEtc);
472 if (FAILED(hRet) || !pIEnumFormatEtc)
475 /* Set our enumerator as the browsers property */
476 V_VT(&var) = VT_UNKNOWN;
477 V_UNKNOWN(&var) = (IUnknown*)pIEnumFormatEtc;
479 hRet = IWebBrowserApp_PutProperty(pBrowser, (BSTR)szProperty, var);
482 IEnumFORMATETC_Release(pIEnumFormatEtc);
483 goto RegisterDefaultAcceptHeaders_Exit;
487 if (V_VT(&var) == VT_UNKNOWN)
489 /* Our variant is holding the clipboard enumerator */
490 IUnknown* pIUnknown = V_UNKNOWN(&var);
491 IEnumFORMATETC* pClone = NULL;
493 TRACE("Retrieved IEnumFORMATETC property\n");
495 /* Get an IEnumFormatEtc interface from the variants value */
496 pIEnumFormatEtc = NULL;
497 hRet = IUnknown_QueryInterface(pIUnknown, &IID_IEnumFORMATETC,
498 (PVOID)&pIEnumFormatEtc);
499 if (!hRet && pIEnumFormatEtc)
501 /* Clone and register the enumerator */
502 hRet = IEnumFORMATETC_Clone(pIEnumFormatEtc, &pClone);
505 GET_FUNC(pRegisterFormatEnumerator, urlmon, "RegisterFormatEnumerator", E_FAIL);
506 pRegisterFormatEnumerator(lpBC, pClone, 0);
508 IEnumFORMATETC_Release(pClone);
511 /* Release the IEnumFormatEtc interface */
512 IEnumFORMATETC_Release(pIUnknown);
514 IUnknown_Release(V_UNKNOWN(&var));
517 RegisterDefaultAcceptHeaders_Exit:
518 IWebBrowserApp_Release(pBrowser);
522 /*************************************************************************
525 * Get Explorers "AcceptLanguage" setting.
528 * langbuf [O] Destination for language string
529 * buflen [I] Length of langbuf
530 * [0] Success: used length of langbuf
533 * Success: S_OK. langbuf is set to the language string found.
534 * Failure: E_FAIL, If any arguments are invalid, error occurred, or Explorer
535 * does not contain the setting.
536 * E_INVALIDARG, If the buffer is not big enough
538 HRESULT WINAPI GetAcceptLanguagesW( LPWSTR langbuf, LPDWORD buflen)
540 static const WCHAR szkeyW[] = {
541 'S','o','f','t','w','a','r','e','\\',
542 'M','i','c','r','o','s','o','f','t','\\',
543 'I','n','t','e','r','n','e','t',' ','E','x','p','l','o','r','e','r','\\',
544 'I','n','t','e','r','n','a','t','i','o','n','a','l',0};
545 static const WCHAR valueW[] = {
546 'A','c','c','e','p','t','L','a','n','g','u','a','g','e',0};
547 static const WCHAR enusW[] = {'e','n','-','u','s',0};
548 DWORD mystrlen, mytype;
554 if(!langbuf || !buflen || !*buflen)
557 mystrlen = (*buflen > 20) ? *buflen : 20 ;
558 mystr = HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR) * mystrlen);
559 RegOpenKeyW(HKEY_CURRENT_USER, szkeyW, &mykey);
560 if(RegQueryValueExW(mykey, valueW, 0, &mytype, (PBYTE)mystr, &mystrlen)) {
561 /* Did not find value */
562 mylcid = GetUserDefaultLCID();
563 /* somehow the mylcid translates into "en-us"
564 * this is similar to "LOCALE_SABBREVLANGNAME"
565 * which could be gotten via GetLocaleInfo.
566 * The only problem is LOCALE_SABBREVLANGUAGE" is
567 * a 3 char string (first 2 are country code and third is
568 * letter for "sublanguage", which does not come close to
571 lstrcpyW(mystr, enusW);
572 mystrlen = lstrlenW(mystr);
574 /* handle returned string */
575 FIXME("missing code\n");
577 memcpy( langbuf, mystr, min(*buflen,strlenW(mystr)+1)*sizeof(WCHAR) );
579 if(*buflen > lstrlenW(mystr)) {
580 *buflen = lstrlenW(mystr);
584 retval = E_INVALIDARG;
585 SetLastError(ERROR_INSUFFICIENT_BUFFER);
588 HeapFree(GetProcessHeap(), 0, mystr);
592 /*************************************************************************
595 * Ascii version of GetAcceptLanguagesW.
597 HRESULT WINAPI GetAcceptLanguagesA( LPSTR langbuf, LPDWORD buflen)
600 DWORD buflenW, convlen;
603 if(!langbuf || !buflen || !*buflen) return E_FAIL;
606 langbufW = HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR) * buflenW);
607 retval = GetAcceptLanguagesW(langbufW, &buflenW);
609 /* FIXME: this is wrong, the string may not be null-terminated */
610 convlen = WideCharToMultiByte(CP_ACP, 0, langbufW, -1, langbuf,
611 *buflen, NULL, NULL);
612 *buflen = buflenW ? convlen : 0;
614 if(langbufW) HeapFree(GetProcessHeap(), 0, langbufW);
618 /*************************************************************************
621 * Convert a GUID to a string.
624 * guid [I] GUID to convert
625 * str [O] Destination for string
626 * cmax [I] Length of output buffer
629 * The length of the string created.
631 INT WINAPI SHStringFromGUIDA(REFGUID guid, LPSTR lpszDest, INT cchMax)
636 TRACE("(%s,%p,%d)\n", debugstr_guid(guid), lpszDest, cchMax);
638 sprintf(xguid, "{%08lX-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
639 guid->Data1, guid->Data2, guid->Data3,
640 guid->Data4[0], guid->Data4[1], guid->Data4[2], guid->Data4[3],
641 guid->Data4[4], guid->Data4[5], guid->Data4[6], guid->Data4[7]);
643 iLen = strlen(xguid) + 1;
647 memcpy(lpszDest, xguid, iLen);
651 /*************************************************************************
654 * Unicode version of SHStringFromGUIDA.
656 INT WINAPI SHStringFromGUIDW(REFGUID guid, LPWSTR lpszDest, INT cchMax)
659 INT iLen = SHStringFromGUIDA(guid, xguid, cchMax);
662 MultiByteToWideChar(CP_ACP, 0, xguid, -1, lpszDest, cchMax);
666 /*************************************************************************
669 * Determine if a Unicode character is alphabetic.
672 * wc [I] Character to check.
675 * TRUE, if wc is alphabetic,
678 BOOL WINAPI IsCharAlphaWrapW(WCHAR wc)
680 return (get_char_typeW(wc) & C1_ALPHA) != 0;
683 /*************************************************************************
686 * Determine if a Unicode character is upper-case.
689 * wc [I] Character to check.
692 * TRUE, if wc is upper-case,
695 BOOL WINAPI IsCharUpperWrapW(WCHAR wc)
697 return (get_char_typeW(wc) & C1_UPPER) != 0;
700 /*************************************************************************
703 * Determine if a Unicode character is lower-case.
706 * wc [I] Character to check.
709 * TRUE, if wc is lower-case,
712 BOOL WINAPI IsCharLowerWrapW(WCHAR wc)
714 return (get_char_typeW(wc) & C1_LOWER) != 0;
717 /*************************************************************************
720 * Determine if a Unicode character is alphabetic or a digit.
723 * wc [I] Character to check.
726 * TRUE, if wc is alphabetic or a digit,
729 BOOL WINAPI IsCharAlphaNumericWrapW(WCHAR wc)
731 return (get_char_typeW(wc) & (C1_ALPHA|C1_DIGIT)) != 0;
734 /*************************************************************************
737 * Determine if a Unicode character is a space.
740 * wc [I] Character to check.
743 * TRUE, if wc is a space,
746 BOOL WINAPI IsCharSpaceW(WCHAR wc)
748 return (get_char_typeW(wc) & C1_SPACE) != 0;
751 /*************************************************************************
754 * Determine if a Unicode character is a blank.
757 * wc [I] Character to check.
760 * TRUE, if wc is a blank,
764 BOOL WINAPI IsCharBlankW(WCHAR wc)
766 return (get_char_typeW(wc) & C1_BLANK) != 0;
769 /*************************************************************************
772 * Determine if a Unicode character is punctuation.
775 * wc [I] Character to check.
778 * TRUE, if wc is punctuation,
781 BOOL WINAPI IsCharPunctW(WCHAR wc)
783 return (get_char_typeW(wc) & C1_PUNCT) != 0;
786 /*************************************************************************
789 * Determine if a Unicode character is a control character.
792 * wc [I] Character to check.
795 * TRUE, if wc is a control character,
798 BOOL WINAPI IsCharCntrlW(WCHAR wc)
800 return (get_char_typeW(wc) & C1_CNTRL) != 0;
803 /*************************************************************************
806 * Determine if a Unicode character is a digit.
809 * wc [I] Character to check.
812 * TRUE, if wc is a digit,
815 BOOL WINAPI IsCharDigitW(WCHAR wc)
817 return (get_char_typeW(wc) & C1_DIGIT) != 0;
820 /*************************************************************************
823 * Determine if a Unicode character is a hex digit.
826 * wc [I] Character to check.
829 * TRUE, if wc is a hex digit,
832 BOOL WINAPI IsCharXDigitW(WCHAR wc)
834 return (get_char_typeW(wc) & C1_XDIGIT) != 0;
837 /*************************************************************************
841 BOOL WINAPI GetStringType3ExW(LPWSTR lpszStr, DWORD dwLen, LPVOID p3)
843 FIXME("(%s,0x%08lx,%p): stub\n", debugstr_w(lpszStr), dwLen, p3);
847 /*************************************************************************
850 * Insert a bitmap menu item at the bottom of a menu.
853 * hMenu [I] Menu to insert into
854 * flags [I] Flags for insertion
855 * id [I] Menu ID of the item
856 * str [I] Menu text for the item
859 * Success: TRUE, the item is inserted into the menu
860 * Failure: FALSE, if any parameter is invalid
862 BOOL WINAPI AppendMenuWrapW(HMENU hMenu, UINT flags, UINT id, LPCWSTR str)
864 TRACE("(%p,0x%08x,0x%08x,%s)\n",hMenu, flags, id, debugstr_w(str));
865 return InsertMenuW(hMenu, -1, flags | MF_BITMAP, id, str);
868 /*************************************************************************
871 * Get the text from a given dialog item.
874 * hWnd [I] Handle of dialog
875 * nItem [I] Index of item
876 * lpsDest [O] Buffer for receiving window text
877 * nDestLen [I] Length of buffer.
880 * Success: The length of the returned text.
883 INT WINAPI GetDlgItemTextWrapW(HWND hWnd, INT nItem, LPWSTR lpsDest,INT nDestLen)
885 HWND hItem = GetDlgItem(hWnd, nItem);
888 return GetWindowTextW(hItem, lpsDest, nDestLen);
890 *lpsDest = (WCHAR)'\0';
894 /*************************************************************************
897 * Set the text of a given dialog item.
900 * hWnd [I] Handle of dialog
901 * iItem [I] Index of item
902 * lpszText [O] Text to set
905 * Success: TRUE. The text of the dialog is set to lpszText.
906 * Failure: FALSE, Otherwise.
908 BOOL WINAPI SetDlgItemTextWrapW(HWND hWnd, INT iItem, LPCWSTR lpszText)
910 HWND hWndItem = GetDlgItem(hWnd, iItem);
912 return SetWindowTextW(hWndItem, lpszText);
916 /*************************************************************************
919 * Compare two Ascii strings up to a given length.
922 * lpszSrc [I] Source string
923 * lpszCmp [I] String to compare to lpszSrc
924 * len [I] Maximum length
927 * A number greater than, less than or equal to 0 depending on whether
928 * lpszSrc is greater than, less than or equal to lpszCmp.
930 DWORD WINAPI StrCmpNCA(LPCSTR lpszSrc, LPCSTR lpszCmp, INT len)
932 return strncmp(lpszSrc, lpszCmp, len);
935 /*************************************************************************
938 * Unicode version of StrCmpNCA.
940 DWORD WINAPI StrCmpNCW(LPCWSTR lpszSrc, LPCWSTR lpszCmp, INT len)
942 return strncmpW(lpszSrc, lpszCmp, len);
945 /*************************************************************************
948 * Compare two Ascii strings up to a given length, ignoring case.
951 * lpszSrc [I] Source string
952 * lpszCmp [I] String to compare to lpszSrc
953 * len [I] Maximum length
956 * A number greater than, less than or equal to 0 depending on whether
957 * lpszSrc is greater than, less than or equal to lpszCmp.
959 DWORD WINAPI StrCmpNICA(LPCSTR lpszSrc, LPCSTR lpszCmp, DWORD len)
961 return strncasecmp(lpszSrc, lpszCmp, len);
964 /*************************************************************************
967 * Unicode version of StrCmpNICA.
969 DWORD WINAPI StrCmpNICW(LPCWSTR lpszSrc, LPCWSTR lpszCmp, DWORD len)
971 return strncmpiW(lpszSrc, lpszCmp, len);
974 /*************************************************************************
977 * Compare two Ascii strings.
980 * lpszSrc [I] Source string
981 * lpszCmp [I] String to compare to lpszSrc
984 * A number greater than, less than or equal to 0 depending on whether
985 * lpszSrc is greater than, less than or equal to lpszCmp.
987 DWORD WINAPI StrCmpCA(LPCSTR lpszSrc, LPCSTR lpszCmp)
989 return strcmp(lpszSrc, lpszCmp);
992 /*************************************************************************
995 * Unicode version of StrCmpCA.
997 DWORD WINAPI StrCmpCW(LPCWSTR lpszSrc, LPCWSTR lpszCmp)
999 return strcmpW(lpszSrc, lpszCmp);
1002 /*************************************************************************
1005 * Compare two Ascii strings, ignoring case.
1008 * lpszSrc [I] Source string
1009 * lpszCmp [I] String to compare to lpszSrc
1012 * A number greater than, less than or equal to 0 depending on whether
1013 * lpszSrc is greater than, less than or equal to lpszCmp.
1015 DWORD WINAPI StrCmpICA(LPCSTR lpszSrc, LPCSTR lpszCmp)
1017 return strcasecmp(lpszSrc, lpszCmp);
1020 /*************************************************************************
1023 * Unicode version of StrCmpICA.
1025 DWORD WINAPI StrCmpICW(LPCWSTR lpszSrc, LPCWSTR lpszCmp)
1027 return strcmpiW(lpszSrc, lpszCmp);
1030 /*************************************************************************
1033 * Get an identification string for the OS and explorer.
1036 * lpszDest [O] Destination for Id string
1037 * dwDestLen [I] Length of lpszDest
1040 * TRUE, If the string was created successfully
1043 BOOL WINAPI SHAboutInfoA(LPSTR lpszDest, DWORD dwDestLen)
1047 TRACE("(%p,%ld)\n", lpszDest, dwDestLen);
1049 if (lpszDest && SHAboutInfoW(buff, dwDestLen))
1051 WideCharToMultiByte(CP_ACP, 0, buff, -1, lpszDest, dwDestLen, NULL, NULL);
1057 /*************************************************************************
1060 * Unicode version of SHAboutInfoA.
1062 BOOL WINAPI SHAboutInfoW(LPWSTR lpszDest, DWORD dwDestLen)
1064 static const WCHAR szIEKey[] = { 'S','O','F','T','W','A','R','E','\\',
1065 'M','i','c','r','o','s','o','f','t','\\','I','n','t','e','r','n','e','t',
1066 ' ','E','x','p','l','o','r','e','r','\0' };
1067 static const WCHAR szWinNtKey[] = { 'S','O','F','T','W','A','R','E','\\',
1068 'M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s',' ',
1069 'N','T','\\','C','u','r','r','e','n','t','V','e','r','s','i','o','n','\0' };
1070 static const WCHAR szWinKey[] = { 'S','O','F','T','W','A','R','E','\\',
1071 'M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\',
1072 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\0' };
1073 static const WCHAR szRegKey[] = { 'S','O','F','T','W','A','R','E','\\',
1074 'M','i','c','r','o','s','o','f','t','\\','I','n','t','e','r','n','e','t',
1075 ' ','E','x','p','l','o','r','e','r','\\',
1076 'R','e','g','i','s','t','r','a','t','i','o','n','\0' };
1077 static const WCHAR szVersion[] = { 'V','e','r','s','i','o','n','\0' };
1078 static const WCHAR szCustomized[] = { 'C','u','s','t','o','m','i','z','e','d',
1079 'V','e','r','s','i','o','n','\0' };
1080 static const WCHAR szOwner[] = { 'R','e','g','i','s','t','e','r','e','d',
1081 'O','w','n','e','r','\0' };
1082 static const WCHAR szOrg[] = { 'R','e','g','i','s','t','e','r','e','d',
1083 'O','r','g','a','n','i','z','a','t','i','o','n','\0' };
1084 static const WCHAR szProduct[] = { 'P','r','o','d','u','c','t','I','d','\0' };
1085 static const WCHAR szUpdate[] = { 'I','E','A','K',
1086 'U','p','d','a','t','e','U','r','l','\0' };
1087 static const WCHAR szHelp[] = { 'I','E','A','K',
1088 'H','e','l','p','S','t','r','i','n','g','\0' };
1091 DWORD dwType, dwLen;
1093 TRACE("(%p,%ld)\n", lpszDest, dwDestLen);
1100 /* Try the NT key first, followed by 95/98 key */
1101 if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, szWinNtKey, 0, KEY_READ, &hReg) &&
1102 RegOpenKeyExW(HKEY_LOCAL_MACHINE, szWinKey, 0, KEY_READ, &hReg))
1108 if (!SHGetValueW(HKEY_LOCAL_MACHINE, szIEKey, szVersion, &dwType, buff, &dwLen))
1110 DWORD dwStrLen = strlenW(buff);
1111 dwLen = 30 - dwStrLen;
1112 SHGetValueW(HKEY_LOCAL_MACHINE, szIEKey,
1113 szCustomized, &dwType, buff+dwStrLen, &dwLen);
1115 StrCatBuffW(lpszDest, buff, dwDestLen);
1117 /* ~Registered Owner */
1120 if (SHGetValueW(hReg, szOwner, 0, &dwType, buff+1, &dwLen))
1122 StrCatBuffW(lpszDest, buff, dwDestLen);
1124 /* ~Registered Organization */
1126 if (SHGetValueW(hReg, szOrg, 0, &dwType, buff+1, &dwLen))
1128 StrCatBuffW(lpszDest, buff, dwDestLen);
1130 /* FIXME: Not sure where this number comes from */
1134 StrCatBuffW(lpszDest, buff, dwDestLen);
1138 if (SHGetValueW(HKEY_LOCAL_MACHINE, szRegKey, szProduct, &dwType, buff+1, &dwLen))
1140 StrCatBuffW(lpszDest, buff, dwDestLen);
1142 /* ~IE Update Url */
1144 if(SHGetValueW(HKEY_LOCAL_MACHINE, szWinKey, szUpdate, &dwType, buff+1, &dwLen))
1146 StrCatBuffW(lpszDest, buff, dwDestLen);
1148 /* ~IE Help String */
1150 if(SHGetValueW(hReg, szHelp, 0, &dwType, buff+1, &dwLen))
1152 StrCatBuffW(lpszDest, buff, dwDestLen);
1158 /*************************************************************************
1161 * Call IOleCommandTarget_QueryStatus() on an object.
1164 * lpUnknown [I] Object supporting the IOleCommandTarget interface
1165 * pguidCmdGroup [I] GUID for the command group
1167 * prgCmds [O] Commands
1168 * pCmdText [O] Command text
1172 * Failure: E_FAIL, if lpUnknown is NULL.
1173 * E_NOINTERFACE, if lpUnknown does not support IOleCommandTarget.
1174 * Otherwise, an error code from IOleCommandTarget_QueryStatus().
1176 HRESULT WINAPI IUnknown_QueryStatus(IUnknown* lpUnknown, REFGUID pguidCmdGroup,
1177 ULONG cCmds, OLECMD *prgCmds, OLECMDTEXT* pCmdText)
1179 HRESULT hRet = E_FAIL;
1181 TRACE("(%p,%p,%ld,%p,%p)\n",lpUnknown, pguidCmdGroup, cCmds, prgCmds, pCmdText);
1185 IOleCommandTarget* lpOle;
1187 hRet = IUnknown_QueryInterface(lpUnknown, &IID_IOleCommandTarget,
1190 if (SUCCEEDED(hRet) && lpOle)
1192 hRet = IOleCommandTarget_QueryStatus(lpOle, pguidCmdGroup, cCmds,
1194 IOleCommandTarget_Release(lpOle);
1200 /*************************************************************************
1203 * Call IOleCommandTarget_Exec() on an object.
1206 * lpUnknown [I] Object supporting the IOleCommandTarget interface
1207 * pguidCmdGroup [I] GUID for the command group
1211 * Failure: E_FAIL, if lpUnknown is NULL.
1212 * E_NOINTERFACE, if lpUnknown does not support IOleCommandTarget.
1213 * Otherwise, an error code from IOleCommandTarget_Exec().
1215 HRESULT WINAPI IUnknown_Exec(IUnknown* lpUnknown, REFGUID pguidCmdGroup,
1216 DWORD nCmdID, DWORD nCmdexecopt, VARIANT* pvaIn,
1219 HRESULT hRet = E_FAIL;
1221 TRACE("(%p,%p,%ld,%ld,%p,%p)\n",lpUnknown, pguidCmdGroup, nCmdID,
1222 nCmdexecopt, pvaIn, pvaOut);
1226 IOleCommandTarget* lpOle;
1228 hRet = IUnknown_QueryInterface(lpUnknown, &IID_IOleCommandTarget,
1230 if (SUCCEEDED(hRet) && lpOle)
1232 hRet = IOleCommandTarget_Exec(lpOle, pguidCmdGroup, nCmdID,
1233 nCmdexecopt, pvaIn, pvaOut);
1234 IOleCommandTarget_Release(lpOle);
1240 /*************************************************************************
1243 * Retrieve, modify, and re-set a value from a window.
1246 * hWnd [I] Window to get value from
1247 * offset [I] Offset of value
1248 * wMask [I] Mask for uiFlags
1249 * wFlags [I] Bits to set in window value
1252 * The new value as it was set, or 0 if any parameter is invalid.
1255 * Any bits set in uiMask are cleared from the value, then any bits set in
1256 * uiFlags are set in the value.
1258 LONG WINAPI SHSetWindowBits(HWND hwnd, INT offset, UINT wMask, UINT wFlags)
1260 LONG ret = GetWindowLongA(hwnd, offset);
1261 LONG newFlags = (wFlags & wMask) | (ret & ~wFlags);
1263 if (newFlags != ret)
1264 ret = SetWindowLongA(hwnd, offset, newFlags);
1268 /*************************************************************************
1271 * Change a window's parent.
1274 * hWnd [I] Window to change parent of
1275 * hWndParent [I] New parent window
1278 * The old parent of hWnd.
1281 * If hWndParent is NULL (desktop), the window style is changed to WS_POPUP.
1282 * If hWndParent is NOT NULL then we set the WS_CHILD style.
1284 HWND WINAPI SHSetParentHwnd(HWND hWnd, HWND hWndParent)
1286 TRACE("%p, %p\n", hWnd, hWndParent);
1288 if(GetParent(hWnd) == hWndParent)
1292 SHSetWindowBits(hWnd, GWL_STYLE, WS_CHILD, WS_CHILD);
1294 SHSetWindowBits(hWnd, GWL_STYLE, WS_POPUP, WS_POPUP);
1296 return SetParent(hWnd, hWndParent);
1299 /*************************************************************************
1302 * Locate and advise a connection point in an IConnectionPointContainer object.
1305 * lpUnkSink [I] Sink for the connection point advise call
1306 * riid [I] REFIID of connection point to advise
1307 * bAdviseOnly [I] TRUE = Advise only, FALSE = Unadvise first
1308 * lpUnknown [I] Object supporting the IConnectionPointContainer interface
1309 * lpCookie [O] Pointer to connection point cookie
1310 * lppCP [O] Destination for the IConnectionPoint found
1313 * Success: S_OK. If lppCP is non-NULL, it is filled with the IConnectionPoint
1314 * that was advised. The caller is responsable for releasing it.
1315 * Failure: E_FAIL, if any arguments are invalid.
1316 * E_NOINTERFACE, if lpUnknown isn't an IConnectionPointContainer,
1317 * Or an HRESULT error code if any call fails.
1319 HRESULT WINAPI ConnectToConnectionPoint(IUnknown* lpUnkSink, REFIID riid, BOOL bAdviseOnly,
1320 IUnknown* lpUnknown, LPDWORD lpCookie,
1321 IConnectionPoint **lppCP)
1324 IConnectionPointContainer* lpContainer;
1325 IConnectionPoint *lpCP;
1327 if(!lpUnknown || (bAdviseOnly && !lpUnkSink))
1333 hRet = IUnknown_QueryInterface(lpUnknown, &IID_IConnectionPointContainer,
1334 (void**)&lpContainer);
1335 if (SUCCEEDED(hRet))
1337 hRet = IConnectionPointContainer_FindConnectionPoint(lpContainer, riid, &lpCP);
1339 if (SUCCEEDED(hRet))
1342 hRet = IConnectionPoint_Unadvise(lpCP, *lpCookie);
1343 hRet = IConnectionPoint_Advise(lpCP, lpUnkSink, lpCookie);
1348 if (lppCP && SUCCEEDED(hRet))
1349 *lppCP = lpCP; /* Caller keeps the interface */
1351 IConnectionPoint_Release(lpCP); /* Release it */
1354 IUnknown_Release(lpContainer);
1359 /*************************************************************************
1362 * Release an interface.
1365 * lpUnknown [I] Object to release
1370 DWORD WINAPI IUnknown_AtomicRelease(IUnknown ** lpUnknown)
1374 TRACE("(%p)\n",lpUnknown);
1376 if(!lpUnknown || !*((LPDWORD)lpUnknown)) return 0;
1380 TRACE("doing Release\n");
1382 return IUnknown_Release(temp);
1385 /*************************************************************************
1388 * Skip '//' if present in a string.
1391 * lpszSrc [I] String to check for '//'
1394 * Success: The next character after the '//' or the string if not present
1395 * Failure: NULL, if lpszStr is NULL.
1397 LPCSTR WINAPI PathSkipLeadingSlashesA(LPCSTR lpszSrc)
1399 if (lpszSrc && lpszSrc[0] == '/' && lpszSrc[1] == '/')
1404 /*************************************************************************
1407 * Check if two interfaces come from the same object.
1410 * lpInt1 [I] Interface to check against lpInt2.
1411 * lpInt2 [I] Interface to check against lpInt1.
1414 * TRUE, If the interfaces come from the same object.
1417 BOOL WINAPI SHIsSameObject(IUnknown* lpInt1, IUnknown* lpInt2)
1419 LPVOID lpUnknown1, lpUnknown2;
1421 TRACE("%p %p\n", lpInt1, lpInt2);
1423 if (!lpInt1 || !lpInt2)
1426 if (lpInt1 == lpInt2)
1429 if (!SUCCEEDED(IUnknown_QueryInterface(lpInt1, &IID_IUnknown,
1430 (LPVOID *)&lpUnknown1)))
1433 if (!SUCCEEDED(IUnknown_QueryInterface(lpInt2, &IID_IUnknown,
1434 (LPVOID *)&lpUnknown2)))
1437 if (lpUnknown1 == lpUnknown2)
1443 /*************************************************************************
1446 * Get the window handle of an object.
1449 * lpUnknown [I] Object to get the window handle of
1450 * lphWnd [O] Destination for window handle
1453 * Success: S_OK. lphWnd contains the objects window handle.
1454 * Failure: An HRESULT error code.
1457 * lpUnknown is expected to support one of the following interfaces:
1458 * IOleWindow(), IInternetSecurityMgrSite(), or IShellView().
1460 HRESULT WINAPI IUnknown_GetWindow(IUnknown *lpUnknown, HWND *lphWnd)
1462 /* FIXME: Wine has no header for this object */
1463 static const GUID IID_IInternetSecurityMgrSite = { 0x79eac9ed,
1464 0xbaf9, 0x11ce, { 0x8c, 0x82, 0x00, 0xaa, 0x00, 0x4b, 0xa9, 0x0b }};
1466 HRESULT hRet = E_FAIL;
1468 TRACE("(%p,%p)\n", lpUnknown, lphWnd);
1473 hRet = IUnknown_QueryInterface(lpUnknown, &IID_IOleWindow, (void**)&lpOle);
1477 hRet = IUnknown_QueryInterface(lpUnknown,&IID_IShellView, (void**)&lpOle);
1481 hRet = IUnknown_QueryInterface(lpUnknown, &IID_IInternetSecurityMgrSite,
1486 if (SUCCEEDED(hRet))
1488 /* Lazyness here - Since GetWindow() is the first method for the above 3
1489 * interfaces, we use the same call for them all.
1491 hRet = IOleWindow_GetWindow((IOleWindow*)lpOle, lphWnd);
1492 IUnknown_Release(lpOle);
1494 TRACE("Returning HWND=%p\n", *lphWnd);
1500 /*************************************************************************
1503 * Call a method on as as yet unidentified object.
1506 * pUnk [I] Object supporting the unidentified interface,
1507 * arg [I] Argument for the call on the object.
1512 HRESULT WINAPI IUnknown_SetOwner(IUnknown *pUnk, ULONG arg)
1514 static const GUID guid_173 = {
1515 0x5836fb00, 0x8187, 0x11cf, { 0xa1,0x2b,0x00,0xaa,0x00,0x4a,0xe8,0x37 }
1519 TRACE("(%p,%ld)\n", pUnk, arg);
1521 /* Note: arg may not be a ULONG and pUnk2 is for sure not an IMalloc -
1522 * We use this interface as its vtable entry is compatible with the
1523 * object in question.
1524 * FIXME: Find out what this object is and where it should be defined.
1527 SUCCEEDED(IUnknown_QueryInterface(pUnk, &guid_173, (void**)&pUnk2)))
1529 IMalloc_Alloc(pUnk2, arg); /* Faked call!! */
1530 IMalloc_Release(pUnk2);
1535 /*************************************************************************
1538 * Call either IObjectWithSite_SetSite() or IPersistMoniker_GetClassID() on
1543 * Failure: E_FAIL, if p1 is NULL.
1544 * E_NOINTERFACE If p1 does not support the IPersist interface,
1545 * Or an HRESULT error code.
1547 DWORD WINAPI IUnknown_SetSite(
1548 IUnknown *p1, /* [in] OLE object */
1549 LPVOID *p2) /* [out] ptr for call results */
1553 if (!p1) return E_FAIL;
1555 /* see if SetSite interface exists for IObjectWithSite object */
1556 ret = IUnknown_QueryInterface((IUnknown *)p1, (REFIID)id1, (LPVOID *)&p1);
1557 TRACE("first IU_QI ret=%08lx, p1=%p\n", ret, p1);
1560 /* see if GetClassId interface exists for IPersistMoniker object */
1561 ret = IUnknown_QueryInterface((IUnknown *)p1, (REFIID)id2, (LPVOID *)&aa);
1562 TRACE("second IU_QI ret=%08lx, aa=%08lx\n", ret, aa);
1563 if (ret) return ret;
1565 /* fake a GetClassId call */
1566 ret = IOleWindow_GetWindow((IOleWindow *)aa, (HWND*)p2);
1567 TRACE("second IU_QI doing 0x0c ret=%08lx, *p2=%08lx\n", ret,
1569 IUnknown_Release((IUnknown *)aa);
1572 /* fake a SetSite call */
1573 ret = IOleWindow_GetWindow((IOleWindow *)p1, (HWND*)p2);
1574 TRACE("first IU_QI doing 0x0c ret=%08lx, *p2=%08lx\n", ret,
1576 IUnknown_Release((IUnknown *)p1);
1581 /*************************************************************************
1584 * Call IPersist_GetClassID() on an object.
1587 * lpUnknown [I] Object supporting the IPersist interface
1588 * lpClassId [O] Destination for Class Id
1591 * Success: S_OK. lpClassId contains the Class Id requested.
1592 * Failure: E_FAIL, If lpUnknown is NULL,
1593 * E_NOINTERFACE If lpUnknown does not support IPersist,
1594 * Or an HRESULT error code.
1596 HRESULT WINAPI IUnknown_GetClassID(IUnknown *lpUnknown, CLSID* lpClassId)
1598 IPersist* lpPersist;
1599 HRESULT hRet = E_FAIL;
1601 TRACE("(%p,%p)\n", lpUnknown, debugstr_guid(lpClassId));
1605 hRet = IUnknown_QueryInterface(lpUnknown,&IID_IPersist,(void**)&lpPersist);
1606 if (SUCCEEDED(hRet))
1608 IPersist_GetClassID(lpPersist, lpClassId);
1609 IPersist_Release(lpPersist);
1615 /*************************************************************************
1618 * Retrieve a Service Interface from an object.
1621 * lpUnknown [I] Object to get an IServiceProvider interface from
1622 * sid [I] Service ID for IServiceProvider_QueryService() call
1623 * riid [I] Function requested for QueryService call
1624 * lppOut [O] Destination for the service interface pointer
1627 * Success: S_OK. lppOut contains an object providing the requested service
1628 * Failure: An HRESULT error code
1631 * lpUnknown is expected to support the IServiceProvider interface.
1633 HRESULT WINAPI IUnknown_QueryService(IUnknown* lpUnknown, REFGUID sid, REFIID riid,
1636 IServiceProvider* pService = NULL;
1647 /* Get an IServiceProvider interface from the object */
1648 hRet = IUnknown_QueryInterface(lpUnknown, &IID_IServiceProvider,
1649 (LPVOID*)&pService);
1651 if (!hRet && pService)
1653 TRACE("QueryInterface returned (IServiceProvider*)%p\n", pService);
1655 /* Get a Service interface from the object */
1656 hRet = IServiceProvider_QueryService(pService, sid, riid, lppOut);
1658 TRACE("(IServiceProvider*)%p returned (IUnknown*)%p\n", pService, *lppOut);
1660 /* Release the IServiceProvider interface */
1661 IUnknown_Release(pService);
1666 /*************************************************************************
1669 * Loads a popup menu.
1672 * hInst [I] Instance handle
1673 * szName [I] Menu name
1679 BOOL WINAPI SHLoadMenuPopup(HINSTANCE hInst, LPCWSTR szName)
1681 HMENU hMenu, hSubMenu;
1683 if ((hMenu = LoadMenuW(hInst, szName)))
1685 if ((hSubMenu = GetSubMenu(hMenu, 0)))
1686 RemoveMenu(hMenu, 0, MF_BYPOSITION);
1694 typedef struct _enumWndData
1699 LRESULT (WINAPI *pfnPost)(HWND,UINT,WPARAM,LPARAM);
1702 /* Callback for SHLWAPI_178 */
1703 static BOOL CALLBACK SHLWAPI_EnumChildProc(HWND hWnd, LPARAM lParam)
1705 enumWndData *data = (enumWndData *)lParam;
1707 TRACE("(%p,%p)\n", hWnd, data);
1708 data->pfnPost(hWnd, data->uiMsgId, data->wParam, data->lParam);
1712 /*************************************************************************
1715 * Send or post a message to every child of a window.
1718 * hWnd [I] Window whose children will get the messages
1719 * uiMsgId [I] Message Id
1720 * wParam [I] WPARAM of message
1721 * lParam [I] LPARAM of message
1722 * bSend [I] TRUE = Use SendMessageA(), FALSE = Use PostMessageA()
1728 * The appropriate ASCII or Unicode function is called for the window.
1730 void WINAPI SHPropagateMessage(HWND hWnd, UINT uiMsgId, WPARAM wParam, LPARAM lParam, BOOL bSend)
1734 TRACE("(%p,%u,%d,%ld,%d)\n", hWnd, uiMsgId, wParam, lParam, bSend);
1738 data.uiMsgId = uiMsgId;
1739 data.wParam = wParam;
1740 data.lParam = lParam;
1743 data.pfnPost = IsWindowUnicode(hWnd) ? (void*)SendMessageW : (void*)SendMessageA;
1745 data.pfnPost = IsWindowUnicode(hWnd) ? (void*)PostMessageW : (void*)PostMessageA;
1747 EnumChildWindows(hWnd, SHLWAPI_EnumChildProc, (LPARAM)&data);
1751 /*************************************************************************
1754 * Remove all sub-menus from a menu.
1757 * hMenu [I] Menu to remove sub-menus from
1760 * Success: 0. All sub-menus under hMenu are removed
1761 * Failure: -1, if any parameter is invalid
1763 DWORD WINAPI SHRemoveAllSubMenus(HMENU hMenu)
1765 int iItemCount = GetMenuItemCount(hMenu) - 1;
1766 while (iItemCount >= 0)
1768 HMENU hSubMenu = GetSubMenu(hMenu, iItemCount);
1770 RemoveMenu(hMenu, iItemCount, MF_BYPOSITION);
1776 /*************************************************************************
1779 * Enable or disable a menu item.
1782 * hMenu [I] Menu holding menu item
1783 * uID [I] ID of menu item to enable/disable
1784 * bEnable [I] Whether to enable (TRUE) or disable (FALSE) the item.
1787 * The return code from EnableMenuItem.
1789 UINT WINAPI SHEnableMenuItem(HMENU hMenu, UINT wItemID, BOOL bEnable)
1791 return EnableMenuItem(hMenu, wItemID, bEnable ? MF_ENABLED : MF_GRAYED);
1794 /*************************************************************************
1797 * Check or uncheck a menu item.
1800 * hMenu [I] Menu holding menu item
1801 * uID [I] ID of menu item to check/uncheck
1802 * bCheck [I] Whether to check (TRUE) or uncheck (FALSE) the item.
1805 * The return code from CheckMenuItem.
1807 DWORD WINAPI SHCheckMenuItem(HMENU hMenu, UINT uID, BOOL bCheck)
1809 return CheckMenuItem(hMenu, uID, bCheck ? MF_CHECKED : MF_UNCHECKED);
1812 /*************************************************************************
1815 * Register a window class if it isn't already.
1818 * lpWndClass [I] Window class to register
1821 * The result of the RegisterClassA call.
1823 DWORD WINAPI SHRegisterClassA(WNDCLASSA *wndclass)
1826 if (GetClassInfoA(wndclass->hInstance, wndclass->lpszClassName, &wca))
1828 return (DWORD)RegisterClassA(wndclass);
1831 /*************************************************************************
1834 * Call IPersistPropertyBag_Load() on an object.
1837 * lpUnknown [I] Object supporting the IPersistPropertyBag interface
1838 * lpPropBag [O] Destination for loaded IPropertyBag
1842 * Failure: An HRESULT error code, or E_FAIL if lpUnknown is NULL.
1844 DWORD WINAPI SHLoadFromPropertyBag(IUnknown *lpUnknown, IPropertyBag* lpPropBag)
1846 IPersistPropertyBag* lpPPBag;
1847 HRESULT hRet = E_FAIL;
1849 TRACE("(%p,%p)\n", lpUnknown, lpPropBag);
1853 hRet = IUnknown_QueryInterface(lpUnknown, &IID_IPersistPropertyBag,
1855 if (SUCCEEDED(hRet) && lpPPBag)
1857 hRet = IPersistPropertyBag_Load(lpPPBag, lpPropBag, NULL);
1858 IPersistPropertyBag_Release(lpPPBag);
1864 /*************************************************************************
1867 * Call IOleControlSite_GetExtendedControl() on an object.
1870 * lpUnknown [I] Object supporting the IOleControlSite interface
1871 * lppDisp [O] Destination for resulting IDispatch.
1875 * Failure: An HRESULT error code, or E_FAIL if lpUnknown is NULL.
1877 DWORD WINAPI IUnknown_OnFocusOCS(IUnknown *lpUnknown, IDispatch** lppDisp)
1879 IOleControlSite* lpCSite;
1880 HRESULT hRet = E_FAIL;
1882 TRACE("(%p,%p)\n", lpUnknown, lppDisp);
1885 hRet = IUnknown_QueryInterface(lpUnknown, &IID_IOleControlSite,
1887 if (SUCCEEDED(hRet) && lpCSite)
1889 hRet = IOleControlSite_GetExtendedControl(lpCSite, lppDisp);
1890 IOleControlSite_Release(lpCSite);
1896 /*************************************************************************
1899 * Get a sub-menu from a menu item.
1902 * hMenu [I] Menu to get sub-menu from
1903 * uID [I] ID of menu item containing sub-menu
1906 * The sub-menu of the item, or a NULL handle if any parameters are invalid.
1908 HMENU WINAPI SHGetMenuFromID(HMENU hMenu, UINT uID)
1912 TRACE("(%p,%uld)\n", hMenu, uID);
1914 mi.cbSize = sizeof(MENUITEMINFOA);
1915 mi.fMask = MIIM_SUBMENU;
1917 if (!GetMenuItemInfoA(hMenu, uID, 0, &mi))
1923 /*************************************************************************
1926 * Get the color depth of the primary display.
1932 * The color depth of the primary display.
1934 DWORD WINAPI SHGetCurColorRes()
1942 ret = GetDeviceCaps(hdc, BITSPIXEL) * GetDeviceCaps(hdc, PLANES);
1947 /*************************************************************************
1950 * Wait for a message to arrive, with a timeout.
1953 * hand [I] Handle to query
1954 * dwTimeout [I] Timeout in ticks or INFINITE to never timeout
1957 * STATUS_TIMEOUT if no message is received before dwTimeout ticks passes.
1958 * Otherwise returns the value from MsgWaitForMultipleObjectsEx when a
1959 * message is available.
1961 DWORD WINAPI SHWaitForSendMessageThread(HANDLE hand, DWORD dwTimeout)
1963 DWORD dwEndTicks = GetTickCount() + dwTimeout;
1966 while ((dwRet = MsgWaitForMultipleObjectsEx(1, &hand, dwTimeout, QS_SENDMESSAGE, 0)) == 1)
1970 PeekMessageW(&msg, NULL, 0, 0, PM_NOREMOVE);
1972 if (dwTimeout != INFINITE)
1974 if ((int)(dwTimeout = dwEndTicks - GetTickCount()) <= 0)
1975 return WAIT_TIMEOUT;
1982 /*************************************************************************
1985 * Blank out a region of text by drawing the background only.
1988 * hDC [I] Device context to draw in
1989 * pRect [I] Area to draw in
1990 * cRef [I] Color to draw in
1995 DWORD WINAPI SHFillRectClr(HDC hDC, LPCRECT pRect, COLORREF cRef)
1997 COLORREF cOldColor = SetBkColor(hDC, cRef);
1998 ExtTextOutA(hDC, 0, 0, ETO_OPAQUE, pRect, 0, 0, 0);
1999 SetBkColor(hDC, cOldColor);
2003 /*************************************************************************
2006 * Return the value asociated with a key in a map.
2009 * lpKeys [I] A list of keys of length iLen
2010 * lpValues [I] A list of values associated with lpKeys, of length iLen
2011 * iLen [I] Length of both lpKeys and lpValues
2012 * iKey [I] The key value to look up in lpKeys
2015 * The value in lpValues associated with iKey, or -1 if iKey is not
2019 * - If two elements in the map share the same key, this function returns
2020 * the value closest to the start of the map
2021 * - The native version of this function crashes if lpKeys or lpValues is NULL.
2023 int WINAPI SHSearchMapInt(const int *lpKeys, const int *lpValues, int iLen, int iKey)
2025 if (lpKeys && lpValues)
2031 if (lpKeys[i] == iKey)
2032 return lpValues[i]; /* Found */
2036 return -1; /* Not found */
2040 /*************************************************************************
2043 * Copy an interface pointer
2046 * lppDest [O] Destination for copy
2047 * lpUnknown [I] Source for copy
2052 VOID WINAPI IUnknown_Set(IUnknown **lppDest, IUnknown *lpUnknown)
2054 TRACE("(%p,%p)\n", lppDest, lpUnknown);
2057 IUnknown_AtomicRelease(lppDest); /* Release existing interface */
2062 IUnknown_AddRef(lpUnknown);
2063 *lppDest = lpUnknown;
2067 /*************************************************************************
2071 HRESULT WINAPI MayExecForward(IUnknown* lpUnknown, INT iUnk, REFGUID pguidCmdGroup,
2072 DWORD nCmdID, DWORD nCmdexecopt, VARIANT* pvaIn,
2075 FIXME("(%p,%d,%p,%ld,%ld,%p,%p) - stub!\n", lpUnknown, iUnk, pguidCmdGroup,
2076 nCmdID, nCmdexecopt, pvaIn, pvaOut);
2077 return DRAGDROP_E_NOTREGISTERED;
2080 /*************************************************************************
2084 HRESULT WINAPI IsQSForward(REFGUID pguidCmdGroup,ULONG cCmds, OLECMD *prgCmds)
2086 FIXME("(%p,%ld,%p) - stub!\n", pguidCmdGroup, cCmds, prgCmds);
2087 return DRAGDROP_E_NOTREGISTERED;
2090 /*************************************************************************
2093 * Determine if a window is not a child of another window.
2096 * hParent [I] Suspected parent window
2097 * hChild [I] Suspected child window
2100 * TRUE: If hChild is a child window of hParent
2101 * FALSE: If hChild is not a child window of hParent, or they are equal
2103 BOOL WINAPI SHIsChildOrSelf(HWND hParent, HWND hChild)
2105 TRACE("(%p,%p)\n", hParent, hChild);
2107 if (!hParent || !hChild)
2109 else if(hParent == hChild)
2111 return !IsChild(hParent, hChild);
2114 /*************************************************************************
2117 * Some sort of memory management process.
2119 DWORD WINAPI FDSA_Initialize(
2126 FIXME("(0x%08lx 0x%08lx %p %p 0x%08lx) stub\n",
2131 /*************************************************************************
2134 * Some sort of memory management process.
2136 DWORD WINAPI FDSA_Destroy(
2139 FIXME("(%p) stub\n",
2144 /*************************************************************************
2147 * Some sort of memory management process.
2149 DWORD WINAPI FDSA_InsertItem(
2154 FIXME("(%p 0x%08lx %p) stub\n",
2159 /*************************************************************************
2162 DWORD WINAPI FDSA_DeleteItem(
2166 FIXME("(%p 0x%08lx) stub\n",
2176 /*************************************************************************
2179 * Call IUnknown_QueryInterface() on a table of objects.
2183 * Failure: E_POINTER or E_NOINTERFACE.
2185 HRESULT WINAPI QISearch(
2186 LPVOID w, /* [in] Table of interfaces */
2187 IFACE_INDEX_TBL *x, /* [in] Array of REFIIDs and indexes into the table */
2188 REFIID riid, /* [in] REFIID to get interface for */
2189 LPVOID *ppv) /* [out] Destination for interface pointer */
2193 IFACE_INDEX_TBL *xmove;
2195 TRACE("(%p %p %s %p)\n", w,x,debugstr_guid(riid),ppv);
2198 while (xmove->refid) {
2199 TRACE("trying (indx %ld) %s\n", xmove->indx, debugstr_guid(xmove->refid));
2200 if (IsEqualIID(riid, xmove->refid)) {
2201 a_vtbl = (IUnknown*)(xmove->indx + (LPBYTE)w);
2202 TRACE("matched, returning (%p)\n", a_vtbl);
2203 *ppv = (LPVOID)a_vtbl;
2204 IUnknown_AddRef(a_vtbl);
2210 if (IsEqualIID(riid, &IID_IUnknown)) {
2211 a_vtbl = (IUnknown*)(x->indx + (LPBYTE)w);
2212 TRACE("returning first for IUnknown (%p)\n", a_vtbl);
2213 *ppv = (LPVOID)a_vtbl;
2214 IUnknown_AddRef(a_vtbl);
2218 ret = E_NOINTERFACE;
2222 TRACE("-- 0x%08lx\n", ret);
2226 /*************************************************************************
2229 * Remove the "PropDlgFont" property from a window.
2232 * hWnd [I] Window to remove the property from
2235 * A handle to the removed property, or NULL if it did not exist.
2237 HANDLE WINAPI SHRemoveDefaultDialogFont(HWND hWnd)
2241 TRACE("(%p)\n", hWnd);
2243 hProp = GetPropA(hWnd, "PropDlgFont");
2247 DeleteObject(hProp);
2248 hProp = RemovePropA(hWnd, "PropDlgFont");
2253 /*************************************************************************
2256 * Load the in-process server of a given GUID.
2259 * refiid [I] GUID of the server to load.
2262 * Success: A handle to the loaded server dll.
2263 * Failure: A NULL handle.
2265 HMODULE WINAPI SHPinDllOfCLSID(REFIID refiid)
2269 CHAR value[MAX_PATH], string[MAX_PATH];
2271 strcpy(string, "CLSID\\");
2272 SHStringFromGUIDA(refiid, string + 6, sizeof(string)/sizeof(char) - 6);
2273 strcat(string, "\\InProcServer32");
2276 RegOpenKeyExA(HKEY_CLASSES_ROOT, string, 0, 1, &newkey);
2277 RegQueryValueExA(newkey, 0, 0, &type, (PBYTE)value, &count);
2278 RegCloseKey(newkey);
2279 return LoadLibraryExA(value, 0, 0);
2282 /*************************************************************************
2285 * Unicode version of SHLWAPI_183.
2287 DWORD WINAPI SHRegisterClassW(WNDCLASSW * lpWndClass)
2291 TRACE("(%p %s)\n",lpWndClass->hInstance, debugstr_w(lpWndClass->lpszClassName));
2293 if (GetClassInfoW(lpWndClass->hInstance, lpWndClass->lpszClassName, &WndClass))
2295 return RegisterClassW(lpWndClass);
2298 /*************************************************************************
2301 * Unregister a list of classes.
2304 * hInst [I] Application instance that registered the classes
2305 * lppClasses [I] List of class names
2306 * iCount [I] Number of names in lppClasses
2311 void WINAPI SHUnregisterClassesA(HINSTANCE hInst, LPCSTR *lppClasses, INT iCount)
2315 TRACE("(%p,%p,%d)\n", hInst, lppClasses, iCount);
2319 if (GetClassInfoA(hInst, *lppClasses, &WndClass))
2320 UnregisterClassA(*lppClasses, hInst);
2326 /*************************************************************************
2329 * Unicode version of SHUnregisterClassesA.
2331 void WINAPI SHUnregisterClassesW(HINSTANCE hInst, LPCWSTR *lppClasses, INT iCount)
2335 TRACE("(%p,%p,%d)\n", hInst, lppClasses, iCount);
2339 if (GetClassInfoW(hInst, *lppClasses, &WndClass))
2340 UnregisterClassW(*lppClasses, hInst);
2346 /*************************************************************************
2349 * Call The correct (Ascii/Unicode) default window procedure for a window.
2352 * hWnd [I] Window to call the default procedure for
2353 * uMessage [I] Message ID
2354 * wParam [I] WPARAM of message
2355 * lParam [I] LPARAM of message
2358 * The result of calling DefWindowProcA() or DefWindowProcW().
2360 LRESULT CALLBACK SHDefWindowProc(HWND hWnd, UINT uMessage, WPARAM wParam, LPARAM lParam)
2362 if (IsWindowUnicode(hWnd))
2363 return DefWindowProcW(hWnd, uMessage, wParam, lParam);
2364 return DefWindowProcA(hWnd, uMessage, wParam, lParam);
2367 /*************************************************************************
2370 * Create a worker window using CreateWindowExA().
2373 * wndProc [I] Window procedure
2374 * hWndParent [I] Parent window
2375 * dwExStyle [I] Extra style flags
2376 * dwStyle [I] Style flags
2377 * hMenu [I] Window menu
2381 * Success: The window handle of the newly created window.
2384 HWND WINAPI SHCreateWorkerWindowA(LONG wndProc, HWND hWndParent, DWORD dwExStyle,
2385 DWORD dwStyle, HMENU hMenu, LONG z)
2387 static const char* szClass = "WorkerA";
2391 TRACE("(0x%08lx,%p,0x%08lx,0x%08lx,%p,0x%08lx)\n",
2392 wndProc, hWndParent, dwExStyle, dwStyle, hMenu, z);
2394 /* Create Window class */
2396 wc.lpfnWndProc = DefWindowProcA;
2399 wc.hInstance = shlwapi_hInstance;
2400 wc.hIcon = (HICON)0;
2401 wc.hCursor = LoadCursorA((HINSTANCE)0, (LPSTR)IDC_ARROW);
2402 wc.hbrBackground = (HBRUSH)COLOR_BTNSHADOW;
2403 wc.lpszMenuName = NULL;
2404 wc.lpszClassName = szClass;
2406 SHRegisterClassA(&wc); /* Register class */
2408 /* FIXME: Set extra bits in dwExStyle */
2410 hWnd = CreateWindowExA(dwExStyle, szClass, 0, dwStyle, 0, 0, 0, 0,
2411 hWndParent, hMenu, shlwapi_hInstance, 0);
2414 SetWindowLongA(hWnd, DWL_MSGRESULT, z);
2417 SetWindowLongA(hWnd, GWL_WNDPROC, wndProc);
2422 typedef struct tagPOLICYDATA
2424 DWORD policy; /* flags value passed to SHRestricted */
2425 LPCWSTR appstr; /* application str such as "Explorer" */
2426 LPCWSTR keystr; /* name of the actual registry key / policy */
2427 } POLICYDATA, *LPPOLICYDATA;
2429 #define SHELL_NO_POLICY 0xffffffff
2431 /* default shell policy registry key */
2432 static const WCHAR strRegistryPolicyW[] = {'S','o','f','t','w','a','r','e','\\','M','i','c','r','o',
2433 's','o','f','t','\\','W','i','n','d','o','w','s','\\',
2434 'C','u','r','r','e','n','t','V','e','r','s','i','o','n',
2435 '\\','P','o','l','i','c','i','e','s',0};
2437 /*************************************************************************
2440 * Retrieve a policy value from the registry.
2443 * lpSubKey [I] registry key name
2444 * lpSubName [I] subname of registry key
2445 * lpValue [I] value name of registry value
2448 * the value associated with the registry key or 0 if not found
2450 DWORD WINAPI SHGetRestriction(LPCWSTR lpSubKey, LPCWSTR lpSubName, LPCWSTR lpValue)
2452 DWORD retval, datsize = sizeof(retval);
2456 lpSubKey = strRegistryPolicyW;
2458 retval = RegOpenKeyW(HKEY_LOCAL_MACHINE, lpSubKey, &hKey);
2459 if (retval != ERROR_SUCCESS)
2460 retval = RegOpenKeyW(HKEY_CURRENT_USER, lpSubKey, &hKey);
2461 if (retval != ERROR_SUCCESS)
2464 SHGetValueW(hKey, lpSubName, lpValue, NULL, (LPBYTE)&retval, &datsize);
2469 /*************************************************************************
2472 * Helper function to retrieve the possibly cached value for a specific policy
2475 * policy [I] The policy to look for
2476 * initial [I] Main registry key to open, if NULL use default
2477 * polTable [I] Table of known policies, 0 terminated
2478 * polArr [I] Cache array of policy values
2481 * The retrieved policy value or 0 if not successful
2484 * This function is used by the native SHRestricted function to search for the
2485 * policy and cache it once retrieved. The current Wine implementation uses a
2486 * different POLICYDATA structure and implements a similar algorithme adapted to
2489 DWORD WINAPI SHRestrictionLookup(
2492 LPPOLICYDATA polTable,
2495 TRACE("(0x%08lx %s %p %p)\n", policy, debugstr_w(initial), polTable, polArr);
2497 if (!polTable || !polArr)
2500 for (;polTable->policy; polTable++, polArr++)
2502 if (policy == polTable->policy)
2504 /* we have a known policy */
2506 /* check if this policy has been cached */
2507 if (*polArr == SHELL_NO_POLICY)
2508 *polArr = SHGetRestriction(initial, polTable->appstr, polTable->keystr);
2512 /* we don't know this policy, return 0 */
2513 TRACE("unknown policy: (%08lx)\n", policy);
2517 /*************************************************************************
2520 * Get an interface from an object.
2523 * Success: S_OK. ppv contains the requested interface.
2524 * Failure: An HRESULT error code.
2527 * This QueryInterface asks the inner object for a interface. In case
2528 * of aggregation this request would be forwarded by the inner to the
2529 * outer object. This function asks the inner object directly for the
2530 * interface circumventing the forwarding to the outer object.
2532 HRESULT WINAPI SHWeakQueryInterface(
2533 IUnknown * pUnk, /* [in] Outer object */
2534 IUnknown * pInner, /* [in] Inner object */
2535 IID * riid, /* [in] Interface GUID to query for */
2536 LPVOID* ppv) /* [out] Destination for queried interface */
2538 HRESULT hret = E_NOINTERFACE;
2539 TRACE("(pUnk=%p pInner=%p\n\tIID: %s %p)\n",pUnk,pInner,debugstr_guid(riid), ppv);
2542 if(pUnk && pInner) {
2543 hret = IUnknown_QueryInterface(pInner, riid, (LPVOID*)ppv);
2544 if (SUCCEEDED(hret)) IUnknown_Release(pUnk);
2546 TRACE("-- 0x%08lx\n", hret);
2550 /*************************************************************************
2553 * Move a reference from one interface to another.
2556 * lpDest [O] Destination to receive the reference
2557 * lppUnknown [O] Source to give up the reference to lpDest
2562 VOID WINAPI SHWeakReleaseInterface(IUnknown *lpDest, IUnknown **lppUnknown)
2564 TRACE("(%p,%p)\n", lpDest, lppUnknown);
2569 IUnknown_AddRef(lpDest);
2570 IUnknown_AtomicRelease(lppUnknown); /* Release existing interface */
2574 /*************************************************************************
2577 * Convert an ASCII string of a CLSID into a CLSID.
2580 * idstr [I] String representing a CLSID in registry format
2581 * id [O] Destination for the converted CLSID
2584 * Success: TRUE. id contains the converted CLSID.
2587 BOOL WINAPI GUIDFromStringA(LPCSTR idstr, CLSID *id)
2590 MultiByteToWideChar(CP_ACP, 0, idstr, -1, wClsid, sizeof(wClsid)/sizeof(WCHAR));
2591 return SUCCEEDED(CLSIDFromStringWrap(wClsid, id));
2594 /*************************************************************************
2597 * Unicode version of GUIDFromStringA.
2599 BOOL WINAPI GUIDFromStringW(LPCWSTR idstr, CLSID *id)
2601 return SUCCEEDED(CLSIDFromStringWrap(idstr, id));
2604 /*************************************************************************
2607 * Determine if the browser is integrated into the shell, and set a registry
2614 * 1, If the browser is not integrated.
2615 * 2, If the browser is integrated.
2618 * The key "HKLM\Software\Microsoft\Internet Explorer\IntegratedBrowser" is
2619 * either set to TRUE, or removed depending on whether the browser is deemed
2622 DWORD WINAPI WhichPlatform()
2624 static LPCSTR szIntegratedBrowser = "IntegratedBrowser";
2625 static DWORD dwState = 0;
2627 DWORD dwRet, dwData, dwSize;
2632 /* If shell32 exports DllGetVersion(), the browser is integrated */
2633 GET_FUNC(pDllGetVersion, shell32, "DllGetVersion", 1);
2634 dwState = pDllGetVersion ? 2 : 1;
2636 /* Set or delete the key accordingly */
2637 dwRet = RegOpenKeyExA(HKEY_LOCAL_MACHINE,
2638 "Software\\Microsoft\\Internet Explorer", 0,
2639 KEY_ALL_ACCESS, &hKey);
2642 dwRet = RegQueryValueExA(hKey, szIntegratedBrowser, 0, 0,
2643 (LPBYTE)&dwData, &dwSize);
2645 if (!dwRet && dwState == 1)
2647 /* Value exists but browser is not integrated */
2648 RegDeleteValueA(hKey, szIntegratedBrowser);
2650 else if (dwRet && dwState == 2)
2652 /* Browser is integrated but value does not exist */
2654 RegSetValueExA(hKey, szIntegratedBrowser, 0, REG_DWORD,
2655 (LPBYTE)&dwData, sizeof(dwData));
2662 /*************************************************************************
2665 * Unicode version of SHCreateWorkerWindowA.
2667 HWND WINAPI SHCreateWorkerWindowW(LONG wndProc, HWND hWndParent, DWORD dwExStyle,
2668 DWORD dwStyle, HMENU hMenu, LONG z)
2670 static const WCHAR szClass[] = { 'W', 'o', 'r', 'k', 'e', 'r', 'W', '\0' };
2674 TRACE("(0x%08lx,%p,0x%08lx,0x%08lx,%p,0x%08lx)\n",
2675 wndProc, hWndParent, dwExStyle, dwStyle, hMenu, z);
2677 /* If our OS is natively ASCII, use the ASCII version */
2678 if (!(GetVersion() & 0x80000000)) /* NT */
2679 return SHCreateWorkerWindowA(wndProc, hWndParent, dwExStyle, dwStyle, hMenu, z);
2681 /* Create Window class */
2683 wc.lpfnWndProc = DefWindowProcW;
2686 wc.hInstance = shlwapi_hInstance;
2687 wc.hIcon = (HICON)0;
2688 wc.hCursor = LoadCursorA((HINSTANCE)0, (LPSTR)IDC_ARROW);
2689 wc.hbrBackground = (HBRUSH)COLOR_BTNSHADOW;
2690 wc.lpszMenuName = NULL;
2691 wc.lpszClassName = szClass;
2693 SHRegisterClassW(&wc); /* Register class */
2695 /* FIXME: Set extra bits in dwExStyle */
2697 hWnd = CreateWindowExW(dwExStyle, szClass, 0, dwStyle, 0, 0, 0, 0,
2698 hWndParent, hMenu, shlwapi_hInstance, 0);
2701 SetWindowLongA(hWnd, DWL_MSGRESULT, z);
2704 SetWindowLongA(hWnd, GWL_WNDPROC, wndProc);
2709 /*************************************************************************
2712 * Get and show a context menu from a shell folder.
2715 * hWnd [I] Window displaying the shell folder
2716 * lpFolder [I] IShellFolder interface
2717 * lpApidl [I] Id for the particular folder desired
2721 * Failure: An HRESULT error code indicating the error.
2723 HRESULT WINAPI SHInvokeDefaultCommand(HWND hWnd, IShellFolder* lpFolder, LPCITEMIDLIST lpApidl)
2725 return SHInvokeCommand(hWnd, lpFolder, lpApidl, FALSE);
2728 /*************************************************************************
2731 * _SHPackDispParamsV
2733 HRESULT WINAPI SHPackDispParamsV(LPVOID w, LPVOID x, LPVOID y, LPVOID z)
2735 FIXME("%p %p %p %p\n",w,x,y,z);
2739 /*************************************************************************
2742 * This function seems to be a forward to SHPackDispParamsV (whatever THAT
2743 * function does...).
2745 HRESULT WINAPI SHPackDispParams(LPVOID w, LPVOID x, LPVOID y, LPVOID z)
2747 FIXME("%p %p %p %p\n", w, x, y, z);
2751 /*************************************************************************
2754 * _IConnectionPoint_SimpleInvoke
2756 DWORD WINAPI IConnectionPoint_SimpleInvoke(
2761 FIXME("(%p %p %p) stub\n",x,y,z);
2765 /*************************************************************************
2768 * Notify an IConnectionPoint object of changes.
2771 * lpCP [I] Object to notify
2776 * Failure: E_NOINTERFACE, if lpCP is NULL or does not support the
2777 * IConnectionPoint interface.
2779 HRESULT WINAPI IConnectionPoint_OnChanged(IConnectionPoint* lpCP, DISPID dispID)
2781 IEnumConnections *lpEnum;
2782 HRESULT hRet = E_NOINTERFACE;
2784 TRACE("(%p,0x%8lX)\n", lpCP, dispID);
2786 /* Get an enumerator for the connections */
2788 hRet = IConnectionPoint_EnumConnections(lpCP, &lpEnum);
2790 if (SUCCEEDED(hRet))
2792 IPropertyNotifySink *lpSink;
2793 CONNECTDATA connData;
2796 /* Call OnChanged() for every notify sink in the connection point */
2797 while (IEnumConnections_Next(lpEnum, 1, &connData, &ulFetched) == S_OK)
2799 if (SUCCEEDED(IUnknown_QueryInterface(connData.pUnk, &IID_IPropertyNotifySink, (void**)&lpSink)) &&
2802 IPropertyNotifySink_OnChanged(lpSink, dispID);
2803 IPropertyNotifySink_Release(lpSink);
2805 IUnknown_Release(connData.pUnk);
2808 IEnumConnections_Release(lpEnum);
2813 /*************************************************************************
2816 * Notify an IConnectionPointContainer object of changes.
2819 * lpUnknown [I] Object to notify
2824 * Failure: E_NOINTERFACE, if lpUnknown is NULL or does not support the
2825 * IConnectionPointContainer interface.
2827 HRESULT WINAPI IUnknown_CPContainerOnChanged(IUnknown *lpUnknown, DISPID dispID)
2829 IConnectionPointContainer* lpCPC = NULL;
2830 HRESULT hRet = E_NOINTERFACE;
2832 TRACE("(%p,0x%8lX)\n", lpUnknown, dispID);
2835 hRet = IUnknown_QueryInterface(lpUnknown, &IID_IConnectionPointContainer, (void**)&lpCPC);
2837 if (SUCCEEDED(hRet))
2839 IConnectionPoint* lpCP;
2841 hRet = IConnectionPointContainer_FindConnectionPoint(lpCPC, &IID_IPropertyNotifySink, &lpCP);
2842 IConnectionPointContainer_Release(lpCPC);
2844 hRet = IConnectionPoint_OnChanged(lpCP, dispID);
2845 IConnectionPoint_Release(lpCP);
2850 /*************************************************************************
2855 BOOL WINAPI PlaySoundWrapW(LPCWSTR pszSound, HMODULE hmod, DWORD fdwSound)
2857 GET_FUNC(pPlaySoundW, winmm, "PlaySoundW", FALSE);
2858 return pPlaySoundW(pszSound, hmod, fdwSound);
2861 /*************************************************************************
2864 BOOL WINAPI SHGetIniStringW(LPSTR str1, LPSTR str2, LPSTR pStr, DWORD some_len, LPCSTR lpStr2)
2867 * str1: "I" "I" pushl esp+0x20
2868 * str2: "U" "I" pushl 0x77c93810
2869 * (is "I" and "U" "integer" and "unsigned" ??)
2871 * pStr: "" "" pushl eax
2872 * some_len: 0x824 0x104 pushl 0x824
2873 * lpStr2: "%l" "%l" pushl esp+0xc
2875 * shlwapi. StrCpyNW(lpStr2, irrelevant_var, 0x104);
2876 * LocalAlloc(0x00, some_len) -> irrelevant_var
2877 * LocalAlloc(0x40, irrelevant_len) -> pStr
2878 * shlwapi.294(str1, str2, pStr, some_len, lpStr2);
2879 * shlwapi.PathRemoveBlanksW(pStr);
2881 FIXME("('%s', '%s', '%s', %08lx, '%s'): stub!\n", str1, str2, pStr, some_len, lpStr2);
2885 /*************************************************************************
2888 * Called by ICQ2000b install via SHDOCVW:
2889 * str1: "InternetShortcut"
2890 * x: some unknown pointer
2891 * str2: "http://free.aol.com/tryaolfree/index.adp?139269"
2892 * str3: "C:\\WINDOWS\\Desktop.new2\\Free AOL & Unlimited Internet.url"
2894 * In short: this one maybe creates a desktop link :-)
2896 BOOL WINAPI SHSetIniStringW(LPWSTR str1, LPVOID x, LPWSTR str2, LPWSTR str3)
2898 FIXME("('%s', %p, '%s', '%s'), stub.\n", debugstr_w(str1), x, debugstr_w(str2), debugstr_w(str3));
2902 /*************************************************************************
2907 BOOL WINAPI ExtTextOutWrapW(HDC hdc, INT x, INT y, UINT flags, const RECT *lprect,
2908 LPCWSTR str, UINT count, const INT *lpDx)
2910 GET_FUNC(pCOMCTL32_417, comctl32, (LPCSTR)417, FALSE);
2911 return pCOMCTL32_417(hdc, x, y, flags, lprect, str, count, lpDx);
2914 /*************************************************************************
2917 * See SHGetFileInfoW.
2919 DWORD WINAPI SHGetFileInfoWrapW(LPCWSTR path, DWORD dwFileAttributes,
2920 SHFILEINFOW *psfi, UINT sizeofpsfi, UINT flags)
2922 GET_FUNC(pSHGetFileInfoW, shell32, "SHGetFileInfoW", 0);
2923 return pSHGetFileInfoW(path, dwFileAttributes, psfi, sizeofpsfi, flags);
2926 /*************************************************************************
2929 * See DragQueryFileW.
2931 UINT WINAPI DragQueryFileWrapW(HDROP hDrop, UINT lFile, LPWSTR lpszFile, UINT lLength)
2933 GET_FUNC(pDragQueryFileW, shell32, "DragQueryFileW", 0);
2934 return pDragQueryFileW(hDrop, lFile, lpszFile, lLength);
2937 /*************************************************************************
2940 * See SHBrowseForFolderW.
2942 LPITEMIDLIST WINAPI SHBrowseForFolderWrapW(LPBROWSEINFOW lpBi)
2944 GET_FUNC(pSHBrowseForFolderW, shell32, "SHBrowseForFolderW", NULL);
2945 return pSHBrowseForFolderW(lpBi);
2948 /*************************************************************************
2951 * See SHGetPathFromIDListW.
2953 BOOL WINAPI SHGetPathFromIDListWrapW(LPCITEMIDLIST pidl,LPWSTR pszPath)
2955 GET_FUNC(pSHGetPathFromIDListW, shell32, "SHGetPathFromIDListW", 0);
2956 return pSHGetPathFromIDListW(pidl, pszPath);
2959 /*************************************************************************
2962 * See ShellExecuteExW.
2964 BOOL WINAPI ShellExecuteExWrapW(LPSHELLEXECUTEINFOW lpExecInfo)
2966 GET_FUNC(pShellExecuteExW, shell32, "ShellExecuteExW", FALSE);
2967 return pShellExecuteExW(lpExecInfo);
2970 /*************************************************************************
2973 * See SHFileOperationW.
2975 HICON WINAPI SHFileOperationWrapW(LPSHFILEOPSTRUCTW lpFileOp)
2977 GET_FUNC(pSHFileOperationW, shell32, "SHFileOperationW", 0);
2978 return pSHFileOperationW(lpFileOp);
2981 /*************************************************************************
2984 * See ExtractIconExW.
2986 UINT WINAPI ExtractIconExWrapW(LPCWSTR lpszFile, INT nIconIndex, HICON *phiconLarge,
2987 HICON *phiconSmall, UINT nIcons)
2989 GET_FUNC(pExtractIconExW, shell32, "ExtractIconExW", 0);
2990 return pExtractIconExW(lpszFile, nIconIndex, phiconLarge, phiconSmall, nIcons);
2993 /*************************************************************************
2997 LONG WINAPI SHInterlockedCompareExchange( PLONG dest, LONG xchg, LONG compare)
2999 return InterlockedCompareExchange(dest, xchg, compare);
3002 /*************************************************************************
3005 DWORD WINAPI SHUnicodeToUnicode(
3010 FIXME("(%s %p 0x%08x)stub\n",debugstr_w(src),dest,len);
3011 lstrcpynW(dest, src, len);
3012 return lstrlenW(dest)+1;
3015 /*************************************************************************
3018 * See GetFileVersionInfoSizeW.
3020 DWORD WINAPI GetFileVersionInfoSizeWrapW(
3026 GET_FUNC(pGetFileVersionInfoSizeW, version, "GetFileVersionInfoSizeW", 0);
3027 ret = pGetFileVersionInfoSizeW(x, y);
3031 /*************************************************************************
3034 * See GetFileVersionInfoW.
3036 BOOL WINAPI GetFileVersionInfoWrapW(
3037 LPWSTR w, /* [in] path to dll */
3038 DWORD x, /* [in] parm 2 to GetFileVersionInfoA */
3039 DWORD y, /* [in] return value from SHLWAPI_350() - assume length */
3040 LPVOID z) /* [in/out] buffer (+0x208 sent to GetFileVersionInfoA()) */
3042 GET_FUNC(pGetFileVersionInfoW, version, "GetFileVersionInfoW", 0);
3043 return pGetFileVersionInfoW(w, x, y-0x208, (char*)z+0x208);
3046 /*************************************************************************
3049 * See VerQueryValueW.
3051 WORD WINAPI VerQueryValueWrapW(
3052 LPVOID w, /* [in] Buffer from SHLWAPI_351() */
3053 LPWSTR x, /* [in] Value to retrieve - converted and passed to VerQueryValueA() as #2 */
3054 LPVOID y, /* [out] Ver buffer - passed to VerQueryValueA as #3 */
3055 UINT* z) /* [in] Ver length - passed to VerQueryValueA as #4 */
3057 GET_FUNC(pVerQueryValueW, version, "VerQueryValueW", 0);
3058 return pVerQueryValueW((char*)w+0x208, x, y, z);
3061 #define IsIface(type) SUCCEEDED((hRet = IUnknown_QueryInterface(lpUnknown, &IID_##type, (void**)&lpObj)))
3062 #define IShellBrowser_EnableModeless IShellBrowser_EnableModelessSB
3063 #define EnableModeless(type) type##_EnableModeless((type*)lpObj, bModeless)
3065 /*************************************************************************
3068 * Change the modality of a shell object.
3071 * lpUnknown [I] Object to make modeless
3072 * bModeless [I] TRUE=Make modeless, FALSE=Make modal
3075 * Success: S_OK. The modality lpUnknown is changed.
3076 * Failure: An HRESULT error code indicating the error.
3079 * lpUnknown must support the IOleInPlaceFrame interface, the
3080 * IInternetSecurityMgrSite interface, the IShellBrowser interface
3081 * or the IDocHostUIHandler interface, or this call fails.
3083 HRESULT WINAPI IUnknown_EnableModeless(IUnknown *lpUnknown, BOOL bModeless)
3088 TRACE("(%p,%d)\n", lpUnknown, bModeless);
3093 if (IsIface(IOleInPlaceFrame))
3094 EnableModeless(IOleInPlaceFrame);
3095 else if (IsIface(IShellBrowser))
3096 EnableModeless(IShellBrowser);
3098 /* FIXME: Wine has no headers for these objects yet */
3099 else if (IsIface(IInternetSecurityMgrSite))
3100 EnableModeless(IInternetSecurityMgrSite);
3101 else if (IsIface(IDocHostUIHandler))
3102 EnableModeless(IDocHostUIHandler);
3107 IUnknown_Release(lpObj);
3111 /*************************************************************************
3114 * See SHGetNewLinkInfoW.
3116 BOOL WINAPI SHGetNewLinkInfoWrapW(LPCWSTR pszLinkTo, LPCWSTR pszDir, LPWSTR pszName,
3117 BOOL *pfMustCopy, UINT uFlags)
3119 GET_FUNC(pSHGetNewLinkInfoW, shell32, "SHGetNewLinkInfoW", FALSE);
3120 return pSHGetNewLinkInfoW(pszLinkTo, pszDir, pszName, pfMustCopy, uFlags);
3123 /*************************************************************************
3126 * See SHDefExtractIconW.
3128 UINT WINAPI SHDefExtractIconWrapW(LPCWSTR pszIconFile, int iIndex, UINT uFlags, HICON* phiconLarge,
3129 HICON* phiconSmall, UINT nIconSize)
3131 GET_FUNC(pSHDefExtractIconW, shell32, "SHDefExtractIconW", 0);
3132 return pSHDefExtractIconW(pszIconFile, iIndex, uFlags, phiconLarge, phiconSmall, nIconSize);
3135 /*************************************************************************
3138 * Get and show a context menu from a shell folder.
3141 * hWnd [I] Window displaying the shell folder
3142 * lpFolder [I] IShellFolder interface
3143 * lpApidl [I] Id for the particular folder desired
3144 * bInvokeDefault [I] Whether to invoke the default menu item
3147 * Success: S_OK. If bInvokeDefault is TRUE, the default menu action was
3149 * Failure: An HRESULT error code indicating the error.
3151 HRESULT WINAPI SHInvokeCommand(HWND hWnd, IShellFolder* lpFolder, LPCITEMIDLIST lpApidl, BOOL bInvokeDefault)
3153 IContextMenu *iContext;
3154 HRESULT hRet = E_FAIL;
3156 TRACE("(%p,%p,%p,%d)\n", hWnd, lpFolder, lpApidl, bInvokeDefault);
3161 /* Get the context menu from the shell folder */
3162 hRet = IShellFolder_GetUIObjectOf(lpFolder, hWnd, 1, &lpApidl,
3163 &IID_IContextMenu, 0, (void**)&iContext);
3164 if (SUCCEEDED(hRet))
3167 if ((hMenu = CreatePopupMenu()))
3170 DWORD dwDefaultId = 0;
3172 /* Add the context menu entries to the popup */
3173 hQuery = IContextMenu_QueryContextMenu(iContext, hMenu, 0, 1, 0x7FFF,
3174 bInvokeDefault ? CMF_NORMAL : CMF_DEFAULTONLY);
3176 if (SUCCEEDED(hQuery))
3178 if (bInvokeDefault &&
3179 (dwDefaultId = GetMenuDefaultItem(hMenu, 0, 0)) != 0xFFFFFFFF)
3181 CMINVOKECOMMANDINFO cmIci;
3182 /* Invoke the default item */
3183 memset(&cmIci,0,sizeof(cmIci));
3184 cmIci.cbSize = sizeof(cmIci);
3185 cmIci.fMask = CMIC_MASK_ASYNCOK;
3187 cmIci.lpVerb = MAKEINTRESOURCEA(dwDefaultId);
3188 cmIci.nShow = SW_SCROLLCHILDREN;
3190 hRet = IContextMenu_InvokeCommand(iContext, &cmIci);
3195 IContextMenu_Release(iContext);
3200 /*************************************************************************
3205 HICON WINAPI ExtractIconWrapW(HINSTANCE hInstance, LPCWSTR lpszExeFileName,
3208 GET_FUNC(pExtractIconW, shell32, "ExtractIconW", NULL);
3209 return pExtractIconW(hInstance, lpszExeFileName, nIconIndex);
3212 /*************************************************************************
3215 LANGID WINAPI MLGetUILanguage()
3218 /* FIXME: This should be a forward in the .spec file to the win2k function
3219 * kernel32.GetUserDefaultUILanguage, however that function isn't there yet.
3221 return GetUserDefaultLangID();
3224 /*************************************************************************
3227 * Load a library from the directory of a particular process.
3230 * new_mod [I] Library name
3231 * inst_hwnd [I] Module whose directory is to be used
3232 * dwFlags [I] Flags controlling the load
3235 * Success: A handle to the loaded module
3236 * Failure: A NULL handle.
3238 HMODULE WINAPI MLLoadLibraryA(LPCSTR new_mod, HMODULE inst_hwnd, DWORD dwFlags)
3240 /* FIXME: Native appears to do DPA_Create and a DPA_InsertPtr for
3242 * FIXME: Native shows calls to:
3243 * SHRegGetUSValue for "Software\Microsoft\Internet Explorer\International"
3245 * RegOpenKeyExA for "HKLM\Software\Microsoft\Internet Explorer"
3246 * RegQueryValueExA for "LPKInstalled"
3248 * RegOpenKeyExA for "HKCU\Software\Microsoft\Internet Explorer\International"
3249 * RegQueryValueExA for "ResourceLocale"
3251 * RegOpenKeyExA for "HKLM\Software\Microsoft\Active Setup\Installed Components\{guid}"
3252 * RegQueryValueExA for "Locale"
3254 * and then tests the Locale ("en" for me).
3256 * after the code then a DPA_Create (first time) and DPA_InsertPtr are done.
3258 CHAR mod_path[2*MAX_PATH];
3262 FIXME("(%s,%p,0x%08lx) semi-stub!\n", debugstr_a(new_mod), inst_hwnd, dwFlags);
3263 len = GetModuleFileNameA(inst_hwnd, mod_path, sizeof(mod_path));
3264 if (!len || len >= sizeof(mod_path)) return NULL;
3266 ptr = strrchr(mod_path, '\\');
3268 strcpy(ptr+1, new_mod);
3269 TRACE("loading %s\n", debugstr_a(mod_path));
3270 return LoadLibraryA(mod_path);
3275 /*************************************************************************
3278 * Unicode version of MLLoadLibraryA.
3280 HMODULE WINAPI MLLoadLibraryW(LPCWSTR new_mod, HMODULE inst_hwnd, DWORD dwFlags)
3282 WCHAR mod_path[2*MAX_PATH];
3286 FIXME("(%s,%p,0x%08lx) semi-stub!\n", debugstr_w(new_mod), inst_hwnd, dwFlags);
3287 len = GetModuleFileNameW(inst_hwnd, mod_path, sizeof(mod_path) / sizeof(WCHAR));
3288 if (!len || len >= sizeof(mod_path) / sizeof(WCHAR)) return NULL;
3290 ptr = strrchrW(mod_path, '\\');
3292 strcpyW(ptr+1, new_mod);
3293 TRACE("loading %s\n", debugstr_w(mod_path));
3294 return LoadLibraryW(mod_path);
3299 /*************************************************************************
3300 * ColorAdjustLuma [SHLWAPI.@]
3302 * Adjust the luminosity of a color
3305 * cRGB [I] RGB value to convert
3306 * dwLuma [I] Luma adjustment
3307 * bUnknown [I] Unknown
3310 * The adjusted RGB color.
3312 COLORREF WINAPI ColorAdjustLuma(COLORREF cRGB, int dwLuma, BOOL bUnknown)
3314 TRACE("(0x%8lx,%d,%d)\n", cRGB, dwLuma, bUnknown);
3320 ColorRGBToHLS(cRGB, &wH, &wL, &wS);
3322 FIXME("Ignoring luma adjustment\n");
3324 /* FIXME: The ajdustment is not linear */
3326 cRGB = ColorHLSToRGB(wH, wL, wS);
3331 /*************************************************************************
3334 * See GetSaveFileNameW.
3336 BOOL WINAPI GetSaveFileNameWrapW(LPOPENFILENAMEW ofn)
3338 GET_FUNC(pGetSaveFileNameW, comdlg32, "GetSaveFileNameW", FALSE);
3339 return pGetSaveFileNameW(ofn);
3342 /*************************************************************************
3345 * See WNetRestoreConnectionW.
3347 DWORD WINAPI WNetRestoreConnectionWrapW(HWND hwndOwner, LPWSTR lpszDevice)
3349 GET_FUNC(pWNetRestoreConnectionW, mpr, "WNetRestoreConnectionW", 0);
3350 return pWNetRestoreConnectionW(hwndOwner, lpszDevice);
3353 /*************************************************************************
3356 * See WNetGetLastErrorW.
3358 DWORD WINAPI WNetGetLastErrorWrapW(LPDWORD lpError, LPWSTR lpErrorBuf, DWORD nErrorBufSize,
3359 LPWSTR lpNameBuf, DWORD nNameBufSize)
3361 GET_FUNC(pWNetGetLastErrorW, mpr, "WNetGetLastErrorW", 0);
3362 return pWNetGetLastErrorW(lpError, lpErrorBuf, nErrorBufSize, lpNameBuf, nNameBufSize);
3365 /*************************************************************************
3368 * See PageSetupDlgW.
3370 BOOL WINAPI PageSetupDlgWrapW(LPPAGESETUPDLGW pagedlg)
3372 GET_FUNC(pPageSetupDlgW, comdlg32, "PageSetupDlgW", FALSE);
3373 return pPageSetupDlgW(pagedlg);
3376 /*************************************************************************
3381 BOOL WINAPI PrintDlgWrapW(LPPRINTDLGW printdlg)
3383 GET_FUNC(pPrintDlgW, comdlg32, "PrintDlgW", FALSE);
3384 return pPrintDlgW(printdlg);
3387 /*************************************************************************
3390 * See GetOpenFileNameW.
3392 BOOL WINAPI GetOpenFileNameWrapW(LPOPENFILENAMEW ofn)
3394 GET_FUNC(pGetOpenFileNameW, comdlg32, "GetOpenFileNameW", FALSE);
3395 return pGetOpenFileNameW(ofn);
3398 /* INTERNAL: Map from HLS color space to RGB */
3399 static WORD WINAPI ConvertHue(int wHue, WORD wMid1, WORD wMid2)
3401 wHue = wHue > 240 ? wHue - 240 : wHue < 0 ? wHue + 240 : wHue;
3405 else if (wHue > 120)
3410 return ((wHue * (wMid2 - wMid1) + 20) / 40) + wMid1;
3413 /* Convert to RGB and scale into RGB range (0..255) */
3414 #define GET_RGB(h) (ConvertHue(h, wMid1, wMid2) * 255 + 120) / 240
3416 /*************************************************************************
3417 * ColorHLSToRGB [SHLWAPI.@]
3419 * Convert from hls color space into an rgb COLORREF.
3422 * wHue [I] Hue amount
3423 * wLuminosity [I] Luminosity amount
3424 * wSaturation [I] Saturation amount
3427 * A COLORREF representing the converted color.
3430 * Input hls values are constrained to the range (0..240).
3432 COLORREF WINAPI ColorHLSToRGB(WORD wHue, WORD wLuminosity, WORD wSaturation)
3438 WORD wGreen, wBlue, wMid1, wMid2;
3440 if (wLuminosity > 120)
3441 wMid2 = wSaturation + wLuminosity - (wSaturation * wLuminosity + 120) / 240;
3443 wMid2 = ((wSaturation + 240) * wLuminosity + 120) / 240;
3445 wMid1 = wLuminosity * 2 - wMid2;
3447 wRed = GET_RGB(wHue + 80);
3448 wGreen = GET_RGB(wHue);
3449 wBlue = GET_RGB(wHue - 80);
3451 return RGB(wRed, wGreen, wBlue);
3454 wRed = wLuminosity * 255 / 240;
3455 return RGB(wRed, wRed, wRed);
3458 /*************************************************************************
3461 * Get the current docking status of the system.
3464 * dwFlags [I] DOCKINFO_ flags from "winbase.h", unused
3467 * One of DOCKINFO_UNDOCKED, DOCKINFO_UNDOCKED, or 0 if the system is not
3470 DWORD WINAPI SHGetMachineInfo(DWORD dwFlags)
3472 HW_PROFILE_INFOA hwInfo;
3474 TRACE("(0x%08lx)\n", dwFlags);
3476 GetCurrentHwProfileA(&hwInfo);
3477 switch (hwInfo.dwDockInfo & (DOCKINFO_DOCKED|DOCKINFO_UNDOCKED))
3479 case DOCKINFO_DOCKED:
3480 case DOCKINFO_UNDOCKED:
3481 return hwInfo.dwDockInfo & (DOCKINFO_DOCKED|DOCKINFO_UNDOCKED);
3487 /*************************************************************************
3490 * Function seems to do FreeLibrary plus other things.
3492 * FIXME native shows the following calls:
3493 * RtlEnterCriticalSection
3495 * GetProcAddress(Comctl32??, 150L)
3497 * RtlLeaveCriticalSection
3498 * followed by the FreeLibrary.
3499 * The above code may be related to .377 above.
3501 BOOL WINAPI MLFreeLibrary(HMODULE hModule)
3503 FIXME("(%p) semi-stub\n", hModule);
3504 return FreeLibrary(hModule);
3507 /*************************************************************************
3510 BOOL WINAPI SHFlushSFCacheWrap(void) {
3515 /*************************************************************************
3517 * FIXME I have no idea what this function does or what its arguments are.
3519 BOOL WINAPI MLIsMLHInstance(HINSTANCE hInst)
3521 FIXME("(%p) stub\n", hInst);
3526 /*************************************************************************
3529 DWORD WINAPI MLSetMLHInstance(HINSTANCE hInst, HANDLE hHeap)
3531 FIXME("(%p,%p) stub\n", hInst, hHeap);
3532 return E_FAIL; /* This is what is used if shlwapi not loaded */
3535 /*************************************************************************
3538 DWORD WINAPI MLClearMLHInstance(DWORD x)
3540 FIXME("(0x%08lx)stub\n", x);
3544 /*************************************************************************
3547 * Convert an Unicode string CLSID into a CLSID.
3550 * idstr [I] string containing a CLSID in text form
3551 * id [O] CLSID extracted from the string
3554 * S_OK on success or E_INVALIDARG on failure
3557 * This is really CLSIDFromString() which is exported by ole32.dll,
3558 * however the native shlwapi.dll does *not* import ole32. Nor does
3559 * ole32.dll import this ordinal from shlwapi. Therefore we must conclude
3560 * that MS duplicated the code for CLSIDFromString(), and yes they did, only
3561 * it returns an E_INVALIDARG error code on failure.
3562 * This is a duplicate (with changes for Unicode) of CLSIDFromString16()
3563 * in "dlls/ole32/compobj.c".
3565 HRESULT WINAPI CLSIDFromStringWrap(LPCWSTR idstr, CLSID *id)
3573 memset(id, 0, sizeof(CLSID));
3576 else { /* validate the CLSID string */
3578 if (strlenW(s) != 38)
3579 return E_INVALIDARG;
3581 if ((s[0]!=L'{') || (s[9]!=L'-') || (s[14]!=L'-') || (s[19]!=L'-') || (s[24]!=L'-') || (s[37]!=L'}'))
3582 return E_INVALIDARG;
3584 for (i=1; i<37; i++)
3586 if ((i == 9)||(i == 14)||(i == 19)||(i == 24))
3588 if (!(((s[i] >= L'0') && (s[i] <= L'9')) ||
3589 ((s[i] >= L'a') && (s[i] <= L'f')) ||
3590 ((s[i] >= L'A') && (s[i] <= L'F')))
3592 return E_INVALIDARG;
3596 TRACE("%s -> %p\n", debugstr_w(s), id);
3598 /* quick lookup table */
3599 memset(table, 0, 256*sizeof(WCHAR));
3601 for (i = 0; i < 10; i++) {
3604 for (i = 0; i < 6; i++) {
3605 table['A' + i] = i+10;
3606 table['a' + i] = i+10;
3609 /* in form {XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX} */
3613 s++; /* skip leading brace */
3614 for (i = 0; i < 4; i++) {
3615 p[3 - i] = table[*s]<<4 | table[*(s+1)];
3621 for (i = 0; i < 2; i++) {
3622 p[1-i] = table[*s]<<4 | table[*(s+1)];
3628 for (i = 0; i < 2; i++) {
3629 p[1-i] = table[*s]<<4 | table[*(s+1)];
3635 /* these are just sequential bytes */
3636 for (i = 0; i < 2; i++) {
3637 *p++ = table[*s]<<4 | table[*(s+1)];
3642 for (i = 0; i < 6; i++) {
3643 *p++ = table[*s]<<4 | table[*(s+1)];
3650 /*************************************************************************
3653 * Determine if the OS supports a given feature.
3656 * dwFeature [I] Feature requested (undocumented)
3659 * TRUE If the feature is available.
3660 * FALSE If the feature is not available.
3662 BOOL WINAPI IsOS(DWORD feature)
3664 OSVERSIONINFOA osvi;
3665 DWORD platform, majorv, minorv;
3667 osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOA);
3668 if(!GetVersionExA(&osvi)) {
3669 ERR("GetVersionEx failed");
3673 majorv = osvi.dwMajorVersion;
3674 minorv = osvi.dwMinorVersion;
3675 platform = osvi.dwPlatformId;
3677 #define ISOS_RETURN(x) \
3678 TRACE("(0x%lx) ret=%d\n",feature,(x)); \
3682 case OS_WIN32SORGREATER:
3683 ISOS_RETURN(platform == VER_PLATFORM_WIN32s
3684 || platform == VER_PLATFORM_WIN32_WINDOWS)
3686 ISOS_RETURN(platform == VER_PLATFORM_WIN32_NT)
3687 case OS_WIN95ORGREATER:
3688 ISOS_RETURN(platform == VER_PLATFORM_WIN32_WINDOWS)
3689 case OS_NT4ORGREATER:
3690 ISOS_RETURN(platform == VER_PLATFORM_WIN32_NT && majorv >= 4)
3691 case OS_WIN2000ORGREATER_ALT:
3692 case OS_WIN2000ORGREATER:
3693 ISOS_RETURN(platform == VER_PLATFORM_WIN32_NT && majorv >= 5)
3694 case OS_WIN98ORGREATER:
3695 ISOS_RETURN(platform == VER_PLATFORM_WIN32_WINDOWS && minorv >= 10)
3697 ISOS_RETURN(platform == VER_PLATFORM_WIN32_WINDOWS && minorv == 10)
3699 ISOS_RETURN(platform == VER_PLATFORM_WIN32_NT && majorv >= 5)
3700 case OS_WIN2000SERVER:
3701 ISOS_RETURN(platform == VER_PLATFORM_WIN32_NT && (minorv == 0 || minorv == 1))
3702 case OS_WIN2000ADVSERVER:
3703 ISOS_RETURN(platform == VER_PLATFORM_WIN32_NT && (minorv == 0 || minorv == 1))
3704 case OS_WIN2000DATACENTER:
3705 ISOS_RETURN(platform == VER_PLATFORM_WIN32_NT && (minorv == 0 || minorv == 1))
3706 case OS_WIN2000TERMINAL:
3707 ISOS_RETURN(platform == VER_PLATFORM_WIN32_NT && (minorv == 0 || minorv == 1))
3709 FIXME("(OS_EMBEDDED) What should we return here?\n");
3711 case OS_TERMINALCLIENT:
3712 FIXME("(OS_TERMINALCLIENT) What should we return here?\n");
3714 case OS_TERMINALREMOTEADMIN:
3715 FIXME("(OS_TERMINALREMOTEADMIN) What should we return here?\n");
3718 ISOS_RETURN(platform == VER_PLATFORM_WIN32_WINDOWS && minorv == 0)
3719 case OS_MEORGREATER:
3720 ISOS_RETURN(platform == VER_PLATFORM_WIN32_WINDOWS && minorv >= 90)
3721 case OS_XPORGREATER:
3722 ISOS_RETURN(platform == VER_PLATFORM_WIN32_NT && majorv >= 5 && minorv >= 1)
3724 ISOS_RETURN(platform == VER_PLATFORM_WIN32_NT && majorv >= 5 && minorv >= 1)
3725 case OS_PROFESSIONAL:
3726 ISOS_RETURN(platform == VER_PLATFORM_WIN32_NT)
3728 ISOS_RETURN(platform == VER_PLATFORM_WIN32_NT)
3730 ISOS_RETURN(platform == VER_PLATFORM_WIN32_NT && majorv >= 5)
3732 ISOS_RETURN(platform == VER_PLATFORM_WIN32_NT)
3733 case OS_TERMINALSERVER:
3734 ISOS_RETURN(platform == VER_PLATFORM_WIN32_NT)
3735 case OS_PERSONALTERMINALSERVER:
3736 ISOS_RETURN(platform == VER_PLATFORM_WIN32_NT && minorv >= 1 && majorv >= 5)
3737 case OS_FASTUSERSWITCHING:
3738 FIXME("(OS_FASTUSERSWITCHING) What should we return here?\n");
3740 case OS_WELCOMELOGONUI:
3741 FIXME("(OS_WELCOMELOGONUI) What should we return here?\n");
3743 case OS_DOMAINMEMBER:
3744 FIXME("(OS_DOMAINMEMBER) What should we return here?\n");
3747 ISOS_RETURN(platform == VER_PLATFORM_WIN32_NT)
3749 FIXME("(OS_WOW6432) Should we check this?\n");
3752 ISOS_RETURN(platform == VER_PLATFORM_WIN32_NT)
3753 case OS_SMALLBUSINESSSERVER:
3754 ISOS_RETURN(platform == VER_PLATFORM_WIN32_NT)
3756 FIXME("(OS_TABLEPC) What should we return here?\n");
3758 case OS_SERVERADMINUI:
3759 FIXME("(OS_SERVERADMINUI) What should we return here?\n");
3761 case OS_MEDIACENTER:
3762 FIXME("(OS_MEDIACENTER) What should we return here?\n");
3765 FIXME("(OS_APPLIANCE) What should we return here?\n");
3771 WARN("(0x%lx) unknown parameter\n",feature);
3776 /*************************************************************************
3777 * ColorRGBToHLS [SHLWAPI.@]
3779 * Convert an rgb COLORREF into the hls color space.
3782 * cRGB [I] Source rgb value
3783 * pwHue [O] Destination for converted hue
3784 * pwLuminance [O] Destination for converted luminance
3785 * pwSaturation [O] Destination for converted saturation
3788 * Nothing. pwHue, pwLuminance and pwSaturation are set to the converted
3792 * Output HLS values are constrained to the range (0..240).
3793 * For Achromatic conversions, Hue is set to 160.
3795 VOID WINAPI ColorRGBToHLS(COLORREF cRGB, LPWORD pwHue,
3796 LPWORD pwLuminance, LPWORD pwSaturation)
3798 int wR, wG, wB, wMax, wMin, wHue, wLuminosity, wSaturation;
3800 TRACE("(%08lx,%p,%p,%p)\n", cRGB, pwHue, pwLuminance, pwSaturation);
3802 wR = GetRValue(cRGB);
3803 wG = GetGValue(cRGB);
3804 wB = GetBValue(cRGB);
3806 wMax = max(wR, max(wG, wB));
3807 wMin = min(wR, min(wG, wB));
3810 wLuminosity = ((wMax + wMin) * 240 + 255) / 510;
3814 /* Achromatic case */
3816 /* Hue is now unrepresentable, but this is what native returns... */
3821 /* Chromatic case */
3822 int wDelta = wMax - wMin, wRNorm, wGNorm, wBNorm;
3825 if (wLuminosity <= 120)
3826 wSaturation = ((wMax + wMin)/2 + wDelta * 240) / (wMax + wMin);
3828 wSaturation = ((510 - wMax - wMin)/2 + wDelta * 240) / (510 - wMax - wMin);
3831 wRNorm = (wDelta/2 + wMax * 40 - wR * 40) / wDelta;
3832 wGNorm = (wDelta/2 + wMax * 40 - wG * 40) / wDelta;
3833 wBNorm = (wDelta/2 + wMax * 40 - wB * 40) / wDelta;
3836 wHue = wBNorm - wGNorm;
3837 else if (wG == wMax)
3838 wHue = 80 + wRNorm - wBNorm;
3840 wHue = 160 + wGNorm - wRNorm;
3843 else if (wHue > 240)
3849 *pwLuminance = wLuminosity;
3851 *pwSaturation = wSaturation;
3854 /*************************************************************************
3855 * SHCreateShellPalette [SHLWAPI.@]
3857 HPALETTE WINAPI SHCreateShellPalette(HDC hdc)
3860 return CreateHalftonePalette(hdc);
3863 /*************************************************************************
3864 * SHGetInverseCMAP (SHLWAPI.@)
3866 * Get an inverse color map table.
3869 * lpCmap [O] Destination for color map
3870 * dwSize [I] Size of memory pointed to by lpCmap
3874 * Failure: E_POINTER, If lpCmap is invalid.
3875 * E_INVALIDARG, If dwFlags is invalid
3876 * E_OUTOFMEMORY, If there is no memory available
3879 * dwSize may only be CMAP_PTR_SIZE (4) or CMAP_SIZE (8192).
3880 * If dwSize = CMAP_PTR_SIZE, *lpCmap is set to the address of this DLL's
3882 * If dwSize = CMAP_SIZE, lpCmap is filled with a copy of the data from
3883 * this DLL's internal CMap.
3885 HRESULT WINAPI SHGetInverseCMAP(LPDWORD dest, DWORD dwSize)
3888 FIXME(" - returning bogus address for SHGetInverseCMAP\n");
3889 *dest = (DWORD)0xabba1249;
3892 FIXME("(%p, %#lx) stub\n", dest, dwSize);
3896 /*************************************************************************
3897 * SHIsLowMemoryMachine [SHLWAPI.@]
3899 * Determine if the current computer has low memory.
3905 * TRUE if the users machine has 16 Megabytes of memory or less,
3908 BOOL WINAPI SHIsLowMemoryMachine (DWORD x)
3910 FIXME("(0x%08lx) stub\n", x);
3914 /*************************************************************************
3915 * GetMenuPosFromID [SHLWAPI.@]
3917 * Return the position of a menu item from its Id.
3920 * hMenu [I] Menu containing the item
3921 * wID [I] Id of the menu item
3924 * Success: The index of the menu item in hMenu.
3925 * Failure: -1, If the item is not found.
3927 INT WINAPI GetMenuPosFromID(HMENU hMenu, UINT wID)
3930 INT nCount = GetMenuItemCount(hMenu), nIter = 0;
3932 while (nIter < nCount)
3935 if (!GetMenuItemInfoA(hMenu, nIter, TRUE, &mi) && mi.wID == wID)
3942 /*************************************************************************
3945 * Same as SHLWAPI.GetMenuPosFromID
3947 DWORD WINAPI SHMenuIndexFromID(HMENU hMenu, UINT uID)
3949 return GetMenuPosFromID(hMenu, uID);
3953 /*************************************************************************
3956 VOID WINAPI FixSlashesAndColonW(LPWSTR lpwstr)
3967 /*************************************************************************
3970 DWORD WINAPI SHGetAppCompatFlags()
3977 /*************************************************************************
3980 HRESULT WINAPI SHCoCreateInstanceAC(REFCLSID rclsid, LPUNKNOWN pUnkOuter,
3981 DWORD dwClsContext, REFIID iid, LPVOID *ppv)
3983 return CoCreateInstance(rclsid, pUnkOuter, dwClsContext, iid, ppv);
3986 /*************************************************************************
3987 * SHSkipJunction [SHLWAPI.@]
3989 * Determine if a bind context can be bound to an object
3992 * pbc [I] Bind context to check
3993 * pclsid [I] CLSID of object to be bound to
3996 * TRUE: If it is safe to bind
3997 * FALSE: If pbc is invalid or binding would not be safe
4000 BOOL WINAPI SHSkipJunction(IBindCtx *pbc, const CLSID *pclsid)
4002 static const WCHAR szSkipBinding[] = { 'S','k','i','p',' ',
4003 'B','i','n','d','i','n','g',' ','C','L','S','I','D','\0' };
4010 if (SUCCEEDED(IBindCtx_GetObjectParam(pbc, (LPOLESTR)szSkipBinding, &lpUnk)))
4014 if (SUCCEEDED(IUnknown_GetClassID(lpUnk, &clsid)) &&
4015 IsEqualGUID(pclsid, &clsid))
4018 IUnknown_Release(lpUnk);
4024 /***********************************************************************
4025 * SHGetShellKey (SHLWAPI.@)
4027 DWORD WINAPI SHGetShellKey(DWORD a, DWORD b, DWORD c)
4029 FIXME("(%lx, %lx, %lx): stub\n", a, b, c);
4033 /***********************************************************************
4034 * SHQueueUserWorkItem (SHLWAPI.@)
4036 HRESULT WINAPI SHQueueUserWorkItem(DWORD a, DWORD b, DWORD c, DWORD d, DWORD e, DWORD f, DWORD g)
4038 FIXME("(%lx, %lx, %lx, %lx, %lx, %lx, %lx): stub\n", a, b, c, d, e, f, g);
4042 /***********************************************************************
4043 * IUnknown_OnFocusChangeIS (SHLWAPI.@)
4045 DWORD WINAPI IUnknown_OnFocusChangeIS(IUnknown * pUnk, IUnknown * pFocusObject, BOOL bChange)
4047 FIXME("(%p, %p, %s)\n", pUnk, pFocusObject, bChange ? "TRUE" : "FALSE");
4050 IInputObjectSite * pIOS = NULL;
4051 if (SUCCEEDED(IUnknown_QueryInterface(pUnk, &IID_IInputObjectSite, (void **)&pIOS))
4052 IInputObjectSite_OnFocusChangeIS(pIOS, pFocusObject, bChange);
4058 /***********************************************************************
4059 * SHGetValueW (SHLWAPI.@)
4061 HRESULT WINAPI SKGetValueW(DWORD a, LPWSTR b, LPWSTR c, DWORD d, DWORD e, DWORD f)
4063 FIXME("(%lx, %s, %s, %lx, %lx, %lx): stub\n", a, debugstr_w(b), debugstr_w(c), d, e, f);
4067 typedef HRESULT (WINAPI *DllGetVersion_func)(DLLVERSIONINFO *);
4069 /***********************************************************************
4070 * GetUIVersion (SHLWAPI.452)
4072 DWORD WINAPI GetUIVersion(void)
4074 static DWORD version;
4078 DllGetVersion_func pDllGetVersion;
4079 HMODULE dll = LoadLibraryA("shell32.dll");
4082 pDllGetVersion = (DllGetVersion_func)GetProcAddress(dll, "DllGetVersion");
4086 dvi.cbSize = sizeof(DLLVERSIONINFO);
4087 if (pDllGetVersion(&dvi) == S_OK) version = dvi.dwMajorVersion;
4090 if (!version) version = 3; /* old shell dlls don't have DllGetVersion */