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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
30 #include <shdeprecated.h>
36 /* DLL handles for late bound calls */
37 extern HINSTANCE shlwapi_hInstance
;
38 extern DWORD SHLWAPI_ThreadRef_index
;
40 HRESULT WINAPI
IUnknown_QueryService(IUnknown
*,REFGUID
,REFIID
,LPVOID
*);
41 HRESULT WINAPI
SHInvokeCommand(HWND
,IShellFolder
*,LPCITEMIDLIST
,DWORD
);
42 BOOL WINAPI
SHAboutInfoW(LPWSTR
,DWORD
);
45 NOTES: Most functions exported by ordinal seem to be superfluous.
46 The reason for these functions to be there is to provide a wrapper
47 for unicode functions to provide these functions on systems without
48 unicode functions eg. win95/win98. Since we have such functions we just
49 call these. If running Wine with native DLLs, some late bound calls may
50 fail. However, it is better to implement the functions in the forward DLL
51 and recommend the builtin rather than reimplementing the calls here!
54 /*************************************************************************
57 * Copy a sharable memory handle from one process to another.
60 * hShared [I] Shared memory handle to duplicate
61 * dwSrcProcId [I] ID of the process owning hShared
62 * dwDstProcId [I] ID of the process wanting the duplicated handle
63 * dwAccess [I] Desired DuplicateHandle() access
64 * dwOptions [I] Desired DuplicateHandle() options
67 * Success: A handle suitable for use by the dwDstProcId process.
68 * Failure: A NULL handle.
71 HANDLE WINAPI
SHMapHandle(HANDLE hShared
, DWORD dwSrcProcId
, DWORD dwDstProcId
,
72 DWORD dwAccess
, DWORD dwOptions
)
75 DWORD dwMyProcId
= GetCurrentProcessId();
78 TRACE("(%p,%d,%d,%08x,%08x)\n", hShared
, dwDstProcId
, dwSrcProcId
,
81 /* Get dest process handle */
82 if (dwDstProcId
== dwMyProcId
)
83 hDst
= GetCurrentProcess();
85 hDst
= OpenProcess(PROCESS_DUP_HANDLE
, 0, dwDstProcId
);
89 /* Get src process handle */
90 if (dwSrcProcId
== dwMyProcId
)
91 hSrc
= GetCurrentProcess();
93 hSrc
= OpenProcess(PROCESS_DUP_HANDLE
, 0, dwSrcProcId
);
97 /* Make handle available to dest process */
98 if (!DuplicateHandle(hSrc
, hShared
, hDst
, &hRet
,
99 dwAccess
, 0, dwOptions
| DUPLICATE_SAME_ACCESS
))
102 if (dwSrcProcId
!= dwMyProcId
)
106 if (dwDstProcId
!= dwMyProcId
)
110 TRACE("Returning handle %p\n", hRet
);
114 /*************************************************************************
117 * Create a block of sharable memory and initialise it with data.
120 * lpvData [I] Pointer to data to write
121 * dwSize [I] Size of data
122 * dwProcId [I] ID of process owning data
125 * Success: A shared memory handle
129 * Ordinals 7-11 provide a set of calls to create shared memory between a
130 * group of processes. The shared memory is treated opaquely in that its size
131 * is not exposed to clients who map it. This is accomplished by storing
132 * the size of the map as the first DWORD of mapped data, and then offsetting
133 * the view pointer returned by this size.
136 HANDLE WINAPI
SHAllocShared(LPCVOID lpvData
, DWORD dwSize
, DWORD dwProcId
)
142 TRACE("(%p,%d,%d)\n", lpvData
, dwSize
, dwProcId
);
144 /* Create file mapping of the correct length */
145 hMap
= CreateFileMappingA(INVALID_HANDLE_VALUE
, NULL
, FILE_MAP_READ
, 0,
146 dwSize
+ sizeof(dwSize
), NULL
);
150 /* Get a view in our process address space */
151 pMapped
= MapViewOfFile(hMap
, FILE_MAP_READ
| FILE_MAP_WRITE
, 0, 0, 0);
155 /* Write size of data, followed by the data, to the view */
156 *((DWORD
*)pMapped
) = dwSize
;
158 memcpy((char *) pMapped
+ sizeof(dwSize
), lpvData
, dwSize
);
160 /* Release view. All further views mapped will be opaque */
161 UnmapViewOfFile(pMapped
);
162 hRet
= SHMapHandle(hMap
, GetCurrentProcessId(), dwProcId
,
163 FILE_MAP_ALL_ACCESS
, DUPLICATE_SAME_ACCESS
);
170 /*************************************************************************
173 * Get a pointer to a block of shared memory from a shared memory handle.
176 * hShared [I] Shared memory handle
177 * dwProcId [I] ID of process owning hShared
180 * Success: A pointer to the shared memory
184 PVOID WINAPI
SHLockShared(HANDLE hShared
, DWORD dwProcId
)
189 TRACE("(%p %d)\n", hShared
, dwProcId
);
191 /* Get handle to shared memory for current process */
192 hDup
= SHMapHandle(hShared
, dwProcId
, GetCurrentProcessId(), FILE_MAP_ALL_ACCESS
, 0);
195 pMapped
= MapViewOfFile(hDup
, FILE_MAP_READ
| FILE_MAP_WRITE
, 0, 0, 0);
199 return (char *) pMapped
+ sizeof(DWORD
); /* Hide size */
203 /*************************************************************************
206 * Release a pointer to a block of shared memory.
209 * lpView [I] Shared memory pointer
216 BOOL WINAPI
SHUnlockShared(LPVOID lpView
)
218 TRACE("(%p)\n", lpView
);
219 return UnmapViewOfFile((char *) lpView
- sizeof(DWORD
)); /* Include size */
222 /*************************************************************************
225 * Destroy a block of sharable memory.
228 * hShared [I] Shared memory handle
229 * dwProcId [I] ID of process owning hShared
236 BOOL WINAPI
SHFreeShared(HANDLE hShared
, DWORD dwProcId
)
240 TRACE("(%p %d)\n", hShared
, dwProcId
);
245 /* Get a copy of the handle for our process, closing the source handle */
246 hClose
= SHMapHandle(hShared
, dwProcId
, GetCurrentProcessId(),
247 FILE_MAP_ALL_ACCESS
,DUPLICATE_CLOSE_SOURCE
);
248 /* Close local copy */
249 return CloseHandle(hClose
);
252 /*************************************************************************
255 * Create and register a clipboard enumerator for a web browser.
258 * lpBC [I] Binding context
259 * lpUnknown [I] An object exposing the IWebBrowserApp interface
263 * Failure: An HRESULT error code.
266 * The enumerator is stored as a property of the web browser. If it does not
267 * yet exist, it is created and set before being registered.
269 HRESULT WINAPI
RegisterDefaultAcceptHeaders(LPBC lpBC
, IUnknown
*lpUnknown
)
271 static const WCHAR szProperty
[] = { '{','D','0','F','C','A','4','2','0',
272 '-','D','3','F','5','-','1','1','C','F', '-','B','2','1','1','-','0',
273 '0','A','A','0','0','4','A','E','8','3','7','}','\0' };
275 IEnumFORMATETC
* pIEnumFormatEtc
= NULL
;
278 IWebBrowserApp
* pBrowser
;
280 TRACE("(%p, %p)\n", lpBC
, lpUnknown
);
282 hr
= IUnknown_QueryService(lpUnknown
, &IID_IWebBrowserApp
, &IID_IWebBrowserApp
, (void**)&pBrowser
);
286 V_VT(&var
) = VT_EMPTY
;
288 /* The property we get is the browsers clipboard enumerator */
289 property
= SysAllocString(szProperty
);
290 hr
= IWebBrowserApp_GetProperty(pBrowser
, property
, &var
);
291 SysFreeString(property
);
292 if (FAILED(hr
)) goto exit
;
294 if (V_VT(&var
) == VT_EMPTY
)
296 /* Iterate through accepted documents and RegisterClipBoardFormatA() them */
297 char szKeyBuff
[128], szValueBuff
[128];
298 DWORD dwKeySize
, dwValueSize
, dwRet
= 0, dwCount
= 0, dwNumValues
, dwType
;
299 FORMATETC
* formatList
, *format
;
302 TRACE("Registering formats and creating IEnumFORMATETC instance\n");
304 if (!RegOpenKeyA(HKEY_LOCAL_MACHINE
, "Software\\Microsoft\\Windows\\Current"
305 "Version\\Internet Settings\\Accepted Documents", &hDocs
))
311 /* Get count of values in key */
314 dwKeySize
= sizeof(szKeyBuff
);
315 dwRet
= RegEnumValueA(hDocs
,dwCount
,szKeyBuff
,&dwKeySize
,0,&dwType
,0,0);
319 dwNumValues
= dwCount
;
321 /* Note: dwCount = number of items + 1; The extra item is the end node */
322 format
= formatList
= HeapAlloc(GetProcessHeap(), 0, dwCount
* sizeof(FORMATETC
));
337 /* Register clipboard formats for the values and populate format list */
338 while(!dwRet
&& dwCount
< dwNumValues
)
340 dwKeySize
= sizeof(szKeyBuff
);
341 dwValueSize
= sizeof(szValueBuff
);
342 dwRet
= RegEnumValueA(hDocs
, dwCount
, szKeyBuff
, &dwKeySize
, 0, &dwType
,
343 (PBYTE
)szValueBuff
, &dwValueSize
);
346 HeapFree(GetProcessHeap(), 0, formatList
);
352 format
->cfFormat
= RegisterClipboardFormatA(szValueBuff
);
354 format
->dwAspect
= 1;
365 /* Terminate the (maybe empty) list, last entry has a cfFormat of 0 */
366 format
->cfFormat
= 0;
368 format
->dwAspect
= 1;
372 /* Create a clipboard enumerator */
373 hr
= CreateFormatEnumerator(dwNumValues
, formatList
, &pIEnumFormatEtc
);
374 HeapFree(GetProcessHeap(), 0, formatList
);
375 if (FAILED(hr
)) goto exit
;
377 /* Set our enumerator as the browsers property */
378 V_VT(&var
) = VT_UNKNOWN
;
379 V_UNKNOWN(&var
) = (IUnknown
*)pIEnumFormatEtc
;
381 property
= SysAllocString(szProperty
);
382 hr
= IWebBrowserApp_PutProperty(pBrowser
, property
, var
);
383 SysFreeString(property
);
386 IEnumFORMATETC_Release(pIEnumFormatEtc
);
391 if (V_VT(&var
) == VT_UNKNOWN
)
393 /* Our variant is holding the clipboard enumerator */
394 IUnknown
* pIUnknown
= V_UNKNOWN(&var
);
395 IEnumFORMATETC
* pClone
= NULL
;
397 TRACE("Retrieved IEnumFORMATETC property\n");
399 /* Get an IEnumFormatEtc interface from the variants value */
400 pIEnumFormatEtc
= NULL
;
401 hr
= IUnknown_QueryInterface(pIUnknown
, &IID_IEnumFORMATETC
, (void**)&pIEnumFormatEtc
);
402 if (hr
== S_OK
&& pIEnumFormatEtc
)
404 /* Clone and register the enumerator */
405 hr
= IEnumFORMATETC_Clone(pIEnumFormatEtc
, &pClone
);
406 if (hr
== S_OK
&& pClone
)
408 RegisterFormatEnumerator(lpBC
, pClone
, 0);
410 IEnumFORMATETC_Release(pClone
);
413 IUnknown_Release(pIUnknown
);
415 IUnknown_Release(V_UNKNOWN(&var
));
419 IWebBrowserApp_Release(pBrowser
);
423 /*************************************************************************
426 * Get Explorers "AcceptLanguage" setting.
429 * langbuf [O] Destination for language string
430 * buflen [I] Length of langbuf in characters
431 * [0] Success: used length of langbuf
434 * Success: S_OK. langbuf is set to the language string found.
435 * Failure: E_FAIL, If any arguments are invalid, error occurred, or Explorer
436 * does not contain the setting.
437 * E_NOT_SUFFICIENT_BUFFER, If the buffer is not big enough
439 HRESULT WINAPI
GetAcceptLanguagesW( LPWSTR langbuf
, LPDWORD buflen
)
441 static const WCHAR szkeyW
[] = {
442 'S','o','f','t','w','a','r','e','\\',
443 'M','i','c','r','o','s','o','f','t','\\',
444 'I','n','t','e','r','n','e','t',' ','E','x','p','l','o','r','e','r','\\',
445 'I','n','t','e','r','n','a','t','i','o','n','a','l',0};
446 static const WCHAR valueW
[] = {
447 'A','c','c','e','p','t','L','a','n','g','u','a','g','e',0};
448 DWORD mystrlen
, mytype
;
455 TRACE("(%p, %p) *%p: %d\n", langbuf
, buflen
, buflen
, buflen
? *buflen
: -1);
457 if(!langbuf
|| !buflen
|| !*buflen
)
460 mystrlen
= (*buflen
> 20) ? *buflen
: 20 ;
461 len
= mystrlen
* sizeof(WCHAR
);
462 mystr
= HeapAlloc(GetProcessHeap(), 0, len
);
464 RegOpenKeyW(HKEY_CURRENT_USER
, szkeyW
, &mykey
);
465 lres
= RegQueryValueExW(mykey
, valueW
, 0, &mytype
, (PBYTE
)mystr
, &len
);
467 len
= lstrlenW(mystr
);
469 if (!lres
&& (*buflen
> len
)) {
470 lstrcpyW(langbuf
, mystr
);
472 HeapFree(GetProcessHeap(), 0, mystr
);
476 /* Did not find a value in the registry or the user buffer is too small */
477 mylcid
= GetUserDefaultLCID();
478 LcidToRfc1766W(mylcid
, mystr
, mystrlen
);
479 len
= lstrlenW(mystr
);
481 memcpy( langbuf
, mystr
, min(*buflen
, len
+1)*sizeof(WCHAR
) );
482 HeapFree(GetProcessHeap(), 0, mystr
);
490 return E_NOT_SUFFICIENT_BUFFER
;
493 /*************************************************************************
496 * Ascii version of GetAcceptLanguagesW.
498 HRESULT WINAPI
GetAcceptLanguagesA( LPSTR langbuf
, LPDWORD buflen
)
501 DWORD buflenW
, convlen
;
504 TRACE("(%p, %p) *%p: %d\n", langbuf
, buflen
, buflen
, buflen
? *buflen
: -1);
506 if(!langbuf
|| !buflen
|| !*buflen
) return E_FAIL
;
509 langbufW
= HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR
) * buflenW
);
510 retval
= GetAcceptLanguagesW(langbufW
, &buflenW
);
514 convlen
= WideCharToMultiByte(CP_ACP
, 0, langbufW
, -1, langbuf
, *buflen
, NULL
, NULL
);
515 convlen
--; /* do not count the terminating 0 */
517 else /* copy partial string anyway */
519 convlen
= WideCharToMultiByte(CP_ACP
, 0, langbufW
, *buflen
, langbuf
, *buflen
, NULL
, NULL
);
520 if (convlen
< *buflen
)
522 langbuf
[convlen
] = 0;
523 convlen
--; /* do not count the terminating 0 */
530 *buflen
= buflenW
? convlen
: 0;
532 HeapFree(GetProcessHeap(), 0, langbufW
);
536 /*************************************************************************
539 * Convert a GUID to a string.
542 * guid [I] GUID to convert
543 * lpszDest [O] Destination for string
544 * cchMax [I] Length of output buffer
547 * The length of the string created.
549 INT WINAPI
SHStringFromGUIDA(REFGUID guid
, LPSTR lpszDest
, INT cchMax
)
554 TRACE("(%s,%p,%d)\n", debugstr_guid(guid
), lpszDest
, cchMax
);
556 sprintf(xguid
, "{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
557 guid
->Data1
, guid
->Data2
, guid
->Data3
,
558 guid
->Data4
[0], guid
->Data4
[1], guid
->Data4
[2], guid
->Data4
[3],
559 guid
->Data4
[4], guid
->Data4
[5], guid
->Data4
[6], guid
->Data4
[7]);
561 iLen
= strlen(xguid
) + 1;
565 memcpy(lpszDest
, xguid
, iLen
);
569 /*************************************************************************
572 * Convert a GUID to a string.
575 * guid [I] GUID to convert
576 * str [O] Destination for string
577 * cmax [I] Length of output buffer
580 * The length of the string created.
582 INT WINAPI
SHStringFromGUIDW(REFGUID guid
, LPWSTR lpszDest
, INT cchMax
)
586 static const WCHAR wszFormat
[] = {'{','%','0','8','l','X','-','%','0','4','X','-','%','0','4','X','-',
587 '%','0','2','X','%','0','2','X','-','%','0','2','X','%','0','2','X','%','0','2','X','%','0','2',
588 'X','%','0','2','X','%','0','2','X','}',0};
590 TRACE("(%s,%p,%d)\n", debugstr_guid(guid
), lpszDest
, cchMax
);
592 sprintfW(xguid
, wszFormat
, guid
->Data1
, guid
->Data2
, guid
->Data3
,
593 guid
->Data4
[0], guid
->Data4
[1], guid
->Data4
[2], guid
->Data4
[3],
594 guid
->Data4
[4], guid
->Data4
[5], guid
->Data4
[6], guid
->Data4
[7]);
596 iLen
= strlenW(xguid
) + 1;
600 memcpy(lpszDest
, xguid
, iLen
*sizeof(WCHAR
));
604 /*************************************************************************
607 * Determine if a Unicode character is a blank.
610 * wc [I] Character to check.
613 * TRUE, if wc is a blank,
617 BOOL WINAPI
IsCharBlankW(WCHAR wc
)
621 return GetStringTypeW(CT_CTYPE1
, &wc
, 1, &CharType
) && (CharType
& C1_BLANK
);
624 /*************************************************************************
627 * Determine if a Unicode character is punctuation.
630 * wc [I] Character to check.
633 * TRUE, if wc is punctuation,
636 BOOL WINAPI
IsCharPunctW(WCHAR wc
)
640 return GetStringTypeW(CT_CTYPE1
, &wc
, 1, &CharType
) && (CharType
& C1_PUNCT
);
643 /*************************************************************************
646 * Determine if a Unicode character is a control character.
649 * wc [I] Character to check.
652 * TRUE, if wc is a control character,
655 BOOL WINAPI
IsCharCntrlW(WCHAR wc
)
659 return GetStringTypeW(CT_CTYPE1
, &wc
, 1, &CharType
) && (CharType
& C1_CNTRL
);
662 /*************************************************************************
665 * Determine if a Unicode character is a digit.
668 * wc [I] Character to check.
671 * TRUE, if wc is a digit,
674 BOOL WINAPI
IsCharDigitW(WCHAR wc
)
678 return GetStringTypeW(CT_CTYPE1
, &wc
, 1, &CharType
) && (CharType
& C1_DIGIT
);
681 /*************************************************************************
684 * Determine if a Unicode character is a hex digit.
687 * wc [I] Character to check.
690 * TRUE, if wc is a hex digit,
693 BOOL WINAPI
IsCharXDigitW(WCHAR wc
)
697 return GetStringTypeW(CT_CTYPE1
, &wc
, 1, &CharType
) && (CharType
& C1_XDIGIT
);
700 /*************************************************************************
704 BOOL WINAPI
GetStringType3ExW(LPWSTR src
, INT count
, LPWORD type
)
706 return GetStringTypeW(CT_CTYPE3
, src
, count
, type
);
709 /*************************************************************************
712 * Compare two Ascii strings up to a given length.
715 * lpszSrc [I] Source string
716 * lpszCmp [I] String to compare to lpszSrc
717 * len [I] Maximum length
720 * A number greater than, less than or equal to 0 depending on whether
721 * lpszSrc is greater than, less than or equal to lpszCmp.
723 DWORD WINAPI
StrCmpNCA(LPCSTR lpszSrc
, LPCSTR lpszCmp
, INT len
)
725 return StrCmpNA(lpszSrc
, lpszCmp
, len
);
728 /*************************************************************************
731 * Unicode version of StrCmpNCA.
733 DWORD WINAPI
StrCmpNCW(LPCWSTR lpszSrc
, LPCWSTR lpszCmp
, INT len
)
735 return StrCmpNW(lpszSrc
, lpszCmp
, len
);
738 /*************************************************************************
741 * Compare two Ascii strings up to a given length, ignoring case.
744 * lpszSrc [I] Source string
745 * lpszCmp [I] String to compare to lpszSrc
746 * len [I] Maximum length
749 * A number greater than, less than or equal to 0 depending on whether
750 * lpszSrc is greater than, less than or equal to lpszCmp.
752 DWORD WINAPI
StrCmpNICA(LPCSTR lpszSrc
, LPCSTR lpszCmp
, DWORD len
)
754 return StrCmpNIA(lpszSrc
, lpszCmp
, len
);
757 /*************************************************************************
760 * Unicode version of StrCmpNICA.
762 DWORD WINAPI
StrCmpNICW(LPCWSTR lpszSrc
, LPCWSTR lpszCmp
, DWORD len
)
764 return StrCmpNIW(lpszSrc
, lpszCmp
, len
);
767 /*************************************************************************
770 * Compare two Ascii strings.
773 * lpszSrc [I] Source string
774 * lpszCmp [I] String to compare to lpszSrc
777 * A number greater than, less than or equal to 0 depending on whether
778 * lpszSrc is greater than, less than or equal to lpszCmp.
780 DWORD WINAPI
StrCmpCA(LPCSTR lpszSrc
, LPCSTR lpszCmp
)
782 return lstrcmpA(lpszSrc
, lpszCmp
);
785 /*************************************************************************
788 * Unicode version of StrCmpCA.
790 DWORD WINAPI
StrCmpCW(LPCWSTR lpszSrc
, LPCWSTR lpszCmp
)
792 return lstrcmpW(lpszSrc
, lpszCmp
);
795 /*************************************************************************
798 * Compare two Ascii strings, ignoring case.
801 * lpszSrc [I] Source string
802 * lpszCmp [I] String to compare to lpszSrc
805 * A number greater than, less than or equal to 0 depending on whether
806 * lpszSrc is greater than, less than or equal to lpszCmp.
808 DWORD WINAPI
StrCmpICA(LPCSTR lpszSrc
, LPCSTR lpszCmp
)
810 return lstrcmpiA(lpszSrc
, lpszCmp
);
813 /*************************************************************************
816 * Unicode version of StrCmpICA.
818 DWORD WINAPI
StrCmpICW(LPCWSTR lpszSrc
, LPCWSTR lpszCmp
)
820 return lstrcmpiW(lpszSrc
, lpszCmp
);
823 /*************************************************************************
826 * Get an identification string for the OS and explorer.
829 * lpszDest [O] Destination for Id string
830 * dwDestLen [I] Length of lpszDest
833 * TRUE, If the string was created successfully
836 BOOL WINAPI
SHAboutInfoA(LPSTR lpszDest
, DWORD dwDestLen
)
840 TRACE("(%p,%d)\n", lpszDest
, dwDestLen
);
842 if (lpszDest
&& SHAboutInfoW(buff
, dwDestLen
))
844 WideCharToMultiByte(CP_ACP
, 0, buff
, -1, lpszDest
, dwDestLen
, NULL
, NULL
);
850 /*************************************************************************
853 * Unicode version of SHAboutInfoA.
855 BOOL WINAPI
SHAboutInfoW(LPWSTR lpszDest
, DWORD dwDestLen
)
857 static const WCHAR szIEKey
[] = { 'S','O','F','T','W','A','R','E','\\',
858 'M','i','c','r','o','s','o','f','t','\\','I','n','t','e','r','n','e','t',
859 ' ','E','x','p','l','o','r','e','r','\0' };
860 static const WCHAR szWinNtKey
[] = { 'S','O','F','T','W','A','R','E','\\',
861 'M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s',' ',
862 'N','T','\\','C','u','r','r','e','n','t','V','e','r','s','i','o','n','\0' };
863 static const WCHAR szWinKey
[] = { 'S','O','F','T','W','A','R','E','\\',
864 'M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\',
865 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\0' };
866 static const WCHAR szRegKey
[] = { 'S','O','F','T','W','A','R','E','\\',
867 'M','i','c','r','o','s','o','f','t','\\','I','n','t','e','r','n','e','t',
868 ' ','E','x','p','l','o','r','e','r','\\',
869 'R','e','g','i','s','t','r','a','t','i','o','n','\0' };
870 static const WCHAR szVersion
[] = { 'V','e','r','s','i','o','n','\0' };
871 static const WCHAR szCustomized
[] = { 'C','u','s','t','o','m','i','z','e','d',
872 'V','e','r','s','i','o','n','\0' };
873 static const WCHAR szOwner
[] = { 'R','e','g','i','s','t','e','r','e','d',
874 'O','w','n','e','r','\0' };
875 static const WCHAR szOrg
[] = { 'R','e','g','i','s','t','e','r','e','d',
876 'O','r','g','a','n','i','z','a','t','i','o','n','\0' };
877 static const WCHAR szProduct
[] = { 'P','r','o','d','u','c','t','I','d','\0' };
878 static const WCHAR szUpdate
[] = { 'I','E','A','K',
879 'U','p','d','a','t','e','U','r','l','\0' };
880 static const WCHAR szHelp
[] = { 'I','E','A','K',
881 'H','e','l','p','S','t','r','i','n','g','\0' };
886 TRACE("(%p,%d)\n", lpszDest
, dwDestLen
);
893 /* Try the NT key first, followed by 95/98 key */
894 if (RegOpenKeyExW(HKEY_LOCAL_MACHINE
, szWinNtKey
, 0, KEY_READ
, &hReg
) &&
895 RegOpenKeyExW(HKEY_LOCAL_MACHINE
, szWinKey
, 0, KEY_READ
, &hReg
))
901 if (!SHGetValueW(HKEY_LOCAL_MACHINE
, szIEKey
, szVersion
, &dwType
, buff
, &dwLen
))
903 DWORD dwStrLen
= strlenW(buff
);
904 dwLen
= 30 - dwStrLen
;
905 SHGetValueW(HKEY_LOCAL_MACHINE
, szIEKey
,
906 szCustomized
, &dwType
, buff
+dwStrLen
, &dwLen
);
908 StrCatBuffW(lpszDest
, buff
, dwDestLen
);
910 /* ~Registered Owner */
913 if (SHGetValueW(hReg
, szOwner
, 0, &dwType
, buff
+1, &dwLen
))
915 StrCatBuffW(lpszDest
, buff
, dwDestLen
);
917 /* ~Registered Organization */
919 if (SHGetValueW(hReg
, szOrg
, 0, &dwType
, buff
+1, &dwLen
))
921 StrCatBuffW(lpszDest
, buff
, dwDestLen
);
923 /* FIXME: Not sure where this number comes from */
927 StrCatBuffW(lpszDest
, buff
, dwDestLen
);
931 if (SHGetValueW(HKEY_LOCAL_MACHINE
, szRegKey
, szProduct
, &dwType
, buff
+1, &dwLen
))
933 StrCatBuffW(lpszDest
, buff
, dwDestLen
);
937 if(SHGetValueW(HKEY_LOCAL_MACHINE
, szWinKey
, szUpdate
, &dwType
, buff
+1, &dwLen
))
939 StrCatBuffW(lpszDest
, buff
, dwDestLen
);
941 /* ~IE Help String */
943 if(SHGetValueW(hReg
, szHelp
, 0, &dwType
, buff
+1, &dwLen
))
945 StrCatBuffW(lpszDest
, buff
, dwDestLen
);
951 /*************************************************************************
954 * Call IOleCommandTarget_QueryStatus() on an object.
957 * lpUnknown [I] Object supporting the IOleCommandTarget interface
958 * pguidCmdGroup [I] GUID for the command group
960 * prgCmds [O] Commands
961 * pCmdText [O] Command text
965 * Failure: E_FAIL, if lpUnknown is NULL.
966 * E_NOINTERFACE, if lpUnknown does not support IOleCommandTarget.
967 * Otherwise, an error code from IOleCommandTarget_QueryStatus().
969 HRESULT WINAPI
IUnknown_QueryStatus(IUnknown
* lpUnknown
, REFGUID pguidCmdGroup
,
970 ULONG cCmds
, OLECMD
*prgCmds
, OLECMDTEXT
* pCmdText
)
972 HRESULT hRet
= E_FAIL
;
974 TRACE("(%p,%p,%d,%p,%p)\n",lpUnknown
, pguidCmdGroup
, cCmds
, prgCmds
, pCmdText
);
978 IOleCommandTarget
* lpOle
;
980 hRet
= IUnknown_QueryInterface(lpUnknown
, &IID_IOleCommandTarget
,
983 if (SUCCEEDED(hRet
) && lpOle
)
985 hRet
= IOleCommandTarget_QueryStatus(lpOle
, pguidCmdGroup
, cCmds
,
987 IOleCommandTarget_Release(lpOle
);
993 /*************************************************************************
996 * Call IOleCommandTarget_Exec() on an object.
999 * lpUnknown [I] Object supporting the IOleCommandTarget interface
1000 * pguidCmdGroup [I] GUID for the command group
1004 * Failure: E_FAIL, if lpUnknown is NULL.
1005 * E_NOINTERFACE, if lpUnknown does not support IOleCommandTarget.
1006 * Otherwise, an error code from IOleCommandTarget_Exec().
1008 HRESULT WINAPI
IUnknown_Exec(IUnknown
* lpUnknown
, REFGUID pguidCmdGroup
,
1009 DWORD nCmdID
, DWORD nCmdexecopt
, VARIANT
* pvaIn
,
1012 HRESULT hRet
= E_FAIL
;
1014 TRACE("(%p,%p,%d,%d,%p,%p)\n",lpUnknown
, pguidCmdGroup
, nCmdID
,
1015 nCmdexecopt
, pvaIn
, pvaOut
);
1019 IOleCommandTarget
* lpOle
;
1021 hRet
= IUnknown_QueryInterface(lpUnknown
, &IID_IOleCommandTarget
,
1023 if (SUCCEEDED(hRet
) && lpOle
)
1025 hRet
= IOleCommandTarget_Exec(lpOle
, pguidCmdGroup
, nCmdID
,
1026 nCmdexecopt
, pvaIn
, pvaOut
);
1027 IOleCommandTarget_Release(lpOle
);
1033 /*************************************************************************
1036 * Retrieve, modify, and re-set a value from a window.
1039 * hWnd [I] Window to get value from
1040 * offset [I] Offset of value
1041 * mask [I] Mask for flags
1042 * flags [I] Bits to set in window value
1045 * The new value as it was set, or 0 if any parameter is invalid.
1048 * Only bits specified in mask are affected - set if present in flags and
1051 LONG WINAPI
SHSetWindowBits(HWND hwnd
, INT offset
, UINT mask
, UINT flags
)
1053 LONG ret
= GetWindowLongW(hwnd
, offset
);
1054 LONG new_flags
= (flags
& mask
) | (ret
& ~mask
);
1056 TRACE("%p %d %x %x\n", hwnd
, offset
, mask
, flags
);
1058 if (new_flags
!= ret
)
1059 ret
= SetWindowLongW(hwnd
, offset
, new_flags
);
1063 /*************************************************************************
1066 * Change a window's parent.
1069 * hWnd [I] Window to change parent of
1070 * hWndParent [I] New parent window
1073 * The old parent of hWnd.
1076 * If hWndParent is NULL (desktop), the window style is changed to WS_POPUP.
1077 * If hWndParent is NOT NULL then we set the WS_CHILD style.
1079 HWND WINAPI
SHSetParentHwnd(HWND hWnd
, HWND hWndParent
)
1081 TRACE("%p, %p\n", hWnd
, hWndParent
);
1083 if(GetParent(hWnd
) == hWndParent
)
1087 SHSetWindowBits(hWnd
, GWL_STYLE
, WS_CHILD
| WS_POPUP
, WS_CHILD
);
1089 SHSetWindowBits(hWnd
, GWL_STYLE
, WS_CHILD
| WS_POPUP
, WS_POPUP
);
1091 return hWndParent
? SetParent(hWnd
, hWndParent
) : NULL
;
1094 /*************************************************************************
1097 * Locate and advise a connection point in an IConnectionPointContainer object.
1100 * lpUnkSink [I] Sink for the connection point advise call
1101 * riid [I] REFIID of connection point to advise
1102 * fConnect [I] TRUE = Connection being establisted, FALSE = broken
1103 * lpUnknown [I] Object supporting the IConnectionPointContainer interface
1104 * lpCookie [O] Pointer to connection point cookie
1105 * lppCP [O] Destination for the IConnectionPoint found
1108 * Success: S_OK. If lppCP is non-NULL, it is filled with the IConnectionPoint
1109 * that was advised. The caller is responsible for releasing it.
1110 * Failure: E_FAIL, if any arguments are invalid.
1111 * E_NOINTERFACE, if lpUnknown isn't an IConnectionPointContainer,
1112 * Or an HRESULT error code if any call fails.
1114 HRESULT WINAPI
ConnectToConnectionPoint(IUnknown
* lpUnkSink
, REFIID riid
, BOOL fConnect
,
1115 IUnknown
* lpUnknown
, LPDWORD lpCookie
,
1116 IConnectionPoint
**lppCP
)
1119 IConnectionPointContainer
* lpContainer
;
1120 IConnectionPoint
*lpCP
;
1122 if(!lpUnknown
|| (fConnect
&& !lpUnkSink
))
1128 hRet
= IUnknown_QueryInterface(lpUnknown
, &IID_IConnectionPointContainer
,
1129 (void**)&lpContainer
);
1130 if (SUCCEEDED(hRet
))
1132 hRet
= IConnectionPointContainer_FindConnectionPoint(lpContainer
, riid
, &lpCP
);
1134 if (SUCCEEDED(hRet
))
1137 hRet
= IConnectionPoint_Unadvise(lpCP
, *lpCookie
);
1139 hRet
= IConnectionPoint_Advise(lpCP
, lpUnkSink
, lpCookie
);
1144 if (lppCP
&& SUCCEEDED(hRet
))
1145 *lppCP
= lpCP
; /* Caller keeps the interface */
1147 IConnectionPoint_Release(lpCP
); /* Release it */
1150 IConnectionPointContainer_Release(lpContainer
);
1155 /*************************************************************************
1158 * Release an interface and zero a supplied pointer.
1161 * lpUnknown [I] Object to release
1166 void WINAPI
IUnknown_AtomicRelease(IUnknown
** lpUnknown
)
1168 TRACE("(%p)\n", lpUnknown
);
1170 if(!lpUnknown
|| !*lpUnknown
) return;
1172 TRACE("doing Release\n");
1174 IUnknown_Release(*lpUnknown
);
1178 /*************************************************************************
1181 * Skip '//' if present in a string.
1184 * lpszSrc [I] String to check for '//'
1187 * Success: The next character after the '//' or the string if not present
1188 * Failure: NULL, if lpszStr is NULL.
1190 LPCSTR WINAPI
PathSkipLeadingSlashesA(LPCSTR lpszSrc
)
1192 if (lpszSrc
&& lpszSrc
[0] == '/' && lpszSrc
[1] == '/')
1197 /*************************************************************************
1200 * Check if two interfaces come from the same object.
1203 * lpInt1 [I] Interface to check against lpInt2.
1204 * lpInt2 [I] Interface to check against lpInt1.
1207 * TRUE, If the interfaces come from the same object.
1210 BOOL WINAPI
SHIsSameObject(IUnknown
* lpInt1
, IUnknown
* lpInt2
)
1212 IUnknown
*lpUnknown1
, *lpUnknown2
;
1215 TRACE("(%p %p)\n", lpInt1
, lpInt2
);
1217 if (!lpInt1
|| !lpInt2
)
1220 if (lpInt1
== lpInt2
)
1223 if (IUnknown_QueryInterface(lpInt1
, &IID_IUnknown
, (void**)&lpUnknown1
) != S_OK
)
1226 if (IUnknown_QueryInterface(lpInt2
, &IID_IUnknown
, (void**)&lpUnknown2
) != S_OK
)
1228 IUnknown_Release(lpUnknown1
);
1232 ret
= lpUnknown1
== lpUnknown2
;
1234 IUnknown_Release(lpUnknown1
);
1235 IUnknown_Release(lpUnknown2
);
1240 /*************************************************************************
1243 * Get the window handle of an object.
1246 * lpUnknown [I] Object to get the window handle of
1247 * lphWnd [O] Destination for window handle
1250 * Success: S_OK. lphWnd contains the objects window handle.
1251 * Failure: An HRESULT error code.
1254 * lpUnknown is expected to support one of the following interfaces:
1255 * IOleWindow(), IInternetSecurityMgrSite(), or IShellView().
1257 HRESULT WINAPI
IUnknown_GetWindow(IUnknown
*lpUnknown
, HWND
*lphWnd
)
1260 HRESULT hRet
= E_FAIL
;
1262 TRACE("(%p,%p)\n", lpUnknown
, lphWnd
);
1267 hRet
= IUnknown_QueryInterface(lpUnknown
, &IID_IOleWindow
, (void**)&lpOle
);
1271 hRet
= IUnknown_QueryInterface(lpUnknown
,&IID_IShellView
, (void**)&lpOle
);
1275 hRet
= IUnknown_QueryInterface(lpUnknown
, &IID_IInternetSecurityMgrSite
,
1280 if (SUCCEEDED(hRet
))
1282 /* Laziness here - Since GetWindow() is the first method for the above 3
1283 * interfaces, we use the same call for them all.
1285 hRet
= IOleWindow_GetWindow((IOleWindow
*)lpOle
, lphWnd
);
1286 IUnknown_Release(lpOle
);
1288 TRACE("Returning HWND=%p\n", *lphWnd
);
1294 /*************************************************************************
1297 * Call a SetOwner method of IShellService from specified object.
1300 * iface [I] Object that supports IShellService
1301 * pUnk [I] Argument for the SetOwner call
1304 * Corresponding return value from last call or E_FAIL for null input
1306 HRESULT WINAPI
IUnknown_SetOwner(IUnknown
*iface
, IUnknown
*pUnk
)
1308 IShellService
*service
;
1311 TRACE("(%p, %p)\n", iface
, pUnk
);
1313 if (!iface
) return E_FAIL
;
1315 hr
= IUnknown_QueryInterface(iface
, &IID_IShellService
, (void**)&service
);
1318 hr
= IShellService_SetOwner(service
, pUnk
);
1319 IShellService_Release(service
);
1325 /*************************************************************************
1328 * Call either IObjectWithSite_SetSite() or IInternetSecurityManager_SetSecuritySite() on
1332 HRESULT WINAPI
IUnknown_SetSite(
1333 IUnknown
*obj
, /* [in] OLE object */
1334 IUnknown
*site
) /* [in] Site interface */
1337 IObjectWithSite
*iobjwithsite
;
1338 IInternetSecurityManager
*isecmgr
;
1340 if (!obj
) return E_FAIL
;
1342 hr
= IUnknown_QueryInterface(obj
, &IID_IObjectWithSite
, (LPVOID
*)&iobjwithsite
);
1343 TRACE("IID_IObjectWithSite QI ret=%08x, %p\n", hr
, iobjwithsite
);
1346 hr
= IObjectWithSite_SetSite(iobjwithsite
, site
);
1347 TRACE("done IObjectWithSite_SetSite ret=%08x\n", hr
);
1348 IObjectWithSite_Release(iobjwithsite
);
1352 hr
= IUnknown_QueryInterface(obj
, &IID_IInternetSecurityManager
, (LPVOID
*)&isecmgr
);
1353 TRACE("IID_IInternetSecurityManager QI ret=%08x, %p\n", hr
, isecmgr
);
1354 if (FAILED(hr
)) return hr
;
1356 hr
= IInternetSecurityManager_SetSecuritySite(isecmgr
, (IInternetSecurityMgrSite
*)site
);
1357 TRACE("done IInternetSecurityManager_SetSecuritySite ret=%08x\n", hr
);
1358 IInternetSecurityManager_Release(isecmgr
);
1363 /*************************************************************************
1366 * Call IPersist_GetClassID() on an object.
1369 * lpUnknown [I] Object supporting the IPersist interface
1370 * clsid [O] Destination for Class Id
1373 * Success: S_OK. lpClassId contains the Class Id requested.
1374 * Failure: E_FAIL, If lpUnknown is NULL,
1375 * E_NOINTERFACE If lpUnknown does not support IPersist,
1376 * Or an HRESULT error code.
1378 HRESULT WINAPI
IUnknown_GetClassID(IUnknown
*lpUnknown
, CLSID
*clsid
)
1383 TRACE("(%p, %p)\n", lpUnknown
, clsid
);
1387 memset(clsid
, 0, sizeof(*clsid
));
1391 hr
= IUnknown_QueryInterface(lpUnknown
, &IID_IPersist
, (void**)&persist
);
1394 hr
= IUnknown_QueryInterface(lpUnknown
, &IID_IPersistFolder
, (void**)&persist
);
1399 hr
= IPersist_GetClassID(persist
, clsid
);
1400 IPersist_Release(persist
);
1404 /*************************************************************************
1407 * Retrieve a Service Interface from an object.
1410 * lpUnknown [I] Object to get an IServiceProvider interface from
1411 * sid [I] Service ID for IServiceProvider_QueryService() call
1412 * riid [I] Function requested for QueryService call
1413 * lppOut [O] Destination for the service interface pointer
1416 * Success: S_OK. lppOut contains an object providing the requested service
1417 * Failure: An HRESULT error code
1420 * lpUnknown is expected to support the IServiceProvider interface.
1422 HRESULT WINAPI
IUnknown_QueryService(IUnknown
* lpUnknown
, REFGUID sid
, REFIID riid
,
1425 IServiceProvider
* pService
= NULL
;
1436 hRet
= IUnknown_QueryInterface(lpUnknown
, &IID_IServiceProvider
,
1437 (LPVOID
*)&pService
);
1439 if (hRet
== S_OK
&& pService
)
1441 TRACE("QueryInterface returned (IServiceProvider*)%p\n", pService
);
1443 /* Get a Service interface from the object */
1444 hRet
= IServiceProvider_QueryService(pService
, sid
, riid
, lppOut
);
1446 TRACE("(IServiceProvider*)%p returned (IUnknown*)%p\n", pService
, *lppOut
);
1448 IServiceProvider_Release(pService
);
1453 /*************************************************************************
1456 * Calls IOleCommandTarget::Exec() for specified service object.
1459 * lpUnknown [I] Object to get an IServiceProvider interface from
1460 * service [I] Service ID for IServiceProvider_QueryService() call
1461 * group [I] Group ID for IOleCommandTarget::Exec() call
1462 * cmdId [I] Command ID for IOleCommandTarget::Exec() call
1463 * cmdOpt [I] Options flags for command
1464 * pIn [I] Input arguments for command
1465 * pOut [O] Output arguments for command
1468 * Success: S_OK. lppOut contains an object providing the requested service
1469 * Failure: An HRESULT error code
1472 * lpUnknown is expected to support the IServiceProvider interface.
1474 HRESULT WINAPI
IUnknown_QueryServiceExec(IUnknown
*lpUnknown
, REFIID service
,
1475 const GUID
*group
, DWORD cmdId
, DWORD cmdOpt
, VARIANT
*pIn
, VARIANT
*pOut
)
1477 IOleCommandTarget
*target
;
1480 TRACE("%p %s %s %d %08x %p %p\n", lpUnknown
, debugstr_guid(service
),
1481 debugstr_guid(group
), cmdId
, cmdOpt
, pIn
, pOut
);
1483 hr
= IUnknown_QueryService(lpUnknown
, service
, &IID_IOleCommandTarget
, (void**)&target
);
1486 hr
= IOleCommandTarget_Exec(target
, group
, cmdId
, cmdOpt
, pIn
, pOut
);
1487 IOleCommandTarget_Release(target
);
1490 TRACE("<-- hr=0x%08x\n", hr
);
1495 /*************************************************************************
1498 * Calls IProfferService methods to proffer/revoke specified service.
1501 * lpUnknown [I] Object to get an IServiceProvider interface from
1502 * service [I] Service ID for IProfferService::Proffer/Revoke calls
1503 * pService [I] Service to proffer. If NULL ::Revoke is called
1504 * pCookie [IO] Group ID for IOleCommandTarget::Exec() call
1507 * Success: S_OK. IProffer method returns S_OK
1508 * Failure: An HRESULT error code
1511 * lpUnknown is expected to support the IServiceProvider interface.
1513 HRESULT WINAPI
IUnknown_ProfferService(IUnknown
*lpUnknown
, REFGUID service
, IServiceProvider
*pService
, DWORD
*pCookie
)
1515 IProfferService
*proffer
;
1518 TRACE("%p %s %p %p\n", lpUnknown
, debugstr_guid(service
), pService
, pCookie
);
1520 hr
= IUnknown_QueryService(lpUnknown
, &IID_IProfferService
, &IID_IProfferService
, (void**)&proffer
);
1524 hr
= IProfferService_ProfferService(proffer
, service
, pService
, pCookie
);
1527 hr
= IProfferService_RevokeService(proffer
, *pCookie
);
1531 IProfferService_Release(proffer
);
1537 /*************************************************************************
1540 * Call an object's UIActivateIO method.
1543 * unknown [I] Object to call the UIActivateIO method on
1544 * activate [I] Parameter for UIActivateIO call
1545 * msg [I] Parameter for UIActivateIO call
1548 * Success: Value of UI_ActivateIO call
1549 * Failure: An HRESULT error code
1552 * unknown is expected to support the IInputObject interface.
1554 HRESULT WINAPI
IUnknown_UIActivateIO(IUnknown
*unknown
, BOOL activate
, LPMSG msg
)
1556 IInputObject
* object
= NULL
;
1562 /* Get an IInputObject interface from the object */
1563 ret
= IUnknown_QueryInterface(unknown
, &IID_IInputObject
, (LPVOID
*) &object
);
1567 ret
= IInputObject_UIActivateIO(object
, activate
, msg
);
1568 IInputObject_Release(object
);
1574 /*************************************************************************
1577 * Loads a popup menu.
1580 * hInst [I] Instance handle
1581 * szName [I] Menu name
1587 BOOL WINAPI
SHLoadMenuPopup(HINSTANCE hInst
, LPCWSTR szName
)
1591 TRACE("%p %s\n", hInst
, debugstr_w(szName
));
1593 if ((hMenu
= LoadMenuW(hInst
, szName
)))
1595 if (GetSubMenu(hMenu
, 0))
1596 RemoveMenu(hMenu
, 0, MF_BYPOSITION
);
1604 typedef struct _enumWndData
1609 LRESULT (WINAPI
*pfnPost
)(HWND
,UINT
,WPARAM
,LPARAM
);
1612 /* Callback for SHLWAPI_178 */
1613 static BOOL CALLBACK
SHLWAPI_EnumChildProc(HWND hWnd
, LPARAM lParam
)
1615 enumWndData
*data
= (enumWndData
*)lParam
;
1617 TRACE("(%p,%p)\n", hWnd
, data
);
1618 data
->pfnPost(hWnd
, data
->uiMsgId
, data
->wParam
, data
->lParam
);
1622 /*************************************************************************
1625 * Send or post a message to every child of a window.
1628 * hWnd [I] Window whose children will get the messages
1629 * uiMsgId [I] Message Id
1630 * wParam [I] WPARAM of message
1631 * lParam [I] LPARAM of message
1632 * bSend [I] TRUE = Use SendMessageA(), FALSE = Use PostMessageA()
1638 * The appropriate ASCII or Unicode function is called for the window.
1640 void WINAPI
SHPropagateMessage(HWND hWnd
, UINT uiMsgId
, WPARAM wParam
, LPARAM lParam
, BOOL bSend
)
1644 TRACE("(%p,%u,%ld,%ld,%d)\n", hWnd
, uiMsgId
, wParam
, lParam
, bSend
);
1648 data
.uiMsgId
= uiMsgId
;
1649 data
.wParam
= wParam
;
1650 data
.lParam
= lParam
;
1653 data
.pfnPost
= IsWindowUnicode(hWnd
) ? (void*)SendMessageW
: (void*)SendMessageA
;
1655 data
.pfnPost
= IsWindowUnicode(hWnd
) ? (void*)PostMessageW
: (void*)PostMessageA
;
1657 EnumChildWindows(hWnd
, SHLWAPI_EnumChildProc
, (LPARAM
)&data
);
1661 /*************************************************************************
1664 * Remove all sub-menus from a menu.
1667 * hMenu [I] Menu to remove sub-menus from
1670 * Success: 0. All sub-menus under hMenu are removed
1671 * Failure: -1, if any parameter is invalid
1673 DWORD WINAPI
SHRemoveAllSubMenus(HMENU hMenu
)
1675 int iItemCount
= GetMenuItemCount(hMenu
) - 1;
1677 TRACE("%p\n", hMenu
);
1679 while (iItemCount
>= 0)
1681 HMENU hSubMenu
= GetSubMenu(hMenu
, iItemCount
);
1683 RemoveMenu(hMenu
, iItemCount
, MF_BYPOSITION
);
1689 /*************************************************************************
1692 * Enable or disable a menu item.
1695 * hMenu [I] Menu holding menu item
1696 * uID [I] ID of menu item to enable/disable
1697 * bEnable [I] Whether to enable (TRUE) or disable (FALSE) the item.
1700 * The return code from EnableMenuItem.
1702 UINT WINAPI
SHEnableMenuItem(HMENU hMenu
, UINT wItemID
, BOOL bEnable
)
1704 TRACE("%p, %u, %d\n", hMenu
, wItemID
, bEnable
);
1705 return EnableMenuItem(hMenu
, wItemID
, bEnable
? MF_ENABLED
: MF_GRAYED
);
1708 /*************************************************************************
1711 * Check or uncheck a menu item.
1714 * hMenu [I] Menu holding menu item
1715 * uID [I] ID of menu item to check/uncheck
1716 * bCheck [I] Whether to check (TRUE) or uncheck (FALSE) the item.
1719 * The return code from CheckMenuItem.
1721 DWORD WINAPI
SHCheckMenuItem(HMENU hMenu
, UINT uID
, BOOL bCheck
)
1723 TRACE("%p, %u, %d\n", hMenu
, uID
, bCheck
);
1724 return CheckMenuItem(hMenu
, uID
, bCheck
? MF_CHECKED
: MF_UNCHECKED
);
1727 /*************************************************************************
1730 * Register a window class if it isn't already.
1733 * lpWndClass [I] Window class to register
1736 * The result of the RegisterClassA call.
1738 DWORD WINAPI
SHRegisterClassA(WNDCLASSA
*wndclass
)
1741 if (GetClassInfoA(wndclass
->hInstance
, wndclass
->lpszClassName
, &wca
))
1743 return (DWORD
)RegisterClassA(wndclass
);
1746 /*************************************************************************
1749 BOOL WINAPI
SHSimulateDrop(IDropTarget
*pDrop
, IDataObject
*pDataObj
,
1750 DWORD grfKeyState
, PPOINTL lpPt
, DWORD
* pdwEffect
)
1752 DWORD dwEffect
= DROPEFFECT_LINK
| DROPEFFECT_MOVE
| DROPEFFECT_COPY
;
1753 POINTL pt
= { 0, 0 };
1755 TRACE("%p %p 0x%08x %p %p\n", pDrop
, pDataObj
, grfKeyState
, lpPt
, pdwEffect
);
1761 pdwEffect
= &dwEffect
;
1763 IDropTarget_DragEnter(pDrop
, pDataObj
, grfKeyState
, *lpPt
, pdwEffect
);
1765 if (*pdwEffect
!= DROPEFFECT_NONE
)
1766 return IDropTarget_Drop(pDrop
, pDataObj
, grfKeyState
, *lpPt
, pdwEffect
);
1768 IDropTarget_DragLeave(pDrop
);
1772 /*************************************************************************
1775 * Call IPersistPropertyBag_Load() on an object.
1778 * lpUnknown [I] Object supporting the IPersistPropertyBag interface
1779 * lpPropBag [O] Destination for loaded IPropertyBag
1783 * Failure: An HRESULT error code, or E_FAIL if lpUnknown is NULL.
1785 DWORD WINAPI
SHLoadFromPropertyBag(IUnknown
*lpUnknown
, IPropertyBag
* lpPropBag
)
1787 IPersistPropertyBag
* lpPPBag
;
1788 HRESULT hRet
= E_FAIL
;
1790 TRACE("(%p,%p)\n", lpUnknown
, lpPropBag
);
1794 hRet
= IUnknown_QueryInterface(lpUnknown
, &IID_IPersistPropertyBag
,
1796 if (SUCCEEDED(hRet
) && lpPPBag
)
1798 hRet
= IPersistPropertyBag_Load(lpPPBag
, lpPropBag
, NULL
);
1799 IPersistPropertyBag_Release(lpPPBag
);
1805 /*************************************************************************
1808 * Call IOleControlSite_TranslateAccelerator() on an object.
1811 * lpUnknown [I] Object supporting the IOleControlSite interface.
1812 * lpMsg [I] Key message to be processed.
1813 * dwModifiers [I] Flags containing the state of the modifier keys.
1817 * Failure: An HRESULT error code, or E_INVALIDARG if lpUnknown is NULL.
1819 HRESULT WINAPI
IUnknown_TranslateAcceleratorOCS(IUnknown
*lpUnknown
, LPMSG lpMsg
, DWORD dwModifiers
)
1821 IOleControlSite
* lpCSite
= NULL
;
1822 HRESULT hRet
= E_INVALIDARG
;
1824 TRACE("(%p,%p,0x%08x)\n", lpUnknown
, lpMsg
, dwModifiers
);
1827 hRet
= IUnknown_QueryInterface(lpUnknown
, &IID_IOleControlSite
,
1829 if (SUCCEEDED(hRet
) && lpCSite
)
1831 hRet
= IOleControlSite_TranslateAccelerator(lpCSite
, lpMsg
, dwModifiers
);
1832 IOleControlSite_Release(lpCSite
);
1839 /*************************************************************************
1842 * Call IOleControlSite_OnFocus() on an object.
1845 * lpUnknown [I] Object supporting the IOleControlSite interface.
1846 * fGotFocus [I] Whether focus was gained (TRUE) or lost (FALSE).
1850 * Failure: An HRESULT error code, or E_FAIL if lpUnknown is NULL.
1852 HRESULT WINAPI
IUnknown_OnFocusOCS(IUnknown
*lpUnknown
, BOOL fGotFocus
)
1854 IOleControlSite
* lpCSite
= NULL
;
1855 HRESULT hRet
= E_FAIL
;
1857 TRACE("(%p, %d)\n", lpUnknown
, fGotFocus
);
1860 hRet
= IUnknown_QueryInterface(lpUnknown
, &IID_IOleControlSite
,
1862 if (SUCCEEDED(hRet
) && lpCSite
)
1864 hRet
= IOleControlSite_OnFocus(lpCSite
, fGotFocus
);
1865 IOleControlSite_Release(lpCSite
);
1871 /*************************************************************************
1874 HRESULT WINAPI
IUnknown_HandleIRestrict(LPUNKNOWN lpUnknown
, PVOID lpArg1
,
1875 PVOID lpArg2
, PVOID lpArg3
, PVOID lpArg4
)
1877 /* FIXME: {D12F26B2-D90A-11D0-830D-00AA005B4383} - What object does this represent? */
1878 static const DWORD service_id
[] = { 0xd12f26b2, 0x11d0d90a, 0xaa000d83, 0x83435b00 };
1879 /* FIXME: {D12F26B1-D90A-11D0-830D-00AA005B4383} - Also Unknown/undocumented */
1880 static const DWORD function_id
[] = { 0xd12f26b1, 0x11d0d90a, 0xaa000d83, 0x83435b00 };
1881 HRESULT hRet
= E_INVALIDARG
;
1882 LPUNKNOWN lpUnkInner
= NULL
; /* FIXME: Real type is unknown */
1884 TRACE("(%p,%p,%p,%p,%p)\n", lpUnknown
, lpArg1
, lpArg2
, lpArg3
, lpArg4
);
1886 if (lpUnknown
&& lpArg4
)
1888 hRet
= IUnknown_QueryService(lpUnknown
, (REFGUID
)service_id
,
1889 (REFGUID
)function_id
, (void**)&lpUnkInner
);
1891 if (SUCCEEDED(hRet
) && lpUnkInner
)
1893 /* FIXME: The type of service object requested is unknown, however
1894 * testing shows that its first method is called with 4 parameters.
1895 * Fake this by using IParseDisplayName_ParseDisplayName since the
1896 * signature and position in the vtable matches our unknown object type.
1898 hRet
= IParseDisplayName_ParseDisplayName((LPPARSEDISPLAYNAME
)lpUnkInner
,
1899 lpArg1
, lpArg2
, lpArg3
, lpArg4
);
1900 IUnknown_Release(lpUnkInner
);
1906 /*************************************************************************
1909 * Get a sub-menu from a menu item.
1912 * hMenu [I] Menu to get sub-menu from
1913 * uID [I] ID of menu item containing sub-menu
1916 * The sub-menu of the item, or a NULL handle if any parameters are invalid.
1918 HMENU WINAPI
SHGetMenuFromID(HMENU hMenu
, UINT uID
)
1922 TRACE("(%p,%u)\n", hMenu
, uID
);
1924 mi
.cbSize
= sizeof(mi
);
1925 mi
.fMask
= MIIM_SUBMENU
;
1927 if (!GetMenuItemInfoW(hMenu
, uID
, FALSE
, &mi
))
1933 /*************************************************************************
1936 * Get the color depth of the primary display.
1942 * The color depth of the primary display.
1944 DWORD WINAPI
SHGetCurColorRes(void)
1952 ret
= GetDeviceCaps(hdc
, BITSPIXEL
) * GetDeviceCaps(hdc
, PLANES
);
1957 /*************************************************************************
1960 * Wait for a message to arrive, with a timeout.
1963 * hand [I] Handle to query
1964 * dwTimeout [I] Timeout in ticks or INFINITE to never timeout
1967 * STATUS_TIMEOUT if no message is received before dwTimeout ticks passes.
1968 * Otherwise returns the value from MsgWaitForMultipleObjectsEx when a
1969 * message is available.
1971 DWORD WINAPI
SHWaitForSendMessageThread(HANDLE hand
, DWORD dwTimeout
)
1973 DWORD dwEndTicks
= GetTickCount() + dwTimeout
;
1976 while ((dwRet
= MsgWaitForMultipleObjectsEx(1, &hand
, dwTimeout
, QS_SENDMESSAGE
, 0)) == 1)
1980 PeekMessageW(&msg
, NULL
, 0, 0, PM_NOREMOVE
);
1982 if (dwTimeout
!= INFINITE
)
1984 if ((int)(dwTimeout
= dwEndTicks
- GetTickCount()) <= 0)
1985 return WAIT_TIMEOUT
;
1992 /*************************************************************************
1995 * Determine if a shell folder can be expanded.
1998 * lpFolder [I] Parent folder containing the object to test.
1999 * pidl [I] Id of the object to test.
2002 * Success: S_OK, if the object is expandable, S_FALSE otherwise.
2003 * Failure: E_INVALIDARG, if any argument is invalid.
2006 * If the object to be tested does not expose the IQueryInfo() interface it
2007 * will not be identified as an expandable folder.
2009 HRESULT WINAPI
SHIsExpandableFolder(LPSHELLFOLDER lpFolder
, LPCITEMIDLIST pidl
)
2011 HRESULT hRet
= E_INVALIDARG
;
2014 if (lpFolder
&& pidl
)
2016 hRet
= IShellFolder_GetUIObjectOf(lpFolder
, NULL
, 1, &pidl
, &IID_IQueryInfo
,
2017 NULL
, (void**)&lpInfo
);
2019 hRet
= S_FALSE
; /* Doesn't expose IQueryInfo */
2024 /* MSDN states of IQueryInfo_GetInfoFlags() that "This method is not
2025 * currently used". Really? You wouldn't be holding out on me would you?
2027 hRet
= IQueryInfo_GetInfoFlags(lpInfo
, &dwFlags
);
2029 if (SUCCEEDED(hRet
))
2031 /* 0x2 is an undocumented flag apparently indicating expandability */
2032 hRet
= dwFlags
& 0x2 ? S_OK
: S_FALSE
;
2035 IQueryInfo_Release(lpInfo
);
2041 /*************************************************************************
2044 * Blank out a region of text by drawing the background only.
2047 * hDC [I] Device context to draw in
2048 * pRect [I] Area to draw in
2049 * cRef [I] Color to draw in
2054 DWORD WINAPI
SHFillRectClr(HDC hDC
, LPCRECT pRect
, COLORREF cRef
)
2056 COLORREF cOldColor
= SetBkColor(hDC
, cRef
);
2057 ExtTextOutA(hDC
, 0, 0, ETO_OPAQUE
, pRect
, 0, 0, 0);
2058 SetBkColor(hDC
, cOldColor
);
2062 /*************************************************************************
2065 * Return the value associated with a key in a map.
2068 * lpKeys [I] A list of keys of length iLen
2069 * lpValues [I] A list of values associated with lpKeys, of length iLen
2070 * iLen [I] Length of both lpKeys and lpValues
2071 * iKey [I] The key value to look up in lpKeys
2074 * The value in lpValues associated with iKey, or -1 if iKey is not
2078 * - If two elements in the map share the same key, this function returns
2079 * the value closest to the start of the map
2080 * - The native version of this function crashes if lpKeys or lpValues is NULL.
2082 int WINAPI
SHSearchMapInt(const int *lpKeys
, const int *lpValues
, int iLen
, int iKey
)
2084 if (lpKeys
&& lpValues
)
2090 if (lpKeys
[i
] == iKey
)
2091 return lpValues
[i
]; /* Found */
2095 return -1; /* Not found */
2099 /*************************************************************************
2102 * Copy an interface pointer
2105 * lppDest [O] Destination for copy
2106 * lpUnknown [I] Source for copy
2111 VOID WINAPI
IUnknown_Set(IUnknown
**lppDest
, IUnknown
*lpUnknown
)
2113 TRACE("(%p,%p)\n", lppDest
, lpUnknown
);
2115 IUnknown_AtomicRelease(lppDest
);
2119 IUnknown_AddRef(lpUnknown
);
2120 *lppDest
= lpUnknown
;
2124 /*************************************************************************
2128 HRESULT WINAPI
MayQSForward(IUnknown
* lpUnknown
, PVOID lpReserved
,
2129 REFGUID riidCmdGrp
, ULONG cCmds
,
2130 OLECMD
*prgCmds
, OLECMDTEXT
* pCmdText
)
2132 FIXME("(%p,%p,%p,%d,%p,%p) - stub\n",
2133 lpUnknown
, lpReserved
, riidCmdGrp
, cCmds
, prgCmds
, pCmdText
);
2135 /* FIXME: Calls IsQSForward & IUnknown_QueryStatus */
2136 return DRAGDROP_E_NOTREGISTERED
;
2139 /*************************************************************************
2143 HRESULT WINAPI
MayExecForward(IUnknown
* lpUnknown
, INT iUnk
, REFGUID pguidCmdGroup
,
2144 DWORD nCmdID
, DWORD nCmdexecopt
, VARIANT
* pvaIn
,
2147 FIXME("(%p,%d,%p,%d,%d,%p,%p) - stub!\n", lpUnknown
, iUnk
, pguidCmdGroup
,
2148 nCmdID
, nCmdexecopt
, pvaIn
, pvaOut
);
2149 return DRAGDROP_E_NOTREGISTERED
;
2152 /*************************************************************************
2156 HRESULT WINAPI
IsQSForward(REFGUID pguidCmdGroup
,ULONG cCmds
, OLECMD
*prgCmds
)
2158 FIXME("(%p,%d,%p) - stub!\n", pguidCmdGroup
, cCmds
, prgCmds
);
2159 return DRAGDROP_E_NOTREGISTERED
;
2162 /*************************************************************************
2165 * Determine if a window is not a child of another window.
2168 * hParent [I] Suspected parent window
2169 * hChild [I] Suspected child window
2172 * TRUE: If hChild is a child window of hParent
2173 * FALSE: If hChild is not a child window of hParent, or they are equal
2175 BOOL WINAPI
SHIsChildOrSelf(HWND hParent
, HWND hChild
)
2177 TRACE("(%p,%p)\n", hParent
, hChild
);
2179 if (!hParent
|| !hChild
)
2181 else if(hParent
== hChild
)
2183 return !IsChild(hParent
, hChild
);
2186 /*************************************************************************
2187 * FDSA functions. Manage a dynamic array of fixed size memory blocks.
2192 DWORD num_items
; /* Number of elements inserted */
2193 void *mem
; /* Ptr to array */
2194 DWORD blocks_alloced
; /* Number of elements allocated */
2195 BYTE inc
; /* Number of elements to grow by when we need to expand */
2196 BYTE block_size
; /* Size in bytes of an element */
2197 BYTE flags
; /* Flags */
2200 #define FDSA_FLAG_INTERNAL_ALLOC 0x01 /* When set we have allocated mem internally */
2202 /*************************************************************************
2205 * Initialize an FDSA array.
2207 BOOL WINAPI
FDSA_Initialize(DWORD block_size
, DWORD inc
, FDSA_info
*info
, void *mem
,
2210 TRACE("(0x%08x 0x%08x %p %p 0x%08x)\n", block_size
, inc
, info
, mem
, init_blocks
);
2216 memset(mem
, 0, block_size
* init_blocks
);
2218 info
->num_items
= 0;
2221 info
->blocks_alloced
= init_blocks
;
2222 info
->block_size
= block_size
;
2228 /*************************************************************************
2231 * Destroy an FDSA array
2233 BOOL WINAPI
FDSA_Destroy(FDSA_info
*info
)
2235 TRACE("(%p)\n", info
);
2237 if(info
->flags
& FDSA_FLAG_INTERNAL_ALLOC
)
2239 HeapFree(GetProcessHeap(), 0, info
->mem
);
2246 /*************************************************************************
2249 * Insert element into an FDSA array
2251 DWORD WINAPI
FDSA_InsertItem(FDSA_info
*info
, DWORD where
, const void *block
)
2253 TRACE("(%p 0x%08x %p)\n", info
, where
, block
);
2254 if(where
> info
->num_items
)
2255 where
= info
->num_items
;
2257 if(info
->num_items
>= info
->blocks_alloced
)
2259 DWORD size
= (info
->blocks_alloced
+ info
->inc
) * info
->block_size
;
2260 if(info
->flags
& 0x1)
2261 info
->mem
= HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, info
->mem
, size
);
2264 void *old_mem
= info
->mem
;
2265 info
->mem
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, size
);
2266 memcpy(info
->mem
, old_mem
, info
->blocks_alloced
* info
->block_size
);
2268 info
->blocks_alloced
+= info
->inc
;
2272 if(where
< info
->num_items
)
2274 memmove((char*)info
->mem
+ (where
+ 1) * info
->block_size
,
2275 (char*)info
->mem
+ where
* info
->block_size
,
2276 (info
->num_items
- where
) * info
->block_size
);
2278 memcpy((char*)info
->mem
+ where
* info
->block_size
, block
, info
->block_size
);
2284 /*************************************************************************
2287 * Delete an element from an FDSA array.
2289 BOOL WINAPI
FDSA_DeleteItem(FDSA_info
*info
, DWORD where
)
2291 TRACE("(%p 0x%08x)\n", info
, where
);
2293 if(where
>= info
->num_items
)
2296 if(where
< info
->num_items
- 1)
2298 memmove((char*)info
->mem
+ where
* info
->block_size
,
2299 (char*)info
->mem
+ (where
+ 1) * info
->block_size
,
2300 (info
->num_items
- where
- 1) * info
->block_size
);
2302 memset((char*)info
->mem
+ (info
->num_items
- 1) * info
->block_size
,
2303 0, info
->block_size
);
2308 /*************************************************************************
2311 * Call IUnknown_QueryInterface() on a table of objects.
2315 * Failure: E_POINTER or E_NOINTERFACE.
2317 HRESULT WINAPI
QISearch(
2318 void *base
, /* [in] Table of interfaces */
2319 const QITAB
*table
, /* [in] Array of REFIIDs and indexes into the table */
2320 REFIID riid
, /* [in] REFIID to get interface for */
2321 void **ppv
) /* [out] Destination for interface pointer */
2327 TRACE("(%p %p %s %p)\n", base
, table
, debugstr_guid(riid
), ppv
);
2330 while (xmove
->piid
) {
2331 TRACE("trying (offset %d) %s\n", xmove
->dwOffset
, debugstr_guid(xmove
->piid
));
2332 if (IsEqualIID(riid
, xmove
->piid
)) {
2333 a_vtbl
= (IUnknown
*)(xmove
->dwOffset
+ (LPBYTE
)base
);
2334 TRACE("matched, returning (%p)\n", a_vtbl
);
2336 IUnknown_AddRef(a_vtbl
);
2342 if (IsEqualIID(riid
, &IID_IUnknown
)) {
2343 a_vtbl
= (IUnknown
*)(table
->dwOffset
+ (LPBYTE
)base
);
2344 TRACE("returning first for IUnknown (%p)\n", a_vtbl
);
2346 IUnknown_AddRef(a_vtbl
);
2350 ret
= E_NOINTERFACE
;
2354 TRACE("-- 0x%08x\n", ret
);
2358 /*************************************************************************
2361 * Set the Font for a window and the "PropDlgFont" property of the parent window.
2364 * hWnd [I] Parent Window to set the property
2365 * id [I] Index of child Window to set the Font
2371 HRESULT WINAPI
SHSetDefaultDialogFont(HWND hWnd
, INT id
)
2373 FIXME("(%p, %d) stub\n", hWnd
, id
);
2377 /*************************************************************************
2380 * Remove the "PropDlgFont" property from a window.
2383 * hWnd [I] Window to remove the property from
2386 * A handle to the removed property, or NULL if it did not exist.
2388 HANDLE WINAPI
SHRemoveDefaultDialogFont(HWND hWnd
)
2392 TRACE("(%p)\n", hWnd
);
2394 hProp
= GetPropA(hWnd
, "PropDlgFont");
2398 DeleteObject(hProp
);
2399 hProp
= RemovePropA(hWnd
, "PropDlgFont");
2404 /*************************************************************************
2407 * Load the in-process server of a given GUID.
2410 * refiid [I] GUID of the server to load.
2413 * Success: A handle to the loaded server dll.
2414 * Failure: A NULL handle.
2416 HMODULE WINAPI
SHPinDllOfCLSID(REFIID refiid
)
2420 CHAR value
[MAX_PATH
], string
[MAX_PATH
];
2422 strcpy(string
, "CLSID\\");
2423 SHStringFromGUIDA(refiid
, string
+ 6, sizeof(string
)/sizeof(char) - 6);
2424 strcat(string
, "\\InProcServer32");
2427 RegOpenKeyExA(HKEY_CLASSES_ROOT
, string
, 0, 1, &newkey
);
2428 RegQueryValueExA(newkey
, 0, 0, &type
, (PBYTE
)value
, &count
);
2429 RegCloseKey(newkey
);
2430 return LoadLibraryExA(value
, 0, 0);
2433 /*************************************************************************
2436 * Unicode version of SHLWAPI_183.
2438 DWORD WINAPI
SHRegisterClassW(WNDCLASSW
* lpWndClass
)
2442 TRACE("(%p %s)\n",lpWndClass
->hInstance
, debugstr_w(lpWndClass
->lpszClassName
));
2444 if (GetClassInfoW(lpWndClass
->hInstance
, lpWndClass
->lpszClassName
, &WndClass
))
2446 return RegisterClassW(lpWndClass
);
2449 /*************************************************************************
2452 * Unregister a list of classes.
2455 * hInst [I] Application instance that registered the classes
2456 * lppClasses [I] List of class names
2457 * iCount [I] Number of names in lppClasses
2462 void WINAPI
SHUnregisterClassesA(HINSTANCE hInst
, LPCSTR
*lppClasses
, INT iCount
)
2466 TRACE("(%p,%p,%d)\n", hInst
, lppClasses
, iCount
);
2470 if (GetClassInfoA(hInst
, *lppClasses
, &WndClass
))
2471 UnregisterClassA(*lppClasses
, hInst
);
2477 /*************************************************************************
2480 * Unicode version of SHUnregisterClassesA.
2482 void WINAPI
SHUnregisterClassesW(HINSTANCE hInst
, LPCWSTR
*lppClasses
, INT iCount
)
2486 TRACE("(%p,%p,%d)\n", hInst
, lppClasses
, iCount
);
2490 if (GetClassInfoW(hInst
, *lppClasses
, &WndClass
))
2491 UnregisterClassW(*lppClasses
, hInst
);
2497 /*************************************************************************
2500 * Call The correct (Ascii/Unicode) default window procedure for a window.
2503 * hWnd [I] Window to call the default procedure for
2504 * uMessage [I] Message ID
2505 * wParam [I] WPARAM of message
2506 * lParam [I] LPARAM of message
2509 * The result of calling DefWindowProcA() or DefWindowProcW().
2511 LRESULT CALLBACK
SHDefWindowProc(HWND hWnd
, UINT uMessage
, WPARAM wParam
, LPARAM lParam
)
2513 if (IsWindowUnicode(hWnd
))
2514 return DefWindowProcW(hWnd
, uMessage
, wParam
, lParam
);
2515 return DefWindowProcA(hWnd
, uMessage
, wParam
, lParam
);
2518 /*************************************************************************
2521 HRESULT WINAPI
IUnknown_GetSite(LPUNKNOWN lpUnknown
, REFIID iid
, PVOID
*lppSite
)
2523 HRESULT hRet
= E_INVALIDARG
;
2524 LPOBJECTWITHSITE lpSite
= NULL
;
2526 TRACE("(%p,%s,%p)\n", lpUnknown
, debugstr_guid(iid
), lppSite
);
2528 if (lpUnknown
&& iid
&& lppSite
)
2530 hRet
= IUnknown_QueryInterface(lpUnknown
, &IID_IObjectWithSite
,
2532 if (SUCCEEDED(hRet
) && lpSite
)
2534 hRet
= IObjectWithSite_GetSite(lpSite
, iid
, lppSite
);
2535 IObjectWithSite_Release(lpSite
);
2541 /*************************************************************************
2544 * Create a worker window using CreateWindowExA().
2547 * wndProc [I] Window procedure
2548 * hWndParent [I] Parent window
2549 * dwExStyle [I] Extra style flags
2550 * dwStyle [I] Style flags
2551 * hMenu [I] Window menu
2552 * wnd_extra [I] Window extra bytes value
2555 * Success: The window handle of the newly created window.
2558 HWND WINAPI
SHCreateWorkerWindowA(LONG wndProc
, HWND hWndParent
, DWORD dwExStyle
,
2559 DWORD dwStyle
, HMENU hMenu
, LONG_PTR wnd_extra
)
2561 static const char szClass
[] = "WorkerA";
2565 TRACE("(0x%08x, %p, 0x%08x, 0x%08x, %p, 0x%08lx)\n",
2566 wndProc
, hWndParent
, dwExStyle
, dwStyle
, hMenu
, wnd_extra
);
2568 /* Create Window class */
2570 wc
.lpfnWndProc
= DefWindowProcA
;
2572 wc
.cbWndExtra
= sizeof(LONG_PTR
);
2573 wc
.hInstance
= shlwapi_hInstance
;
2575 wc
.hCursor
= LoadCursorA(NULL
, (LPSTR
)IDC_ARROW
);
2576 wc
.hbrBackground
= (HBRUSH
)(COLOR_BTNFACE
+ 1);
2577 wc
.lpszMenuName
= NULL
;
2578 wc
.lpszClassName
= szClass
;
2580 SHRegisterClassA(&wc
);
2582 hWnd
= CreateWindowExA(dwExStyle
, szClass
, 0, dwStyle
, 0, 0, 0, 0,
2583 hWndParent
, hMenu
, shlwapi_hInstance
, 0);
2586 SetWindowLongPtrW(hWnd
, 0, wnd_extra
);
2588 if (wndProc
) SetWindowLongPtrA(hWnd
, GWLP_WNDPROC
, wndProc
);
2594 typedef struct tagPOLICYDATA
2596 DWORD policy
; /* flags value passed to SHRestricted */
2597 LPCWSTR appstr
; /* application str such as "Explorer" */
2598 LPCWSTR keystr
; /* name of the actual registry key / policy */
2599 } POLICYDATA
, *LPPOLICYDATA
;
2601 #define SHELL_NO_POLICY 0xffffffff
2603 /* default shell policy registry key */
2604 static const WCHAR strRegistryPolicyW
[] = {'S','o','f','t','w','a','r','e','\\','M','i','c','r','o',
2605 's','o','f','t','\\','W','i','n','d','o','w','s','\\',
2606 'C','u','r','r','e','n','t','V','e','r','s','i','o','n',
2607 '\\','P','o','l','i','c','i','e','s',0};
2609 /*************************************************************************
2612 * Retrieve a policy value from the registry.
2615 * lpSubKey [I] registry key name
2616 * lpSubName [I] subname of registry key
2617 * lpValue [I] value name of registry value
2620 * the value associated with the registry key or 0 if not found
2622 DWORD WINAPI
SHGetRestriction(LPCWSTR lpSubKey
, LPCWSTR lpSubName
, LPCWSTR lpValue
)
2624 DWORD retval
, datsize
= sizeof(retval
);
2628 lpSubKey
= strRegistryPolicyW
;
2630 retval
= RegOpenKeyW(HKEY_LOCAL_MACHINE
, lpSubKey
, &hKey
);
2631 if (retval
!= ERROR_SUCCESS
)
2632 retval
= RegOpenKeyW(HKEY_CURRENT_USER
, lpSubKey
, &hKey
);
2633 if (retval
!= ERROR_SUCCESS
)
2636 SHGetValueW(hKey
, lpSubName
, lpValue
, NULL
, &retval
, &datsize
);
2641 /*************************************************************************
2644 * Helper function to retrieve the possibly cached value for a specific policy
2647 * policy [I] The policy to look for
2648 * initial [I] Main registry key to open, if NULL use default
2649 * polTable [I] Table of known policies, 0 terminated
2650 * polArr [I] Cache array of policy values
2653 * The retrieved policy value or 0 if not successful
2656 * This function is used by the native SHRestricted function to search for the
2657 * policy and cache it once retrieved. The current Wine implementation uses a
2658 * different POLICYDATA structure and implements a similar algorithm adapted to
2661 DWORD WINAPI
SHRestrictionLookup(
2664 LPPOLICYDATA polTable
,
2667 TRACE("(0x%08x %s %p %p)\n", policy
, debugstr_w(initial
), polTable
, polArr
);
2669 if (!polTable
|| !polArr
)
2672 for (;polTable
->policy
; polTable
++, polArr
++)
2674 if (policy
== polTable
->policy
)
2676 /* we have a known policy */
2678 /* check if this policy has been cached */
2679 if (*polArr
== SHELL_NO_POLICY
)
2680 *polArr
= SHGetRestriction(initial
, polTable
->appstr
, polTable
->keystr
);
2684 /* we don't know this policy, return 0 */
2685 TRACE("unknown policy: (%08x)\n", policy
);
2689 /*************************************************************************
2692 * Get an interface from an object.
2695 * Success: S_OK. ppv contains the requested interface.
2696 * Failure: An HRESULT error code.
2699 * This QueryInterface asks the inner object for an interface. In case
2700 * of aggregation this request would be forwarded by the inner to the
2701 * outer object. This function asks the inner object directly for the
2702 * interface circumventing the forwarding to the outer object.
2704 HRESULT WINAPI
SHWeakQueryInterface(
2705 IUnknown
* pUnk
, /* [in] Outer object */
2706 IUnknown
* pInner
, /* [in] Inner object */
2707 IID
* riid
, /* [in] Interface GUID to query for */
2708 LPVOID
* ppv
) /* [out] Destination for queried interface */
2710 HRESULT hret
= E_NOINTERFACE
;
2711 TRACE("(pUnk=%p pInner=%p\n\tIID: %s %p)\n",pUnk
,pInner
,debugstr_guid(riid
), ppv
);
2714 if(pUnk
&& pInner
) {
2715 hret
= IUnknown_QueryInterface(pInner
, riid
, ppv
);
2716 if (SUCCEEDED(hret
)) IUnknown_Release(pUnk
);
2718 TRACE("-- 0x%08x\n", hret
);
2722 /*************************************************************************
2725 * Move a reference from one interface to another.
2728 * lpDest [O] Destination to receive the reference
2729 * lppUnknown [O] Source to give up the reference to lpDest
2734 VOID WINAPI
SHWeakReleaseInterface(IUnknown
*lpDest
, IUnknown
**lppUnknown
)
2736 TRACE("(%p,%p)\n", lpDest
, lppUnknown
);
2741 IUnknown_AddRef(lpDest
);
2742 IUnknown_AtomicRelease(lppUnknown
); /* Release existing interface */
2746 /*************************************************************************
2749 * Convert an ASCII string of a CLSID into a CLSID.
2752 * idstr [I] String representing a CLSID in registry format
2753 * id [O] Destination for the converted CLSID
2756 * Success: TRUE. id contains the converted CLSID.
2759 BOOL WINAPI
GUIDFromStringA(LPCSTR idstr
, CLSID
*id
)
2762 MultiByteToWideChar(CP_ACP
, 0, idstr
, -1, wClsid
, sizeof(wClsid
)/sizeof(WCHAR
));
2763 return SUCCEEDED(CLSIDFromString(wClsid
, id
));
2766 /*************************************************************************
2769 * Unicode version of GUIDFromStringA.
2771 BOOL WINAPI
GUIDFromStringW(LPCWSTR idstr
, CLSID
*id
)
2773 return SUCCEEDED(CLSIDFromString((LPCOLESTR
)idstr
, id
));
2776 /*************************************************************************
2779 * Determine if the browser is integrated into the shell, and set a registry
2786 * 1, If the browser is not integrated.
2787 * 2, If the browser is integrated.
2790 * The key "HKLM\Software\Microsoft\Internet Explorer\IntegratedBrowser" is
2791 * either set to TRUE, or removed depending on whether the browser is deemed
2794 DWORD WINAPI
WhichPlatform(void)
2796 static const char szIntegratedBrowser
[] = "IntegratedBrowser";
2797 static DWORD dwState
= 0;
2799 DWORD dwRet
, dwData
, dwSize
;
2805 /* If shell32 exports DllGetVersion(), the browser is integrated */
2807 hshell32
= LoadLibraryA("shell32.dll");
2810 FARPROC pDllGetVersion
;
2811 pDllGetVersion
= GetProcAddress(hshell32
, "DllGetVersion");
2812 dwState
= pDllGetVersion
? 2 : 1;
2813 FreeLibrary(hshell32
);
2816 /* Set or delete the key accordingly */
2817 dwRet
= RegOpenKeyExA(HKEY_LOCAL_MACHINE
,
2818 "Software\\Microsoft\\Internet Explorer", 0,
2819 KEY_ALL_ACCESS
, &hKey
);
2822 dwRet
= RegQueryValueExA(hKey
, szIntegratedBrowser
, 0, 0,
2823 (LPBYTE
)&dwData
, &dwSize
);
2825 if (!dwRet
&& dwState
== 1)
2827 /* Value exists but browser is not integrated */
2828 RegDeleteValueA(hKey
, szIntegratedBrowser
);
2830 else if (dwRet
&& dwState
== 2)
2832 /* Browser is integrated but value does not exist */
2834 RegSetValueExA(hKey
, szIntegratedBrowser
, 0, REG_DWORD
,
2835 (LPBYTE
)&dwData
, sizeof(dwData
));
2842 /*************************************************************************
2845 * Unicode version of SHCreateWorkerWindowA.
2847 HWND WINAPI
SHCreateWorkerWindowW(LONG wndProc
, HWND hWndParent
, DWORD dwExStyle
,
2848 DWORD dwStyle
, HMENU hMenu
, LONG msg_result
)
2850 static const WCHAR szClass
[] = { 'W', 'o', 'r', 'k', 'e', 'r', 'W', 0 };
2854 TRACE("(0x%08x, %p, 0x%08x, 0x%08x, %p, 0x%08x)\n",
2855 wndProc
, hWndParent
, dwExStyle
, dwStyle
, hMenu
, msg_result
);
2857 /* If our OS is natively ANSI, use the ANSI version */
2858 if (GetVersion() & 0x80000000) /* not NT */
2860 TRACE("fallback to ANSI, ver 0x%08x\n", GetVersion());
2861 return SHCreateWorkerWindowA(wndProc
, hWndParent
, dwExStyle
, dwStyle
, hMenu
, msg_result
);
2864 /* Create Window class */
2866 wc
.lpfnWndProc
= DefWindowProcW
;
2869 wc
.hInstance
= shlwapi_hInstance
;
2871 wc
.hCursor
= LoadCursorW(NULL
, (LPWSTR
)IDC_ARROW
);
2872 wc
.hbrBackground
= (HBRUSH
)(COLOR_BTNFACE
+ 1);
2873 wc
.lpszMenuName
= NULL
;
2874 wc
.lpszClassName
= szClass
;
2876 SHRegisterClassW(&wc
);
2878 hWnd
= CreateWindowExW(dwExStyle
, szClass
, 0, dwStyle
, 0, 0, 0, 0,
2879 hWndParent
, hMenu
, shlwapi_hInstance
, 0);
2882 SetWindowLongPtrW(hWnd
, DWLP_MSGRESULT
, msg_result
);
2884 if (wndProc
) SetWindowLongPtrW(hWnd
, GWLP_WNDPROC
, wndProc
);
2890 /*************************************************************************
2893 * Get and show a context menu from a shell folder.
2896 * hWnd [I] Window displaying the shell folder
2897 * lpFolder [I] IShellFolder interface
2898 * lpApidl [I] Id for the particular folder desired
2902 * Failure: An HRESULT error code indicating the error.
2904 HRESULT WINAPI
SHInvokeDefaultCommand(HWND hWnd
, IShellFolder
* lpFolder
, LPCITEMIDLIST lpApidl
)
2906 TRACE("%p %p %p\n", hWnd
, lpFolder
, lpApidl
);
2907 return SHInvokeCommand(hWnd
, lpFolder
, lpApidl
, 0);
2910 /*************************************************************************
2913 * _SHPackDispParamsV
2915 HRESULT WINAPI
SHPackDispParamsV(DISPPARAMS
*params
, VARIANTARG
*args
, UINT cnt
, __ms_va_list valist
)
2919 TRACE("(%p %p %u ...)\n", params
, args
, cnt
);
2921 params
->rgvarg
= args
;
2922 params
->rgdispidNamedArgs
= NULL
;
2923 params
->cArgs
= cnt
;
2924 params
->cNamedArgs
= 0;
2928 while(iter
-- > args
) {
2929 V_VT(iter
) = va_arg(valist
, enum VARENUM
);
2931 TRACE("vt=%d\n", V_VT(iter
));
2933 if(V_VT(iter
) & VT_BYREF
) {
2934 V_BYREF(iter
) = va_arg(valist
, LPVOID
);
2936 switch(V_VT(iter
)) {
2938 V_I4(iter
) = va_arg(valist
, LONG
);
2941 V_BSTR(iter
) = va_arg(valist
, BSTR
);
2944 V_DISPATCH(iter
) = va_arg(valist
, IDispatch
*);
2947 V_BOOL(iter
) = va_arg(valist
, int);
2950 V_UNKNOWN(iter
) = va_arg(valist
, IUnknown
*);
2954 V_I4(iter
) = va_arg(valist
, LONG
);
2962 /*************************************************************************
2967 HRESULT WINAPIV
SHPackDispParams(DISPPARAMS
*params
, VARIANTARG
*args
, UINT cnt
, ...)
2969 __ms_va_list valist
;
2972 __ms_va_start(valist
, cnt
);
2973 hres
= SHPackDispParamsV(params
, args
, cnt
, valist
);
2974 __ms_va_end(valist
);
2978 /*************************************************************************
2979 * SHLWAPI_InvokeByIID
2981 * This helper function calls IDispatch::Invoke for each sink
2982 * which implements given iid or IDispatch.
2985 static HRESULT
SHLWAPI_InvokeByIID(
2986 IConnectionPoint
* iCP
,
2989 DISPPARAMS
* dispParams
)
2991 IEnumConnections
*enumerator
;
2993 static DISPPARAMS empty
= {NULL
, NULL
, 0, 0};
2994 DISPPARAMS
* params
= dispParams
;
2996 HRESULT result
= IConnectionPoint_EnumConnections(iCP
, &enumerator
);
3000 /* Invoke is never happening with an NULL dispParams */
3004 while(IEnumConnections_Next(enumerator
, 1, &rgcd
, NULL
)==S_OK
)
3006 IDispatch
*dispIface
;
3007 if ((iid
&& SUCCEEDED(IUnknown_QueryInterface(rgcd
.pUnk
, iid
, (LPVOID
*)&dispIface
))) ||
3008 SUCCEEDED(IUnknown_QueryInterface(rgcd
.pUnk
, &IID_IDispatch
, (LPVOID
*)&dispIface
)))
3010 IDispatch_Invoke(dispIface
, dispId
, &IID_NULL
, 0, DISPATCH_METHOD
, params
, NULL
, NULL
, NULL
);
3011 IDispatch_Release(dispIface
);
3013 IUnknown_Release(rgcd
.pUnk
);
3016 IEnumConnections_Release(enumerator
);
3021 /*************************************************************************
3022 * IConnectionPoint_InvokeWithCancel [SHLWAPI.283]
3024 HRESULT WINAPI
IConnectionPoint_InvokeWithCancel( IConnectionPoint
* iCP
,
3025 DISPID dispId
, DISPPARAMS
* dispParams
,
3026 DWORD unknown1
, DWORD unknown2
)
3031 FIXME("(%p)->(0x%x %p %x %x) partial stub\n", iCP
, dispId
, dispParams
, unknown1
, unknown2
);
3033 result
= IConnectionPoint_GetConnectionInterface(iCP
, &iid
);
3034 if (SUCCEEDED(result
))
3035 result
= SHLWAPI_InvokeByIID(iCP
, &iid
, dispId
, dispParams
);
3037 result
= SHLWAPI_InvokeByIID(iCP
, NULL
, dispId
, dispParams
);
3043 /*************************************************************************
3046 * IConnectionPoint_SimpleInvoke
3048 HRESULT WINAPI
IConnectionPoint_SimpleInvoke(
3049 IConnectionPoint
* iCP
,
3051 DISPPARAMS
* dispParams
)
3056 TRACE("(%p)->(0x%x %p)\n",iCP
,dispId
,dispParams
);
3058 result
= IConnectionPoint_GetConnectionInterface(iCP
, &iid
);
3059 if (SUCCEEDED(result
))
3060 result
= SHLWAPI_InvokeByIID(iCP
, &iid
, dispId
, dispParams
);
3062 result
= SHLWAPI_InvokeByIID(iCP
, NULL
, dispId
, dispParams
);
3067 /*************************************************************************
3070 * Notify an IConnectionPoint object of changes.
3073 * lpCP [I] Object to notify
3078 * Failure: E_NOINTERFACE, if lpCP is NULL or does not support the
3079 * IConnectionPoint interface.
3081 HRESULT WINAPI
IConnectionPoint_OnChanged(IConnectionPoint
* lpCP
, DISPID dispID
)
3083 IEnumConnections
*lpEnum
;
3084 HRESULT hRet
= E_NOINTERFACE
;
3086 TRACE("(%p,0x%8X)\n", lpCP
, dispID
);
3088 /* Get an enumerator for the connections */
3090 hRet
= IConnectionPoint_EnumConnections(lpCP
, &lpEnum
);
3092 if (SUCCEEDED(hRet
))
3094 IPropertyNotifySink
*lpSink
;
3095 CONNECTDATA connData
;
3098 /* Call OnChanged() for every notify sink in the connection point */
3099 while (IEnumConnections_Next(lpEnum
, 1, &connData
, &ulFetched
) == S_OK
)
3101 if (SUCCEEDED(IUnknown_QueryInterface(connData
.pUnk
, &IID_IPropertyNotifySink
, (void**)&lpSink
)) &&
3104 IPropertyNotifySink_OnChanged(lpSink
, dispID
);
3105 IPropertyNotifySink_Release(lpSink
);
3107 IUnknown_Release(connData
.pUnk
);
3110 IEnumConnections_Release(lpEnum
);
3115 /*************************************************************************
3118 * IUnknown_CPContainerInvokeParam
3120 HRESULT WINAPIV
IUnknown_CPContainerInvokeParam(
3121 IUnknown
*container
,
3128 IConnectionPoint
*iCP
;
3129 IConnectionPointContainer
*iCPC
;
3130 DISPPARAMS dispParams
= {buffer
, NULL
, cParams
, 0};
3131 __ms_va_list valist
;
3134 return E_NOINTERFACE
;
3136 result
= IUnknown_QueryInterface(container
, &IID_IConnectionPointContainer
,(LPVOID
*) &iCPC
);
3140 result
= IConnectionPointContainer_FindConnectionPoint(iCPC
, riid
, &iCP
);
3141 IConnectionPointContainer_Release(iCPC
);
3145 __ms_va_start(valist
, cParams
);
3146 SHPackDispParamsV(&dispParams
, buffer
, cParams
, valist
);
3147 __ms_va_end(valist
);
3149 result
= SHLWAPI_InvokeByIID(iCP
, riid
, dispId
, &dispParams
);
3150 IConnectionPoint_Release(iCP
);
3155 /*************************************************************************
3158 * Notify an IConnectionPointContainer object of changes.
3161 * lpUnknown [I] Object to notify
3166 * Failure: E_NOINTERFACE, if lpUnknown is NULL or does not support the
3167 * IConnectionPointContainer interface.
3169 HRESULT WINAPI
IUnknown_CPContainerOnChanged(IUnknown
*lpUnknown
, DISPID dispID
)
3171 IConnectionPointContainer
* lpCPC
= NULL
;
3172 HRESULT hRet
= E_NOINTERFACE
;
3174 TRACE("(%p,0x%8X)\n", lpUnknown
, dispID
);
3177 hRet
= IUnknown_QueryInterface(lpUnknown
, &IID_IConnectionPointContainer
, (void**)&lpCPC
);
3179 if (SUCCEEDED(hRet
))
3181 IConnectionPoint
* lpCP
;
3183 hRet
= IConnectionPointContainer_FindConnectionPoint(lpCPC
, &IID_IPropertyNotifySink
, &lpCP
);
3184 IConnectionPointContainer_Release(lpCPC
);
3186 hRet
= IConnectionPoint_OnChanged(lpCP
, dispID
);
3187 IConnectionPoint_Release(lpCP
);
3192 /*************************************************************************
3197 BOOL WINAPI
PlaySoundWrapW(LPCWSTR pszSound
, HMODULE hmod
, DWORD fdwSound
)
3199 return PlaySoundW(pszSound
, hmod
, fdwSound
);
3202 /*************************************************************************
3205 * Retrieve a key value from an INI file. See GetPrivateProfileString for
3209 * appName [I] The section in the INI file that contains the key
3210 * keyName [I] The key to be retrieved
3211 * out [O] The buffer into which the key's value will be copied
3212 * outLen [I] The length of the `out' buffer
3213 * filename [I] The location of the INI file
3216 * Length of string copied into `out'.
3218 DWORD WINAPI
SHGetIniStringW(LPCWSTR appName
, LPCWSTR keyName
, LPWSTR out
,
3219 DWORD outLen
, LPCWSTR filename
)
3224 TRACE("(%s,%s,%p,%08x,%s)\n", debugstr_w(appName
), debugstr_w(keyName
),
3225 out
, outLen
, debugstr_w(filename
));
3230 buf
= HeapAlloc(GetProcessHeap(), 0, outLen
* sizeof(WCHAR
));
3236 ret
= GetPrivateProfileStringW(appName
, keyName
, NULL
, buf
, outLen
, filename
);
3242 HeapFree(GetProcessHeap(), 0, buf
);
3244 return strlenW(out
);
3247 /*************************************************************************
3250 * Set a key value in an INI file. See WritePrivateProfileString for
3254 * appName [I] The section in the INI file that contains the key
3255 * keyName [I] The key to be set
3256 * str [O] The value of the key
3257 * filename [I] The location of the INI file
3263 BOOL WINAPI
SHSetIniStringW(LPCWSTR appName
, LPCWSTR keyName
, LPCWSTR str
,
3266 TRACE("(%s, %p, %s, %s)\n", debugstr_w(appName
), keyName
, debugstr_w(str
),
3267 debugstr_w(filename
));
3269 return WritePrivateProfileStringW(appName
, keyName
, str
, filename
);
3272 /*************************************************************************
3275 * See SHGetFileInfoW.
3277 DWORD WINAPI
SHGetFileInfoWrapW(LPCWSTR path
, DWORD dwFileAttributes
,
3278 SHFILEINFOW
*psfi
, UINT sizeofpsfi
, UINT flags
)
3280 return SHGetFileInfoW(path
, dwFileAttributes
, psfi
, sizeofpsfi
, flags
);
3283 /*************************************************************************
3286 * See DragQueryFileW.
3288 UINT WINAPI
DragQueryFileWrapW(HDROP hDrop
, UINT lFile
, LPWSTR lpszFile
, UINT lLength
)
3290 return DragQueryFileW(hDrop
, lFile
, lpszFile
, lLength
);
3293 /*************************************************************************
3296 * See SHBrowseForFolderW.
3298 LPITEMIDLIST WINAPI
SHBrowseForFolderWrapW(LPBROWSEINFOW lpBi
)
3300 return SHBrowseForFolderW(lpBi
);
3303 /*************************************************************************
3306 * See SHGetPathFromIDListW.
3308 BOOL WINAPI
SHGetPathFromIDListWrapW(LPCITEMIDLIST pidl
,LPWSTR pszPath
)
3310 return SHGetPathFromIDListW(pidl
, pszPath
);
3313 /*************************************************************************
3316 * See ShellExecuteExW.
3318 BOOL WINAPI
ShellExecuteExWrapW(LPSHELLEXECUTEINFOW lpExecInfo
)
3320 return ShellExecuteExW(lpExecInfo
);
3323 /*************************************************************************
3326 * See SHFileOperationW.
3328 INT WINAPI
SHFileOperationWrapW(LPSHFILEOPSTRUCTW lpFileOp
)
3330 return SHFileOperationW(lpFileOp
);
3333 /*************************************************************************
3337 PVOID WINAPI
SHInterlockedCompareExchange( PVOID
*dest
, PVOID xchg
, PVOID compare
)
3339 return InterlockedCompareExchangePointer( dest
, xchg
, compare
);
3342 /*************************************************************************
3345 * See GetFileVersionInfoSizeW.
3347 DWORD WINAPI
GetFileVersionInfoSizeWrapW( LPCWSTR filename
, LPDWORD handle
)
3349 return GetFileVersionInfoSizeW( filename
, handle
);
3352 /*************************************************************************
3355 * See GetFileVersionInfoW.
3357 BOOL WINAPI
GetFileVersionInfoWrapW( LPCWSTR filename
, DWORD handle
,
3358 DWORD datasize
, LPVOID data
)
3360 return GetFileVersionInfoW( filename
, handle
, datasize
, data
);
3363 /*************************************************************************
3366 * See VerQueryValueW.
3368 WORD WINAPI
VerQueryValueWrapW( LPVOID pBlock
, LPCWSTR lpSubBlock
,
3369 LPVOID
*lplpBuffer
, UINT
*puLen
)
3371 return VerQueryValueW( pBlock
, lpSubBlock
, lplpBuffer
, puLen
);
3374 #define IsIface(type) SUCCEEDED((hRet = IUnknown_QueryInterface(lpUnknown, &IID_##type, (void**)&lpObj)))
3375 #define IShellBrowser_EnableModeless IShellBrowser_EnableModelessSB
3376 #define EnableModeless(type) type##_EnableModeless((type*)lpObj, bModeless)
3378 /*************************************************************************
3381 * Change the modality of a shell object.
3384 * lpUnknown [I] Object to make modeless
3385 * bModeless [I] TRUE=Make modeless, FALSE=Make modal
3388 * Success: S_OK. The modality lpUnknown is changed.
3389 * Failure: An HRESULT error code indicating the error.
3392 * lpUnknown must support the IOleInPlaceFrame interface, the
3393 * IInternetSecurityMgrSite interface, the IShellBrowser interface
3394 * the IDocHostUIHandler interface, or the IOleInPlaceActiveObject interface,
3395 * or this call will fail.
3397 HRESULT WINAPI
IUnknown_EnableModeless(IUnknown
*lpUnknown
, BOOL bModeless
)
3402 TRACE("(%p,%d)\n", lpUnknown
, bModeless
);
3407 if (IsIface(IOleInPlaceActiveObject
))
3408 EnableModeless(IOleInPlaceActiveObject
);
3409 else if (IsIface(IOleInPlaceFrame
))
3410 EnableModeless(IOleInPlaceFrame
);
3411 else if (IsIface(IShellBrowser
))
3412 EnableModeless(IShellBrowser
);
3413 else if (IsIface(IInternetSecurityMgrSite
))
3414 EnableModeless(IInternetSecurityMgrSite
);
3415 else if (IsIface(IDocHostUIHandler
))
3416 EnableModeless(IDocHostUIHandler
);
3420 IUnknown_Release(lpObj
);
3424 /*************************************************************************
3427 * See SHGetNewLinkInfoW.
3429 BOOL WINAPI
SHGetNewLinkInfoWrapW(LPCWSTR pszLinkTo
, LPCWSTR pszDir
, LPWSTR pszName
,
3430 BOOL
*pfMustCopy
, UINT uFlags
)
3432 return SHGetNewLinkInfoW(pszLinkTo
, pszDir
, pszName
, pfMustCopy
, uFlags
);
3435 /*************************************************************************
3438 * See SHDefExtractIconW.
3440 UINT WINAPI
SHDefExtractIconWrapW(LPCWSTR pszIconFile
, int iIndex
, UINT uFlags
, HICON
* phiconLarge
,
3441 HICON
* phiconSmall
, UINT nIconSize
)
3443 return SHDefExtractIconW(pszIconFile
, iIndex
, uFlags
, phiconLarge
, phiconSmall
, nIconSize
);
3446 /*************************************************************************
3449 * Get and show a context menu from a shell folder.
3452 * hWnd [I] Window displaying the shell folder
3453 * lpFolder [I] IShellFolder interface
3454 * lpApidl [I] Id for the particular folder desired
3455 * dwCommandId [I] The command ID to invoke (0=invoke default)
3458 * Success: S_OK. If bInvokeDefault is TRUE, the default menu action was
3460 * Failure: An HRESULT error code indicating the error.
3462 HRESULT WINAPI
SHInvokeCommand(HWND hWnd
, IShellFolder
* lpFolder
, LPCITEMIDLIST lpApidl
, DWORD dwCommandId
)
3464 IContextMenu
*iContext
;
3467 TRACE("(%p, %p, %p, %u)\n", hWnd
, lpFolder
, lpApidl
, dwCommandId
);
3472 /* Get the context menu from the shell folder */
3473 hRet
= IShellFolder_GetUIObjectOf(lpFolder
, hWnd
, 1, &lpApidl
,
3474 &IID_IContextMenu
, 0, (void**)&iContext
);
3475 if (SUCCEEDED(hRet
))
3478 if ((hMenu
= CreatePopupMenu()))
3482 /* Add the context menu entries to the popup */
3483 hQuery
= IContextMenu_QueryContextMenu(iContext
, hMenu
, 0, 1, 0x7FFF,
3484 dwCommandId
? CMF_NORMAL
: CMF_DEFAULTONLY
);
3486 if (SUCCEEDED(hQuery
))
3489 dwCommandId
= GetMenuDefaultItem(hMenu
, 0, 0);
3490 if (dwCommandId
!= (UINT
)-1)
3492 CMINVOKECOMMANDINFO cmIci
;
3493 /* Invoke the default item */
3494 memset(&cmIci
,0,sizeof(cmIci
));
3495 cmIci
.cbSize
= sizeof(cmIci
);
3496 cmIci
.fMask
= CMIC_MASK_ASYNCOK
;
3498 #ifdef __REACTOS__ /* r75561 */
3499 cmIci
.lpVerb
= MAKEINTRESOURCEA(dwCommandId
- 1);
3501 cmIci
.lpVerb
= MAKEINTRESOURCEA(dwCommandId
);
3503 cmIci
.nShow
= SW_SHOWNORMAL
;
3505 hRet
= IContextMenu_InvokeCommand(iContext
, &cmIci
);
3510 IContextMenu_Release(iContext
);
3515 /*************************************************************************
3520 HICON WINAPI
ExtractIconWrapW(HINSTANCE hInstance
, LPCWSTR lpszExeFileName
,
3523 return ExtractIconW(hInstance
, lpszExeFileName
, nIconIndex
);
3526 /*************************************************************************
3529 * Load a library from the directory of a particular process.
3532 * new_mod [I] Library name
3533 * inst_hwnd [I] Module whose directory is to be used
3534 * dwCrossCodePage [I] Should be FALSE (currently ignored)
3537 * Success: A handle to the loaded module
3538 * Failure: A NULL handle.
3540 HMODULE WINAPI
MLLoadLibraryA(LPCSTR new_mod
, HMODULE inst_hwnd
, DWORD dwCrossCodePage
)
3542 /* FIXME: Native appears to do DPA_Create and a DPA_InsertPtr for
3544 * FIXME: Native shows calls to:
3545 * SHRegGetUSValue for "Software\Microsoft\Internet Explorer\International"
3547 * RegOpenKeyExA for "HKLM\Software\Microsoft\Internet Explorer"
3548 * RegQueryValueExA for "LPKInstalled"
3550 * RegOpenKeyExA for "HKCU\Software\Microsoft\Internet Explorer\International"
3551 * RegQueryValueExA for "ResourceLocale"
3553 * RegOpenKeyExA for "HKLM\Software\Microsoft\Active Setup\Installed Components\{guid}"
3554 * RegQueryValueExA for "Locale"
3556 * and then tests the Locale ("en" for me).
3558 * after the code then a DPA_Create (first time) and DPA_InsertPtr are done.
3560 CHAR mod_path
[2*MAX_PATH
];
3564 FIXME("(%s,%p,%d) semi-stub!\n", debugstr_a(new_mod
), inst_hwnd
, dwCrossCodePage
);
3565 len
= GetModuleFileNameA(inst_hwnd
, mod_path
, sizeof(mod_path
));
3566 if (!len
|| len
>= sizeof(mod_path
)) return NULL
;
3568 ptr
= strrchr(mod_path
, '\\');
3570 strcpy(ptr
+1, new_mod
);
3571 TRACE("loading %s\n", debugstr_a(mod_path
));
3572 return LoadLibraryA(mod_path
);
3577 /*************************************************************************
3580 * Unicode version of MLLoadLibraryA.
3582 HMODULE WINAPI
MLLoadLibraryW(LPCWSTR new_mod
, HMODULE inst_hwnd
, DWORD dwCrossCodePage
)
3584 WCHAR mod_path
[2*MAX_PATH
];
3588 FIXME("(%s,%p,%d) semi-stub!\n", debugstr_w(new_mod
), inst_hwnd
, dwCrossCodePage
);
3589 len
= GetModuleFileNameW(inst_hwnd
, mod_path
, sizeof(mod_path
) / sizeof(WCHAR
));
3590 if (!len
|| len
>= sizeof(mod_path
) / sizeof(WCHAR
)) return NULL
;
3592 ptr
= strrchrW(mod_path
, '\\');
3594 strcpyW(ptr
+1, new_mod
);
3595 TRACE("loading %s\n", debugstr_w(mod_path
));
3596 return LoadLibraryW(mod_path
);
3601 /*************************************************************************
3602 * ColorAdjustLuma [SHLWAPI.@]
3604 * Adjust the luminosity of a color
3607 * cRGB [I] RGB value to convert
3608 * dwLuma [I] Luma adjustment
3609 * bUnknown [I] Unknown
3612 * The adjusted RGB color.
3614 COLORREF WINAPI
ColorAdjustLuma(COLORREF cRGB
, int dwLuma
, BOOL bUnknown
)
3616 TRACE("(0x%8x,%d,%d)\n", cRGB
, dwLuma
, bUnknown
);
3622 ColorRGBToHLS(cRGB
, &wH
, &wL
, &wS
);
3624 FIXME("Ignoring luma adjustment\n");
3626 /* FIXME: The adjustment is not linear */
3628 cRGB
= ColorHLSToRGB(wH
, wL
, wS
);
3633 /*************************************************************************
3636 * See GetSaveFileNameW.
3638 BOOL WINAPI
GetSaveFileNameWrapW(LPOPENFILENAMEW ofn
)
3640 return GetSaveFileNameW(ofn
);
3643 /*************************************************************************
3646 * See WNetRestoreConnectionW.
3648 DWORD WINAPI
WNetRestoreConnectionWrapW(HWND hwndOwner
, LPWSTR lpszDevice
)
3650 return WNetRestoreConnectionW(hwndOwner
, lpszDevice
);
3653 /*************************************************************************
3656 * See WNetGetLastErrorW.
3658 DWORD WINAPI
WNetGetLastErrorWrapW(LPDWORD lpError
, LPWSTR lpErrorBuf
, DWORD nErrorBufSize
,
3659 LPWSTR lpNameBuf
, DWORD nNameBufSize
)
3661 return WNetGetLastErrorW(lpError
, lpErrorBuf
, nErrorBufSize
, lpNameBuf
, nNameBufSize
);
3664 /*************************************************************************
3667 * See PageSetupDlgW.
3669 BOOL WINAPI
PageSetupDlgWrapW(LPPAGESETUPDLGW pagedlg
)
3671 return PageSetupDlgW(pagedlg
);
3674 /*************************************************************************
3679 BOOL WINAPI
PrintDlgWrapW(LPPRINTDLGW printdlg
)
3681 return PrintDlgW(printdlg
);
3684 /*************************************************************************
3687 * See GetOpenFileNameW.
3689 BOOL WINAPI
GetOpenFileNameWrapW(LPOPENFILENAMEW ofn
)
3691 return GetOpenFileNameW(ofn
);
3694 /*************************************************************************
3697 HRESULT WINAPI
SHIShellFolder_EnumObjects(LPSHELLFOLDER lpFolder
, HWND hwnd
, SHCONTF flags
, IEnumIDList
**ppenum
)
3699 /* Windows attempts to get an IPersist interface and, if that fails, an
3700 * IPersistFolder interface on the folder passed-in here. If one of those
3701 * interfaces is available, it then calls GetClassID on the folder... and
3702 * then calls IShellFolder_EnumObjects no matter what, even crashing if
3703 * lpFolder isn't actually an IShellFolder object. The purpose of getting
3704 * the ClassID is unknown, so we don't do it here.
3706 * For discussion and detailed tests, see:
3707 * "shlwapi: Be less strict on which type of IShellFolder can be enumerated"
3708 * wine-devel mailing list, 3 Jun 2010
3711 return IShellFolder_EnumObjects(lpFolder
, hwnd
, flags
, ppenum
);
3714 /* INTERNAL: Map from HLS color space to RGB */
3715 static WORD
ConvertHue(int wHue
, WORD wMid1
, WORD wMid2
)
3717 wHue
= wHue
> 240 ? wHue
- 240 : wHue
< 0 ? wHue
+ 240 : wHue
;
3721 else if (wHue
> 120)
3726 return ((wHue
* (wMid2
- wMid1
) + 20) / 40) + wMid1
;
3729 /* Convert to RGB and scale into RGB range (0..255) */
3730 #define GET_RGB(h) (ConvertHue(h, wMid1, wMid2) * 255 + 120) / 240
3732 /*************************************************************************
3733 * ColorHLSToRGB [SHLWAPI.@]
3735 * Convert from hls color space into an rgb COLORREF.
3738 * wHue [I] Hue amount
3739 * wLuminosity [I] Luminosity amount
3740 * wSaturation [I] Saturation amount
3743 * A COLORREF representing the converted color.
3746 * Input hls values are constrained to the range (0..240).
3748 COLORREF WINAPI
ColorHLSToRGB(WORD wHue
, WORD wLuminosity
, WORD wSaturation
)
3754 WORD wGreen
, wBlue
, wMid1
, wMid2
;
3756 if (wLuminosity
> 120)
3757 wMid2
= wSaturation
+ wLuminosity
- (wSaturation
* wLuminosity
+ 120) / 240;
3759 wMid2
= ((wSaturation
+ 240) * wLuminosity
+ 120) / 240;
3761 wMid1
= wLuminosity
* 2 - wMid2
;
3763 wRed
= GET_RGB(wHue
+ 80);
3764 wGreen
= GET_RGB(wHue
);
3765 wBlue
= GET_RGB(wHue
- 80);
3767 return RGB(wRed
, wGreen
, wBlue
);
3770 wRed
= wLuminosity
* 255 / 240;
3771 return RGB(wRed
, wRed
, wRed
);
3774 /*************************************************************************
3777 * Get the current docking status of the system.
3780 * dwFlags [I] DOCKINFO_ flags from "winbase.h", unused
3783 * One of DOCKINFO_UNDOCKED, DOCKINFO_UNDOCKED, or 0 if the system is not
3786 DWORD WINAPI
SHGetMachineInfo(DWORD dwFlags
)
3788 HW_PROFILE_INFOA hwInfo
;
3790 TRACE("(0x%08x)\n", dwFlags
);
3792 GetCurrentHwProfileA(&hwInfo
);
3793 switch (hwInfo
.dwDockInfo
& (DOCKINFO_DOCKED
|DOCKINFO_UNDOCKED
))
3795 case DOCKINFO_DOCKED
:
3796 case DOCKINFO_UNDOCKED
:
3797 return hwInfo
.dwDockInfo
& (DOCKINFO_DOCKED
|DOCKINFO_UNDOCKED
);
3803 /*************************************************************************
3807 DWORD WINAPI
SHWinHelpOnDemandW(HWND hwnd
, LPCWSTR helpfile
, DWORD flags1
, VOID
*ptr1
, DWORD flags2
)
3810 FIXME("(%p, %s, 0x%x, %p, %d)\n", hwnd
, debugstr_w(helpfile
), flags1
, ptr1
, flags2
);
3814 /*************************************************************************
3818 DWORD WINAPI
SHWinHelpOnDemandA(HWND hwnd
, LPCSTR helpfile
, DWORD flags1
, VOID
*ptr1
, DWORD flags2
)
3821 FIXME("(%p, %s, 0x%x, %p, %d)\n", hwnd
, debugstr_a(helpfile
), flags1
, ptr1
, flags2
);
3825 /*************************************************************************
3828 * Function seems to do FreeLibrary plus other things.
3830 * FIXME native shows the following calls:
3831 * RtlEnterCriticalSection
3833 * GetProcAddress(Comctl32??, 150L)
3835 * RtlLeaveCriticalSection
3836 * followed by the FreeLibrary.
3837 * The above code may be related to .377 above.
3839 BOOL WINAPI
MLFreeLibrary(HMODULE hModule
)
3841 FIXME("(%p) semi-stub\n", hModule
);
3842 return FreeLibrary(hModule
);
3845 /*************************************************************************
3848 BOOL WINAPI
SHFlushSFCacheWrap(void) {
3853 /*************************************************************************
3855 * FIXME I have no idea what this function does or what its arguments are.
3857 BOOL WINAPI
MLIsMLHInstance(HINSTANCE hInst
)
3859 FIXME("(%p) stub\n", hInst
);
3864 /*************************************************************************
3867 DWORD WINAPI
MLSetMLHInstance(HINSTANCE hInst
, HANDLE hHeap
)
3869 FIXME("(%p,%p) stub\n", hInst
, hHeap
);
3870 return E_FAIL
; /* This is what is used if shlwapi not loaded */
3873 /*************************************************************************
3876 DWORD WINAPI
MLClearMLHInstance(DWORD x
)
3878 FIXME("(0x%08x)stub\n", x
);
3882 /*************************************************************************
3885 * See SHSendMessageBroadcastW
3888 DWORD WINAPI
SHSendMessageBroadcastA(UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
3890 return SendMessageTimeoutA(HWND_BROADCAST
, uMsg
, wParam
, lParam
,
3891 SMTO_ABORTIFHUNG
, 2000, NULL
);
3894 /*************************************************************************
3897 * A wrapper for sending Broadcast Messages to all top level Windows
3900 DWORD WINAPI
SHSendMessageBroadcastW(UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
3902 return SendMessageTimeoutW(HWND_BROADCAST
, uMsg
, wParam
, lParam
,
3903 SMTO_ABORTIFHUNG
, 2000, NULL
);
3906 /*************************************************************************
3909 * Convert a Unicode string CLSID into a CLSID.
3912 * idstr [I] string containing a CLSID in text form
3913 * id [O] CLSID extracted from the string
3916 * S_OK on success or E_INVALIDARG on failure
3918 HRESULT WINAPI
CLSIDFromStringWrap(LPCWSTR idstr
, CLSID
*id
)
3920 return CLSIDFromString((LPCOLESTR
)idstr
, id
);
3923 /*************************************************************************
3926 * Determine if the OS supports a given feature.
3929 * dwFeature [I] Feature requested (undocumented)
3932 * TRUE If the feature is available.
3933 * FALSE If the feature is not available.
3935 BOOL WINAPI
IsOS(DWORD feature
)
3937 OSVERSIONINFOA osvi
;
3938 DWORD platform
, majorv
, minorv
;
3940 osvi
.dwOSVersionInfoSize
= sizeof(OSVERSIONINFOA
);
3941 if(!GetVersionExA(&osvi
)) {
3942 ERR("GetVersionEx failed\n");
3946 majorv
= osvi
.dwMajorVersion
;
3947 minorv
= osvi
.dwMinorVersion
;
3948 platform
= osvi
.dwPlatformId
;
3950 #define ISOS_RETURN(x) \
3951 TRACE("(0x%x) ret=%d\n",feature,(x)); \
3955 case OS_WIN32SORGREATER
:
3956 ISOS_RETURN(platform
== VER_PLATFORM_WIN32s
3957 || platform
== VER_PLATFORM_WIN32_WINDOWS
)
3959 ISOS_RETURN(platform
== VER_PLATFORM_WIN32_NT
)
3960 case OS_WIN95ORGREATER
:
3961 ISOS_RETURN(platform
== VER_PLATFORM_WIN32_WINDOWS
)
3962 case OS_NT4ORGREATER
:
3963 ISOS_RETURN(platform
== VER_PLATFORM_WIN32_NT
&& majorv
>= 4)
3964 case OS_WIN2000ORGREATER_ALT
:
3965 case OS_WIN2000ORGREATER
:
3966 ISOS_RETURN(platform
== VER_PLATFORM_WIN32_NT
&& majorv
>= 5)
3967 case OS_WIN98ORGREATER
:
3968 ISOS_RETURN(platform
== VER_PLATFORM_WIN32_WINDOWS
&& minorv
>= 10)
3970 ISOS_RETURN(platform
== VER_PLATFORM_WIN32_WINDOWS
&& minorv
== 10)
3972 ISOS_RETURN(platform
== VER_PLATFORM_WIN32_NT
&& majorv
>= 5)
3973 case OS_WIN2000SERVER
:
3974 ISOS_RETURN(platform
== VER_PLATFORM_WIN32_NT
&& (minorv
== 0 || minorv
== 1))
3975 case OS_WIN2000ADVSERVER
:
3976 ISOS_RETURN(platform
== VER_PLATFORM_WIN32_NT
&& (minorv
== 0 || minorv
== 1))
3977 case OS_WIN2000DATACENTER
:
3978 ISOS_RETURN(platform
== VER_PLATFORM_WIN32_NT
&& (minorv
== 0 || minorv
== 1))
3979 case OS_WIN2000TERMINAL
:
3980 ISOS_RETURN(platform
== VER_PLATFORM_WIN32_NT
&& (minorv
== 0 || minorv
== 1))
3982 FIXME("(OS_EMBEDDED) What should we return here?\n");
3984 case OS_TERMINALCLIENT
:
3985 FIXME("(OS_TERMINALCLIENT) What should we return here?\n");
3987 case OS_TERMINALREMOTEADMIN
:
3988 FIXME("(OS_TERMINALREMOTEADMIN) What should we return here?\n");
3991 ISOS_RETURN(platform
== VER_PLATFORM_WIN32_WINDOWS
&& minorv
== 0)
3992 case OS_MEORGREATER
:
3993 ISOS_RETURN(platform
== VER_PLATFORM_WIN32_WINDOWS
&& minorv
>= 90)
3994 case OS_XPORGREATER
:
3995 ISOS_RETURN(platform
== VER_PLATFORM_WIN32_NT
&& majorv
>= 5 && minorv
>= 1)
3997 ISOS_RETURN(platform
== VER_PLATFORM_WIN32_NT
&& majorv
>= 5 && minorv
>= 1)
3998 case OS_PROFESSIONAL
:
3999 ISOS_RETURN(platform
== VER_PLATFORM_WIN32_NT
)
4001 ISOS_RETURN(platform
== VER_PLATFORM_WIN32_NT
)
4003 ISOS_RETURN(platform
== VER_PLATFORM_WIN32_NT
&& majorv
>= 5)
4005 ISOS_RETURN(platform
== VER_PLATFORM_WIN32_NT
)
4006 case OS_TERMINALSERVER
:
4007 ISOS_RETURN(platform
== VER_PLATFORM_WIN32_NT
)
4008 case OS_PERSONALTERMINALSERVER
:
4009 ISOS_RETURN(platform
== VER_PLATFORM_WIN32_NT
&& minorv
>= 1 && majorv
>= 5)
4010 case OS_FASTUSERSWITCHING
:
4011 FIXME("(OS_FASTUSERSWITCHING) What should we return here?\n");
4013 case OS_WELCOMELOGONUI
:
4014 FIXME("(OS_WELCOMELOGONUI) What should we return here?\n");
4016 case OS_DOMAINMEMBER
:
4017 FIXME("(OS_DOMAINMEMBER) What should we return here?\n");
4020 ISOS_RETURN(platform
== VER_PLATFORM_WIN32_NT
)
4024 IsWow64Process(GetCurrentProcess(), &is_wow64
);
4028 ISOS_RETURN(platform
== VER_PLATFORM_WIN32_NT
)
4029 case OS_SMALLBUSINESSSERVER
:
4030 ISOS_RETURN(platform
== VER_PLATFORM_WIN32_NT
)
4032 FIXME("(OS_TABLETPC) What should we return here?\n");
4034 case OS_SERVERADMINUI
:
4035 FIXME("(OS_SERVERADMINUI) What should we return here?\n");
4037 case OS_MEDIACENTER
:
4038 FIXME("(OS_MEDIACENTER) What should we return here?\n");
4041 FIXME("(OS_APPLIANCE) What should we return here?\n");
4043 case 0x25: /*OS_VISTAORGREATER*/
4044 ISOS_RETURN(platform
== VER_PLATFORM_WIN32_NT
&& majorv
>= 6)
4049 WARN("(0x%x) unknown parameter\n",feature
);
4054 /*************************************************************************
4057 HRESULT WINAPI
SHLoadRegUIStringW(HKEY hkey
, LPCWSTR value
, LPWSTR buf
, DWORD size
)
4059 DWORD type
, sz
= size
;
4061 if(RegQueryValueExW(hkey
, value
, NULL
, &type
, (LPBYTE
)buf
, &sz
) != ERROR_SUCCESS
)
4064 return SHLoadIndirectString(buf
, buf
, size
, NULL
);
4067 /*************************************************************************
4070 * Call IInputObject_TranslateAcceleratorIO() on an object.
4073 * lpUnknown [I] Object supporting the IInputObject interface.
4074 * lpMsg [I] Key message to be processed.
4078 * Failure: An HRESULT error code, or E_INVALIDARG if lpUnknown is NULL.
4080 HRESULT WINAPI
IUnknown_TranslateAcceleratorIO(IUnknown
*lpUnknown
, LPMSG lpMsg
)
4082 IInputObject
* lpInput
= NULL
;
4083 HRESULT hRet
= E_INVALIDARG
;
4085 TRACE("(%p,%p)\n", lpUnknown
, lpMsg
);
4088 hRet
= IUnknown_QueryInterface(lpUnknown
, &IID_IInputObject
,
4090 if (SUCCEEDED(hRet
) && lpInput
)
4092 hRet
= IInputObject_TranslateAcceleratorIO(lpInput
, lpMsg
);
4093 IInputObject_Release(lpInput
);
4099 /*************************************************************************
4102 * Call IInputObject_HasFocusIO() on an object.
4105 * lpUnknown [I] Object supporting the IInputObject interface.
4108 * Success: S_OK, if lpUnknown is an IInputObject object and has the focus,
4109 * or S_FALSE otherwise.
4110 * Failure: An HRESULT error code, or E_INVALIDARG if lpUnknown is NULL.
4112 HRESULT WINAPI
IUnknown_HasFocusIO(IUnknown
*lpUnknown
)
4114 IInputObject
* lpInput
= NULL
;
4115 HRESULT hRet
= E_INVALIDARG
;
4117 TRACE("(%p)\n", lpUnknown
);
4120 hRet
= IUnknown_QueryInterface(lpUnknown
, &IID_IInputObject
,
4122 if (SUCCEEDED(hRet
) && lpInput
)
4124 hRet
= IInputObject_HasFocusIO(lpInput
);
4125 IInputObject_Release(lpInput
);
4131 /*************************************************************************
4132 * ColorRGBToHLS [SHLWAPI.@]
4134 * Convert an rgb COLORREF into the hls color space.
4137 * cRGB [I] Source rgb value
4138 * pwHue [O] Destination for converted hue
4139 * pwLuminance [O] Destination for converted luminance
4140 * pwSaturation [O] Destination for converted saturation
4143 * Nothing. pwHue, pwLuminance and pwSaturation are set to the converted
4147 * Output HLS values are constrained to the range (0..240).
4148 * For Achromatic conversions, Hue is set to 160.
4150 VOID WINAPI
ColorRGBToHLS(COLORREF cRGB
, LPWORD pwHue
,
4151 LPWORD pwLuminance
, LPWORD pwSaturation
)
4153 int wR
, wG
, wB
, wMax
, wMin
, wHue
, wLuminosity
, wSaturation
;
4155 TRACE("(%08x,%p,%p,%p)\n", cRGB
, pwHue
, pwLuminance
, pwSaturation
);
4157 wR
= GetRValue(cRGB
);
4158 wG
= GetGValue(cRGB
);
4159 wB
= GetBValue(cRGB
);
4161 wMax
= max(wR
, max(wG
, wB
));
4162 wMin
= min(wR
, min(wG
, wB
));
4165 wLuminosity
= ((wMax
+ wMin
) * 240 + 255) / 510;
4169 /* Achromatic case */
4171 /* Hue is now unrepresentable, but this is what native returns... */
4176 /* Chromatic case */
4177 int wDelta
= wMax
- wMin
, wRNorm
, wGNorm
, wBNorm
;
4180 if (wLuminosity
<= 120)
4181 wSaturation
= ((wMax
+ wMin
)/2 + wDelta
* 240) / (wMax
+ wMin
);
4183 wSaturation
= ((510 - wMax
- wMin
)/2 + wDelta
* 240) / (510 - wMax
- wMin
);
4186 wRNorm
= (wDelta
/2 + wMax
* 40 - wR
* 40) / wDelta
;
4187 wGNorm
= (wDelta
/2 + wMax
* 40 - wG
* 40) / wDelta
;
4188 wBNorm
= (wDelta
/2 + wMax
* 40 - wB
* 40) / wDelta
;
4191 wHue
= wBNorm
- wGNorm
;
4192 else if (wG
== wMax
)
4193 wHue
= 80 + wRNorm
- wBNorm
;
4195 wHue
= 160 + wGNorm
- wRNorm
;
4198 else if (wHue
> 240)
4204 *pwLuminance
= wLuminosity
;
4206 *pwSaturation
= wSaturation
;
4209 /*************************************************************************
4210 * SHCreateShellPalette [SHLWAPI.@]
4212 HPALETTE WINAPI
SHCreateShellPalette(HDC hdc
)
4215 return CreateHalftonePalette(hdc
);
4218 /*************************************************************************
4219 * SHGetInverseCMAP (SHLWAPI.@)
4221 * Get an inverse color map table.
4224 * lpCmap [O] Destination for color map
4225 * dwSize [I] Size of memory pointed to by lpCmap
4229 * Failure: E_POINTER, If lpCmap is invalid.
4230 * E_INVALIDARG, If dwFlags is invalid
4231 * E_OUTOFMEMORY, If there is no memory available
4234 * dwSize may only be CMAP_PTR_SIZE (4) or CMAP_SIZE (8192).
4235 * If dwSize = CMAP_PTR_SIZE, *lpCmap is set to the address of this DLL's
4237 * If dwSize = CMAP_SIZE, lpCmap is filled with a copy of the data from
4238 * this DLL's internal CMap.
4240 HRESULT WINAPI
SHGetInverseCMAP(LPDWORD dest
, DWORD dwSize
)
4243 FIXME(" - returning bogus address for SHGetInverseCMAP\n");
4244 *dest
= (DWORD
)0xabba1249;
4247 FIXME("(%p, %#x) stub\n", dest
, dwSize
);
4251 /*************************************************************************
4252 * SHIsLowMemoryMachine [SHLWAPI.@]
4254 * Determine if the current computer has low memory.
4260 * TRUE if the users machine has 16 Megabytes of memory or less,
4263 BOOL WINAPI
SHIsLowMemoryMachine (DWORD x
)
4265 FIXME("(0x%08x) stub\n", x
);
4269 /*************************************************************************
4270 * GetMenuPosFromID [SHLWAPI.@]
4272 * Return the position of a menu item from its Id.
4275 * hMenu [I] Menu containing the item
4276 * wID [I] Id of the menu item
4279 * Success: The index of the menu item in hMenu.
4280 * Failure: -1, If the item is not found.
4282 INT WINAPI
GetMenuPosFromID(HMENU hMenu
, UINT wID
)
4285 INT nCount
= GetMenuItemCount(hMenu
), nIter
= 0;
4287 TRACE("%p %u\n", hMenu
, wID
);
4289 while (nIter
< nCount
)
4291 mi
.cbSize
= sizeof(mi
);
4293 if (GetMenuItemInfoW(hMenu
, nIter
, TRUE
, &mi
) && mi
.wID
== wID
)
4295 TRACE("ret %d\n", nIter
);
4304 /*************************************************************************
4307 * Same as SHLWAPI.GetMenuPosFromID
4309 DWORD WINAPI
SHMenuIndexFromID(HMENU hMenu
, UINT uID
)
4311 TRACE("%p %u\n", hMenu
, uID
);
4312 return GetMenuPosFromID(hMenu
, uID
);
4316 /*************************************************************************
4319 VOID WINAPI
FixSlashesAndColonW(LPWSTR lpwstr
)
4330 /*************************************************************************
4333 DWORD WINAPI
SHGetAppCompatFlags(DWORD dwUnknown
)
4335 FIXME("(0x%08x) stub\n", dwUnknown
);
4340 /*************************************************************************
4343 HRESULT WINAPI
SHCoCreateInstanceAC(REFCLSID rclsid
, LPUNKNOWN pUnkOuter
,
4344 DWORD dwClsContext
, REFIID iid
, LPVOID
*ppv
)
4346 return CoCreateInstance(rclsid
, pUnkOuter
, dwClsContext
, iid
, ppv
);
4349 /*************************************************************************
4350 * SHSkipJunction [SHLWAPI.@]
4352 * Determine if a bind context can be bound to an object
4355 * pbc [I] Bind context to check
4356 * pclsid [I] CLSID of object to be bound to
4359 * TRUE: If it is safe to bind
4360 * FALSE: If pbc is invalid or binding would not be safe
4363 BOOL WINAPI
SHSkipJunction(IBindCtx
*pbc
, const CLSID
*pclsid
)
4365 static WCHAR szSkipBinding
[] = { 'S','k','i','p',' ',
4366 'B','i','n','d','i','n','g',' ','C','L','S','I','D','\0' };
4373 if (SUCCEEDED(IBindCtx_GetObjectParam(pbc
, szSkipBinding
, &lpUnk
)))
4377 if (SUCCEEDED(IUnknown_GetClassID(lpUnk
, &clsid
)) &&
4378 IsEqualGUID(pclsid
, &clsid
))
4381 IUnknown_Release(lpUnk
);
4387 /***********************************************************************
4388 * SHGetShellKey (SHLWAPI.491)
4390 HKEY WINAPI
SHGetShellKey(DWORD flags
, LPCWSTR sub_key
, BOOL create
)
4392 enum _shellkey_flags
{
4393 SHKEY_Root_HKCU
= 0x1,
4394 SHKEY_Root_HKLM
= 0x2,
4395 SHKEY_Key_Explorer
= 0x00,
4396 SHKEY_Key_Shell
= 0x10,
4397 SHKEY_Key_ShellNoRoam
= 0x20,
4398 SHKEY_Key_Classes
= 0x30,
4399 SHKEY_Subkey_Default
= 0x0000,
4400 SHKEY_Subkey_ResourceName
= 0x1000,
4401 SHKEY_Subkey_Handlers
= 0x2000,
4402 SHKEY_Subkey_Associations
= 0x3000,
4403 SHKEY_Subkey_Volatile
= 0x4000,
4404 SHKEY_Subkey_MUICache
= 0x5000,
4405 SHKEY_Subkey_FileExts
= 0x6000
4408 static const WCHAR explorerW
[] = {'S','o','f','t','w','a','r','e','\\',
4409 'M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\',
4410 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
4411 'E','x','p','l','o','r','e','r','\\'};
4412 static const WCHAR shellW
[] = {'S','o','f','t','w','a','r','e','\\',
4413 'M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\',
4414 'S','h','e','l','l','\\'};
4415 static const WCHAR shell_no_roamW
[] = {'S','o','f','t','w','a','r','e','\\',
4416 'M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\',
4417 'S','h','e','l','l','N','o','R','o','a','m','\\'};
4418 static const WCHAR classesW
[] = {'S','o','f','t','w','a','r','e','\\',
4419 'C','l','a','s','s','e','s','\\'};
4421 static const WCHAR localized_resource_nameW
[] = {'L','o','c','a','l','i','z','e','d',
4422 'R','e','s','o','u','r','c','e','N','a','m','e','\\'};
4423 static const WCHAR handlersW
[] = {'H','a','n','d','l','e','r','s','\\'};
4424 static const WCHAR associationsW
[] = {'A','s','s','o','c','i','a','t','i','o','n','s','\\'};
4425 static const WCHAR volatileW
[] = {'V','o','l','a','t','i','l','e','\\'};
4426 static const WCHAR mui_cacheW
[] = {'M','U','I','C','a','c','h','e','\\'};
4427 static const WCHAR file_extsW
[] = {'F','i','l','e','E','x','t','s','\\'};
4430 const WCHAR
*key
, *subkey
;
4431 int size_key
, size_subkey
, size_user
;
4434 TRACE("(0x%08x, %s, %d)\n", flags
, debugstr_w(sub_key
), create
);
4436 /* For compatibility with Vista+ */
4437 if(flags
== 0x1ffff)
4440 switch(flags
&0xff0) {
4441 case SHKEY_Key_Explorer
:
4443 size_key
= sizeof(explorerW
);
4445 case SHKEY_Key_Shell
:
4447 size_key
= sizeof(shellW
);
4449 case SHKEY_Key_ShellNoRoam
:
4450 key
= shell_no_roamW
;
4451 size_key
= sizeof(shell_no_roamW
);
4453 case SHKEY_Key_Classes
:
4455 size_key
= sizeof(classesW
);
4458 FIXME("unsupported flags (0x%08x)\n", flags
);
4462 switch(flags
&0xff000) {
4463 case SHKEY_Subkey_Default
:
4467 case SHKEY_Subkey_ResourceName
:
4468 subkey
= localized_resource_nameW
;
4469 size_subkey
= sizeof(localized_resource_nameW
);
4471 case SHKEY_Subkey_Handlers
:
4473 size_subkey
= sizeof(handlersW
);
4475 case SHKEY_Subkey_Associations
:
4476 subkey
= associationsW
;
4477 size_subkey
= sizeof(associationsW
);
4479 case SHKEY_Subkey_Volatile
:
4481 size_subkey
= sizeof(volatileW
);
4483 case SHKEY_Subkey_MUICache
:
4484 subkey
= mui_cacheW
;
4485 size_subkey
= sizeof(mui_cacheW
);
4487 case SHKEY_Subkey_FileExts
:
4488 subkey
= file_extsW
;
4489 size_subkey
= sizeof(file_extsW
);
4492 FIXME("unsupported flags (0x%08x)\n", flags
);
4497 size_user
= lstrlenW(sub_key
)*sizeof(WCHAR
);
4501 path
= HeapAlloc(GetProcessHeap(), 0, size_key
+size_subkey
+size_user
+sizeof(WCHAR
));
4503 ERR("Out of memory\n");
4507 memcpy(path
, key
, size_key
);
4509 memcpy(path
+size_key
/sizeof(WCHAR
), subkey
, size_subkey
);
4511 memcpy(path
+(size_key
+size_subkey
)/sizeof(WCHAR
), sub_key
, size_user
);
4512 path
[(size_key
+size_subkey
+size_user
)/sizeof(WCHAR
)] = '\0';
4515 RegCreateKeyExW((flags
&0xf)==SHKEY_Root_HKLM
?HKEY_LOCAL_MACHINE
:HKEY_CURRENT_USER
,
4516 path
, 0, NULL
, 0, MAXIMUM_ALLOWED
, NULL
, &hkey
, NULL
);
4518 RegOpenKeyExW((flags
&0xf)==SHKEY_Root_HKLM
?HKEY_LOCAL_MACHINE
:HKEY_CURRENT_USER
,
4519 path
, 0, MAXIMUM_ALLOWED
, &hkey
);
4521 HeapFree(GetProcessHeap(), 0, path
);
4525 /***********************************************************************
4526 * SHQueueUserWorkItem (SHLWAPI.@)
4528 BOOL WINAPI
SHQueueUserWorkItem(LPTHREAD_START_ROUTINE pfnCallback
,
4529 LPVOID pContext
, LONG lPriority
, DWORD_PTR dwTag
,
4530 DWORD_PTR
*pdwId
, LPCSTR pszModule
, DWORD dwFlags
)
4532 TRACE("(%p, %p, %d, %lx, %p, %s, %08x)\n", pfnCallback
, pContext
,
4533 lPriority
, dwTag
, pdwId
, debugstr_a(pszModule
), dwFlags
);
4535 if(lPriority
|| dwTag
|| pdwId
|| pszModule
|| dwFlags
)
4536 FIXME("Unsupported arguments\n");
4538 return QueueUserWorkItem(pfnCallback
, pContext
, 0);
4541 /***********************************************************************
4542 * SHSetTimerQueueTimer (SHLWAPI.263)
4544 HANDLE WINAPI
SHSetTimerQueueTimer(HANDLE hQueue
,
4545 WAITORTIMERCALLBACK pfnCallback
, LPVOID pContext
, DWORD dwDueTime
,
4546 DWORD dwPeriod
, LPCSTR lpszLibrary
, DWORD dwFlags
)
4550 /* SHSetTimerQueueTimer flags -> CreateTimerQueueTimer flags */
4551 if (dwFlags
& TPS_LONGEXECTIME
) {
4552 dwFlags
&= ~TPS_LONGEXECTIME
;
4553 dwFlags
|= WT_EXECUTELONGFUNCTION
;
4555 if (dwFlags
& TPS_EXECUTEIO
) {
4556 dwFlags
&= ~TPS_EXECUTEIO
;
4557 dwFlags
|= WT_EXECUTEINIOTHREAD
;
4560 if (!CreateTimerQueueTimer(&hNewTimer
, hQueue
, pfnCallback
, pContext
,
4561 dwDueTime
, dwPeriod
, dwFlags
))
4567 /***********************************************************************
4568 * IUnknown_OnFocusChangeIS (SHLWAPI.@)
4570 HRESULT WINAPI
IUnknown_OnFocusChangeIS(LPUNKNOWN lpUnknown
, LPUNKNOWN pFocusObject
, BOOL bFocus
)
4572 IInputObjectSite
*pIOS
= NULL
;
4573 HRESULT hRet
= E_INVALIDARG
;
4575 TRACE("(%p, %p, %s)\n", lpUnknown
, pFocusObject
, bFocus
? "TRUE" : "FALSE");
4579 hRet
= IUnknown_QueryInterface(lpUnknown
, &IID_IInputObjectSite
,
4581 if (SUCCEEDED(hRet
) && pIOS
)
4583 hRet
= IInputObjectSite_OnFocusChangeIS(pIOS
, pFocusObject
, bFocus
);
4584 IInputObjectSite_Release(pIOS
);
4590 /***********************************************************************
4591 * SKAllocValueW (SHLWAPI.519)
4593 HRESULT WINAPI
SKAllocValueW(DWORD flags
, LPCWSTR subkey
, LPCWSTR value
, DWORD
*type
,
4594 LPVOID
*data
, DWORD
*count
)
4599 TRACE("(0x%x, %s, %s, %p, %p, %p)\n", flags
, debugstr_w(subkey
),
4600 debugstr_w(value
), type
, data
, count
);
4602 hkey
= SHGetShellKey(flags
, subkey
, FALSE
);
4604 return HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND
);
4606 ret
= SHQueryValueExW(hkey
, value
, NULL
, type
, NULL
, &size
);
4609 return HRESULT_FROM_WIN32(ret
);
4613 *data
= LocalAlloc(0, size
);
4616 return E_OUTOFMEMORY
;
4619 ret
= SHQueryValueExW(hkey
, value
, NULL
, type
, *data
, &size
);
4624 return HRESULT_FROM_WIN32(ret
);
4627 /***********************************************************************
4628 * SKDeleteValueW (SHLWAPI.518)
4630 HRESULT WINAPI
SKDeleteValueW(DWORD flags
, LPCWSTR subkey
, LPCWSTR value
)
4635 TRACE("(0x%x, %s %s)\n", flags
, debugstr_w(subkey
), debugstr_w(value
));
4637 hkey
= SHGetShellKey(flags
, subkey
, FALSE
);
4639 return HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND
);
4641 ret
= RegDeleteValueW(hkey
, value
);
4644 return HRESULT_FROM_WIN32(ret
);
4647 /***********************************************************************
4648 * SKGetValueW (SHLWAPI.516)
4650 HRESULT WINAPI
SKGetValueW(DWORD flags
, LPCWSTR subkey
, LPCWSTR value
, DWORD
*type
,
4651 void *data
, DWORD
*count
)
4656 TRACE("(0x%x, %s, %s, %p, %p, %p)\n", flags
, debugstr_w(subkey
),
4657 debugstr_w(value
), type
, data
, count
);
4659 hkey
= SHGetShellKey(flags
, subkey
, FALSE
);
4661 return HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND
);
4663 ret
= SHQueryValueExW(hkey
, value
, NULL
, type
, data
, count
);
4666 return HRESULT_FROM_WIN32(ret
);
4669 /***********************************************************************
4670 * SKSetValueW (SHLWAPI.516)
4672 HRESULT WINAPI
SKSetValueW(DWORD flags
, LPCWSTR subkey
, LPCWSTR value
,
4673 DWORD type
, void *data
, DWORD count
)
4678 TRACE("(0x%x, %s, %s, %x, %p, %d)\n", flags
, debugstr_w(subkey
),
4679 debugstr_w(value
), type
, data
, count
);
4681 hkey
= SHGetShellKey(flags
, subkey
, TRUE
);
4683 return HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND
);
4685 ret
= RegSetValueExW(hkey
, value
, 0, type
, data
, count
);
4688 return HRESULT_FROM_WIN32(ret
);
4691 typedef HRESULT (WINAPI
*DllGetVersion_func
)(DLLVERSIONINFO
*);
4693 /***********************************************************************
4694 * GetUIVersion (SHLWAPI.452)
4696 DWORD WINAPI
GetUIVersion(void)
4698 static DWORD version
;
4702 DllGetVersion_func pDllGetVersion
;
4703 HMODULE dll
= LoadLibraryA("shell32.dll");
4706 pDllGetVersion
= (DllGetVersion_func
)GetProcAddress(dll
, "DllGetVersion");
4710 dvi
.cbSize
= sizeof(DLLVERSIONINFO
);
4711 if (pDllGetVersion(&dvi
) == S_OK
) version
= dvi
.dwMajorVersion
;
4714 if (!version
) version
= 3; /* old shell dlls don't have DllGetVersion */
4719 /***********************************************************************
4720 * ShellMessageBoxWrapW [SHLWAPI.388]
4722 * See shell32.ShellMessageBoxW
4725 * shlwapi.ShellMessageBoxWrapW is a duplicate of shell32.ShellMessageBoxW
4726 * because we can't forward to it in the .spec file since it's exported by
4727 * ordinal. If you change the implementation here please update the code in
4730 INT WINAPIV
ShellMessageBoxWrapW(HINSTANCE hInstance
, HWND hWnd
, LPCWSTR lpText
,
4731 LPCWSTR lpCaption
, UINT uType
, ...)
4733 WCHAR
*szText
= NULL
, szTitle
[100];
4734 LPCWSTR pszText
, pszTitle
= szTitle
;
4739 __ms_va_start(args
, uType
);
4741 TRACE("(%p,%p,%p,%p,%08x)\n", hInstance
, hWnd
, lpText
, lpCaption
, uType
);
4743 if (IS_INTRESOURCE(lpCaption
))
4744 LoadStringW(hInstance
, LOWORD(lpCaption
), szTitle
, sizeof(szTitle
)/sizeof(szTitle
[0]));
4746 pszTitle
= lpCaption
;
4748 if (IS_INTRESOURCE(lpText
))
4751 UINT len
= LoadStringW(hInstance
, LOWORD(lpText
), (LPWSTR
)&ptr
, 0);
4755 szText
= HeapAlloc(GetProcessHeap(), 0, (len
+ 1) * sizeof(WCHAR
));
4756 if (szText
) LoadStringW(hInstance
, LOWORD(lpText
), szText
, len
+ 1);
4760 WARN("Failed to load id %d\n", LOWORD(lpText
));
4768 FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER
| FORMAT_MESSAGE_FROM_STRING
,
4769 pszText
, 0, 0, (LPWSTR
)&pszTemp
, 0, &args
);
4773 ret
= MessageBoxW(hWnd
, pszTemp
, pszTitle
, uType
);
4775 HeapFree(GetProcessHeap(), 0, szText
);
4780 /***********************************************************************
4781 * ZoneComputePaneSize [SHLWAPI.382]
4783 UINT WINAPI
ZoneComputePaneSize(HWND hwnd
)
4789 /***********************************************************************
4790 * SHChangeNotifyWrap [SHLWAPI.394]
4792 void WINAPI
SHChangeNotifyWrap(LONG wEventId
, UINT uFlags
, LPCVOID dwItem1
, LPCVOID dwItem2
)
4794 SHChangeNotify(wEventId
, uFlags
, dwItem1
, dwItem2
);
4797 typedef struct SHELL_USER_SID
{ /* according to MSDN this should be in shlobj.h... */
4798 SID_IDENTIFIER_AUTHORITY sidAuthority
;
4799 DWORD dwUserGroupID
;
4801 } SHELL_USER_SID
, *PSHELL_USER_SID
;
4803 typedef struct SHELL_USER_PERMISSION
{ /* ...and this should be in shlwapi.h */
4804 SHELL_USER_SID susID
;
4808 DWORD dwInheritMask
;
4809 DWORD dwInheritAccessMask
;
4810 } SHELL_USER_PERMISSION
, *PSHELL_USER_PERMISSION
;
4812 /***********************************************************************
4813 * GetShellSecurityDescriptor [SHLWAPI.475]
4815 * prepares SECURITY_DESCRIPTOR from a set of ACEs
4818 * apUserPerm [I] array of pointers to SHELL_USER_PERMISSION structures,
4819 * each of which describes permissions to apply
4820 * cUserPerm [I] number of entries in apUserPerm array
4823 * success: pointer to SECURITY_DESCRIPTOR
4827 * Call should free returned descriptor with LocalFree
4829 PSECURITY_DESCRIPTOR WINAPI
GetShellSecurityDescriptor(const PSHELL_USER_PERMISSION
*apUserPerm
, int cUserPerm
)
4832 PSID cur_user
= NULL
;
4836 PSECURITY_DESCRIPTOR psd
= NULL
;
4838 TRACE("%p %d\n", apUserPerm
, cUserPerm
);
4840 if (apUserPerm
== NULL
|| cUserPerm
<= 0)
4843 sidlist
= HeapAlloc(GetProcessHeap(), 0, cUserPerm
* sizeof(PSID
));
4847 acl_size
= sizeof(ACL
);
4849 for(sid_count
= 0; sid_count
< cUserPerm
; sid_count
++)
4851 static SHELL_USER_SID null_sid
= {{SECURITY_NULL_SID_AUTHORITY
}, 0, 0};
4852 PSHELL_USER_PERMISSION perm
= apUserPerm
[sid_count
];
4853 PSHELL_USER_SID sid
= &perm
->susID
;
4857 if (!memcmp((void*)sid
, (void*)&null_sid
, sizeof(SHELL_USER_SID
)))
4858 { /* current user's SID */
4862 DWORD bufsize
= sizeof(tuUser
);
4864 ret
= OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY
, &Token
);
4867 ret
= GetTokenInformation(Token
, TokenUser
, (void*)tuUser
, bufsize
, &bufsize
);
4869 cur_user
= ((PTOKEN_USER
)tuUser
)->User
.Sid
;
4874 } else if (sid
->dwUserID
==0) /* one sub-authority */
4875 ret
= AllocateAndInitializeSid(&sid
->sidAuthority
, 1, sid
->dwUserGroupID
, 0,
4876 0, 0, 0, 0, 0, 0, &pSid
);
4878 ret
= AllocateAndInitializeSid(&sid
->sidAuthority
, 2, sid
->dwUserGroupID
, sid
->dwUserID
,
4879 0, 0, 0, 0, 0, 0, &pSid
);
4883 sidlist
[sid_count
] = pSid
;
4884 /* increment acl_size (1 ACE for non-inheritable and 2 ACEs for inheritable records */
4885 acl_size
+= (sizeof(ACCESS_ALLOWED_ACE
)-sizeof(DWORD
) + GetLengthSid(pSid
)) * (perm
->fInherit
? 2 : 1);
4888 psd
= LocalAlloc(0, sizeof(SECURITY_DESCRIPTOR
) + acl_size
);
4892 PACL pAcl
= (PACL
)(((BYTE
*)psd
)+sizeof(SECURITY_DESCRIPTOR
));
4894 if (!InitializeSecurityDescriptor(psd
, SECURITY_DESCRIPTOR_REVISION
))
4897 if (!InitializeAcl(pAcl
, acl_size
, ACL_REVISION
))
4900 for(i
= 0; i
< sid_count
; i
++)
4902 PSHELL_USER_PERMISSION sup
= apUserPerm
[i
];
4903 PSID sid
= sidlist
[i
];
4905 switch(sup
->dwAccessType
)
4907 case ACCESS_ALLOWED_ACE_TYPE
:
4908 if (!AddAccessAllowedAce(pAcl
, ACL_REVISION
, sup
->dwAccessMask
, sid
))
4910 if (sup
->fInherit
&& !AddAccessAllowedAceEx(pAcl
, ACL_REVISION
,
4911 (BYTE
)sup
->dwInheritMask
, sup
->dwInheritAccessMask
, sid
))
4914 case ACCESS_DENIED_ACE_TYPE
:
4915 if (!AddAccessDeniedAce(pAcl
, ACL_REVISION
, sup
->dwAccessMask
, sid
))
4917 if (sup
->fInherit
&& !AddAccessDeniedAceEx(pAcl
, ACL_REVISION
,
4918 (BYTE
)sup
->dwInheritMask
, sup
->dwInheritAccessMask
, sid
))
4926 if (!SetSecurityDescriptorDacl(psd
, TRUE
, pAcl
, FALSE
))
4935 for(i
= 0; i
< sid_count
; i
++)
4937 if (!cur_user
|| sidlist
[i
] != cur_user
)
4938 FreeSid(sidlist
[i
]);
4940 HeapFree(GetProcessHeap(), 0, sidlist
);
4945 /***********************************************************************
4946 * SHCreatePropertyBagOnRegKey [SHLWAPI.471]
4948 * Creates a property bag from a registry key
4951 * hKey [I] Handle to the desired registry key
4952 * subkey [I] Name of desired subkey, or NULL to open hKey directly
4953 * grfMode [I] Optional flags
4954 * riid [I] IID of requested property bag interface
4955 * ppv [O] Address to receive pointer to the new interface
4959 * failure: error code
4962 HRESULT WINAPI
SHCreatePropertyBagOnRegKey (HKEY hKey
, LPCWSTR subkey
,
4963 DWORD grfMode
, REFIID riid
, void **ppv
)
4965 FIXME("%p %s %d %s %p STUB\n", hKey
, debugstr_w(subkey
), grfMode
,
4966 debugstr_guid(riid
), ppv
);
4971 /***********************************************************************
4972 * SHGetViewStatePropertyBag [SHLWAPI.515]
4974 * Retrieves a property bag in which the view state information of a folder
4978 * pidl [I] PIDL of the folder requested
4979 * bag_name [I] Name of the property bag requested
4980 * flags [I] Optional flags
4981 * riid [I] IID of requested property bag interface
4982 * ppv [O] Address to receive pointer to the new interface
4986 * failure: error code
4989 HRESULT WINAPI
SHGetViewStatePropertyBag(LPCITEMIDLIST pidl
, LPWSTR bag_name
,
4990 DWORD flags
, REFIID riid
, void **ppv
)
4992 FIXME("%p %s %d %s %p STUB\n", pidl
, debugstr_w(bag_name
), flags
,
4993 debugstr_guid(riid
), ppv
);
4998 /***********************************************************************
4999 * SHFormatDateTimeW [SHLWAPI.354]
5001 * Produces a string representation of a time.
5004 * fileTime [I] Pointer to FILETIME structure specifying the time
5005 * flags [I] Flags specifying the desired output
5006 * buf [O] Pointer to buffer for output
5007 * size [I] Number of characters that can be contained in buffer
5010 * success: number of characters written to the buffer
5014 INT WINAPI
SHFormatDateTimeW(const FILETIME UNALIGNED
*fileTime
, DWORD
*flags
,
5015 LPWSTR buf
, UINT size
)
5017 #define SHFORMATDT_UNSUPPORTED_FLAGS (FDTF_RELATIVE | FDTF_LTRDATE | FDTF_RTLDATE | FDTF_NOAUTOREADINGORDER)
5018 DWORD fmt_flags
= flags
? *flags
: FDTF_DEFAULT
;
5023 TRACE("%p %p %p %u\n", fileTime
, flags
, buf
, size
);
5028 if (fmt_flags
& SHFORMATDT_UNSUPPORTED_FLAGS
)
5029 FIXME("ignoring some flags - 0x%08x\n", fmt_flags
& SHFORMATDT_UNSUPPORTED_FLAGS
);
5031 FileTimeToLocalFileTime(fileTime
, &ft
);
5032 FileTimeToSystemTime(&ft
, &st
);
5034 /* first of all date */
5035 if (fmt_flags
& (FDTF_LONGDATE
| FDTF_SHORTDATE
))
5037 static const WCHAR sep1
[] = {',',' ',0};
5038 static const WCHAR sep2
[] = {' ',0};
5040 DWORD date
= fmt_flags
& FDTF_LONGDATE
? DATE_LONGDATE
: DATE_SHORTDATE
;
5041 ret
= GetDateFormatW(LOCALE_USER_DEFAULT
, date
, &st
, NULL
, buf
, size
);
5042 if (ret
>= size
) return ret
;
5045 if (ret
< size
&& (fmt_flags
& (FDTF_LONGTIME
| FDTF_SHORTTIME
)))
5047 if ((fmt_flags
& FDTF_LONGDATE
) && (ret
< size
+ 2))
5049 lstrcatW(&buf
[ret
-1], sep1
);
5054 lstrcatW(&buf
[ret
-1], sep2
);
5060 if (fmt_flags
& (FDTF_LONGTIME
| FDTF_SHORTTIME
))
5062 DWORD time
= fmt_flags
& FDTF_LONGTIME
? 0 : TIME_NOSECONDS
;
5065 ret
+= GetTimeFormatW(LOCALE_USER_DEFAULT
, time
, &st
, NULL
, &buf
[ret
], size
- ret
);
5070 #undef SHFORMATDT_UNSUPPORTED_FLAGS
5073 /***********************************************************************
5074 * SHFormatDateTimeA [SHLWAPI.353]
5076 * See SHFormatDateTimeW.
5079 INT WINAPI
SHFormatDateTimeA(const FILETIME UNALIGNED
*fileTime
, DWORD
*flags
,
5080 LPSTR buf
, UINT size
)
5088 bufW
= HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR
) * size
);
5089 retval
= SHFormatDateTimeW(fileTime
, flags
, bufW
, size
);
5092 WideCharToMultiByte(CP_ACP
, 0, bufW
, -1, buf
, size
, NULL
, NULL
);
5094 HeapFree(GetProcessHeap(), 0, bufW
);
5098 /***********************************************************************
5099 * ZoneCheckUrlExW [SHLWAPI.231]
5101 * Checks the details of the security zone for the supplied site. (?)
5105 * szURL [I] Pointer to the URL to check
5107 * Other parameters currently unknown.
5113 INT WINAPI
ZoneCheckUrlExW(LPWSTR szURL
, PVOID pUnknown
, DWORD dwUnknown2
,
5114 DWORD dwUnknown3
, DWORD dwUnknown4
, DWORD dwUnknown5
, DWORD dwUnknown6
,
5117 FIXME("(%s,%p,%x,%x,%x,%x,%x,%x) STUB\n", debugstr_w(szURL
), pUnknown
, dwUnknown2
,
5118 dwUnknown3
, dwUnknown4
, dwUnknown5
, dwUnknown6
, dwUnknown7
);
5123 /***********************************************************************
5124 * SHVerbExistsNA [SHLWAPI.196]
5129 * verb [I] a string, often appears to be an extension.
5131 * Other parameters currently unknown.
5136 INT WINAPI
SHVerbExistsNA(LPSTR verb
, PVOID pUnknown
, PVOID pUnknown2
, DWORD dwUnknown3
)
5138 FIXME("(%s, %p, %p, %i) STUB\n",verb
, pUnknown
, pUnknown2
, dwUnknown3
);
5142 /*************************************************************************
5145 * Undocumented: Implementation guessed at via Name and behavior
5148 * lpUnknown [I] Object to get an IServiceProvider interface from
5149 * riid [I] Function requested for QueryService call
5150 * lppOut [O] Destination for the service interface pointer
5153 * Success: S_OK. lppOut contains an object providing the requested service
5154 * Failure: An HRESULT error code
5157 * lpUnknown is expected to support the IServiceProvider interface.
5159 HRESULT WINAPI
IUnknown_QueryServiceForWebBrowserApp(IUnknown
* lpUnknown
,
5160 REFGUID riid
, LPVOID
*lppOut
)
5162 FIXME("%p %s %p semi-STUB\n", lpUnknown
, debugstr_guid(riid
), lppOut
);
5163 return IUnknown_QueryService(lpUnknown
,&IID_IWebBrowserApp
,riid
,lppOut
);
5166 /**************************************************************************
5167 * SHPropertyBag_ReadLONG (SHLWAPI.496)
5169 * This function asks a property bag to read a named property as a LONG.
5172 * ppb: a IPropertyBag interface
5173 * pszPropName: Unicode string that names the property
5174 * pValue: address to receive the property value as a 32-bit signed integer
5179 HRESULT WINAPI
SHPropertyBag_ReadLONG(IPropertyBag
*ppb
, LPCWSTR pszPropName
, LPLONG pValue
)
5183 TRACE("%p %s %p\n", ppb
,debugstr_w(pszPropName
),pValue
);
5184 if (!pszPropName
|| !ppb
|| !pValue
)
5185 return E_INVALIDARG
;
5187 hr
= IPropertyBag_Read(ppb
, pszPropName
, &var
, NULL
);
5190 if (V_VT(&var
) == VT_I4
)
5191 *pValue
= V_I4(&var
);
5193 hr
= DISP_E_BADVARTYPE
;
5199 /**************************************************************************
5200 * SHPropertyBag_WriteLONG (SHLWAPI.497)
5202 * This function asks a property bag to write a named property as a LONG.
5205 * ppb: a IPropertyBag interface
5206 * pszPropName: Unicode string that names the property
5207 * lValue: address to receive the property value as a 32-bit signed integer
5212 HRESULT WINAPI
SHPropertyBag_WriteLONG(IPropertyBag
*ppb
, LPCWSTR pszPropName
, LONG lValue
)
5218 /**************************************************************************
5219 * SHPropertyBag_WriteStr (SHLWAPI.495)
5221 * This function asks a property bag to write a string as the value of a named property.
5224 * ppb: a IPropertyBag interface
5225 * pszPropName: Unicode string that names the property
5226 * pValue: address to write the property value
5231 HRESULT WINAPI
SHPropertyBag_WriteStr(IPropertyBag
*ppb
, LPCWSTR pszPropName
, LPCWSTR pszValue
)
5238 /* return flags for SHGetObjectCompatFlags, names derived from registry value names */
5239 #define OBJCOMPAT_OTNEEDSSFCACHE 0x00000001
5240 #define OBJCOMPAT_NO_WEBVIEW 0x00000002
5241 #define OBJCOMPAT_UNBINDABLE 0x00000004
5242 #define OBJCOMPAT_PINDLL 0x00000008
5243 #define OBJCOMPAT_NEEDSFILESYSANCESTOR 0x00000010
5244 #define OBJCOMPAT_NOTAFILESYSTEM 0x00000020
5245 #define OBJCOMPAT_CTXMENU_NOVERBS 0x00000040
5246 #define OBJCOMPAT_CTXMENU_LIMITEDQI 0x00000080
5247 #define OBJCOMPAT_COCREATESHELLFOLDERONLY 0x00000100
5248 #define OBJCOMPAT_NEEDSSTORAGEANCESTOR 0x00000200
5249 #define OBJCOMPAT_NOLEGACYWEBVIEW 0x00000400
5250 #define OBJCOMPAT_CTXMENU_XPQCMFLAGS 0x00001000
5251 #define OBJCOMPAT_NOIPROPERTYSTORE 0x00002000
5253 /* a search table for compatibility flags */
5254 struct objcompat_entry
{
5255 const WCHAR name
[30];
5259 /* expected to be sorted by name */
5260 static const struct objcompat_entry objcompat_table
[] = {
5261 { {'C','O','C','R','E','A','T','E','S','H','E','L','L','F','O','L','D','E','R','O','N','L','Y',0},
5262 OBJCOMPAT_COCREATESHELLFOLDERONLY
},
5263 { {'C','T','X','M','E','N','U','_','L','I','M','I','T','E','D','Q','I',0},
5264 OBJCOMPAT_CTXMENU_LIMITEDQI
},
5265 { {'C','T','X','M','E','N','U','_','N','O','V','E','R','B','S',0},
5266 OBJCOMPAT_CTXMENU_LIMITEDQI
},
5267 { {'C','T','X','M','E','N','U','_','X','P','Q','C','M','F','L','A','G','S',0},
5268 OBJCOMPAT_CTXMENU_XPQCMFLAGS
},
5269 { {'N','E','E','D','S','F','I','L','E','S','Y','S','A','N','C','E','S','T','O','R',0},
5270 OBJCOMPAT_NEEDSFILESYSANCESTOR
},
5271 { {'N','E','E','D','S','S','T','O','R','A','G','E','A','N','C','E','S','T','O','R',0},
5272 OBJCOMPAT_NEEDSSTORAGEANCESTOR
},
5273 { {'N','O','I','P','R','O','P','E','R','T','Y','S','T','O','R','E',0},
5274 OBJCOMPAT_NOIPROPERTYSTORE
},
5275 { {'N','O','L','E','G','A','C','Y','W','E','B','V','I','E','W',0},
5276 OBJCOMPAT_NOLEGACYWEBVIEW
},
5277 { {'N','O','T','A','F','I','L','E','S','Y','S','T','E','M',0},
5278 OBJCOMPAT_NOTAFILESYSTEM
},
5279 { {'N','O','_','W','E','B','V','I','E','W',0},
5280 OBJCOMPAT_NO_WEBVIEW
},
5281 { {'O','T','N','E','E','D','S','S','F','C','A','C','H','E',0},
5282 OBJCOMPAT_OTNEEDSSFCACHE
},
5283 { {'P','I','N','D','L','L',0},
5285 { {'U','N','B','I','N','D','A','B','L','E',0},
5286 OBJCOMPAT_UNBINDABLE
}
5289 /**************************************************************************
5290 * SHGetObjectCompatFlags (SHLWAPI.476)
5292 * Function returns an integer representation of compatibility flags stored
5293 * in registry for CLSID under ShellCompatibility subkey.
5296 * pUnk: pointer to object IUnknown interface, idetifies CLSID
5297 * clsid: pointer to CLSID to retrieve data for
5300 * 0 on failure, flags set on success
5302 DWORD WINAPI
SHGetObjectCompatFlags(IUnknown
*pUnk
, const CLSID
*clsid
)
5304 static const WCHAR compatpathW
[] =
5305 {'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\',
5306 'W','i','n','d','o','w','s','\\','C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
5307 'S','h','e','l','l','C','o','m','p','a','t','i','b','i','l','i','t','y','\\',
5308 'O','b','j','e','c','t','s','\\','%','s',0};
5309 WCHAR strW
[sizeof(compatpathW
)/sizeof(WCHAR
) + 38 /* { CLSID } */];
5310 DWORD ret
, length
= sizeof(strW
)/sizeof(WCHAR
);
5315 TRACE("%p %s\n", pUnk
, debugstr_guid(clsid
));
5317 if (!pUnk
&& !clsid
) return 0;
5321 FIXME("iface not handled\n");
5325 StringFromCLSID(clsid
, &clsid_str
);
5326 sprintfW(strW
, compatpathW
, clsid_str
);
5327 CoTaskMemFree(clsid_str
);
5329 ret
= RegOpenKeyW(HKEY_LOCAL_MACHINE
, strW
, &key
);
5330 if (ret
!= ERROR_SUCCESS
) return 0;
5332 /* now collect flag values */
5334 for (i
= 0; RegEnumValueW(key
, i
, strW
, &length
, NULL
, NULL
, NULL
, NULL
) == ERROR_SUCCESS
; i
++)
5336 INT left
, right
, res
, x
;
5338 /* search in table */
5340 right
= sizeof(objcompat_table
) / sizeof(struct objcompat_entry
) - 1;
5342 while (right
>= left
) {
5343 x
= (left
+ right
) / 2;
5344 res
= strcmpW(strW
, objcompat_table
[x
].name
);
5347 ret
|= objcompat_table
[x
].value
;
5356 length
= sizeof(strW
)/sizeof(WCHAR
);