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
);
242 /* Get a copy of the handle for our process, closing the source handle */
243 hClose
= SHMapHandle(hShared
, dwProcId
, GetCurrentProcessId(),
244 FILE_MAP_ALL_ACCESS
,DUPLICATE_CLOSE_SOURCE
);
245 /* Close local copy */
246 return CloseHandle(hClose
);
249 /*************************************************************************
252 * Create and register a clipboard enumerator for a web browser.
255 * lpBC [I] Binding context
256 * lpUnknown [I] An object exposing the IWebBrowserApp interface
260 * Failure: An HRESULT error code.
263 * The enumerator is stored as a property of the web browser. If it does not
264 * yet exist, it is created and set before being registered.
266 HRESULT WINAPI
RegisterDefaultAcceptHeaders(LPBC lpBC
, IUnknown
*lpUnknown
)
268 static const WCHAR szProperty
[] = { '{','D','0','F','C','A','4','2','0',
269 '-','D','3','F','5','-','1','1','C','F', '-','B','2','1','1','-','0',
270 '0','A','A','0','0','4','A','E','8','3','7','}','\0' };
272 IEnumFORMATETC
* pIEnumFormatEtc
= NULL
;
275 IWebBrowserApp
* pBrowser
;
277 TRACE("(%p, %p)\n", lpBC
, lpUnknown
);
279 hr
= IUnknown_QueryService(lpUnknown
, &IID_IWebBrowserApp
, &IID_IWebBrowserApp
, (void**)&pBrowser
);
283 V_VT(&var
) = VT_EMPTY
;
285 /* The property we get is the browsers clipboard enumerator */
286 property
= SysAllocString(szProperty
);
287 hr
= IWebBrowserApp_GetProperty(pBrowser
, property
, &var
);
288 SysFreeString(property
);
289 if (FAILED(hr
)) goto exit
;
291 if (V_VT(&var
) == VT_EMPTY
)
293 /* Iterate through accepted documents and RegisterClipBoardFormatA() them */
294 char szKeyBuff
[128], szValueBuff
[128];
295 DWORD dwKeySize
, dwValueSize
, dwRet
= 0, dwCount
= 0, dwNumValues
, dwType
;
296 FORMATETC
* formatList
, *format
;
299 TRACE("Registering formats and creating IEnumFORMATETC instance\n");
301 if (!RegOpenKeyA(HKEY_LOCAL_MACHINE
, "Software\\Microsoft\\Windows\\Current"
302 "Version\\Internet Settings\\Accepted Documents", &hDocs
))
308 /* Get count of values in key */
311 dwKeySize
= sizeof(szKeyBuff
);
312 dwRet
= RegEnumValueA(hDocs
,dwCount
,szKeyBuff
,&dwKeySize
,0,&dwType
,0,0);
316 dwNumValues
= dwCount
;
318 /* Note: dwCount = number of items + 1; The extra item is the end node */
319 format
= formatList
= HeapAlloc(GetProcessHeap(), 0, dwCount
* sizeof(FORMATETC
));
334 /* Register clipboard formats for the values and populate format list */
335 while(!dwRet
&& dwCount
< dwNumValues
)
337 dwKeySize
= sizeof(szKeyBuff
);
338 dwValueSize
= sizeof(szValueBuff
);
339 dwRet
= RegEnumValueA(hDocs
, dwCount
, szKeyBuff
, &dwKeySize
, 0, &dwType
,
340 (PBYTE
)szValueBuff
, &dwValueSize
);
343 HeapFree(GetProcessHeap(), 0, formatList
);
349 format
->cfFormat
= RegisterClipboardFormatA(szValueBuff
);
351 format
->dwAspect
= 1;
362 /* Terminate the (maybe empty) list, last entry has a cfFormat of 0 */
363 format
->cfFormat
= 0;
365 format
->dwAspect
= 1;
369 /* Create a clipboard enumerator */
370 hr
= CreateFormatEnumerator(dwNumValues
, formatList
, &pIEnumFormatEtc
);
371 HeapFree(GetProcessHeap(), 0, formatList
);
372 if (FAILED(hr
)) goto exit
;
374 /* Set our enumerator as the browsers property */
375 V_VT(&var
) = VT_UNKNOWN
;
376 V_UNKNOWN(&var
) = (IUnknown
*)pIEnumFormatEtc
;
378 property
= SysAllocString(szProperty
);
379 hr
= IWebBrowserApp_PutProperty(pBrowser
, property
, var
);
380 SysFreeString(property
);
383 IEnumFORMATETC_Release(pIEnumFormatEtc
);
388 if (V_VT(&var
) == VT_UNKNOWN
)
390 /* Our variant is holding the clipboard enumerator */
391 IUnknown
* pIUnknown
= V_UNKNOWN(&var
);
392 IEnumFORMATETC
* pClone
= NULL
;
394 TRACE("Retrieved IEnumFORMATETC property\n");
396 /* Get an IEnumFormatEtc interface from the variants value */
397 pIEnumFormatEtc
= NULL
;
398 hr
= IUnknown_QueryInterface(pIUnknown
, &IID_IEnumFORMATETC
, (void**)&pIEnumFormatEtc
);
399 if (hr
== S_OK
&& pIEnumFormatEtc
)
401 /* Clone and register the enumerator */
402 hr
= IEnumFORMATETC_Clone(pIEnumFormatEtc
, &pClone
);
403 if (hr
== S_OK
&& pClone
)
405 RegisterFormatEnumerator(lpBC
, pClone
, 0);
407 IEnumFORMATETC_Release(pClone
);
410 IUnknown_Release(pIUnknown
);
412 IUnknown_Release(V_UNKNOWN(&var
));
416 IWebBrowserApp_Release(pBrowser
);
420 /*************************************************************************
423 * Get Explorers "AcceptLanguage" setting.
426 * langbuf [O] Destination for language string
427 * buflen [I] Length of langbuf in characters
428 * [0] Success: used length of langbuf
431 * Success: S_OK. langbuf is set to the language string found.
432 * Failure: E_FAIL, If any arguments are invalid, error occurred, or Explorer
433 * does not contain the setting.
434 * HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER), If the buffer is not big enough
436 HRESULT WINAPI
GetAcceptLanguagesW( LPWSTR langbuf
, LPDWORD buflen
)
438 static const WCHAR szkeyW
[] = {
439 'S','o','f','t','w','a','r','e','\\',
440 'M','i','c','r','o','s','o','f','t','\\',
441 'I','n','t','e','r','n','e','t',' ','E','x','p','l','o','r','e','r','\\',
442 'I','n','t','e','r','n','a','t','i','o','n','a','l',0};
443 static const WCHAR valueW
[] = {
444 'A','c','c','e','p','t','L','a','n','g','u','a','g','e',0};
445 DWORD mystrlen
, mytype
;
452 TRACE("(%p, %p) *%p: %d\n", langbuf
, buflen
, buflen
, buflen
? *buflen
: -1);
454 if(!langbuf
|| !buflen
|| !*buflen
)
457 mystrlen
= (*buflen
> 20) ? *buflen
: 20 ;
458 len
= mystrlen
* sizeof(WCHAR
);
459 mystr
= HeapAlloc(GetProcessHeap(), 0, len
);
461 RegOpenKeyW(HKEY_CURRENT_USER
, szkeyW
, &mykey
);
462 lres
= RegQueryValueExW(mykey
, valueW
, 0, &mytype
, (PBYTE
)mystr
, &len
);
464 len
= lstrlenW(mystr
);
466 if (!lres
&& (*buflen
> len
)) {
467 lstrcpyW(langbuf
, mystr
);
469 HeapFree(GetProcessHeap(), 0, mystr
);
473 /* Did not find a value in the registry or the user buffer is too small */
474 mylcid
= GetUserDefaultLCID();
475 LcidToRfc1766W(mylcid
, mystr
, mystrlen
);
476 len
= lstrlenW(mystr
);
478 memcpy( langbuf
, mystr
, min(*buflen
, len
+1)*sizeof(WCHAR
) );
479 HeapFree(GetProcessHeap(), 0, mystr
);
487 return __HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER
);
490 /*************************************************************************
493 * Ascii version of GetAcceptLanguagesW.
495 HRESULT WINAPI
GetAcceptLanguagesA( LPSTR langbuf
, LPDWORD buflen
)
498 DWORD buflenW
, convlen
;
501 TRACE("(%p, %p) *%p: %d\n", langbuf
, buflen
, buflen
, buflen
? *buflen
: -1);
503 if(!langbuf
|| !buflen
|| !*buflen
) return E_FAIL
;
506 langbufW
= HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR
) * buflenW
);
507 retval
= GetAcceptLanguagesW(langbufW
, &buflenW
);
511 convlen
= WideCharToMultiByte(CP_ACP
, 0, langbufW
, -1, langbuf
, *buflen
, NULL
, NULL
);
512 convlen
--; /* do not count the terminating 0 */
514 else /* copy partial string anyway */
516 convlen
= WideCharToMultiByte(CP_ACP
, 0, langbufW
, *buflen
, langbuf
, *buflen
, NULL
, NULL
);
517 if (convlen
< *buflen
)
519 langbuf
[convlen
] = 0;
520 convlen
--; /* do not count the terminating 0 */
527 *buflen
= buflenW
? convlen
: 0;
529 HeapFree(GetProcessHeap(), 0, langbufW
);
533 /*************************************************************************
536 * Convert a GUID to a string.
539 * guid [I] GUID to convert
540 * lpszDest [O] Destination for string
541 * cchMax [I] Length of output buffer
544 * The length of the string created.
546 INT WINAPI
SHStringFromGUIDA(REFGUID guid
, LPSTR lpszDest
, INT cchMax
)
551 TRACE("(%s,%p,%d)\n", debugstr_guid(guid
), lpszDest
, cchMax
);
553 sprintf(xguid
, "{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
554 guid
->Data1
, guid
->Data2
, guid
->Data3
,
555 guid
->Data4
[0], guid
->Data4
[1], guid
->Data4
[2], guid
->Data4
[3],
556 guid
->Data4
[4], guid
->Data4
[5], guid
->Data4
[6], guid
->Data4
[7]);
558 iLen
= strlen(xguid
) + 1;
562 memcpy(lpszDest
, xguid
, iLen
);
566 /*************************************************************************
569 * Convert a GUID to a string.
572 * guid [I] GUID to convert
573 * str [O] Destination for string
574 * cmax [I] Length of output buffer
577 * The length of the string created.
579 INT WINAPI
SHStringFromGUIDW(REFGUID guid
, LPWSTR lpszDest
, INT cchMax
)
583 static const WCHAR wszFormat
[] = {'{','%','0','8','l','X','-','%','0','4','X','-','%','0','4','X','-',
584 '%','0','2','X','%','0','2','X','-','%','0','2','X','%','0','2','X','%','0','2','X','%','0','2',
585 'X','%','0','2','X','%','0','2','X','}',0};
587 TRACE("(%s,%p,%d)\n", debugstr_guid(guid
), lpszDest
, cchMax
);
589 sprintfW(xguid
, wszFormat
, guid
->Data1
, guid
->Data2
, guid
->Data3
,
590 guid
->Data4
[0], guid
->Data4
[1], guid
->Data4
[2], guid
->Data4
[3],
591 guid
->Data4
[4], guid
->Data4
[5], guid
->Data4
[6], guid
->Data4
[7]);
593 iLen
= strlenW(xguid
) + 1;
597 memcpy(lpszDest
, xguid
, iLen
*sizeof(WCHAR
));
601 /*************************************************************************
604 * Determine if a Unicode character is a blank.
607 * wc [I] Character to check.
610 * TRUE, if wc is a blank,
614 BOOL WINAPI
IsCharBlankW(WCHAR wc
)
618 return GetStringTypeW(CT_CTYPE1
, &wc
, 1, &CharType
) && (CharType
& C1_BLANK
);
621 /*************************************************************************
624 * Determine if a Unicode character is punctuation.
627 * wc [I] Character to check.
630 * TRUE, if wc is punctuation,
633 BOOL WINAPI
IsCharPunctW(WCHAR wc
)
637 return GetStringTypeW(CT_CTYPE1
, &wc
, 1, &CharType
) && (CharType
& C1_PUNCT
);
640 /*************************************************************************
643 * Determine if a Unicode character is a control character.
646 * wc [I] Character to check.
649 * TRUE, if wc is a control character,
652 BOOL WINAPI
IsCharCntrlW(WCHAR wc
)
656 return GetStringTypeW(CT_CTYPE1
, &wc
, 1, &CharType
) && (CharType
& C1_CNTRL
);
659 /*************************************************************************
662 * Determine if a Unicode character is a digit.
665 * wc [I] Character to check.
668 * TRUE, if wc is a digit,
671 BOOL WINAPI
IsCharDigitW(WCHAR wc
)
675 return GetStringTypeW(CT_CTYPE1
, &wc
, 1, &CharType
) && (CharType
& C1_DIGIT
);
678 /*************************************************************************
681 * Determine if a Unicode character is a hex digit.
684 * wc [I] Character to check.
687 * TRUE, if wc is a hex digit,
690 BOOL WINAPI
IsCharXDigitW(WCHAR wc
)
694 return GetStringTypeW(CT_CTYPE1
, &wc
, 1, &CharType
) && (CharType
& C1_XDIGIT
);
697 /*************************************************************************
701 BOOL WINAPI
GetStringType3ExW(LPWSTR src
, INT count
, LPWORD type
)
703 return GetStringTypeW(CT_CTYPE3
, src
, count
, type
);
706 /*************************************************************************
709 * Compare two Ascii strings up to a given length.
712 * lpszSrc [I] Source string
713 * lpszCmp [I] String to compare to lpszSrc
714 * len [I] Maximum length
717 * A number greater than, less than or equal to 0 depending on whether
718 * lpszSrc is greater than, less than or equal to lpszCmp.
720 DWORD WINAPI
StrCmpNCA(LPCSTR lpszSrc
, LPCSTR lpszCmp
, INT len
)
722 return StrCmpNA(lpszSrc
, lpszCmp
, len
);
725 /*************************************************************************
728 * Unicode version of StrCmpNCA.
730 DWORD WINAPI
StrCmpNCW(LPCWSTR lpszSrc
, LPCWSTR lpszCmp
, INT len
)
732 return StrCmpNW(lpszSrc
, lpszCmp
, len
);
735 /*************************************************************************
738 * Compare two Ascii strings up to a given length, ignoring case.
741 * lpszSrc [I] Source string
742 * lpszCmp [I] String to compare to lpszSrc
743 * len [I] Maximum length
746 * A number greater than, less than or equal to 0 depending on whether
747 * lpszSrc is greater than, less than or equal to lpszCmp.
749 DWORD WINAPI
StrCmpNICA(LPCSTR lpszSrc
, LPCSTR lpszCmp
, DWORD len
)
751 return StrCmpNIA(lpszSrc
, lpszCmp
, len
);
754 /*************************************************************************
757 * Unicode version of StrCmpNICA.
759 DWORD WINAPI
StrCmpNICW(LPCWSTR lpszSrc
, LPCWSTR lpszCmp
, DWORD len
)
761 return StrCmpNIW(lpszSrc
, lpszCmp
, len
);
764 /*************************************************************************
767 * Compare two Ascii strings.
770 * lpszSrc [I] Source string
771 * lpszCmp [I] String to compare to lpszSrc
774 * A number greater than, less than or equal to 0 depending on whether
775 * lpszSrc is greater than, less than or equal to lpszCmp.
777 DWORD WINAPI
StrCmpCA(LPCSTR lpszSrc
, LPCSTR lpszCmp
)
779 return lstrcmpA(lpszSrc
, lpszCmp
);
782 /*************************************************************************
785 * Unicode version of StrCmpCA.
787 DWORD WINAPI
StrCmpCW(LPCWSTR lpszSrc
, LPCWSTR lpszCmp
)
789 return lstrcmpW(lpszSrc
, lpszCmp
);
792 /*************************************************************************
795 * Compare two Ascii strings, ignoring case.
798 * lpszSrc [I] Source string
799 * lpszCmp [I] String to compare to lpszSrc
802 * A number greater than, less than or equal to 0 depending on whether
803 * lpszSrc is greater than, less than or equal to lpszCmp.
805 DWORD WINAPI
StrCmpICA(LPCSTR lpszSrc
, LPCSTR lpszCmp
)
807 return lstrcmpiA(lpszSrc
, lpszCmp
);
810 /*************************************************************************
813 * Unicode version of StrCmpICA.
815 DWORD WINAPI
StrCmpICW(LPCWSTR lpszSrc
, LPCWSTR lpszCmp
)
817 return lstrcmpiW(lpszSrc
, lpszCmp
);
820 /*************************************************************************
823 * Get an identification string for the OS and explorer.
826 * lpszDest [O] Destination for Id string
827 * dwDestLen [I] Length of lpszDest
830 * TRUE, If the string was created successfully
833 BOOL WINAPI
SHAboutInfoA(LPSTR lpszDest
, DWORD dwDestLen
)
837 TRACE("(%p,%d)\n", lpszDest
, dwDestLen
);
839 if (lpszDest
&& SHAboutInfoW(buff
, dwDestLen
))
841 WideCharToMultiByte(CP_ACP
, 0, buff
, -1, lpszDest
, dwDestLen
, NULL
, NULL
);
847 /*************************************************************************
850 * Unicode version of SHAboutInfoA.
852 BOOL WINAPI
SHAboutInfoW(LPWSTR lpszDest
, DWORD dwDestLen
)
854 static const WCHAR szIEKey
[] = { 'S','O','F','T','W','A','R','E','\\',
855 'M','i','c','r','o','s','o','f','t','\\','I','n','t','e','r','n','e','t',
856 ' ','E','x','p','l','o','r','e','r','\0' };
857 static const WCHAR szWinNtKey
[] = { 'S','O','F','T','W','A','R','E','\\',
858 'M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s',' ',
859 'N','T','\\','C','u','r','r','e','n','t','V','e','r','s','i','o','n','\0' };
860 static const WCHAR szWinKey
[] = { '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 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\0' };
863 static const WCHAR szRegKey
[] = { 'S','O','F','T','W','A','R','E','\\',
864 'M','i','c','r','o','s','o','f','t','\\','I','n','t','e','r','n','e','t',
865 ' ','E','x','p','l','o','r','e','r','\\',
866 'R','e','g','i','s','t','r','a','t','i','o','n','\0' };
867 static const WCHAR szVersion
[] = { 'V','e','r','s','i','o','n','\0' };
868 static const WCHAR szCustomized
[] = { 'C','u','s','t','o','m','i','z','e','d',
869 'V','e','r','s','i','o','n','\0' };
870 static const WCHAR szOwner
[] = { 'R','e','g','i','s','t','e','r','e','d',
871 'O','w','n','e','r','\0' };
872 static const WCHAR szOrg
[] = { 'R','e','g','i','s','t','e','r','e','d',
873 'O','r','g','a','n','i','z','a','t','i','o','n','\0' };
874 static const WCHAR szProduct
[] = { 'P','r','o','d','u','c','t','I','d','\0' };
875 static const WCHAR szUpdate
[] = { 'I','E','A','K',
876 'U','p','d','a','t','e','U','r','l','\0' };
877 static const WCHAR szHelp
[] = { 'I','E','A','K',
878 'H','e','l','p','S','t','r','i','n','g','\0' };
883 TRACE("(%p,%d)\n", lpszDest
, dwDestLen
);
890 /* Try the NT key first, followed by 95/98 key */
891 if (RegOpenKeyExW(HKEY_LOCAL_MACHINE
, szWinNtKey
, 0, KEY_READ
, &hReg
) &&
892 RegOpenKeyExW(HKEY_LOCAL_MACHINE
, szWinKey
, 0, KEY_READ
, &hReg
))
898 if (!SHGetValueW(HKEY_LOCAL_MACHINE
, szIEKey
, szVersion
, &dwType
, buff
, &dwLen
))
900 DWORD dwStrLen
= strlenW(buff
);
901 dwLen
= 30 - dwStrLen
;
902 SHGetValueW(HKEY_LOCAL_MACHINE
, szIEKey
,
903 szCustomized
, &dwType
, buff
+dwStrLen
, &dwLen
);
905 StrCatBuffW(lpszDest
, buff
, dwDestLen
);
907 /* ~Registered Owner */
910 if (SHGetValueW(hReg
, szOwner
, 0, &dwType
, buff
+1, &dwLen
))
912 StrCatBuffW(lpszDest
, buff
, dwDestLen
);
914 /* ~Registered Organization */
916 if (SHGetValueW(hReg
, szOrg
, 0, &dwType
, buff
+1, &dwLen
))
918 StrCatBuffW(lpszDest
, buff
, dwDestLen
);
920 /* FIXME: Not sure where this number comes from */
924 StrCatBuffW(lpszDest
, buff
, dwDestLen
);
928 if (SHGetValueW(HKEY_LOCAL_MACHINE
, szRegKey
, szProduct
, &dwType
, buff
+1, &dwLen
))
930 StrCatBuffW(lpszDest
, buff
, dwDestLen
);
934 if(SHGetValueW(HKEY_LOCAL_MACHINE
, szWinKey
, szUpdate
, &dwType
, buff
+1, &dwLen
))
936 StrCatBuffW(lpszDest
, buff
, dwDestLen
);
938 /* ~IE Help String */
940 if(SHGetValueW(hReg
, szHelp
, 0, &dwType
, buff
+1, &dwLen
))
942 StrCatBuffW(lpszDest
, buff
, dwDestLen
);
948 /*************************************************************************
951 * Call IOleCommandTarget_QueryStatus() on an object.
954 * lpUnknown [I] Object supporting the IOleCommandTarget interface
955 * pguidCmdGroup [I] GUID for the command group
957 * prgCmds [O] Commands
958 * pCmdText [O] Command text
962 * Failure: E_FAIL, if lpUnknown is NULL.
963 * E_NOINTERFACE, if lpUnknown does not support IOleCommandTarget.
964 * Otherwise, an error code from IOleCommandTarget_QueryStatus().
966 HRESULT WINAPI
IUnknown_QueryStatus(IUnknown
* lpUnknown
, REFGUID pguidCmdGroup
,
967 ULONG cCmds
, OLECMD
*prgCmds
, OLECMDTEXT
* pCmdText
)
969 HRESULT hRet
= E_FAIL
;
971 TRACE("(%p,%p,%d,%p,%p)\n",lpUnknown
, pguidCmdGroup
, cCmds
, prgCmds
, pCmdText
);
975 IOleCommandTarget
* lpOle
;
977 hRet
= IUnknown_QueryInterface(lpUnknown
, &IID_IOleCommandTarget
,
980 if (SUCCEEDED(hRet
) && lpOle
)
982 hRet
= IOleCommandTarget_QueryStatus(lpOle
, pguidCmdGroup
, cCmds
,
984 IOleCommandTarget_Release(lpOle
);
990 /*************************************************************************
993 * Call IOleCommandTarget_Exec() on an object.
996 * lpUnknown [I] Object supporting the IOleCommandTarget interface
997 * pguidCmdGroup [I] GUID for the command group
1001 * Failure: E_FAIL, if lpUnknown is NULL.
1002 * E_NOINTERFACE, if lpUnknown does not support IOleCommandTarget.
1003 * Otherwise, an error code from IOleCommandTarget_Exec().
1005 HRESULT WINAPI
IUnknown_Exec(IUnknown
* lpUnknown
, REFGUID pguidCmdGroup
,
1006 DWORD nCmdID
, DWORD nCmdexecopt
, VARIANT
* pvaIn
,
1009 HRESULT hRet
= E_FAIL
;
1011 TRACE("(%p,%p,%d,%d,%p,%p)\n",lpUnknown
, pguidCmdGroup
, nCmdID
,
1012 nCmdexecopt
, pvaIn
, pvaOut
);
1016 IOleCommandTarget
* lpOle
;
1018 hRet
= IUnknown_QueryInterface(lpUnknown
, &IID_IOleCommandTarget
,
1020 if (SUCCEEDED(hRet
) && lpOle
)
1022 hRet
= IOleCommandTarget_Exec(lpOle
, pguidCmdGroup
, nCmdID
,
1023 nCmdexecopt
, pvaIn
, pvaOut
);
1024 IOleCommandTarget_Release(lpOle
);
1030 /*************************************************************************
1033 * Retrieve, modify, and re-set a value from a window.
1036 * hWnd [I] Window to get value from
1037 * offset [I] Offset of value
1038 * mask [I] Mask for flags
1039 * flags [I] Bits to set in window value
1042 * The new value as it was set, or 0 if any parameter is invalid.
1045 * Only bits specified in mask are affected - set if present in flags and
1048 LONG WINAPI
SHSetWindowBits(HWND hwnd
, INT offset
, UINT mask
, UINT flags
)
1050 LONG ret
= GetWindowLongW(hwnd
, offset
);
1051 LONG new_flags
= (flags
& mask
) | (ret
& ~mask
);
1053 TRACE("%p %d %x %x\n", hwnd
, offset
, mask
, flags
);
1055 if (new_flags
!= ret
)
1056 ret
= SetWindowLongW(hwnd
, offset
, new_flags
);
1060 /*************************************************************************
1063 * Change a window's parent.
1066 * hWnd [I] Window to change parent of
1067 * hWndParent [I] New parent window
1070 * The old parent of hWnd.
1073 * If hWndParent is NULL (desktop), the window style is changed to WS_POPUP.
1074 * If hWndParent is NOT NULL then we set the WS_CHILD style.
1076 HWND WINAPI
SHSetParentHwnd(HWND hWnd
, HWND hWndParent
)
1078 TRACE("%p, %p\n", hWnd
, hWndParent
);
1080 if(GetParent(hWnd
) == hWndParent
)
1084 SHSetWindowBits(hWnd
, GWL_STYLE
, WS_CHILD
| WS_POPUP
, WS_CHILD
);
1086 SHSetWindowBits(hWnd
, GWL_STYLE
, WS_CHILD
| WS_POPUP
, WS_POPUP
);
1088 return hWndParent
? SetParent(hWnd
, hWndParent
) : NULL
;
1091 /*************************************************************************
1094 * Locate and advise a connection point in an IConnectionPointContainer object.
1097 * lpUnkSink [I] Sink for the connection point advise call
1098 * riid [I] REFIID of connection point to advise
1099 * fConnect [I] TRUE = Connection being establisted, FALSE = broken
1100 * lpUnknown [I] Object supporting the IConnectionPointContainer interface
1101 * lpCookie [O] Pointer to connection point cookie
1102 * lppCP [O] Destination for the IConnectionPoint found
1105 * Success: S_OK. If lppCP is non-NULL, it is filled with the IConnectionPoint
1106 * that was advised. The caller is responsible for releasing it.
1107 * Failure: E_FAIL, if any arguments are invalid.
1108 * E_NOINTERFACE, if lpUnknown isn't an IConnectionPointContainer,
1109 * Or an HRESULT error code if any call fails.
1111 HRESULT WINAPI
ConnectToConnectionPoint(IUnknown
* lpUnkSink
, REFIID riid
, BOOL fConnect
,
1112 IUnknown
* lpUnknown
, LPDWORD lpCookie
,
1113 IConnectionPoint
**lppCP
)
1116 IConnectionPointContainer
* lpContainer
;
1117 IConnectionPoint
*lpCP
;
1119 if(!lpUnknown
|| (fConnect
&& !lpUnkSink
))
1125 hRet
= IUnknown_QueryInterface(lpUnknown
, &IID_IConnectionPointContainer
,
1126 (void**)&lpContainer
);
1127 if (SUCCEEDED(hRet
))
1129 hRet
= IConnectionPointContainer_FindConnectionPoint(lpContainer
, riid
, &lpCP
);
1131 if (SUCCEEDED(hRet
))
1134 hRet
= IConnectionPoint_Unadvise(lpCP
, *lpCookie
);
1136 hRet
= IConnectionPoint_Advise(lpCP
, lpUnkSink
, lpCookie
);
1141 if (lppCP
&& SUCCEEDED(hRet
))
1142 *lppCP
= lpCP
; /* Caller keeps the interface */
1144 IConnectionPoint_Release(lpCP
); /* Release it */
1147 IConnectionPointContainer_Release(lpContainer
);
1152 /*************************************************************************
1155 * Release an interface and zero a supplied pointer.
1158 * lpUnknown [I] Object to release
1163 void WINAPI
IUnknown_AtomicRelease(IUnknown
** lpUnknown
)
1165 TRACE("(%p)\n", lpUnknown
);
1167 if(!lpUnknown
|| !*lpUnknown
) return;
1169 TRACE("doing Release\n");
1171 IUnknown_Release(*lpUnknown
);
1175 /*************************************************************************
1178 * Skip '//' if present in a string.
1181 * lpszSrc [I] String to check for '//'
1184 * Success: The next character after the '//' or the string if not present
1185 * Failure: NULL, if lpszStr is NULL.
1187 LPCSTR WINAPI
PathSkipLeadingSlashesA(LPCSTR lpszSrc
)
1189 if (lpszSrc
&& lpszSrc
[0] == '/' && lpszSrc
[1] == '/')
1194 /*************************************************************************
1197 * Check if two interfaces come from the same object.
1200 * lpInt1 [I] Interface to check against lpInt2.
1201 * lpInt2 [I] Interface to check against lpInt1.
1204 * TRUE, If the interfaces come from the same object.
1207 BOOL WINAPI
SHIsSameObject(IUnknown
* lpInt1
, IUnknown
* lpInt2
)
1209 IUnknown
*lpUnknown1
, *lpUnknown2
;
1212 TRACE("(%p %p)\n", lpInt1
, lpInt2
);
1214 if (!lpInt1
|| !lpInt2
)
1217 if (lpInt1
== lpInt2
)
1220 if (IUnknown_QueryInterface(lpInt1
, &IID_IUnknown
, (void**)&lpUnknown1
) != S_OK
)
1223 if (IUnknown_QueryInterface(lpInt2
, &IID_IUnknown
, (void**)&lpUnknown2
) != S_OK
)
1225 IUnknown_Release(lpUnknown1
);
1229 ret
= lpUnknown1
== lpUnknown2
;
1231 IUnknown_Release(lpUnknown1
);
1232 IUnknown_Release(lpUnknown2
);
1237 /*************************************************************************
1240 * Get the window handle of an object.
1243 * lpUnknown [I] Object to get the window handle of
1244 * lphWnd [O] Destination for window handle
1247 * Success: S_OK. lphWnd contains the objects window handle.
1248 * Failure: An HRESULT error code.
1251 * lpUnknown is expected to support one of the following interfaces:
1252 * IOleWindow(), IInternetSecurityMgrSite(), or IShellView().
1254 HRESULT WINAPI
IUnknown_GetWindow(IUnknown
*lpUnknown
, HWND
*lphWnd
)
1257 HRESULT hRet
= E_FAIL
;
1259 TRACE("(%p,%p)\n", lpUnknown
, lphWnd
);
1264 hRet
= IUnknown_QueryInterface(lpUnknown
, &IID_IOleWindow
, (void**)&lpOle
);
1268 hRet
= IUnknown_QueryInterface(lpUnknown
,&IID_IShellView
, (void**)&lpOle
);
1272 hRet
= IUnknown_QueryInterface(lpUnknown
, &IID_IInternetSecurityMgrSite
,
1277 if (SUCCEEDED(hRet
))
1279 /* Laziness here - Since GetWindow() is the first method for the above 3
1280 * interfaces, we use the same call for them all.
1282 hRet
= IOleWindow_GetWindow((IOleWindow
*)lpOle
, lphWnd
);
1283 IUnknown_Release(lpOle
);
1285 TRACE("Returning HWND=%p\n", *lphWnd
);
1291 /*************************************************************************
1294 * Call a SetOwner method of IShellService from specified object.
1297 * iface [I] Object that supports IShellService
1298 * pUnk [I] Argument for the SetOwner call
1301 * Corresponding return value from last call or E_FAIL for null input
1303 HRESULT WINAPI
IUnknown_SetOwner(IUnknown
*iface
, IUnknown
*pUnk
)
1305 IShellService
*service
;
1308 TRACE("(%p, %p)\n", iface
, pUnk
);
1310 if (!iface
) return E_FAIL
;
1312 hr
= IUnknown_QueryInterface(iface
, &IID_IShellService
, (void**)&service
);
1315 hr
= IShellService_SetOwner(service
, pUnk
);
1316 IShellService_Release(service
);
1322 /*************************************************************************
1325 * Call either IObjectWithSite_SetSite() or IInternetSecurityManager_SetSecuritySite() on
1329 HRESULT WINAPI
IUnknown_SetSite(
1330 IUnknown
*obj
, /* [in] OLE object */
1331 IUnknown
*site
) /* [in] Site interface */
1334 IObjectWithSite
*iobjwithsite
;
1335 IInternetSecurityManager
*isecmgr
;
1337 if (!obj
) return E_FAIL
;
1339 hr
= IUnknown_QueryInterface(obj
, &IID_IObjectWithSite
, (LPVOID
*)&iobjwithsite
);
1340 TRACE("IID_IObjectWithSite QI ret=%08x, %p\n", hr
, iobjwithsite
);
1343 hr
= IObjectWithSite_SetSite(iobjwithsite
, site
);
1344 TRACE("done IObjectWithSite_SetSite ret=%08x\n", hr
);
1345 IObjectWithSite_Release(iobjwithsite
);
1349 hr
= IUnknown_QueryInterface(obj
, &IID_IInternetSecurityManager
, (LPVOID
*)&isecmgr
);
1350 TRACE("IID_IInternetSecurityManager QI ret=%08x, %p\n", hr
, isecmgr
);
1351 if (FAILED(hr
)) return hr
;
1353 hr
= IInternetSecurityManager_SetSecuritySite(isecmgr
, (IInternetSecurityMgrSite
*)site
);
1354 TRACE("done IInternetSecurityManager_SetSecuritySite ret=%08x\n", hr
);
1355 IInternetSecurityManager_Release(isecmgr
);
1360 /*************************************************************************
1363 * Call IPersist_GetClassID() on an object.
1366 * lpUnknown [I] Object supporting the IPersist interface
1367 * lpClassId [O] Destination for Class Id
1370 * Success: S_OK. lpClassId contains the Class Id requested.
1371 * Failure: E_FAIL, If lpUnknown is NULL,
1372 * E_NOINTERFACE If lpUnknown does not support IPersist,
1373 * Or an HRESULT error code.
1375 HRESULT WINAPI
IUnknown_GetClassID(IUnknown
*lpUnknown
, CLSID
* lpClassId
)
1377 IPersist
* lpPersist
;
1378 HRESULT hRet
= E_FAIL
;
1380 TRACE("(%p,%s)\n", lpUnknown
, debugstr_guid(lpClassId
));
1384 hRet
= IUnknown_QueryInterface(lpUnknown
,&IID_IPersist
,(void**)&lpPersist
);
1385 if (SUCCEEDED(hRet
))
1387 IPersist_GetClassID(lpPersist
, lpClassId
);
1388 IPersist_Release(lpPersist
);
1394 /*************************************************************************
1397 * Retrieve a Service Interface from an object.
1400 * lpUnknown [I] Object to get an IServiceProvider interface from
1401 * sid [I] Service ID for IServiceProvider_QueryService() call
1402 * riid [I] Function requested for QueryService call
1403 * lppOut [O] Destination for the service interface pointer
1406 * Success: S_OK. lppOut contains an object providing the requested service
1407 * Failure: An HRESULT error code
1410 * lpUnknown is expected to support the IServiceProvider interface.
1412 HRESULT WINAPI
IUnknown_QueryService(IUnknown
* lpUnknown
, REFGUID sid
, REFIID riid
,
1415 IServiceProvider
* pService
= NULL
;
1426 hRet
= IUnknown_QueryInterface(lpUnknown
, &IID_IServiceProvider
,
1427 (LPVOID
*)&pService
);
1429 if (hRet
== S_OK
&& pService
)
1431 TRACE("QueryInterface returned (IServiceProvider*)%p\n", pService
);
1433 /* Get a Service interface from the object */
1434 hRet
= IServiceProvider_QueryService(pService
, sid
, riid
, lppOut
);
1436 TRACE("(IServiceProvider*)%p returned (IUnknown*)%p\n", pService
, *lppOut
);
1438 IServiceProvider_Release(pService
);
1443 /*************************************************************************
1446 * Calls IOleCommandTarget::Exec() for specified service object.
1449 * lpUnknown [I] Object to get an IServiceProvider interface from
1450 * service [I] Service ID for IServiceProvider_QueryService() call
1451 * group [I] Group ID for IOleCommandTarget::Exec() call
1452 * cmdId [I] Command ID for IOleCommandTarget::Exec() call
1453 * cmdOpt [I] Options flags for command
1454 * pIn [I] Input arguments for command
1455 * pOut [O] Output arguments for command
1458 * Success: S_OK. lppOut contains an object providing the requested service
1459 * Failure: An HRESULT error code
1462 * lpUnknown is expected to support the IServiceProvider interface.
1464 HRESULT WINAPI
IUnknown_QueryServiceExec(IUnknown
*lpUnknown
, REFIID service
,
1465 const GUID
*group
, DWORD cmdId
, DWORD cmdOpt
, VARIANT
*pIn
, VARIANT
*pOut
)
1467 IOleCommandTarget
*target
;
1470 TRACE("%p %s %s %d %08x %p %p\n", lpUnknown
, debugstr_guid(service
),
1471 debugstr_guid(group
), cmdId
, cmdOpt
, pIn
, pOut
);
1473 hr
= IUnknown_QueryService(lpUnknown
, service
, &IID_IOleCommandTarget
, (void**)&target
);
1476 hr
= IOleCommandTarget_Exec(target
, group
, cmdId
, cmdOpt
, pIn
, pOut
);
1477 IOleCommandTarget_Release(target
);
1480 TRACE("<-- hr=0x%08x\n", hr
);
1485 /*************************************************************************
1488 * Calls IProfferService methods to proffer/revoke specified service.
1491 * lpUnknown [I] Object to get an IServiceProvider interface from
1492 * service [I] Service ID for IProfferService::Proffer/Revoke calls
1493 * pService [I] Service to proffer. If NULL ::Revoke is called
1494 * pCookie [IO] Group ID for IOleCommandTarget::Exec() call
1497 * Success: S_OK. IProffer method returns S_OK
1498 * Failure: An HRESULT error code
1501 * lpUnknown is expected to support the IServiceProvider interface.
1503 HRESULT WINAPI
IUnknown_ProfferService(IUnknown
*lpUnknown
, REFGUID service
, IServiceProvider
*pService
, DWORD
*pCookie
)
1505 IProfferService
*proffer
;
1508 TRACE("%p %s %p %p\n", lpUnknown
, debugstr_guid(service
), pService
, pCookie
);
1510 hr
= IUnknown_QueryService(lpUnknown
, &IID_IProfferService
, &IID_IProfferService
, (void**)&proffer
);
1514 hr
= IProfferService_ProfferService(proffer
, service
, pService
, pCookie
);
1517 hr
= IProfferService_RevokeService(proffer
, *pCookie
);
1521 IProfferService_Release(proffer
);
1527 /*************************************************************************
1530 * Call an object's UIActivateIO method.
1533 * unknown [I] Object to call the UIActivateIO method on
1534 * activate [I] Parameter for UIActivateIO call
1535 * msg [I] Parameter for UIActivateIO call
1538 * Success: Value of UI_ActivateIO call
1539 * Failure: An HRESULT error code
1542 * unknown is expected to support the IInputObject interface.
1544 HRESULT WINAPI
IUnknown_UIActivateIO(IUnknown
*unknown
, BOOL activate
, LPMSG msg
)
1546 IInputObject
* object
= NULL
;
1552 /* Get an IInputObject interface from the object */
1553 ret
= IUnknown_QueryInterface(unknown
, &IID_IInputObject
, (LPVOID
*) &object
);
1557 ret
= IInputObject_UIActivateIO(object
, activate
, msg
);
1558 IInputObject_Release(object
);
1564 /*************************************************************************
1567 * Loads a popup menu.
1570 * hInst [I] Instance handle
1571 * szName [I] Menu name
1577 BOOL WINAPI
SHLoadMenuPopup(HINSTANCE hInst
, LPCWSTR szName
)
1581 TRACE("%p %s\n", hInst
, debugstr_w(szName
));
1583 if ((hMenu
= LoadMenuW(hInst
, szName
)))
1585 if (GetSubMenu(hMenu
, 0))
1586 RemoveMenu(hMenu
, 0, MF_BYPOSITION
);
1594 typedef struct _enumWndData
1599 LRESULT (WINAPI
*pfnPost
)(HWND
,UINT
,WPARAM
,LPARAM
);
1602 /* Callback for SHLWAPI_178 */
1603 static BOOL CALLBACK
SHLWAPI_EnumChildProc(HWND hWnd
, LPARAM lParam
)
1605 enumWndData
*data
= (enumWndData
*)lParam
;
1607 TRACE("(%p,%p)\n", hWnd
, data
);
1608 data
->pfnPost(hWnd
, data
->uiMsgId
, data
->wParam
, data
->lParam
);
1612 /*************************************************************************
1615 * Send or post a message to every child of a window.
1618 * hWnd [I] Window whose children will get the messages
1619 * uiMsgId [I] Message Id
1620 * wParam [I] WPARAM of message
1621 * lParam [I] LPARAM of message
1622 * bSend [I] TRUE = Use SendMessageA(), FALSE = Use PostMessageA()
1628 * The appropriate ASCII or Unicode function is called for the window.
1630 void WINAPI
SHPropagateMessage(HWND hWnd
, UINT uiMsgId
, WPARAM wParam
, LPARAM lParam
, BOOL bSend
)
1634 TRACE("(%p,%u,%ld,%ld,%d)\n", hWnd
, uiMsgId
, wParam
, lParam
, bSend
);
1638 data
.uiMsgId
= uiMsgId
;
1639 data
.wParam
= wParam
;
1640 data
.lParam
= lParam
;
1643 data
.pfnPost
= IsWindowUnicode(hWnd
) ? (void*)SendMessageW
: (void*)SendMessageA
;
1645 data
.pfnPost
= IsWindowUnicode(hWnd
) ? (void*)PostMessageW
: (void*)PostMessageA
;
1647 EnumChildWindows(hWnd
, SHLWAPI_EnumChildProc
, (LPARAM
)&data
);
1651 /*************************************************************************
1654 * Remove all sub-menus from a menu.
1657 * hMenu [I] Menu to remove sub-menus from
1660 * Success: 0. All sub-menus under hMenu are removed
1661 * Failure: -1, if any parameter is invalid
1663 DWORD WINAPI
SHRemoveAllSubMenus(HMENU hMenu
)
1665 int iItemCount
= GetMenuItemCount(hMenu
) - 1;
1667 TRACE("%p\n", hMenu
);
1669 while (iItemCount
>= 0)
1671 HMENU hSubMenu
= GetSubMenu(hMenu
, iItemCount
);
1673 RemoveMenu(hMenu
, iItemCount
, MF_BYPOSITION
);
1679 /*************************************************************************
1682 * Enable or disable a menu item.
1685 * hMenu [I] Menu holding menu item
1686 * uID [I] ID of menu item to enable/disable
1687 * bEnable [I] Whether to enable (TRUE) or disable (FALSE) the item.
1690 * The return code from EnableMenuItem.
1692 UINT WINAPI
SHEnableMenuItem(HMENU hMenu
, UINT wItemID
, BOOL bEnable
)
1694 TRACE("%p, %u, %d\n", hMenu
, wItemID
, bEnable
);
1695 return EnableMenuItem(hMenu
, wItemID
, bEnable
? MF_ENABLED
: MF_GRAYED
);
1698 /*************************************************************************
1701 * Check or uncheck a menu item.
1704 * hMenu [I] Menu holding menu item
1705 * uID [I] ID of menu item to check/uncheck
1706 * bCheck [I] Whether to check (TRUE) or uncheck (FALSE) the item.
1709 * The return code from CheckMenuItem.
1711 DWORD WINAPI
SHCheckMenuItem(HMENU hMenu
, UINT uID
, BOOL bCheck
)
1713 TRACE("%p, %u, %d\n", hMenu
, uID
, bCheck
);
1714 return CheckMenuItem(hMenu
, uID
, bCheck
? MF_CHECKED
: MF_UNCHECKED
);
1717 /*************************************************************************
1720 * Register a window class if it isn't already.
1723 * lpWndClass [I] Window class to register
1726 * The result of the RegisterClassA call.
1728 DWORD WINAPI
SHRegisterClassA(WNDCLASSA
*wndclass
)
1731 if (GetClassInfoA(wndclass
->hInstance
, wndclass
->lpszClassName
, &wca
))
1733 return (DWORD
)RegisterClassA(wndclass
);
1736 /*************************************************************************
1739 BOOL WINAPI
SHSimulateDrop(IDropTarget
*pDrop
, IDataObject
*pDataObj
,
1740 DWORD grfKeyState
, PPOINTL lpPt
, DWORD
* pdwEffect
)
1742 DWORD dwEffect
= DROPEFFECT_LINK
| DROPEFFECT_MOVE
| DROPEFFECT_COPY
;
1743 POINTL pt
= { 0, 0 };
1745 TRACE("%p %p 0x%08x %p %p\n", pDrop
, pDataObj
, grfKeyState
, lpPt
, pdwEffect
);
1751 pdwEffect
= &dwEffect
;
1753 IDropTarget_DragEnter(pDrop
, pDataObj
, grfKeyState
, *lpPt
, pdwEffect
);
1755 if (*pdwEffect
!= DROPEFFECT_NONE
)
1756 return IDropTarget_Drop(pDrop
, pDataObj
, grfKeyState
, *lpPt
, pdwEffect
);
1758 IDropTarget_DragLeave(pDrop
);
1762 /*************************************************************************
1765 * Call IPersistPropertyBag_Load() on an object.
1768 * lpUnknown [I] Object supporting the IPersistPropertyBag interface
1769 * lpPropBag [O] Destination for loaded IPropertyBag
1773 * Failure: An HRESULT error code, or E_FAIL if lpUnknown is NULL.
1775 DWORD WINAPI
SHLoadFromPropertyBag(IUnknown
*lpUnknown
, IPropertyBag
* lpPropBag
)
1777 IPersistPropertyBag
* lpPPBag
;
1778 HRESULT hRet
= E_FAIL
;
1780 TRACE("(%p,%p)\n", lpUnknown
, lpPropBag
);
1784 hRet
= IUnknown_QueryInterface(lpUnknown
, &IID_IPersistPropertyBag
,
1786 if (SUCCEEDED(hRet
) && lpPPBag
)
1788 hRet
= IPersistPropertyBag_Load(lpPPBag
, lpPropBag
, NULL
);
1789 IPersistPropertyBag_Release(lpPPBag
);
1795 /*************************************************************************
1798 * Call IOleControlSite_TranslateAccelerator() on an object.
1801 * lpUnknown [I] Object supporting the IOleControlSite interface.
1802 * lpMsg [I] Key message to be processed.
1803 * dwModifiers [I] Flags containing the state of the modifier keys.
1807 * Failure: An HRESULT error code, or E_INVALIDARG if lpUnknown is NULL.
1809 HRESULT WINAPI
IUnknown_TranslateAcceleratorOCS(IUnknown
*lpUnknown
, LPMSG lpMsg
, DWORD dwModifiers
)
1811 IOleControlSite
* lpCSite
= NULL
;
1812 HRESULT hRet
= E_INVALIDARG
;
1814 TRACE("(%p,%p,0x%08x)\n", lpUnknown
, lpMsg
, dwModifiers
);
1817 hRet
= IUnknown_QueryInterface(lpUnknown
, &IID_IOleControlSite
,
1819 if (SUCCEEDED(hRet
) && lpCSite
)
1821 hRet
= IOleControlSite_TranslateAccelerator(lpCSite
, lpMsg
, dwModifiers
);
1822 IOleControlSite_Release(lpCSite
);
1829 /*************************************************************************
1832 * Call IOleControlSite_OnFocus() on an object.
1835 * lpUnknown [I] Object supporting the IOleControlSite interface.
1836 * fGotFocus [I] Whether focus was gained (TRUE) or lost (FALSE).
1840 * Failure: An HRESULT error code, or E_FAIL if lpUnknown is NULL.
1842 HRESULT WINAPI
IUnknown_OnFocusOCS(IUnknown
*lpUnknown
, BOOL fGotFocus
)
1844 IOleControlSite
* lpCSite
= NULL
;
1845 HRESULT hRet
= E_FAIL
;
1847 TRACE("(%p, %d)\n", lpUnknown
, fGotFocus
);
1850 hRet
= IUnknown_QueryInterface(lpUnknown
, &IID_IOleControlSite
,
1852 if (SUCCEEDED(hRet
) && lpCSite
)
1854 hRet
= IOleControlSite_OnFocus(lpCSite
, fGotFocus
);
1855 IOleControlSite_Release(lpCSite
);
1861 /*************************************************************************
1864 HRESULT WINAPI
IUnknown_HandleIRestrict(LPUNKNOWN lpUnknown
, PVOID lpArg1
,
1865 PVOID lpArg2
, PVOID lpArg3
, PVOID lpArg4
)
1867 /* FIXME: {D12F26B2-D90A-11D0-830D-00AA005B4383} - What object does this represent? */
1868 static const DWORD service_id
[] = { 0xd12f26b2, 0x11d0d90a, 0xaa000d83, 0x83435b00 };
1869 /* FIXME: {D12F26B1-D90A-11D0-830D-00AA005B4383} - Also Unknown/undocumented */
1870 static const DWORD function_id
[] = { 0xd12f26b1, 0x11d0d90a, 0xaa000d83, 0x83435b00 };
1871 HRESULT hRet
= E_INVALIDARG
;
1872 LPUNKNOWN lpUnkInner
= NULL
; /* FIXME: Real type is unknown */
1874 TRACE("(%p,%p,%p,%p,%p)\n", lpUnknown
, lpArg1
, lpArg2
, lpArg3
, lpArg4
);
1876 if (lpUnknown
&& lpArg4
)
1878 hRet
= IUnknown_QueryService(lpUnknown
, (REFGUID
)service_id
,
1879 (REFGUID
)function_id
, (void**)&lpUnkInner
);
1881 if (SUCCEEDED(hRet
) && lpUnkInner
)
1883 /* FIXME: The type of service object requested is unknown, however
1884 * testing shows that its first method is called with 4 parameters.
1885 * Fake this by using IParseDisplayName_ParseDisplayName since the
1886 * signature and position in the vtable matches our unknown object type.
1888 hRet
= IParseDisplayName_ParseDisplayName((LPPARSEDISPLAYNAME
)lpUnkInner
,
1889 lpArg1
, lpArg2
, lpArg3
, lpArg4
);
1890 IUnknown_Release(lpUnkInner
);
1896 /*************************************************************************
1899 * Get a sub-menu from a menu item.
1902 * hMenu [I] Menu to get sub-menu from
1903 * uID [I] ID of menu item containing sub-menu
1906 * The sub-menu of the item, or a NULL handle if any parameters are invalid.
1908 HMENU WINAPI
SHGetMenuFromID(HMENU hMenu
, UINT uID
)
1912 TRACE("(%p,%u)\n", hMenu
, uID
);
1914 mi
.cbSize
= sizeof(mi
);
1915 mi
.fMask
= MIIM_SUBMENU
;
1917 if (!GetMenuItemInfoW(hMenu
, uID
, FALSE
, &mi
))
1923 /*************************************************************************
1926 * Get the color depth of the primary display.
1932 * The color depth of the primary display.
1934 DWORD WINAPI
SHGetCurColorRes(void)
1942 ret
= GetDeviceCaps(hdc
, BITSPIXEL
) * GetDeviceCaps(hdc
, PLANES
);
1947 /*************************************************************************
1950 * Wait for a message to arrive, with a timeout.
1953 * hand [I] Handle to query
1954 * dwTimeout [I] Timeout in ticks or INFINITE to never timeout
1957 * STATUS_TIMEOUT if no message is received before dwTimeout ticks passes.
1958 * Otherwise returns the value from MsgWaitForMultipleObjectsEx when a
1959 * message is available.
1961 DWORD WINAPI
SHWaitForSendMessageThread(HANDLE hand
, DWORD dwTimeout
)
1963 DWORD dwEndTicks
= GetTickCount() + dwTimeout
;
1966 while ((dwRet
= MsgWaitForMultipleObjectsEx(1, &hand
, dwTimeout
, QS_SENDMESSAGE
, 0)) == 1)
1970 PeekMessageW(&msg
, NULL
, 0, 0, PM_NOREMOVE
);
1972 if (dwTimeout
!= INFINITE
)
1974 if ((int)(dwTimeout
= dwEndTicks
- GetTickCount()) <= 0)
1975 return WAIT_TIMEOUT
;
1982 /*************************************************************************
1985 * Determine if a shell folder can be expanded.
1988 * lpFolder [I] Parent folder containing the object to test.
1989 * pidl [I] Id of the object to test.
1992 * Success: S_OK, if the object is expandable, S_FALSE otherwise.
1993 * Failure: E_INVALIDARG, if any argument is invalid.
1996 * If the object to be tested does not expose the IQueryInfo() interface it
1997 * will not be identified as an expandable folder.
1999 HRESULT WINAPI
SHIsExpandableFolder(LPSHELLFOLDER lpFolder
, LPCITEMIDLIST pidl
)
2001 HRESULT hRet
= E_INVALIDARG
;
2004 if (lpFolder
&& pidl
)
2006 hRet
= IShellFolder_GetUIObjectOf(lpFolder
, NULL
, 1, &pidl
, &IID_IQueryInfo
,
2007 NULL
, (void**)&lpInfo
);
2009 hRet
= S_FALSE
; /* Doesn't expose IQueryInfo */
2014 /* MSDN states of IQueryInfo_GetInfoFlags() that "This method is not
2015 * currently used". Really? You wouldn't be holding out on me would you?
2017 hRet
= IQueryInfo_GetInfoFlags(lpInfo
, &dwFlags
);
2019 if (SUCCEEDED(hRet
))
2021 /* 0x2 is an undocumented flag apparently indicating expandability */
2022 hRet
= dwFlags
& 0x2 ? S_OK
: S_FALSE
;
2025 IQueryInfo_Release(lpInfo
);
2031 /*************************************************************************
2034 * Blank out a region of text by drawing the background only.
2037 * hDC [I] Device context to draw in
2038 * pRect [I] Area to draw in
2039 * cRef [I] Color to draw in
2044 DWORD WINAPI
SHFillRectClr(HDC hDC
, LPCRECT pRect
, COLORREF cRef
)
2046 COLORREF cOldColor
= SetBkColor(hDC
, cRef
);
2047 ExtTextOutA(hDC
, 0, 0, ETO_OPAQUE
, pRect
, 0, 0, 0);
2048 SetBkColor(hDC
, cOldColor
);
2052 /*************************************************************************
2055 * Return the value associated with a key in a map.
2058 * lpKeys [I] A list of keys of length iLen
2059 * lpValues [I] A list of values associated with lpKeys, of length iLen
2060 * iLen [I] Length of both lpKeys and lpValues
2061 * iKey [I] The key value to look up in lpKeys
2064 * The value in lpValues associated with iKey, or -1 if iKey is not
2068 * - If two elements in the map share the same key, this function returns
2069 * the value closest to the start of the map
2070 * - The native version of this function crashes if lpKeys or lpValues is NULL.
2072 int WINAPI
SHSearchMapInt(const int *lpKeys
, const int *lpValues
, int iLen
, int iKey
)
2074 if (lpKeys
&& lpValues
)
2080 if (lpKeys
[i
] == iKey
)
2081 return lpValues
[i
]; /* Found */
2085 return -1; /* Not found */
2089 /*************************************************************************
2092 * Copy an interface pointer
2095 * lppDest [O] Destination for copy
2096 * lpUnknown [I] Source for copy
2101 VOID WINAPI
IUnknown_Set(IUnknown
**lppDest
, IUnknown
*lpUnknown
)
2103 TRACE("(%p,%p)\n", lppDest
, lpUnknown
);
2105 IUnknown_AtomicRelease(lppDest
);
2109 IUnknown_AddRef(lpUnknown
);
2110 *lppDest
= lpUnknown
;
2114 /*************************************************************************
2118 HRESULT WINAPI
MayQSForward(IUnknown
* lpUnknown
, PVOID lpReserved
,
2119 REFGUID riidCmdGrp
, ULONG cCmds
,
2120 OLECMD
*prgCmds
, OLECMDTEXT
* pCmdText
)
2122 FIXME("(%p,%p,%p,%d,%p,%p) - stub\n",
2123 lpUnknown
, lpReserved
, riidCmdGrp
, cCmds
, prgCmds
, pCmdText
);
2125 /* FIXME: Calls IsQSForward & IUnknown_QueryStatus */
2126 return DRAGDROP_E_NOTREGISTERED
;
2129 /*************************************************************************
2133 HRESULT WINAPI
MayExecForward(IUnknown
* lpUnknown
, INT iUnk
, REFGUID pguidCmdGroup
,
2134 DWORD nCmdID
, DWORD nCmdexecopt
, VARIANT
* pvaIn
,
2137 FIXME("(%p,%d,%p,%d,%d,%p,%p) - stub!\n", lpUnknown
, iUnk
, pguidCmdGroup
,
2138 nCmdID
, nCmdexecopt
, pvaIn
, pvaOut
);
2139 return DRAGDROP_E_NOTREGISTERED
;
2142 /*************************************************************************
2146 HRESULT WINAPI
IsQSForward(REFGUID pguidCmdGroup
,ULONG cCmds
, OLECMD
*prgCmds
)
2148 FIXME("(%p,%d,%p) - stub!\n", pguidCmdGroup
, cCmds
, prgCmds
);
2149 return DRAGDROP_E_NOTREGISTERED
;
2152 /*************************************************************************
2155 * Determine if a window is not a child of another window.
2158 * hParent [I] Suspected parent window
2159 * hChild [I] Suspected child window
2162 * TRUE: If hChild is a child window of hParent
2163 * FALSE: If hChild is not a child window of hParent, or they are equal
2165 BOOL WINAPI
SHIsChildOrSelf(HWND hParent
, HWND hChild
)
2167 TRACE("(%p,%p)\n", hParent
, hChild
);
2169 if (!hParent
|| !hChild
)
2171 else if(hParent
== hChild
)
2173 return !IsChild(hParent
, hChild
);
2176 /*************************************************************************
2177 * FDSA functions. Manage a dynamic array of fixed size memory blocks.
2182 DWORD num_items
; /* Number of elements inserted */
2183 void *mem
; /* Ptr to array */
2184 DWORD blocks_alloced
; /* Number of elements allocated */
2185 BYTE inc
; /* Number of elements to grow by when we need to expand */
2186 BYTE block_size
; /* Size in bytes of an element */
2187 BYTE flags
; /* Flags */
2190 #define FDSA_FLAG_INTERNAL_ALLOC 0x01 /* When set we have allocated mem internally */
2192 /*************************************************************************
2195 * Initialize an FDSA array.
2197 BOOL WINAPI
FDSA_Initialize(DWORD block_size
, DWORD inc
, FDSA_info
*info
, void *mem
,
2200 TRACE("(0x%08x 0x%08x %p %p 0x%08x)\n", block_size
, inc
, info
, mem
, init_blocks
);
2206 memset(mem
, 0, block_size
* init_blocks
);
2208 info
->num_items
= 0;
2211 info
->blocks_alloced
= init_blocks
;
2212 info
->block_size
= block_size
;
2218 /*************************************************************************
2221 * Destroy an FDSA array
2223 BOOL WINAPI
FDSA_Destroy(FDSA_info
*info
)
2225 TRACE("(%p)\n", info
);
2227 if(info
->flags
& FDSA_FLAG_INTERNAL_ALLOC
)
2229 HeapFree(GetProcessHeap(), 0, info
->mem
);
2236 /*************************************************************************
2239 * Insert element into an FDSA array
2241 DWORD WINAPI
FDSA_InsertItem(FDSA_info
*info
, DWORD where
, const void *block
)
2243 TRACE("(%p 0x%08x %p)\n", info
, where
, block
);
2244 if(where
> info
->num_items
)
2245 where
= info
->num_items
;
2247 if(info
->num_items
>= info
->blocks_alloced
)
2249 DWORD size
= (info
->blocks_alloced
+ info
->inc
) * info
->block_size
;
2250 if(info
->flags
& 0x1)
2251 info
->mem
= HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, info
->mem
, size
);
2254 void *old_mem
= info
->mem
;
2255 info
->mem
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, size
);
2256 memcpy(info
->mem
, old_mem
, info
->blocks_alloced
* info
->block_size
);
2258 info
->blocks_alloced
+= info
->inc
;
2262 if(where
< info
->num_items
)
2264 memmove((char*)info
->mem
+ (where
+ 1) * info
->block_size
,
2265 (char*)info
->mem
+ where
* info
->block_size
,
2266 (info
->num_items
- where
) * info
->block_size
);
2268 memcpy((char*)info
->mem
+ where
* info
->block_size
, block
, info
->block_size
);
2274 /*************************************************************************
2277 * Delete an element from an FDSA array.
2279 BOOL WINAPI
FDSA_DeleteItem(FDSA_info
*info
, DWORD where
)
2281 TRACE("(%p 0x%08x)\n", info
, where
);
2283 if(where
>= info
->num_items
)
2286 if(where
< info
->num_items
- 1)
2288 memmove((char*)info
->mem
+ where
* info
->block_size
,
2289 (char*)info
->mem
+ (where
+ 1) * info
->block_size
,
2290 (info
->num_items
- where
- 1) * info
->block_size
);
2292 memset((char*)info
->mem
+ (info
->num_items
- 1) * info
->block_size
,
2293 0, info
->block_size
);
2298 /*************************************************************************
2301 * Call IUnknown_QueryInterface() on a table of objects.
2305 * Failure: E_POINTER or E_NOINTERFACE.
2307 HRESULT WINAPI
QISearch(
2308 void *base
, /* [in] Table of interfaces */
2309 const QITAB
*table
, /* [in] Array of REFIIDs and indexes into the table */
2310 REFIID riid
, /* [in] REFIID to get interface for */
2311 void **ppv
) /* [out] Destination for interface pointer */
2317 TRACE("(%p %p %s %p)\n", base
, table
, debugstr_guid(riid
), ppv
);
2320 while (xmove
->piid
) {
2321 TRACE("trying (offset %d) %s\n", xmove
->dwOffset
, debugstr_guid(xmove
->piid
));
2322 if (IsEqualIID(riid
, xmove
->piid
)) {
2323 a_vtbl
= (IUnknown
*)(xmove
->dwOffset
+ (LPBYTE
)base
);
2324 TRACE("matched, returning (%p)\n", a_vtbl
);
2326 IUnknown_AddRef(a_vtbl
);
2332 if (IsEqualIID(riid
, &IID_IUnknown
)) {
2333 a_vtbl
= (IUnknown
*)(table
->dwOffset
+ (LPBYTE
)base
);
2334 TRACE("returning first for IUnknown (%p)\n", a_vtbl
);
2336 IUnknown_AddRef(a_vtbl
);
2340 ret
= E_NOINTERFACE
;
2344 TRACE("-- 0x%08x\n", ret
);
2348 /*************************************************************************
2351 * Set the Font for a window and the "PropDlgFont" property of the parent window.
2354 * hWnd [I] Parent Window to set the property
2355 * id [I] Index of child Window to set the Font
2361 HRESULT WINAPI
SHSetDefaultDialogFont(HWND hWnd
, INT id
)
2363 FIXME("(%p, %d) stub\n", hWnd
, id
);
2367 /*************************************************************************
2370 * Remove the "PropDlgFont" property from a window.
2373 * hWnd [I] Window to remove the property from
2376 * A handle to the removed property, or NULL if it did not exist.
2378 HANDLE WINAPI
SHRemoveDefaultDialogFont(HWND hWnd
)
2382 TRACE("(%p)\n", hWnd
);
2384 hProp
= GetPropA(hWnd
, "PropDlgFont");
2388 DeleteObject(hProp
);
2389 hProp
= RemovePropA(hWnd
, "PropDlgFont");
2394 /*************************************************************************
2397 * Load the in-process server of a given GUID.
2400 * refiid [I] GUID of the server to load.
2403 * Success: A handle to the loaded server dll.
2404 * Failure: A NULL handle.
2406 HMODULE WINAPI
SHPinDllOfCLSID(REFIID refiid
)
2410 CHAR value
[MAX_PATH
], string
[MAX_PATH
];
2412 strcpy(string
, "CLSID\\");
2413 SHStringFromGUIDA(refiid
, string
+ 6, sizeof(string
)/sizeof(char) - 6);
2414 strcat(string
, "\\InProcServer32");
2417 RegOpenKeyExA(HKEY_CLASSES_ROOT
, string
, 0, 1, &newkey
);
2418 RegQueryValueExA(newkey
, 0, 0, &type
, (PBYTE
)value
, &count
);
2419 RegCloseKey(newkey
);
2420 return LoadLibraryExA(value
, 0, 0);
2423 /*************************************************************************
2426 * Unicode version of SHLWAPI_183.
2428 DWORD WINAPI
SHRegisterClassW(WNDCLASSW
* lpWndClass
)
2432 TRACE("(%p %s)\n",lpWndClass
->hInstance
, debugstr_w(lpWndClass
->lpszClassName
));
2434 if (GetClassInfoW(lpWndClass
->hInstance
, lpWndClass
->lpszClassName
, &WndClass
))
2436 return RegisterClassW(lpWndClass
);
2439 /*************************************************************************
2442 * Unregister a list of classes.
2445 * hInst [I] Application instance that registered the classes
2446 * lppClasses [I] List of class names
2447 * iCount [I] Number of names in lppClasses
2452 void WINAPI
SHUnregisterClassesA(HINSTANCE hInst
, LPCSTR
*lppClasses
, INT iCount
)
2456 TRACE("(%p,%p,%d)\n", hInst
, lppClasses
, iCount
);
2460 if (GetClassInfoA(hInst
, *lppClasses
, &WndClass
))
2461 UnregisterClassA(*lppClasses
, hInst
);
2467 /*************************************************************************
2470 * Unicode version of SHUnregisterClassesA.
2472 void WINAPI
SHUnregisterClassesW(HINSTANCE hInst
, LPCWSTR
*lppClasses
, INT iCount
)
2476 TRACE("(%p,%p,%d)\n", hInst
, lppClasses
, iCount
);
2480 if (GetClassInfoW(hInst
, *lppClasses
, &WndClass
))
2481 UnregisterClassW(*lppClasses
, hInst
);
2487 /*************************************************************************
2490 * Call The correct (Ascii/Unicode) default window procedure for a window.
2493 * hWnd [I] Window to call the default procedure for
2494 * uMessage [I] Message ID
2495 * wParam [I] WPARAM of message
2496 * lParam [I] LPARAM of message
2499 * The result of calling DefWindowProcA() or DefWindowProcW().
2501 LRESULT CALLBACK
SHDefWindowProc(HWND hWnd
, UINT uMessage
, WPARAM wParam
, LPARAM lParam
)
2503 if (IsWindowUnicode(hWnd
))
2504 return DefWindowProcW(hWnd
, uMessage
, wParam
, lParam
);
2505 return DefWindowProcA(hWnd
, uMessage
, wParam
, lParam
);
2508 /*************************************************************************
2511 HRESULT WINAPI
IUnknown_GetSite(LPUNKNOWN lpUnknown
, REFIID iid
, PVOID
*lppSite
)
2513 HRESULT hRet
= E_INVALIDARG
;
2514 LPOBJECTWITHSITE lpSite
= NULL
;
2516 TRACE("(%p,%s,%p)\n", lpUnknown
, debugstr_guid(iid
), lppSite
);
2518 if (lpUnknown
&& iid
&& lppSite
)
2520 hRet
= IUnknown_QueryInterface(lpUnknown
, &IID_IObjectWithSite
,
2522 if (SUCCEEDED(hRet
) && lpSite
)
2524 hRet
= IObjectWithSite_GetSite(lpSite
, iid
, lppSite
);
2525 IObjectWithSite_Release(lpSite
);
2531 /*************************************************************************
2534 * Create a worker window using CreateWindowExA().
2537 * wndProc [I] Window procedure
2538 * hWndParent [I] Parent window
2539 * dwExStyle [I] Extra style flags
2540 * dwStyle [I] Style flags
2541 * hMenu [I] Window menu
2542 * wnd_extra [I] Window extra bytes value
2545 * Success: The window handle of the newly created window.
2548 HWND WINAPI
SHCreateWorkerWindowA(LONG wndProc
, HWND hWndParent
, DWORD dwExStyle
,
2549 DWORD dwStyle
, HMENU hMenu
, LONG_PTR wnd_extra
)
2551 static const char szClass
[] = "WorkerA";
2555 TRACE("(0x%08x, %p, 0x%08x, 0x%08x, %p, 0x%08lx)\n",
2556 wndProc
, hWndParent
, dwExStyle
, dwStyle
, hMenu
, wnd_extra
);
2558 /* Create Window class */
2560 wc
.lpfnWndProc
= DefWindowProcA
;
2562 wc
.cbWndExtra
= sizeof(LONG_PTR
);
2563 wc
.hInstance
= shlwapi_hInstance
;
2565 wc
.hCursor
= LoadCursorA(NULL
, (LPSTR
)IDC_ARROW
);
2566 wc
.hbrBackground
= (HBRUSH
)(COLOR_BTNFACE
+ 1);
2567 wc
.lpszMenuName
= NULL
;
2568 wc
.lpszClassName
= szClass
;
2570 SHRegisterClassA(&wc
);
2572 hWnd
= CreateWindowExA(dwExStyle
, szClass
, 0, dwStyle
, 0, 0, 0, 0,
2573 hWndParent
, hMenu
, shlwapi_hInstance
, 0);
2576 SetWindowLongPtrW(hWnd
, 0, wnd_extra
);
2578 if (wndProc
) SetWindowLongPtrA(hWnd
, GWLP_WNDPROC
, wndProc
);
2584 typedef struct tagPOLICYDATA
2586 DWORD policy
; /* flags value passed to SHRestricted */
2587 LPCWSTR appstr
; /* application str such as "Explorer" */
2588 LPCWSTR keystr
; /* name of the actual registry key / policy */
2589 } POLICYDATA
, *LPPOLICYDATA
;
2591 #define SHELL_NO_POLICY 0xffffffff
2593 /* default shell policy registry key */
2594 static const WCHAR strRegistryPolicyW
[] = {'S','o','f','t','w','a','r','e','\\','M','i','c','r','o',
2595 's','o','f','t','\\','W','i','n','d','o','w','s','\\',
2596 'C','u','r','r','e','n','t','V','e','r','s','i','o','n',
2597 '\\','P','o','l','i','c','i','e','s',0};
2599 /*************************************************************************
2602 * Retrieve a policy value from the registry.
2605 * lpSubKey [I] registry key name
2606 * lpSubName [I] subname of registry key
2607 * lpValue [I] value name of registry value
2610 * the value associated with the registry key or 0 if not found
2612 DWORD WINAPI
SHGetRestriction(LPCWSTR lpSubKey
, LPCWSTR lpSubName
, LPCWSTR lpValue
)
2614 DWORD retval
, datsize
= sizeof(retval
);
2618 lpSubKey
= strRegistryPolicyW
;
2620 retval
= RegOpenKeyW(HKEY_LOCAL_MACHINE
, lpSubKey
, &hKey
);
2621 if (retval
!= ERROR_SUCCESS
)
2622 retval
= RegOpenKeyW(HKEY_CURRENT_USER
, lpSubKey
, &hKey
);
2623 if (retval
!= ERROR_SUCCESS
)
2626 SHGetValueW(hKey
, lpSubName
, lpValue
, NULL
, &retval
, &datsize
);
2631 /*************************************************************************
2634 * Helper function to retrieve the possibly cached value for a specific policy
2637 * policy [I] The policy to look for
2638 * initial [I] Main registry key to open, if NULL use default
2639 * polTable [I] Table of known policies, 0 terminated
2640 * polArr [I] Cache array of policy values
2643 * The retrieved policy value or 0 if not successful
2646 * This function is used by the native SHRestricted function to search for the
2647 * policy and cache it once retrieved. The current Wine implementation uses a
2648 * different POLICYDATA structure and implements a similar algorithm adapted to
2651 DWORD WINAPI
SHRestrictionLookup(
2654 LPPOLICYDATA polTable
,
2657 TRACE("(0x%08x %s %p %p)\n", policy
, debugstr_w(initial
), polTable
, polArr
);
2659 if (!polTable
|| !polArr
)
2662 for (;polTable
->policy
; polTable
++, polArr
++)
2664 if (policy
== polTable
->policy
)
2666 /* we have a known policy */
2668 /* check if this policy has been cached */
2669 if (*polArr
== SHELL_NO_POLICY
)
2670 *polArr
= SHGetRestriction(initial
, polTable
->appstr
, polTable
->keystr
);
2674 /* we don't know this policy, return 0 */
2675 TRACE("unknown policy: (%08x)\n", policy
);
2679 /*************************************************************************
2682 * Get an interface from an object.
2685 * Success: S_OK. ppv contains the requested interface.
2686 * Failure: An HRESULT error code.
2689 * This QueryInterface asks the inner object for an interface. In case
2690 * of aggregation this request would be forwarded by the inner to the
2691 * outer object. This function asks the inner object directly for the
2692 * interface circumventing the forwarding to the outer object.
2694 HRESULT WINAPI
SHWeakQueryInterface(
2695 IUnknown
* pUnk
, /* [in] Outer object */
2696 IUnknown
* pInner
, /* [in] Inner object */
2697 IID
* riid
, /* [in] Interface GUID to query for */
2698 LPVOID
* ppv
) /* [out] Destination for queried interface */
2700 HRESULT hret
= E_NOINTERFACE
;
2701 TRACE("(pUnk=%p pInner=%p\n\tIID: %s %p)\n",pUnk
,pInner
,debugstr_guid(riid
), ppv
);
2704 if(pUnk
&& pInner
) {
2705 hret
= IUnknown_QueryInterface(pInner
, riid
, ppv
);
2706 if (SUCCEEDED(hret
)) IUnknown_Release(pUnk
);
2708 TRACE("-- 0x%08x\n", hret
);
2712 /*************************************************************************
2715 * Move a reference from one interface to another.
2718 * lpDest [O] Destination to receive the reference
2719 * lppUnknown [O] Source to give up the reference to lpDest
2724 VOID WINAPI
SHWeakReleaseInterface(IUnknown
*lpDest
, IUnknown
**lppUnknown
)
2726 TRACE("(%p,%p)\n", lpDest
, lppUnknown
);
2731 IUnknown_AddRef(lpDest
);
2732 IUnknown_AtomicRelease(lppUnknown
); /* Release existing interface */
2736 /*************************************************************************
2739 * Convert an ASCII string of a CLSID into a CLSID.
2742 * idstr [I] String representing a CLSID in registry format
2743 * id [O] Destination for the converted CLSID
2746 * Success: TRUE. id contains the converted CLSID.
2749 BOOL WINAPI
GUIDFromStringA(LPCSTR idstr
, CLSID
*id
)
2752 MultiByteToWideChar(CP_ACP
, 0, idstr
, -1, wClsid
, sizeof(wClsid
)/sizeof(WCHAR
));
2753 return SUCCEEDED(CLSIDFromString(wClsid
, id
));
2756 /*************************************************************************
2759 * Unicode version of GUIDFromStringA.
2761 BOOL WINAPI
GUIDFromStringW(LPCWSTR idstr
, CLSID
*id
)
2763 return SUCCEEDED(CLSIDFromString((LPCOLESTR
)idstr
, id
));
2766 /*************************************************************************
2769 * Determine if the browser is integrated into the shell, and set a registry
2776 * 1, If the browser is not integrated.
2777 * 2, If the browser is integrated.
2780 * The key "HKLM\Software\Microsoft\Internet Explorer\IntegratedBrowser" is
2781 * either set to TRUE, or removed depending on whether the browser is deemed
2784 DWORD WINAPI
WhichPlatform(void)
2786 static const char szIntegratedBrowser
[] = "IntegratedBrowser";
2787 static DWORD dwState
= 0;
2789 DWORD dwRet
, dwData
, dwSize
;
2795 /* If shell32 exports DllGetVersion(), the browser is integrated */
2797 hshell32
= LoadLibraryA("shell32.dll");
2800 FARPROC pDllGetVersion
;
2801 pDllGetVersion
= GetProcAddress(hshell32
, "DllGetVersion");
2802 dwState
= pDllGetVersion
? 2 : 1;
2803 FreeLibrary(hshell32
);
2806 /* Set or delete the key accordingly */
2807 dwRet
= RegOpenKeyExA(HKEY_LOCAL_MACHINE
,
2808 "Software\\Microsoft\\Internet Explorer", 0,
2809 KEY_ALL_ACCESS
, &hKey
);
2812 dwRet
= RegQueryValueExA(hKey
, szIntegratedBrowser
, 0, 0,
2813 (LPBYTE
)&dwData
, &dwSize
);
2815 if (!dwRet
&& dwState
== 1)
2817 /* Value exists but browser is not integrated */
2818 RegDeleteValueA(hKey
, szIntegratedBrowser
);
2820 else if (dwRet
&& dwState
== 2)
2822 /* Browser is integrated but value does not exist */
2824 RegSetValueExA(hKey
, szIntegratedBrowser
, 0, REG_DWORD
,
2825 (LPBYTE
)&dwData
, sizeof(dwData
));
2832 /*************************************************************************
2835 * Unicode version of SHCreateWorkerWindowA.
2837 HWND WINAPI
SHCreateWorkerWindowW(LONG wndProc
, HWND hWndParent
, DWORD dwExStyle
,
2838 DWORD dwStyle
, HMENU hMenu
, LONG msg_result
)
2840 static const WCHAR szClass
[] = { 'W', 'o', 'r', 'k', 'e', 'r', 'W', 0 };
2844 TRACE("(0x%08x, %p, 0x%08x, 0x%08x, %p, 0x%08x)\n",
2845 wndProc
, hWndParent
, dwExStyle
, dwStyle
, hMenu
, msg_result
);
2847 /* If our OS is natively ANSI, use the ANSI version */
2848 if (GetVersion() & 0x80000000) /* not NT */
2850 TRACE("fallback to ANSI, ver 0x%08x\n", GetVersion());
2851 return SHCreateWorkerWindowA(wndProc
, hWndParent
, dwExStyle
, dwStyle
, hMenu
, msg_result
);
2854 /* Create Window class */
2856 wc
.lpfnWndProc
= DefWindowProcW
;
2859 wc
.hInstance
= shlwapi_hInstance
;
2861 wc
.hCursor
= LoadCursorW(NULL
, (LPWSTR
)IDC_ARROW
);
2862 wc
.hbrBackground
= (HBRUSH
)(COLOR_BTNFACE
+ 1);
2863 wc
.lpszMenuName
= NULL
;
2864 wc
.lpszClassName
= szClass
;
2866 SHRegisterClassW(&wc
);
2868 hWnd
= CreateWindowExW(dwExStyle
, szClass
, 0, dwStyle
, 0, 0, 0, 0,
2869 hWndParent
, hMenu
, shlwapi_hInstance
, 0);
2872 SetWindowLongPtrW(hWnd
, DWLP_MSGRESULT
, msg_result
);
2874 if (wndProc
) SetWindowLongPtrW(hWnd
, GWLP_WNDPROC
, wndProc
);
2880 /*************************************************************************
2883 * Get and show a context menu from a shell folder.
2886 * hWnd [I] Window displaying the shell folder
2887 * lpFolder [I] IShellFolder interface
2888 * lpApidl [I] Id for the particular folder desired
2892 * Failure: An HRESULT error code indicating the error.
2894 HRESULT WINAPI
SHInvokeDefaultCommand(HWND hWnd
, IShellFolder
* lpFolder
, LPCITEMIDLIST lpApidl
)
2896 TRACE("%p %p %p\n", hWnd
, lpFolder
, lpApidl
);
2897 return SHInvokeCommand(hWnd
, lpFolder
, lpApidl
, 0);
2900 /*************************************************************************
2903 * _SHPackDispParamsV
2905 HRESULT WINAPI
SHPackDispParamsV(DISPPARAMS
*params
, VARIANTARG
*args
, UINT cnt
, __ms_va_list valist
)
2909 TRACE("(%p %p %u ...)\n", params
, args
, cnt
);
2911 params
->rgvarg
= args
;
2912 params
->rgdispidNamedArgs
= NULL
;
2913 params
->cArgs
= cnt
;
2914 params
->cNamedArgs
= 0;
2918 while(iter
-- > args
) {
2919 V_VT(iter
) = va_arg(valist
, enum VARENUM
);
2921 TRACE("vt=%d\n", V_VT(iter
));
2923 if(V_VT(iter
) & VT_BYREF
) {
2924 V_BYREF(iter
) = va_arg(valist
, LPVOID
);
2926 switch(V_VT(iter
)) {
2928 V_I4(iter
) = va_arg(valist
, LONG
);
2931 V_BSTR(iter
) = va_arg(valist
, BSTR
);
2934 V_DISPATCH(iter
) = va_arg(valist
, IDispatch
*);
2937 V_BOOL(iter
) = va_arg(valist
, int);
2940 V_UNKNOWN(iter
) = va_arg(valist
, IUnknown
*);
2944 V_I4(iter
) = va_arg(valist
, LONG
);
2952 /*************************************************************************
2957 HRESULT WINAPIV
SHPackDispParams(DISPPARAMS
*params
, VARIANTARG
*args
, UINT cnt
, ...)
2959 __ms_va_list valist
;
2962 __ms_va_start(valist
, cnt
);
2963 hres
= SHPackDispParamsV(params
, args
, cnt
, valist
);
2964 __ms_va_end(valist
);
2968 /*************************************************************************
2969 * SHLWAPI_InvokeByIID
2971 * This helper function calls IDispatch::Invoke for each sink
2972 * which implements given iid or IDispatch.
2975 static HRESULT
SHLWAPI_InvokeByIID(
2976 IConnectionPoint
* iCP
,
2979 DISPPARAMS
* dispParams
)
2981 IEnumConnections
*enumerator
;
2983 static DISPPARAMS empty
= {NULL
, NULL
, 0, 0};
2984 DISPPARAMS
* params
= dispParams
;
2986 HRESULT result
= IConnectionPoint_EnumConnections(iCP
, &enumerator
);
2990 /* Invoke is never happening with an NULL dispParams */
2994 while(IEnumConnections_Next(enumerator
, 1, &rgcd
, NULL
)==S_OK
)
2996 IDispatch
*dispIface
;
2997 if ((iid
&& SUCCEEDED(IUnknown_QueryInterface(rgcd
.pUnk
, iid
, (LPVOID
*)&dispIface
))) ||
2998 SUCCEEDED(IUnknown_QueryInterface(rgcd
.pUnk
, &IID_IDispatch
, (LPVOID
*)&dispIface
)))
3000 IDispatch_Invoke(dispIface
, dispId
, &IID_NULL
, 0, DISPATCH_METHOD
, params
, NULL
, NULL
, NULL
);
3001 IDispatch_Release(dispIface
);
3003 IUnknown_Release(rgcd
.pUnk
);
3006 IEnumConnections_Release(enumerator
);
3011 /*************************************************************************
3012 * IConnectionPoint_InvokeWithCancel [SHLWAPI.283]
3014 HRESULT WINAPI
IConnectionPoint_InvokeWithCancel( IConnectionPoint
* iCP
,
3015 DISPID dispId
, DISPPARAMS
* dispParams
,
3016 DWORD unknown1
, DWORD unknown2
)
3021 FIXME("(%p)->(0x%x %p %x %x) partial stub\n", iCP
, dispId
, dispParams
, unknown1
, unknown2
);
3023 result
= IConnectionPoint_GetConnectionInterface(iCP
, &iid
);
3024 if (SUCCEEDED(result
))
3025 result
= SHLWAPI_InvokeByIID(iCP
, &iid
, dispId
, dispParams
);
3027 result
= SHLWAPI_InvokeByIID(iCP
, NULL
, dispId
, dispParams
);
3033 /*************************************************************************
3036 * IConnectionPoint_SimpleInvoke
3038 HRESULT WINAPI
IConnectionPoint_SimpleInvoke(
3039 IConnectionPoint
* iCP
,
3041 DISPPARAMS
* dispParams
)
3046 TRACE("(%p)->(0x%x %p)\n",iCP
,dispId
,dispParams
);
3048 result
= IConnectionPoint_GetConnectionInterface(iCP
, &iid
);
3049 if (SUCCEEDED(result
))
3050 result
= SHLWAPI_InvokeByIID(iCP
, &iid
, dispId
, dispParams
);
3052 result
= SHLWAPI_InvokeByIID(iCP
, NULL
, dispId
, dispParams
);
3057 /*************************************************************************
3060 * Notify an IConnectionPoint object of changes.
3063 * lpCP [I] Object to notify
3068 * Failure: E_NOINTERFACE, if lpCP is NULL or does not support the
3069 * IConnectionPoint interface.
3071 HRESULT WINAPI
IConnectionPoint_OnChanged(IConnectionPoint
* lpCP
, DISPID dispID
)
3073 IEnumConnections
*lpEnum
;
3074 HRESULT hRet
= E_NOINTERFACE
;
3076 TRACE("(%p,0x%8X)\n", lpCP
, dispID
);
3078 /* Get an enumerator for the connections */
3080 hRet
= IConnectionPoint_EnumConnections(lpCP
, &lpEnum
);
3082 if (SUCCEEDED(hRet
))
3084 IPropertyNotifySink
*lpSink
;
3085 CONNECTDATA connData
;
3088 /* Call OnChanged() for every notify sink in the connection point */
3089 while (IEnumConnections_Next(lpEnum
, 1, &connData
, &ulFetched
) == S_OK
)
3091 if (SUCCEEDED(IUnknown_QueryInterface(connData
.pUnk
, &IID_IPropertyNotifySink
, (void**)&lpSink
)) &&
3094 IPropertyNotifySink_OnChanged(lpSink
, dispID
);
3095 IPropertyNotifySink_Release(lpSink
);
3097 IUnknown_Release(connData
.pUnk
);
3100 IEnumConnections_Release(lpEnum
);
3105 /*************************************************************************
3108 * IUnknown_CPContainerInvokeParam
3110 HRESULT WINAPIV
IUnknown_CPContainerInvokeParam(
3111 IUnknown
*container
,
3118 IConnectionPoint
*iCP
;
3119 IConnectionPointContainer
*iCPC
;
3120 DISPPARAMS dispParams
= {buffer
, NULL
, cParams
, 0};
3121 __ms_va_list valist
;
3124 return E_NOINTERFACE
;
3126 result
= IUnknown_QueryInterface(container
, &IID_IConnectionPointContainer
,(LPVOID
*) &iCPC
);
3130 result
= IConnectionPointContainer_FindConnectionPoint(iCPC
, riid
, &iCP
);
3131 IConnectionPointContainer_Release(iCPC
);
3135 __ms_va_start(valist
, cParams
);
3136 SHPackDispParamsV(&dispParams
, buffer
, cParams
, valist
);
3137 __ms_va_end(valist
);
3139 result
= SHLWAPI_InvokeByIID(iCP
, riid
, dispId
, &dispParams
);
3140 IConnectionPoint_Release(iCP
);
3145 /*************************************************************************
3148 * Notify an IConnectionPointContainer object of changes.
3151 * lpUnknown [I] Object to notify
3156 * Failure: E_NOINTERFACE, if lpUnknown is NULL or does not support the
3157 * IConnectionPointContainer interface.
3159 HRESULT WINAPI
IUnknown_CPContainerOnChanged(IUnknown
*lpUnknown
, DISPID dispID
)
3161 IConnectionPointContainer
* lpCPC
= NULL
;
3162 HRESULT hRet
= E_NOINTERFACE
;
3164 TRACE("(%p,0x%8X)\n", lpUnknown
, dispID
);
3167 hRet
= IUnknown_QueryInterface(lpUnknown
, &IID_IConnectionPointContainer
, (void**)&lpCPC
);
3169 if (SUCCEEDED(hRet
))
3171 IConnectionPoint
* lpCP
;
3173 hRet
= IConnectionPointContainer_FindConnectionPoint(lpCPC
, &IID_IPropertyNotifySink
, &lpCP
);
3174 IConnectionPointContainer_Release(lpCPC
);
3176 hRet
= IConnectionPoint_OnChanged(lpCP
, dispID
);
3177 IConnectionPoint_Release(lpCP
);
3182 /*************************************************************************
3187 BOOL WINAPI
PlaySoundWrapW(LPCWSTR pszSound
, HMODULE hmod
, DWORD fdwSound
)
3189 return PlaySoundW(pszSound
, hmod
, fdwSound
);
3192 /*************************************************************************
3195 * Retrieve a key value from an INI file. See GetPrivateProfileString for
3199 * appName [I] The section in the INI file that contains the key
3200 * keyName [I] The key to be retrieved
3201 * out [O] The buffer into which the key's value will be copied
3202 * outLen [I] The length of the `out' buffer
3203 * filename [I] The location of the INI file
3206 * Length of string copied into `out'.
3208 DWORD WINAPI
SHGetIniStringW(LPCWSTR appName
, LPCWSTR keyName
, LPWSTR out
,
3209 DWORD outLen
, LPCWSTR filename
)
3214 TRACE("(%s,%s,%p,%08x,%s)\n", debugstr_w(appName
), debugstr_w(keyName
),
3215 out
, outLen
, debugstr_w(filename
));
3220 buf
= HeapAlloc(GetProcessHeap(), 0, outLen
* sizeof(WCHAR
));
3226 ret
= GetPrivateProfileStringW(appName
, keyName
, NULL
, buf
, outLen
, filename
);
3232 HeapFree(GetProcessHeap(), 0, buf
);
3234 return strlenW(out
);
3237 /*************************************************************************
3240 * Set a key value in an INI file. See WritePrivateProfileString for
3244 * appName [I] The section in the INI file that contains the key
3245 * keyName [I] The key to be set
3246 * str [O] The value of the key
3247 * filename [I] The location of the INI file
3253 BOOL WINAPI
SHSetIniStringW(LPCWSTR appName
, LPCWSTR keyName
, LPCWSTR str
,
3256 TRACE("(%s, %p, %s, %s)\n", debugstr_w(appName
), keyName
, debugstr_w(str
),
3257 debugstr_w(filename
));
3259 return WritePrivateProfileStringW(appName
, keyName
, str
, filename
);
3262 /*************************************************************************
3265 * See SHGetFileInfoW.
3267 DWORD WINAPI
SHGetFileInfoWrapW(LPCWSTR path
, DWORD dwFileAttributes
,
3268 SHFILEINFOW
*psfi
, UINT sizeofpsfi
, UINT flags
)
3270 return SHGetFileInfoW(path
, dwFileAttributes
, psfi
, sizeofpsfi
, flags
);
3273 /*************************************************************************
3276 * See DragQueryFileW.
3278 UINT WINAPI
DragQueryFileWrapW(HDROP hDrop
, UINT lFile
, LPWSTR lpszFile
, UINT lLength
)
3280 return DragQueryFileW(hDrop
, lFile
, lpszFile
, lLength
);
3283 /*************************************************************************
3286 * See SHBrowseForFolderW.
3288 LPITEMIDLIST WINAPI
SHBrowseForFolderWrapW(LPBROWSEINFOW lpBi
)
3290 return SHBrowseForFolderW(lpBi
);
3293 /*************************************************************************
3296 * See SHGetPathFromIDListW.
3298 BOOL WINAPI
SHGetPathFromIDListWrapW(LPCITEMIDLIST pidl
,LPWSTR pszPath
)
3300 return SHGetPathFromIDListW(pidl
, pszPath
);
3303 /*************************************************************************
3306 * See ShellExecuteExW.
3308 BOOL WINAPI
ShellExecuteExWrapW(LPSHELLEXECUTEINFOW lpExecInfo
)
3310 return ShellExecuteExW(lpExecInfo
);
3313 /*************************************************************************
3316 * See SHFileOperationW.
3318 INT WINAPI
SHFileOperationWrapW(LPSHFILEOPSTRUCTW lpFileOp
)
3320 return SHFileOperationW(lpFileOp
);
3323 /*************************************************************************
3327 PVOID WINAPI
SHInterlockedCompareExchange( PVOID
*dest
, PVOID xchg
, PVOID compare
)
3329 return InterlockedCompareExchangePointer( dest
, xchg
, compare
);
3332 /*************************************************************************
3335 * See GetFileVersionInfoSizeW.
3337 DWORD WINAPI
GetFileVersionInfoSizeWrapW( LPCWSTR filename
, LPDWORD handle
)
3339 return GetFileVersionInfoSizeW( filename
, handle
);
3342 /*************************************************************************
3345 * See GetFileVersionInfoW.
3347 BOOL WINAPI
GetFileVersionInfoWrapW( LPCWSTR filename
, DWORD handle
,
3348 DWORD datasize
, LPVOID data
)
3350 return GetFileVersionInfoW( filename
, handle
, datasize
, data
);
3353 /*************************************************************************
3356 * See VerQueryValueW.
3358 WORD WINAPI
VerQueryValueWrapW( LPVOID pBlock
, LPCWSTR lpSubBlock
,
3359 LPVOID
*lplpBuffer
, UINT
*puLen
)
3361 return VerQueryValueW( pBlock
, lpSubBlock
, lplpBuffer
, puLen
);
3364 #define IsIface(type) SUCCEEDED((hRet = IUnknown_QueryInterface(lpUnknown, &IID_##type, (void**)&lpObj)))
3365 #define IShellBrowser_EnableModeless IShellBrowser_EnableModelessSB
3366 #define EnableModeless(type) type##_EnableModeless((type*)lpObj, bModeless)
3368 /*************************************************************************
3371 * Change the modality of a shell object.
3374 * lpUnknown [I] Object to make modeless
3375 * bModeless [I] TRUE=Make modeless, FALSE=Make modal
3378 * Success: S_OK. The modality lpUnknown is changed.
3379 * Failure: An HRESULT error code indicating the error.
3382 * lpUnknown must support the IOleInPlaceFrame interface, the
3383 * IInternetSecurityMgrSite interface, the IShellBrowser interface
3384 * the IDocHostUIHandler interface, or the IOleInPlaceActiveObject interface,
3385 * or this call will fail.
3387 HRESULT WINAPI
IUnknown_EnableModeless(IUnknown
*lpUnknown
, BOOL bModeless
)
3392 TRACE("(%p,%d)\n", lpUnknown
, bModeless
);
3397 if (IsIface(IOleInPlaceActiveObject
))
3398 EnableModeless(IOleInPlaceActiveObject
);
3399 else if (IsIface(IOleInPlaceFrame
))
3400 EnableModeless(IOleInPlaceFrame
);
3401 else if (IsIface(IShellBrowser
))
3402 EnableModeless(IShellBrowser
);
3403 else if (IsIface(IInternetSecurityMgrSite
))
3404 EnableModeless(IInternetSecurityMgrSite
);
3405 else if (IsIface(IDocHostUIHandler
))
3406 EnableModeless(IDocHostUIHandler
);
3410 IUnknown_Release(lpObj
);
3414 /*************************************************************************
3417 * See SHGetNewLinkInfoW.
3419 BOOL WINAPI
SHGetNewLinkInfoWrapW(LPCWSTR pszLinkTo
, LPCWSTR pszDir
, LPWSTR pszName
,
3420 BOOL
*pfMustCopy
, UINT uFlags
)
3422 return SHGetNewLinkInfoW(pszLinkTo
, pszDir
, pszName
, pfMustCopy
, uFlags
);
3425 /*************************************************************************
3428 * See SHDefExtractIconW.
3430 UINT WINAPI
SHDefExtractIconWrapW(LPCWSTR pszIconFile
, int iIndex
, UINT uFlags
, HICON
* phiconLarge
,
3431 HICON
* phiconSmall
, UINT nIconSize
)
3433 return SHDefExtractIconW(pszIconFile
, iIndex
, uFlags
, phiconLarge
, phiconSmall
, nIconSize
);
3436 /*************************************************************************
3439 * Get and show a context menu from a shell folder.
3442 * hWnd [I] Window displaying the shell folder
3443 * lpFolder [I] IShellFolder interface
3444 * lpApidl [I] Id for the particular folder desired
3445 * dwCommandId [I] The command ID to invoke (0=invoke default)
3448 * Success: S_OK. If bInvokeDefault is TRUE, the default menu action was
3450 * Failure: An HRESULT error code indicating the error.
3452 HRESULT WINAPI
SHInvokeCommand(HWND hWnd
, IShellFolder
* lpFolder
, LPCITEMIDLIST lpApidl
, DWORD dwCommandId
)
3454 IContextMenu
*iContext
;
3457 TRACE("(%p, %p, %p, %u)\n", hWnd
, lpFolder
, lpApidl
, dwCommandId
);
3462 /* Get the context menu from the shell folder */
3463 hRet
= IShellFolder_GetUIObjectOf(lpFolder
, hWnd
, 1, &lpApidl
,
3464 &IID_IContextMenu
, 0, (void**)&iContext
);
3465 if (SUCCEEDED(hRet
))
3468 if ((hMenu
= CreatePopupMenu()))
3472 /* Add the context menu entries to the popup */
3473 hQuery
= IContextMenu_QueryContextMenu(iContext
, hMenu
, 0, 1, 0x7FFF,
3474 dwCommandId
? CMF_NORMAL
: CMF_DEFAULTONLY
);
3476 if (SUCCEEDED(hQuery
))
3479 dwCommandId
= GetMenuDefaultItem(hMenu
, 0, 0);
3480 if (dwCommandId
!= (UINT
)-1)
3482 CMINVOKECOMMANDINFO cmIci
;
3483 /* Invoke the default item */
3484 memset(&cmIci
,0,sizeof(cmIci
));
3485 cmIci
.cbSize
= sizeof(cmIci
);
3486 cmIci
.fMask
= CMIC_MASK_ASYNCOK
;
3488 cmIci
.lpVerb
= MAKEINTRESOURCEA(dwCommandId
);
3489 cmIci
.nShow
= SW_SHOWNORMAL
;
3491 hRet
= IContextMenu_InvokeCommand(iContext
, &cmIci
);
3496 IContextMenu_Release(iContext
);
3501 /*************************************************************************
3506 HICON WINAPI
ExtractIconWrapW(HINSTANCE hInstance
, LPCWSTR lpszExeFileName
,
3509 return ExtractIconW(hInstance
, lpszExeFileName
, nIconIndex
);
3512 /*************************************************************************
3515 * Load a library from the directory of a particular process.
3518 * new_mod [I] Library name
3519 * inst_hwnd [I] Module whose directory is to be used
3520 * dwCrossCodePage [I] Should be FALSE (currently ignored)
3523 * Success: A handle to the loaded module
3524 * Failure: A NULL handle.
3526 HMODULE WINAPI
MLLoadLibraryA(LPCSTR new_mod
, HMODULE inst_hwnd
, DWORD dwCrossCodePage
)
3528 /* FIXME: Native appears to do DPA_Create and a DPA_InsertPtr for
3530 * FIXME: Native shows calls to:
3531 * SHRegGetUSValue for "Software\Microsoft\Internet Explorer\International"
3533 * RegOpenKeyExA for "HKLM\Software\Microsoft\Internet Explorer"
3534 * RegQueryValueExA for "LPKInstalled"
3536 * RegOpenKeyExA for "HKCU\Software\Microsoft\Internet Explorer\International"
3537 * RegQueryValueExA for "ResourceLocale"
3539 * RegOpenKeyExA for "HKLM\Software\Microsoft\Active Setup\Installed Components\{guid}"
3540 * RegQueryValueExA for "Locale"
3542 * and then tests the Locale ("en" for me).
3544 * after the code then a DPA_Create (first time) and DPA_InsertPtr are done.
3546 CHAR mod_path
[2*MAX_PATH
];
3550 FIXME("(%s,%p,%d) semi-stub!\n", debugstr_a(new_mod
), inst_hwnd
, dwCrossCodePage
);
3551 len
= GetModuleFileNameA(inst_hwnd
, mod_path
, sizeof(mod_path
));
3552 if (!len
|| len
>= sizeof(mod_path
)) return NULL
;
3554 ptr
= strrchr(mod_path
, '\\');
3556 strcpy(ptr
+1, new_mod
);
3557 TRACE("loading %s\n", debugstr_a(mod_path
));
3558 return LoadLibraryA(mod_path
);
3563 /*************************************************************************
3566 * Unicode version of MLLoadLibraryA.
3568 HMODULE WINAPI
MLLoadLibraryW(LPCWSTR new_mod
, HMODULE inst_hwnd
, DWORD dwCrossCodePage
)
3570 WCHAR mod_path
[2*MAX_PATH
];
3574 FIXME("(%s,%p,%d) semi-stub!\n", debugstr_w(new_mod
), inst_hwnd
, dwCrossCodePage
);
3575 len
= GetModuleFileNameW(inst_hwnd
, mod_path
, sizeof(mod_path
) / sizeof(WCHAR
));
3576 if (!len
|| len
>= sizeof(mod_path
) / sizeof(WCHAR
)) return NULL
;
3578 ptr
= strrchrW(mod_path
, '\\');
3580 strcpyW(ptr
+1, new_mod
);
3581 TRACE("loading %s\n", debugstr_w(mod_path
));
3582 return LoadLibraryW(mod_path
);
3587 /*************************************************************************
3588 * ColorAdjustLuma [SHLWAPI.@]
3590 * Adjust the luminosity of a color
3593 * cRGB [I] RGB value to convert
3594 * dwLuma [I] Luma adjustment
3595 * bUnknown [I] Unknown
3598 * The adjusted RGB color.
3600 COLORREF WINAPI
ColorAdjustLuma(COLORREF cRGB
, int dwLuma
, BOOL bUnknown
)
3602 TRACE("(0x%8x,%d,%d)\n", cRGB
, dwLuma
, bUnknown
);
3608 ColorRGBToHLS(cRGB
, &wH
, &wL
, &wS
);
3610 FIXME("Ignoring luma adjustment\n");
3612 /* FIXME: The adjustment is not linear */
3614 cRGB
= ColorHLSToRGB(wH
, wL
, wS
);
3619 /*************************************************************************
3622 * See GetSaveFileNameW.
3624 BOOL WINAPI
GetSaveFileNameWrapW(LPOPENFILENAMEW ofn
)
3626 return GetSaveFileNameW(ofn
);
3629 /*************************************************************************
3632 * See WNetRestoreConnectionW.
3634 DWORD WINAPI
WNetRestoreConnectionWrapW(HWND hwndOwner
, LPWSTR lpszDevice
)
3636 return WNetRestoreConnectionW(hwndOwner
, lpszDevice
);
3639 /*************************************************************************
3642 * See WNetGetLastErrorW.
3644 DWORD WINAPI
WNetGetLastErrorWrapW(LPDWORD lpError
, LPWSTR lpErrorBuf
, DWORD nErrorBufSize
,
3645 LPWSTR lpNameBuf
, DWORD nNameBufSize
)
3647 return WNetGetLastErrorW(lpError
, lpErrorBuf
, nErrorBufSize
, lpNameBuf
, nNameBufSize
);
3650 /*************************************************************************
3653 * See PageSetupDlgW.
3655 BOOL WINAPI
PageSetupDlgWrapW(LPPAGESETUPDLGW pagedlg
)
3657 return PageSetupDlgW(pagedlg
);
3660 /*************************************************************************
3665 BOOL WINAPI
PrintDlgWrapW(LPPRINTDLGW printdlg
)
3667 return PrintDlgW(printdlg
);
3670 /*************************************************************************
3673 * See GetOpenFileNameW.
3675 BOOL WINAPI
GetOpenFileNameWrapW(LPOPENFILENAMEW ofn
)
3677 return GetOpenFileNameW(ofn
);
3680 /*************************************************************************
3683 HRESULT WINAPI
SHIShellFolder_EnumObjects(LPSHELLFOLDER lpFolder
, HWND hwnd
, SHCONTF flags
, IEnumIDList
**ppenum
)
3685 /* Windows attempts to get an IPersist interface and, if that fails, an
3686 * IPersistFolder interface on the folder passed-in here. If one of those
3687 * interfaces is available, it then calls GetClassID on the folder... and
3688 * then calls IShellFolder_EnumObjects no matter what, even crashing if
3689 * lpFolder isn't actually an IShellFolder object. The purpose of getting
3690 * the ClassID is unknown, so we don't do it here.
3692 * For discussion and detailed tests, see:
3693 * "shlwapi: Be less strict on which type of IShellFolder can be enumerated"
3694 * wine-devel mailing list, 3 Jun 2010
3697 return IShellFolder_EnumObjects(lpFolder
, hwnd
, flags
, ppenum
);
3700 /* INTERNAL: Map from HLS color space to RGB */
3701 static WORD
ConvertHue(int wHue
, WORD wMid1
, WORD wMid2
)
3703 wHue
= wHue
> 240 ? wHue
- 240 : wHue
< 0 ? wHue
+ 240 : wHue
;
3707 else if (wHue
> 120)
3712 return ((wHue
* (wMid2
- wMid1
) + 20) / 40) + wMid1
;
3715 /* Convert to RGB and scale into RGB range (0..255) */
3716 #define GET_RGB(h) (ConvertHue(h, wMid1, wMid2) * 255 + 120) / 240
3718 /*************************************************************************
3719 * ColorHLSToRGB [SHLWAPI.@]
3721 * Convert from hls color space into an rgb COLORREF.
3724 * wHue [I] Hue amount
3725 * wLuminosity [I] Luminosity amount
3726 * wSaturation [I] Saturation amount
3729 * A COLORREF representing the converted color.
3732 * Input hls values are constrained to the range (0..240).
3734 COLORREF WINAPI
ColorHLSToRGB(WORD wHue
, WORD wLuminosity
, WORD wSaturation
)
3740 WORD wGreen
, wBlue
, wMid1
, wMid2
;
3742 if (wLuminosity
> 120)
3743 wMid2
= wSaturation
+ wLuminosity
- (wSaturation
* wLuminosity
+ 120) / 240;
3745 wMid2
= ((wSaturation
+ 240) * wLuminosity
+ 120) / 240;
3747 wMid1
= wLuminosity
* 2 - wMid2
;
3749 wRed
= GET_RGB(wHue
+ 80);
3750 wGreen
= GET_RGB(wHue
);
3751 wBlue
= GET_RGB(wHue
- 80);
3753 return RGB(wRed
, wGreen
, wBlue
);
3756 wRed
= wLuminosity
* 255 / 240;
3757 return RGB(wRed
, wRed
, wRed
);
3760 /*************************************************************************
3763 * Get the current docking status of the system.
3766 * dwFlags [I] DOCKINFO_ flags from "winbase.h", unused
3769 * One of DOCKINFO_UNDOCKED, DOCKINFO_UNDOCKED, or 0 if the system is not
3772 DWORD WINAPI
SHGetMachineInfo(DWORD dwFlags
)
3774 HW_PROFILE_INFOA hwInfo
;
3776 TRACE("(0x%08x)\n", dwFlags
);
3778 GetCurrentHwProfileA(&hwInfo
);
3779 switch (hwInfo
.dwDockInfo
& (DOCKINFO_DOCKED
|DOCKINFO_UNDOCKED
))
3781 case DOCKINFO_DOCKED
:
3782 case DOCKINFO_UNDOCKED
:
3783 return hwInfo
.dwDockInfo
& (DOCKINFO_DOCKED
|DOCKINFO_UNDOCKED
);
3789 /*************************************************************************
3793 DWORD WINAPI
SHWinHelpOnDemandW(HWND hwnd
, LPCWSTR helpfile
, DWORD flags1
, VOID
*ptr1
, DWORD flags2
)
3796 FIXME("(%p, %s, 0x%x, %p, %d)\n", hwnd
, debugstr_w(helpfile
), flags1
, ptr1
, flags2
);
3800 /*************************************************************************
3804 DWORD WINAPI
SHWinHelpOnDemandA(HWND hwnd
, LPCSTR helpfile
, DWORD flags1
, VOID
*ptr1
, DWORD flags2
)
3807 FIXME("(%p, %s, 0x%x, %p, %d)\n", hwnd
, debugstr_a(helpfile
), flags1
, ptr1
, flags2
);
3811 /*************************************************************************
3814 * Function seems to do FreeLibrary plus other things.
3816 * FIXME native shows the following calls:
3817 * RtlEnterCriticalSection
3819 * GetProcAddress(Comctl32??, 150L)
3821 * RtlLeaveCriticalSection
3822 * followed by the FreeLibrary.
3823 * The above code may be related to .377 above.
3825 BOOL WINAPI
MLFreeLibrary(HMODULE hModule
)
3827 FIXME("(%p) semi-stub\n", hModule
);
3828 return FreeLibrary(hModule
);
3831 /*************************************************************************
3834 BOOL WINAPI
SHFlushSFCacheWrap(void) {
3839 /*************************************************************************
3841 * FIXME I have no idea what this function does or what its arguments are.
3843 BOOL WINAPI
MLIsMLHInstance(HINSTANCE hInst
)
3845 FIXME("(%p) stub\n", hInst
);
3850 /*************************************************************************
3853 DWORD WINAPI
MLSetMLHInstance(HINSTANCE hInst
, HANDLE hHeap
)
3855 FIXME("(%p,%p) stub\n", hInst
, hHeap
);
3856 return E_FAIL
; /* This is what is used if shlwapi not loaded */
3859 /*************************************************************************
3862 DWORD WINAPI
MLClearMLHInstance(DWORD x
)
3864 FIXME("(0x%08x)stub\n", x
);
3868 /*************************************************************************
3871 * See SHSendMessageBroadcastW
3874 DWORD WINAPI
SHSendMessageBroadcastA(UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
3876 return SendMessageTimeoutA(HWND_BROADCAST
, uMsg
, wParam
, lParam
,
3877 SMTO_ABORTIFHUNG
, 2000, NULL
);
3880 /*************************************************************************
3883 * A wrapper for sending Broadcast Messages to all top level Windows
3886 DWORD WINAPI
SHSendMessageBroadcastW(UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
3888 return SendMessageTimeoutW(HWND_BROADCAST
, uMsg
, wParam
, lParam
,
3889 SMTO_ABORTIFHUNG
, 2000, NULL
);
3892 /*************************************************************************
3895 * Convert a Unicode string CLSID into a CLSID.
3898 * idstr [I] string containing a CLSID in text form
3899 * id [O] CLSID extracted from the string
3902 * S_OK on success or E_INVALIDARG on failure
3904 HRESULT WINAPI
CLSIDFromStringWrap(LPCWSTR idstr
, CLSID
*id
)
3906 return CLSIDFromString((LPCOLESTR
)idstr
, id
);
3909 /*************************************************************************
3912 * Determine if the OS supports a given feature.
3915 * dwFeature [I] Feature requested (undocumented)
3918 * TRUE If the feature is available.
3919 * FALSE If the feature is not available.
3921 BOOL WINAPI
IsOS(DWORD feature
)
3923 OSVERSIONINFOA osvi
;
3924 DWORD platform
, majorv
, minorv
;
3926 osvi
.dwOSVersionInfoSize
= sizeof(OSVERSIONINFOA
);
3927 if(!GetVersionExA(&osvi
)) {
3928 ERR("GetVersionEx failed\n");
3932 majorv
= osvi
.dwMajorVersion
;
3933 minorv
= osvi
.dwMinorVersion
;
3934 platform
= osvi
.dwPlatformId
;
3936 #define ISOS_RETURN(x) \
3937 TRACE("(0x%x) ret=%d\n",feature,(x)); \
3941 case OS_WIN32SORGREATER
:
3942 ISOS_RETURN(platform
== VER_PLATFORM_WIN32s
3943 || platform
== VER_PLATFORM_WIN32_WINDOWS
)
3945 ISOS_RETURN(platform
== VER_PLATFORM_WIN32_NT
)
3946 case OS_WIN95ORGREATER
:
3947 ISOS_RETURN(platform
== VER_PLATFORM_WIN32_WINDOWS
)
3948 case OS_NT4ORGREATER
:
3949 ISOS_RETURN(platform
== VER_PLATFORM_WIN32_NT
&& majorv
>= 4)
3950 case OS_WIN2000ORGREATER_ALT
:
3951 case OS_WIN2000ORGREATER
:
3952 ISOS_RETURN(platform
== VER_PLATFORM_WIN32_NT
&& majorv
>= 5)
3953 case OS_WIN98ORGREATER
:
3954 ISOS_RETURN(platform
== VER_PLATFORM_WIN32_WINDOWS
&& minorv
>= 10)
3956 ISOS_RETURN(platform
== VER_PLATFORM_WIN32_WINDOWS
&& minorv
== 10)
3958 ISOS_RETURN(platform
== VER_PLATFORM_WIN32_NT
&& majorv
>= 5)
3959 case OS_WIN2000SERVER
:
3960 ISOS_RETURN(platform
== VER_PLATFORM_WIN32_NT
&& (minorv
== 0 || minorv
== 1))
3961 case OS_WIN2000ADVSERVER
:
3962 ISOS_RETURN(platform
== VER_PLATFORM_WIN32_NT
&& (minorv
== 0 || minorv
== 1))
3963 case OS_WIN2000DATACENTER
:
3964 ISOS_RETURN(platform
== VER_PLATFORM_WIN32_NT
&& (minorv
== 0 || minorv
== 1))
3965 case OS_WIN2000TERMINAL
:
3966 ISOS_RETURN(platform
== VER_PLATFORM_WIN32_NT
&& (minorv
== 0 || minorv
== 1))
3968 FIXME("(OS_EMBEDDED) What should we return here?\n");
3970 case OS_TERMINALCLIENT
:
3971 FIXME("(OS_TERMINALCLIENT) What should we return here?\n");
3973 case OS_TERMINALREMOTEADMIN
:
3974 FIXME("(OS_TERMINALREMOTEADMIN) What should we return here?\n");
3977 ISOS_RETURN(platform
== VER_PLATFORM_WIN32_WINDOWS
&& minorv
== 0)
3978 case OS_MEORGREATER
:
3979 ISOS_RETURN(platform
== VER_PLATFORM_WIN32_WINDOWS
&& minorv
>= 90)
3980 case OS_XPORGREATER
:
3981 ISOS_RETURN(platform
== VER_PLATFORM_WIN32_NT
&& majorv
>= 5 && minorv
>= 1)
3983 ISOS_RETURN(platform
== VER_PLATFORM_WIN32_NT
&& majorv
>= 5 && minorv
>= 1)
3984 case OS_PROFESSIONAL
:
3985 ISOS_RETURN(platform
== VER_PLATFORM_WIN32_NT
)
3987 ISOS_RETURN(platform
== VER_PLATFORM_WIN32_NT
)
3989 ISOS_RETURN(platform
== VER_PLATFORM_WIN32_NT
&& majorv
>= 5)
3991 ISOS_RETURN(platform
== VER_PLATFORM_WIN32_NT
)
3992 case OS_TERMINALSERVER
:
3993 ISOS_RETURN(platform
== VER_PLATFORM_WIN32_NT
)
3994 case OS_PERSONALTERMINALSERVER
:
3995 ISOS_RETURN(platform
== VER_PLATFORM_WIN32_NT
&& minorv
>= 1 && majorv
>= 5)
3996 case OS_FASTUSERSWITCHING
:
3997 FIXME("(OS_FASTUSERSWITCHING) What should we return here?\n");
3999 case OS_WELCOMELOGONUI
:
4000 FIXME("(OS_WELCOMELOGONUI) What should we return here?\n");
4002 case OS_DOMAINMEMBER
:
4003 FIXME("(OS_DOMAINMEMBER) What should we return here?\n");
4006 ISOS_RETURN(platform
== VER_PLATFORM_WIN32_NT
)
4010 IsWow64Process(GetCurrentProcess(), &is_wow64
);
4014 ISOS_RETURN(platform
== VER_PLATFORM_WIN32_NT
)
4015 case OS_SMALLBUSINESSSERVER
:
4016 ISOS_RETURN(platform
== VER_PLATFORM_WIN32_NT
)
4018 FIXME("(OS_TABLEPC) What should we return here?\n");
4020 case OS_SERVERADMINUI
:
4021 FIXME("(OS_SERVERADMINUI) What should we return here?\n");
4023 case OS_MEDIACENTER
:
4024 FIXME("(OS_MEDIACENTER) What should we return here?\n");
4027 FIXME("(OS_APPLIANCE) What should we return here?\n");
4029 case 0x25: /*OS_VISTAORGREATER*/
4030 ISOS_RETURN(platform
== VER_PLATFORM_WIN32_NT
&& majorv
>= 6)
4035 WARN("(0x%x) unknown parameter\n",feature
);
4040 /*************************************************************************
4043 HRESULT WINAPI
SHLoadRegUIStringW(HKEY hkey
, LPCWSTR value
, LPWSTR buf
, DWORD size
)
4045 DWORD type
, sz
= size
;
4047 if(RegQueryValueExW(hkey
, value
, NULL
, &type
, (LPBYTE
)buf
, &sz
) != ERROR_SUCCESS
)
4050 return SHLoadIndirectString(buf
, buf
, size
, NULL
);
4053 /*************************************************************************
4056 * Call IInputObject_TranslateAcceleratorIO() on an object.
4059 * lpUnknown [I] Object supporting the IInputObject interface.
4060 * lpMsg [I] Key message to be processed.
4064 * Failure: An HRESULT error code, or E_INVALIDARG if lpUnknown is NULL.
4066 HRESULT WINAPI
IUnknown_TranslateAcceleratorIO(IUnknown
*lpUnknown
, LPMSG lpMsg
)
4068 IInputObject
* lpInput
= NULL
;
4069 HRESULT hRet
= E_INVALIDARG
;
4071 TRACE("(%p,%p)\n", lpUnknown
, lpMsg
);
4074 hRet
= IUnknown_QueryInterface(lpUnknown
, &IID_IInputObject
,
4076 if (SUCCEEDED(hRet
) && lpInput
)
4078 hRet
= IInputObject_TranslateAcceleratorIO(lpInput
, lpMsg
);
4079 IInputObject_Release(lpInput
);
4085 /*************************************************************************
4088 * Call IInputObject_HasFocusIO() on an object.
4091 * lpUnknown [I] Object supporting the IInputObject interface.
4094 * Success: S_OK, if lpUnknown is an IInputObject object and has the focus,
4095 * or S_FALSE otherwise.
4096 * Failure: An HRESULT error code, or E_INVALIDARG if lpUnknown is NULL.
4098 HRESULT WINAPI
IUnknown_HasFocusIO(IUnknown
*lpUnknown
)
4100 IInputObject
* lpInput
= NULL
;
4101 HRESULT hRet
= E_INVALIDARG
;
4103 TRACE("(%p)\n", lpUnknown
);
4106 hRet
= IUnknown_QueryInterface(lpUnknown
, &IID_IInputObject
,
4108 if (SUCCEEDED(hRet
) && lpInput
)
4110 hRet
= IInputObject_HasFocusIO(lpInput
);
4111 IInputObject_Release(lpInput
);
4117 /*************************************************************************
4118 * ColorRGBToHLS [SHLWAPI.@]
4120 * Convert an rgb COLORREF into the hls color space.
4123 * cRGB [I] Source rgb value
4124 * pwHue [O] Destination for converted hue
4125 * pwLuminance [O] Destination for converted luminance
4126 * pwSaturation [O] Destination for converted saturation
4129 * Nothing. pwHue, pwLuminance and pwSaturation are set to the converted
4133 * Output HLS values are constrained to the range (0..240).
4134 * For Achromatic conversions, Hue is set to 160.
4136 VOID WINAPI
ColorRGBToHLS(COLORREF cRGB
, LPWORD pwHue
,
4137 LPWORD pwLuminance
, LPWORD pwSaturation
)
4139 int wR
, wG
, wB
, wMax
, wMin
, wHue
, wLuminosity
, wSaturation
;
4141 TRACE("(%08x,%p,%p,%p)\n", cRGB
, pwHue
, pwLuminance
, pwSaturation
);
4143 wR
= GetRValue(cRGB
);
4144 wG
= GetGValue(cRGB
);
4145 wB
= GetBValue(cRGB
);
4147 wMax
= max(wR
, max(wG
, wB
));
4148 wMin
= min(wR
, min(wG
, wB
));
4151 wLuminosity
= ((wMax
+ wMin
) * 240 + 255) / 510;
4155 /* Achromatic case */
4157 /* Hue is now unrepresentable, but this is what native returns... */
4162 /* Chromatic case */
4163 int wDelta
= wMax
- wMin
, wRNorm
, wGNorm
, wBNorm
;
4166 if (wLuminosity
<= 120)
4167 wSaturation
= ((wMax
+ wMin
)/2 + wDelta
* 240) / (wMax
+ wMin
);
4169 wSaturation
= ((510 - wMax
- wMin
)/2 + wDelta
* 240) / (510 - wMax
- wMin
);
4172 wRNorm
= (wDelta
/2 + wMax
* 40 - wR
* 40) / wDelta
;
4173 wGNorm
= (wDelta
/2 + wMax
* 40 - wG
* 40) / wDelta
;
4174 wBNorm
= (wDelta
/2 + wMax
* 40 - wB
* 40) / wDelta
;
4177 wHue
= wBNorm
- wGNorm
;
4178 else if (wG
== wMax
)
4179 wHue
= 80 + wRNorm
- wBNorm
;
4181 wHue
= 160 + wGNorm
- wRNorm
;
4184 else if (wHue
> 240)
4190 *pwLuminance
= wLuminosity
;
4192 *pwSaturation
= wSaturation
;
4195 /*************************************************************************
4196 * SHCreateShellPalette [SHLWAPI.@]
4198 HPALETTE WINAPI
SHCreateShellPalette(HDC hdc
)
4201 return CreateHalftonePalette(hdc
);
4204 /*************************************************************************
4205 * SHGetInverseCMAP (SHLWAPI.@)
4207 * Get an inverse color map table.
4210 * lpCmap [O] Destination for color map
4211 * dwSize [I] Size of memory pointed to by lpCmap
4215 * Failure: E_POINTER, If lpCmap is invalid.
4216 * E_INVALIDARG, If dwFlags is invalid
4217 * E_OUTOFMEMORY, If there is no memory available
4220 * dwSize may only be CMAP_PTR_SIZE (4) or CMAP_SIZE (8192).
4221 * If dwSize = CMAP_PTR_SIZE, *lpCmap is set to the address of this DLL's
4223 * If dwSize = CMAP_SIZE, lpCmap is filled with a copy of the data from
4224 * this DLL's internal CMap.
4226 HRESULT WINAPI
SHGetInverseCMAP(LPDWORD dest
, DWORD dwSize
)
4229 FIXME(" - returning bogus address for SHGetInverseCMAP\n");
4230 *dest
= (DWORD
)0xabba1249;
4233 FIXME("(%p, %#x) stub\n", dest
, dwSize
);
4237 /*************************************************************************
4238 * SHIsLowMemoryMachine [SHLWAPI.@]
4240 * Determine if the current computer has low memory.
4246 * TRUE if the users machine has 16 Megabytes of memory or less,
4249 BOOL WINAPI
SHIsLowMemoryMachine (DWORD x
)
4251 FIXME("(0x%08x) stub\n", x
);
4255 /*************************************************************************
4256 * GetMenuPosFromID [SHLWAPI.@]
4258 * Return the position of a menu item from its Id.
4261 * hMenu [I] Menu containing the item
4262 * wID [I] Id of the menu item
4265 * Success: The index of the menu item in hMenu.
4266 * Failure: -1, If the item is not found.
4268 INT WINAPI
GetMenuPosFromID(HMENU hMenu
, UINT wID
)
4271 INT nCount
= GetMenuItemCount(hMenu
), nIter
= 0;
4273 TRACE("%p %u\n", hMenu
, wID
);
4275 while (nIter
< nCount
)
4277 mi
.cbSize
= sizeof(mi
);
4279 if (GetMenuItemInfoW(hMenu
, nIter
, TRUE
, &mi
) && mi
.wID
== wID
)
4281 TRACE("ret %d\n", nIter
);
4290 /*************************************************************************
4293 * Same as SHLWAPI.GetMenuPosFromID
4295 DWORD WINAPI
SHMenuIndexFromID(HMENU hMenu
, UINT uID
)
4297 TRACE("%p %u\n", hMenu
, uID
);
4298 return GetMenuPosFromID(hMenu
, uID
);
4302 /*************************************************************************
4305 VOID WINAPI
FixSlashesAndColonW(LPWSTR lpwstr
)
4316 /*************************************************************************
4319 DWORD WINAPI
SHGetAppCompatFlags(DWORD dwUnknown
)
4321 FIXME("(0x%08x) stub\n", dwUnknown
);
4326 /*************************************************************************
4329 HRESULT WINAPI
SHCoCreateInstanceAC(REFCLSID rclsid
, LPUNKNOWN pUnkOuter
,
4330 DWORD dwClsContext
, REFIID iid
, LPVOID
*ppv
)
4332 return CoCreateInstance(rclsid
, pUnkOuter
, dwClsContext
, iid
, ppv
);
4335 /*************************************************************************
4336 * SHSkipJunction [SHLWAPI.@]
4338 * Determine if a bind context can be bound to an object
4341 * pbc [I] Bind context to check
4342 * pclsid [I] CLSID of object to be bound to
4345 * TRUE: If it is safe to bind
4346 * FALSE: If pbc is invalid or binding would not be safe
4349 BOOL WINAPI
SHSkipJunction(IBindCtx
*pbc
, const CLSID
*pclsid
)
4351 static WCHAR szSkipBinding
[] = { 'S','k','i','p',' ',
4352 'B','i','n','d','i','n','g',' ','C','L','S','I','D','\0' };
4359 if (SUCCEEDED(IBindCtx_GetObjectParam(pbc
, szSkipBinding
, &lpUnk
)))
4363 if (SUCCEEDED(IUnknown_GetClassID(lpUnk
, &clsid
)) &&
4364 IsEqualGUID(pclsid
, &clsid
))
4367 IUnknown_Release(lpUnk
);
4373 /***********************************************************************
4374 * SHGetShellKey (SHLWAPI.491)
4376 HKEY WINAPI
SHGetShellKey(DWORD flags
, LPCWSTR sub_key
, BOOL create
)
4378 enum _shellkey_flags
{
4379 SHKEY_Root_HKCU
= 0x1,
4380 SHKEY_Root_HKLM
= 0x2,
4381 SHKEY_Key_Explorer
= 0x00,
4382 SHKEY_Key_Shell
= 0x10,
4383 SHKEY_Key_ShellNoRoam
= 0x20,
4384 SHKEY_Key_Classes
= 0x30,
4385 SHKEY_Subkey_Default
= 0x0000,
4386 SHKEY_Subkey_ResourceName
= 0x1000,
4387 SHKEY_Subkey_Handlers
= 0x2000,
4388 SHKEY_Subkey_Associations
= 0x3000,
4389 SHKEY_Subkey_Volatile
= 0x4000,
4390 SHKEY_Subkey_MUICache
= 0x5000,
4391 SHKEY_Subkey_FileExts
= 0x6000
4394 static const WCHAR explorerW
[] = {'S','o','f','t','w','a','r','e','\\',
4395 'M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\',
4396 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
4397 'E','x','p','l','o','r','e','r','\\'};
4398 static const WCHAR shellW
[] = {'S','o','f','t','w','a','r','e','\\',
4399 'M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\',
4400 'S','h','e','l','l','\\'};
4401 static const WCHAR shell_no_roamW
[] = {'S','o','f','t','w','a','r','e','\\',
4402 'M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\',
4403 'S','h','e','l','l','N','o','R','o','a','m','\\'};
4404 static const WCHAR classesW
[] = {'S','o','f','t','w','a','r','e','\\',
4405 'C','l','a','s','s','e','s','\\'};
4407 static const WCHAR localized_resource_nameW
[] = {'L','o','c','a','l','i','z','e','d',
4408 'R','e','s','o','u','r','c','e','N','a','m','e','\\'};
4409 static const WCHAR handlersW
[] = {'H','a','n','d','l','e','r','s','\\'};
4410 static const WCHAR associationsW
[] = {'A','s','s','o','c','i','a','t','i','o','n','s','\\'};
4411 static const WCHAR volatileW
[] = {'V','o','l','a','t','i','l','e','\\'};
4412 static const WCHAR mui_cacheW
[] = {'M','U','I','C','a','c','h','e','\\'};
4413 static const WCHAR file_extsW
[] = {'F','i','l','e','E','x','t','s','\\'};
4416 const WCHAR
*key
, *subkey
;
4417 int size_key
, size_subkey
, size_user
;
4420 TRACE("(0x%08x, %s, %d)\n", flags
, debugstr_w(sub_key
), create
);
4422 /* For compatibility with Vista+ */
4423 if(flags
== 0x1ffff)
4426 switch(flags
&0xff0) {
4427 case SHKEY_Key_Explorer
:
4429 size_key
= sizeof(explorerW
);
4431 case SHKEY_Key_Shell
:
4433 size_key
= sizeof(shellW
);
4435 case SHKEY_Key_ShellNoRoam
:
4436 key
= shell_no_roamW
;
4437 size_key
= sizeof(shell_no_roamW
);
4439 case SHKEY_Key_Classes
:
4441 size_key
= sizeof(classesW
);
4444 FIXME("unsupported flags (0x%08x)\n", flags
);
4448 switch(flags
&0xff000) {
4449 case SHKEY_Subkey_Default
:
4453 case SHKEY_Subkey_ResourceName
:
4454 subkey
= localized_resource_nameW
;
4455 size_subkey
= sizeof(localized_resource_nameW
);
4457 case SHKEY_Subkey_Handlers
:
4459 size_subkey
= sizeof(handlersW
);
4461 case SHKEY_Subkey_Associations
:
4462 subkey
= associationsW
;
4463 size_subkey
= sizeof(associationsW
);
4465 case SHKEY_Subkey_Volatile
:
4467 size_subkey
= sizeof(volatileW
);
4469 case SHKEY_Subkey_MUICache
:
4470 subkey
= mui_cacheW
;
4471 size_subkey
= sizeof(mui_cacheW
);
4473 case SHKEY_Subkey_FileExts
:
4474 subkey
= file_extsW
;
4475 size_subkey
= sizeof(file_extsW
);
4478 FIXME("unsupported flags (0x%08x)\n", flags
);
4483 size_user
= lstrlenW(sub_key
)*sizeof(WCHAR
);
4487 path
= HeapAlloc(GetProcessHeap(), 0, size_key
+size_subkey
+size_user
+sizeof(WCHAR
));
4489 ERR("Out of memory\n");
4493 memcpy(path
, key
, size_key
);
4495 memcpy(path
+size_key
/sizeof(WCHAR
), subkey
, size_subkey
);
4497 memcpy(path
+(size_key
+size_subkey
)/sizeof(WCHAR
), sub_key
, size_user
);
4498 path
[(size_key
+size_subkey
+size_user
)/sizeof(WCHAR
)] = '\0';
4501 RegCreateKeyExW((flags
&0xf)==SHKEY_Root_HKLM
?HKEY_LOCAL_MACHINE
:HKEY_CURRENT_USER
,
4502 path
, 0, NULL
, 0, MAXIMUM_ALLOWED
, NULL
, &hkey
, NULL
);
4504 RegOpenKeyExW((flags
&0xf)==SHKEY_Root_HKLM
?HKEY_LOCAL_MACHINE
:HKEY_CURRENT_USER
,
4505 path
, 0, MAXIMUM_ALLOWED
, &hkey
);
4507 HeapFree(GetProcessHeap(), 0, path
);
4511 /***********************************************************************
4512 * SHQueueUserWorkItem (SHLWAPI.@)
4514 BOOL WINAPI
SHQueueUserWorkItem(LPTHREAD_START_ROUTINE pfnCallback
,
4515 LPVOID pContext
, LONG lPriority
, DWORD_PTR dwTag
,
4516 DWORD_PTR
*pdwId
, LPCSTR pszModule
, DWORD dwFlags
)
4518 TRACE("(%p, %p, %d, %lx, %p, %s, %08x)\n", pfnCallback
, pContext
,
4519 lPriority
, dwTag
, pdwId
, debugstr_a(pszModule
), dwFlags
);
4521 if(lPriority
|| dwTag
|| pdwId
|| pszModule
|| dwFlags
)
4522 FIXME("Unsupported arguments\n");
4524 return QueueUserWorkItem(pfnCallback
, pContext
, 0);
4527 /***********************************************************************
4528 * SHSetTimerQueueTimer (SHLWAPI.263)
4530 HANDLE WINAPI
SHSetTimerQueueTimer(HANDLE hQueue
,
4531 WAITORTIMERCALLBACK pfnCallback
, LPVOID pContext
, DWORD dwDueTime
,
4532 DWORD dwPeriod
, LPCSTR lpszLibrary
, DWORD dwFlags
)
4536 /* SHSetTimerQueueTimer flags -> CreateTimerQueueTimer flags */
4537 if (dwFlags
& TPS_LONGEXECTIME
) {
4538 dwFlags
&= ~TPS_LONGEXECTIME
;
4539 dwFlags
|= WT_EXECUTELONGFUNCTION
;
4541 if (dwFlags
& TPS_EXECUTEIO
) {
4542 dwFlags
&= ~TPS_EXECUTEIO
;
4543 dwFlags
|= WT_EXECUTEINIOTHREAD
;
4546 if (!CreateTimerQueueTimer(&hNewTimer
, hQueue
, pfnCallback
, pContext
,
4547 dwDueTime
, dwPeriod
, dwFlags
))
4553 /***********************************************************************
4554 * IUnknown_OnFocusChangeIS (SHLWAPI.@)
4556 HRESULT WINAPI
IUnknown_OnFocusChangeIS(LPUNKNOWN lpUnknown
, LPUNKNOWN pFocusObject
, BOOL bFocus
)
4558 IInputObjectSite
*pIOS
= NULL
;
4559 HRESULT hRet
= E_INVALIDARG
;
4561 TRACE("(%p, %p, %s)\n", lpUnknown
, pFocusObject
, bFocus
? "TRUE" : "FALSE");
4565 hRet
= IUnknown_QueryInterface(lpUnknown
, &IID_IInputObjectSite
,
4567 if (SUCCEEDED(hRet
) && pIOS
)
4569 hRet
= IInputObjectSite_OnFocusChangeIS(pIOS
, pFocusObject
, bFocus
);
4570 IInputObjectSite_Release(pIOS
);
4576 /***********************************************************************
4577 * SKAllocValueW (SHLWAPI.519)
4579 HRESULT WINAPI
SKAllocValueW(DWORD flags
, LPCWSTR subkey
, LPCWSTR value
, DWORD
*type
,
4580 LPVOID
*data
, DWORD
*count
)
4585 TRACE("(0x%x, %s, %s, %p, %p, %p)\n", flags
, debugstr_w(subkey
),
4586 debugstr_w(value
), type
, data
, count
);
4588 hkey
= SHGetShellKey(flags
, subkey
, FALSE
);
4590 return HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND
);
4592 ret
= SHQueryValueExW(hkey
, value
, NULL
, type
, NULL
, &size
);
4595 return HRESULT_FROM_WIN32(ret
);
4599 *data
= LocalAlloc(0, size
);
4602 return E_OUTOFMEMORY
;
4605 ret
= SHQueryValueExW(hkey
, value
, NULL
, type
, *data
, &size
);
4610 return HRESULT_FROM_WIN32(ret
);
4613 /***********************************************************************
4614 * SKDeleteValueW (SHLWAPI.518)
4616 HRESULT WINAPI
SKDeleteValueW(DWORD flags
, LPCWSTR subkey
, LPCWSTR value
)
4621 TRACE("(0x%x, %s %s)\n", flags
, debugstr_w(subkey
), debugstr_w(value
));
4623 hkey
= SHGetShellKey(flags
, subkey
, FALSE
);
4625 return HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND
);
4627 ret
= RegDeleteValueW(hkey
, value
);
4630 return HRESULT_FROM_WIN32(ret
);
4633 /***********************************************************************
4634 * SKGetValueW (SHLWAPI.516)
4636 HRESULT WINAPI
SKGetValueW(DWORD flags
, LPCWSTR subkey
, LPCWSTR value
, DWORD
*type
,
4637 void *data
, DWORD
*count
)
4642 TRACE("(0x%x, %s, %s, %p, %p, %p)\n", flags
, debugstr_w(subkey
),
4643 debugstr_w(value
), type
, data
, count
);
4645 hkey
= SHGetShellKey(flags
, subkey
, FALSE
);
4647 return HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND
);
4649 ret
= SHQueryValueExW(hkey
, value
, NULL
, type
, data
, count
);
4652 return HRESULT_FROM_WIN32(ret
);
4655 /***********************************************************************
4656 * SKSetValueW (SHLWAPI.516)
4658 HRESULT WINAPI
SKSetValueW(DWORD flags
, LPCWSTR subkey
, LPCWSTR value
,
4659 DWORD type
, void *data
, DWORD count
)
4664 TRACE("(0x%x, %s, %s, %x, %p, %d)\n", flags
, debugstr_w(subkey
),
4665 debugstr_w(value
), type
, data
, count
);
4667 hkey
= SHGetShellKey(flags
, subkey
, TRUE
);
4669 return HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND
);
4671 ret
= RegSetValueExW(hkey
, value
, 0, type
, data
, count
);
4674 return HRESULT_FROM_WIN32(ret
);
4677 typedef HRESULT (WINAPI
*DllGetVersion_func
)(DLLVERSIONINFO
*);
4679 /***********************************************************************
4680 * GetUIVersion (SHLWAPI.452)
4682 DWORD WINAPI
GetUIVersion(void)
4684 static DWORD version
;
4688 DllGetVersion_func pDllGetVersion
;
4689 HMODULE dll
= LoadLibraryA("shell32.dll");
4692 pDllGetVersion
= (DllGetVersion_func
)GetProcAddress(dll
, "DllGetVersion");
4696 dvi
.cbSize
= sizeof(DLLVERSIONINFO
);
4697 if (pDllGetVersion(&dvi
) == S_OK
) version
= dvi
.dwMajorVersion
;
4700 if (!version
) version
= 3; /* old shell dlls don't have DllGetVersion */
4705 /***********************************************************************
4706 * ShellMessageBoxWrapW [SHLWAPI.388]
4708 * See shell32.ShellMessageBoxW
4711 * shlwapi.ShellMessageBoxWrapW is a duplicate of shell32.ShellMessageBoxW
4712 * because we can't forward to it in the .spec file since it's exported by
4713 * ordinal. If you change the implementation here please update the code in
4716 INT WINAPIV
ShellMessageBoxWrapW(HINSTANCE hInstance
, HWND hWnd
, LPCWSTR lpText
,
4717 LPCWSTR lpCaption
, UINT uType
, ...)
4719 WCHAR
*szText
= NULL
, szTitle
[100];
4720 LPCWSTR pszText
, pszTitle
= szTitle
;
4725 __ms_va_start(args
, uType
);
4727 TRACE("(%p,%p,%p,%p,%08x)\n", hInstance
, hWnd
, lpText
, lpCaption
, uType
);
4729 if (IS_INTRESOURCE(lpCaption
))
4730 LoadStringW(hInstance
, LOWORD(lpCaption
), szTitle
, sizeof(szTitle
)/sizeof(szTitle
[0]));
4732 pszTitle
= lpCaption
;
4734 if (IS_INTRESOURCE(lpText
))
4737 UINT len
= LoadStringW(hInstance
, LOWORD(lpText
), (LPWSTR
)&ptr
, 0);
4741 szText
= HeapAlloc(GetProcessHeap(), 0, (len
+ 1) * sizeof(WCHAR
));
4742 if (szText
) LoadStringW(hInstance
, LOWORD(lpText
), szText
, len
+ 1);
4746 WARN("Failed to load id %d\n", LOWORD(lpText
));
4754 FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER
| FORMAT_MESSAGE_FROM_STRING
,
4755 pszText
, 0, 0, (LPWSTR
)&pszTemp
, 0, &args
);
4759 ret
= MessageBoxW(hWnd
, pszTemp
, pszTitle
, uType
);
4761 HeapFree(GetProcessHeap(), 0, szText
);
4766 /***********************************************************************
4767 * ZoneComputePaneSize [SHLWAPI.382]
4769 UINT WINAPI
ZoneComputePaneSize(HWND hwnd
)
4775 /***********************************************************************
4776 * SHChangeNotifyWrap [SHLWAPI.394]
4778 void WINAPI
SHChangeNotifyWrap(LONG wEventId
, UINT uFlags
, LPCVOID dwItem1
, LPCVOID dwItem2
)
4780 SHChangeNotify(wEventId
, uFlags
, dwItem1
, dwItem2
);
4783 typedef struct SHELL_USER_SID
{ /* according to MSDN this should be in shlobj.h... */
4784 SID_IDENTIFIER_AUTHORITY sidAuthority
;
4785 DWORD dwUserGroupID
;
4787 } SHELL_USER_SID
, *PSHELL_USER_SID
;
4789 typedef struct SHELL_USER_PERMISSION
{ /* ...and this should be in shlwapi.h */
4790 SHELL_USER_SID susID
;
4794 DWORD dwInheritMask
;
4795 DWORD dwInheritAccessMask
;
4796 } SHELL_USER_PERMISSION
, *PSHELL_USER_PERMISSION
;
4798 /***********************************************************************
4799 * GetShellSecurityDescriptor [SHLWAPI.475]
4801 * prepares SECURITY_DESCRIPTOR from a set of ACEs
4804 * apUserPerm [I] array of pointers to SHELL_USER_PERMISSION structures,
4805 * each of which describes permissions to apply
4806 * cUserPerm [I] number of entries in apUserPerm array
4809 * success: pointer to SECURITY_DESCRIPTOR
4813 * Call should free returned descriptor with LocalFree
4815 PSECURITY_DESCRIPTOR WINAPI
GetShellSecurityDescriptor(PSHELL_USER_PERMISSION
*apUserPerm
, int cUserPerm
)
4818 PSID cur_user
= NULL
;
4822 PSECURITY_DESCRIPTOR psd
= NULL
;
4824 TRACE("%p %d\n", apUserPerm
, cUserPerm
);
4826 if (apUserPerm
== NULL
|| cUserPerm
<= 0)
4829 sidlist
= HeapAlloc(GetProcessHeap(), 0, cUserPerm
* sizeof(PSID
));
4833 acl_size
= sizeof(ACL
);
4835 for(sid_count
= 0; sid_count
< cUserPerm
; sid_count
++)
4837 static SHELL_USER_SID null_sid
= {{SECURITY_NULL_SID_AUTHORITY
}, 0, 0};
4838 PSHELL_USER_PERMISSION perm
= apUserPerm
[sid_count
];
4839 PSHELL_USER_SID sid
= &perm
->susID
;
4843 if (!memcmp((void*)sid
, (void*)&null_sid
, sizeof(SHELL_USER_SID
)))
4844 { /* current user's SID */
4848 DWORD bufsize
= sizeof(tuUser
);
4850 ret
= OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY
, &Token
);
4853 ret
= GetTokenInformation(Token
, TokenUser
, (void*)tuUser
, bufsize
, &bufsize
);
4855 cur_user
= ((PTOKEN_USER
)tuUser
)->User
.Sid
;
4860 } else if (sid
->dwUserID
==0) /* one sub-authority */
4861 ret
= AllocateAndInitializeSid(&sid
->sidAuthority
, 1, sid
->dwUserGroupID
, 0,
4862 0, 0, 0, 0, 0, 0, &pSid
);
4864 ret
= AllocateAndInitializeSid(&sid
->sidAuthority
, 2, sid
->dwUserGroupID
, sid
->dwUserID
,
4865 0, 0, 0, 0, 0, 0, &pSid
);
4869 sidlist
[sid_count
] = pSid
;
4870 /* increment acl_size (1 ACE for non-inheritable and 2 ACEs for inheritable records */
4871 acl_size
+= (sizeof(ACCESS_ALLOWED_ACE
)-sizeof(DWORD
) + GetLengthSid(pSid
)) * (perm
->fInherit
? 2 : 1);
4874 psd
= LocalAlloc(0, sizeof(SECURITY_DESCRIPTOR
) + acl_size
);
4878 PACL pAcl
= (PACL
)(((BYTE
*)psd
)+sizeof(SECURITY_DESCRIPTOR
));
4880 if (!InitializeSecurityDescriptor(psd
, SECURITY_DESCRIPTOR_REVISION
))
4883 if (!InitializeAcl(pAcl
, acl_size
, ACL_REVISION
))
4886 for(i
= 0; i
< sid_count
; i
++)
4888 PSHELL_USER_PERMISSION sup
= apUserPerm
[i
];
4889 PSID sid
= sidlist
[i
];
4891 switch(sup
->dwAccessType
)
4893 case ACCESS_ALLOWED_ACE_TYPE
:
4894 if (!AddAccessAllowedAce(pAcl
, ACL_REVISION
, sup
->dwAccessMask
, sid
))
4896 if (sup
->fInherit
&& !AddAccessAllowedAceEx(pAcl
, ACL_REVISION
,
4897 (BYTE
)sup
->dwInheritMask
, sup
->dwInheritAccessMask
, sid
))
4900 case ACCESS_DENIED_ACE_TYPE
:
4901 if (!AddAccessDeniedAce(pAcl
, ACL_REVISION
, sup
->dwAccessMask
, sid
))
4903 if (sup
->fInherit
&& !AddAccessDeniedAceEx(pAcl
, ACL_REVISION
,
4904 (BYTE
)sup
->dwInheritMask
, sup
->dwInheritAccessMask
, sid
))
4912 if (!SetSecurityDescriptorDacl(psd
, TRUE
, pAcl
, FALSE
))
4921 for(i
= 0; i
< sid_count
; i
++)
4923 if (!cur_user
|| sidlist
[i
] != cur_user
)
4924 FreeSid(sidlist
[i
]);
4926 HeapFree(GetProcessHeap(), 0, sidlist
);
4931 /***********************************************************************
4932 * SHCreatePropertyBagOnRegKey [SHLWAPI.471]
4934 * Creates a property bag from a registry key
4937 * hKey [I] Handle to the desired registry key
4938 * subkey [I] Name of desired subkey, or NULL to open hKey directly
4939 * grfMode [I] Optional flags
4940 * riid [I] IID of requested property bag interface
4941 * ppv [O] Address to receive pointer to the new interface
4945 * failure: error code
4948 HRESULT WINAPI
SHCreatePropertyBagOnRegKey (HKEY hKey
, LPCWSTR subkey
,
4949 DWORD grfMode
, REFIID riid
, void **ppv
)
4951 FIXME("%p %s %d %s %p STUB\n", hKey
, debugstr_w(subkey
), grfMode
,
4952 debugstr_guid(riid
), ppv
);
4957 /***********************************************************************
4958 * SHGetViewStatePropertyBag [SHLWAPI.515]
4960 * Retrieves a property bag in which the view state information of a folder
4964 * pidl [I] PIDL of the folder requested
4965 * bag_name [I] Name of the property bag requested
4966 * flags [I] Optional flags
4967 * riid [I] IID of requested property bag interface
4968 * ppv [O] Address to receive pointer to the new interface
4972 * failure: error code
4975 HRESULT WINAPI
SHGetViewStatePropertyBag(LPCITEMIDLIST pidl
, LPWSTR bag_name
,
4976 DWORD flags
, REFIID riid
, void **ppv
)
4978 FIXME("%p %s %d %s %p STUB\n", pidl
, debugstr_w(bag_name
), flags
,
4979 debugstr_guid(riid
), ppv
);
4984 /***********************************************************************
4985 * SHFormatDateTimeW [SHLWAPI.354]
4987 * Produces a string representation of a time.
4990 * fileTime [I] Pointer to FILETIME structure specifying the time
4991 * flags [I] Flags specifying the desired output
4992 * buf [O] Pointer to buffer for output
4993 * size [I] Number of characters that can be contained in buffer
4996 * success: number of characters written to the buffer
5000 INT WINAPI
SHFormatDateTimeW(const FILETIME UNALIGNED
*fileTime
, DWORD
*flags
,
5001 LPWSTR buf
, UINT size
)
5003 #define SHFORMATDT_UNSUPPORTED_FLAGS (FDTF_RELATIVE | FDTF_LTRDATE | FDTF_RTLDATE | FDTF_NOAUTOREADINGORDER)
5004 DWORD fmt_flags
= flags
? *flags
: FDTF_DEFAULT
;
5009 TRACE("%p %p %p %u\n", fileTime
, flags
, buf
, size
);
5014 if (fmt_flags
& SHFORMATDT_UNSUPPORTED_FLAGS
)
5015 FIXME("ignoring some flags - 0x%08x\n", fmt_flags
& SHFORMATDT_UNSUPPORTED_FLAGS
);
5017 FileTimeToLocalFileTime(fileTime
, &ft
);
5018 FileTimeToSystemTime(&ft
, &st
);
5020 /* first of all date */
5021 if (fmt_flags
& (FDTF_LONGDATE
| FDTF_SHORTDATE
))
5023 static const WCHAR sep1
[] = {',',' ',0};
5024 static const WCHAR sep2
[] = {' ',0};
5026 DWORD date
= fmt_flags
& FDTF_LONGDATE
? DATE_LONGDATE
: DATE_SHORTDATE
;
5027 ret
= GetDateFormatW(LOCALE_USER_DEFAULT
, date
, &st
, NULL
, buf
, size
);
5028 if (ret
>= size
) return ret
;
5031 if (ret
< size
&& (fmt_flags
& (FDTF_LONGTIME
| FDTF_SHORTTIME
)))
5033 if ((fmt_flags
& FDTF_LONGDATE
) && (ret
< size
+ 2))
5037 lstrcatW(&buf
[ret
-1], sep1
);
5043 lstrcatW(&buf
[ret
-1], sep2
);
5049 if (fmt_flags
& (FDTF_LONGTIME
| FDTF_SHORTTIME
))
5051 DWORD time
= fmt_flags
& FDTF_LONGTIME
? 0 : TIME_NOSECONDS
;
5054 ret
+= GetTimeFormatW(LOCALE_USER_DEFAULT
, time
, &st
, NULL
, &buf
[ret
], size
- ret
);
5059 #undef SHFORMATDT_UNSUPPORTED_FLAGS
5062 /***********************************************************************
5063 * SHFormatDateTimeA [SHLWAPI.353]
5065 * See SHFormatDateTimeW.
5068 INT WINAPI
SHFormatDateTimeA(const FILETIME UNALIGNED
*fileTime
, DWORD
*flags
,
5069 LPSTR buf
, UINT size
)
5077 bufW
= HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR
) * size
);
5078 retval
= SHFormatDateTimeW(fileTime
, flags
, bufW
, size
);
5081 WideCharToMultiByte(CP_ACP
, 0, bufW
, -1, buf
, size
, NULL
, NULL
);
5083 HeapFree(GetProcessHeap(), 0, bufW
);
5087 /***********************************************************************
5088 * ZoneCheckUrlExW [SHLWAPI.231]
5090 * Checks the details of the security zone for the supplied site. (?)
5094 * szURL [I] Pointer to the URL to check
5096 * Other parameters currently unknown.
5102 INT WINAPI
ZoneCheckUrlExW(LPWSTR szURL
, PVOID pUnknown
, DWORD dwUnknown2
,
5103 DWORD dwUnknown3
, DWORD dwUnknown4
, DWORD dwUnknown5
, DWORD dwUnknown6
,
5106 FIXME("(%s,%p,%x,%x,%x,%x,%x,%x) STUB\n", debugstr_w(szURL
), pUnknown
, dwUnknown2
,
5107 dwUnknown3
, dwUnknown4
, dwUnknown5
, dwUnknown6
, dwUnknown7
);
5112 /***********************************************************************
5113 * SHVerbExistsNA [SHLWAPI.196]
5118 * verb [I] a string, often appears to be an extension.
5120 * Other parameters currently unknown.
5125 INT WINAPI
SHVerbExistsNA(LPSTR verb
, PVOID pUnknown
, PVOID pUnknown2
, DWORD dwUnknown3
)
5127 FIXME("(%s, %p, %p, %i) STUB\n",verb
, pUnknown
, pUnknown2
, dwUnknown3
);
5131 /*************************************************************************
5134 * Undocumented: Implementation guessed at via Name and behavior
5137 * lpUnknown [I] Object to get an IServiceProvider interface from
5138 * riid [I] Function requested for QueryService call
5139 * lppOut [O] Destination for the service interface pointer
5142 * Success: S_OK. lppOut contains an object providing the requested service
5143 * Failure: An HRESULT error code
5146 * lpUnknown is expected to support the IServiceProvider interface.
5148 HRESULT WINAPI
IUnknown_QueryServiceForWebBrowserApp(IUnknown
* lpUnknown
,
5149 REFGUID riid
, LPVOID
*lppOut
)
5151 FIXME("%p %s %p semi-STUB\n", lpUnknown
, debugstr_guid(riid
), lppOut
);
5152 return IUnknown_QueryService(lpUnknown
,&IID_IWebBrowserApp
,riid
,lppOut
);
5155 /**************************************************************************
5156 * SHPropertyBag_ReadLONG (SHLWAPI.496)
5158 * This function asks a property bag to read a named property as a LONG.
5161 * ppb: a IPropertyBag interface
5162 * pszPropName: Unicode string that names the property
5163 * pValue: address to receive the property value as a 32-bit signed integer
5168 BOOL WINAPI
SHPropertyBag_ReadLONG(IPropertyBag
*ppb
, LPCWSTR pszPropName
, LPLONG pValue
)
5172 TRACE("%p %s %p\n", ppb
,debugstr_w(pszPropName
),pValue
);
5173 if (!pszPropName
|| !ppb
|| !pValue
)
5174 return E_INVALIDARG
;
5176 hr
= IPropertyBag_Read(ppb
, pszPropName
, &var
, NULL
);
5179 if (V_VT(&var
) == VT_I4
)
5180 *pValue
= V_I4(&var
);
5182 hr
= DISP_E_BADVARTYPE
;
5187 /* return flags for SHGetObjectCompatFlags, names derived from registry value names */
5188 #define OBJCOMPAT_OTNEEDSSFCACHE 0x00000001
5189 #define OBJCOMPAT_NO_WEBVIEW 0x00000002
5190 #define OBJCOMPAT_UNBINDABLE 0x00000004
5191 #define OBJCOMPAT_PINDLL 0x00000008
5192 #define OBJCOMPAT_NEEDSFILESYSANCESTOR 0x00000010
5193 #define OBJCOMPAT_NOTAFILESYSTEM 0x00000020
5194 #define OBJCOMPAT_CTXMENU_NOVERBS 0x00000040
5195 #define OBJCOMPAT_CTXMENU_LIMITEDQI 0x00000080
5196 #define OBJCOMPAT_COCREATESHELLFOLDERONLY 0x00000100
5197 #define OBJCOMPAT_NEEDSSTORAGEANCESTOR 0x00000200
5198 #define OBJCOMPAT_NOLEGACYWEBVIEW 0x00000400
5199 #define OBJCOMPAT_CTXMENU_XPQCMFLAGS 0x00001000
5200 #define OBJCOMPAT_NOIPROPERTYSTORE 0x00002000
5202 /* a search table for compatibility flags */
5203 struct objcompat_entry
{
5204 const WCHAR name
[30];
5208 /* expected to be sorted by name */
5209 static const struct objcompat_entry objcompat_table
[] = {
5210 { {'C','O','C','R','E','A','T','E','S','H','E','L','L','F','O','L','D','E','R','O','N','L','Y',0},
5211 OBJCOMPAT_COCREATESHELLFOLDERONLY
},
5212 { {'C','T','X','M','E','N','U','_','L','I','M','I','T','E','D','Q','I',0},
5213 OBJCOMPAT_CTXMENU_LIMITEDQI
},
5214 { {'C','T','X','M','E','N','U','_','N','O','V','E','R','B','S',0},
5215 OBJCOMPAT_CTXMENU_LIMITEDQI
},
5216 { {'C','T','X','M','E','N','U','_','X','P','Q','C','M','F','L','A','G','S',0},
5217 OBJCOMPAT_CTXMENU_XPQCMFLAGS
},
5218 { {'N','E','E','D','S','F','I','L','E','S','Y','S','A','N','C','E','S','T','O','R',0},
5219 OBJCOMPAT_NEEDSFILESYSANCESTOR
},
5220 { {'N','E','E','D','S','S','T','O','R','A','G','E','A','N','C','E','S','T','O','R',0},
5221 OBJCOMPAT_NEEDSSTORAGEANCESTOR
},
5222 { {'N','O','I','P','R','O','P','E','R','T','Y','S','T','O','R','E',0},
5223 OBJCOMPAT_NOIPROPERTYSTORE
},
5224 { {'N','O','L','E','G','A','C','Y','W','E','B','V','I','E','W',0},
5225 OBJCOMPAT_NOLEGACYWEBVIEW
},
5226 { {'N','O','T','A','F','I','L','E','S','Y','S','T','E','M',0},
5227 OBJCOMPAT_NOTAFILESYSTEM
},
5228 { {'N','O','_','W','E','B','V','I','E','W',0},
5229 OBJCOMPAT_NO_WEBVIEW
},
5230 { {'O','T','N','E','E','D','S','S','F','C','A','C','H','E',0},
5231 OBJCOMPAT_OTNEEDSSFCACHE
},
5232 { {'P','I','N','D','L','L',0},
5234 { {'U','N','B','I','N','D','A','B','L','E',0},
5235 OBJCOMPAT_UNBINDABLE
}
5238 /**************************************************************************
5239 * SHGetObjectCompatFlags (SHLWAPI.476)
5241 * Function returns an integer representation of compatibility flags stored
5242 * in registry for CLSID under ShellCompatibility subkey.
5245 * pUnk: pointer to object IUnknown interface, idetifies CLSID
5246 * clsid: pointer to CLSID to retrieve data for
5249 * 0 on failure, flags set on success
5251 DWORD WINAPI
SHGetObjectCompatFlags(IUnknown
*pUnk
, const CLSID
*clsid
)
5253 static const WCHAR compatpathW
[] =
5254 {'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\',
5255 'W','i','n','d','o','w','s','\\','C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
5256 'S','h','e','l','l','C','o','m','p','a','t','i','b','i','l','i','t','y','\\',
5257 'O','b','j','e','c','t','s','\\','%','s',0};
5258 WCHAR strW
[sizeof(compatpathW
)/sizeof(WCHAR
) + 38 /* { CLSID } */];
5259 DWORD ret
, length
= sizeof(strW
)/sizeof(WCHAR
);
5264 TRACE("%p %s\n", pUnk
, debugstr_guid(clsid
));
5266 if (!pUnk
&& !clsid
) return 0;
5270 FIXME("iface not handled\n");
5274 StringFromCLSID(clsid
, &clsid_str
);
5275 sprintfW(strW
, compatpathW
, clsid_str
);
5276 CoTaskMemFree(clsid_str
);
5278 ret
= RegOpenKeyW(HKEY_LOCAL_MACHINE
, strW
, &key
);
5279 if (ret
!= ERROR_SUCCESS
) return 0;
5281 /* now collect flag values */
5283 for (i
= 0; RegEnumValueW(key
, i
, strW
, &length
, NULL
, NULL
, NULL
, NULL
) == ERROR_SUCCESS
; i
++)
5285 INT left
, right
, res
, x
;
5287 /* search in table */
5289 right
= sizeof(objcompat_table
) / sizeof(struct objcompat_entry
) - 1;
5291 while (right
>= left
) {
5292 x
= (left
+ right
) / 2;
5293 res
= strcmpW(strW
, objcompat_table
[x
].name
);
5296 ret
|= objcompat_table
[x
].value
;
5305 length
= sizeof(strW
)/sizeof(WCHAR
);