source: trunk/src/shlwapi/ordinal.c@ 5618

Last change on this file since 5618 was 5618, checked in by sandervl, 24 years ago

resync with latest wine

File size: 28.2 KB
Line 
1/*
2 * SHLWAPI ordinal functions
3 *
4 * Copyright 1997 Marcus Meissner
5 * 1998 Jürgen Schmied
6 * 2001 Jon Griffiths
7 */
8
9#include <stdio.h>
10#include <string.h>
11
12#include "windef.h"
13#include "winnls.h"
14#include "winbase.h"
15#include "ddeml.h"
16#include "shlobj.h"
17#include "shellapi.h"
18#include "commdlg.h"
19#include "wine/unicode.h"
20#include "wine/obj_base.h"
21#include "wingdi.h"
22#include "winuser.h"
23#include "debugtools.h"
24
25DEFAULT_DEBUG_CHANNEL(shell);
26
27#ifdef __WIN32OS2__
28extern HINSTANCE shlwapi_hInstance = 0;
29extern HMODULE SHLWAPI_hshell32 = 0;
30extern HMODULE SHLWAPI_hwinmm = 0;
31extern HMODULE SHLWAPI_hcomdlg32 = 0;
32extern HMODULE SHLWAPI_hmpr = 0;
33extern HMODULE SHLWAPI_hmlang = 0;
34#else
35extern HINSTANCE shlwapi_hInstance;
36extern HMODULE SHLWAPI_hshell32;
37extern HMODULE SHLWAPI_hwinmm;
38extern HMODULE SHLWAPI_hcomdlg32;
39extern HMODULE SHLWAPI_hmpr;
40extern HMODULE SHLWAPI_hmlang;
41#endif
42
43/* Macro to get function pointer for a module*/
44#define GET_FUNC(module, name, fail) \
45 if (!SHLWAPI_h##module) SHLWAPI_h##module = LoadLibraryA(#module ".dll"); \
46 if (!SHLWAPI_h##module) return fail; \
47 if (!pfnFunc) pfnFunc = (void*)GetProcAddress(SHLWAPI_h##module, name); \
48 if (!pfnFunc) return fail
49
50/*
51 NOTES: Most functions exported by ordinal seem to be superflous.
52 The reason for these functions to be there is to provide a wraper
53 for unicode functions to provide these functions on systems without
54 unicode functions eg. win95/win98. Since we have such functions we just
55 call these. If running Wine with native DLL's, some late bound calls may
56 fail. However, its better to implement the functions in the forward DLL
57 and recommend the builtin rather than reimplementing the calls here!
58*/
59#ifndef __WIN32OS2__
60/*************************************************************************
61 * SHLWAPI_1 [SHLWAPI.1]
62 */
63DWORD WINAPI SHLWAPI_1 (
64 LPSTR lpStr,
65 LPVOID x)
66{
67 FIXME("(%p %s %p %s)\n",lpStr, debugstr_a(lpStr),x, debugstr_a(x));
68 return 0;
69}
70
71/*************************************************************************
72 * SHLWAPI_2 [SHLWAPI.2]
73 */
74DWORD WINAPI SHLWAPI_2 (LPCWSTR x,LPVOID y)
75{
76 FIXME("(%s,%p)\n",debugstr_w(x),y);
77 return 0;
78}
79
80/*************************************************************************
81 * SHLWAPI_16 [SHLWAPI.16]
82 */
83HRESULT WINAPI SHLWAPI_16 (
84 LPVOID w,
85 LPVOID x,
86 LPVOID y,
87 LPWSTR z)
88{
89 FIXME("(%p %p %p %p)stub\n",w,x,y,z);
90 return 0xabba1252;
91}
92#endif
93
94/*************************************************************************
95 * SHLWAPI_23 [SHLWAPI.23]
96 *
97 * NOTES
98 * converts a guid to a string
99 * returns strlen(str)
100 */
101DWORD WINAPI SHLWAPI_23 (
102 REFGUID guid, /* [in] clsid */
103 LPSTR str, /* [out] buffer */
104 INT cmax) /* [in] size of buffer */
105{
106 char xguid[40];
107
108 sprintf( xguid, "{%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
109 guid->Data1, guid->Data2, guid->Data3,
110 guid->Data4[0], guid->Data4[1], guid->Data4[2], guid->Data4[3],
111 guid->Data4[4], guid->Data4[5], guid->Data4[6], guid->Data4[7] );
112 TRACE("(%s %p 0x%08x)stub\n", xguid, str, cmax);
113 if (strlen(xguid)>=cmax) return 0;
114 strcpy(str,xguid);
115 return strlen(xguid) + 1;
116}
117
118/*************************************************************************
119 * SHLWAPI_24 [SHLWAPI.24]
120 *
121 * NOTES
122 * converts a guid to a string
123 * returns strlen(str)
124 */
125DWORD WINAPI SHLWAPI_24 (
126 REFGUID guid, /* [in] clsid */
127 LPWSTR str, /* [out] buffer */
128 INT cmax) /* [in] size of buffer */
129{
130 char xguid[40];
131
132 sprintf( xguid, "{%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
133 guid->Data1, guid->Data2, guid->Data3,
134 guid->Data4[0], guid->Data4[1], guid->Data4[2], guid->Data4[3],
135 guid->Data4[4], guid->Data4[5], guid->Data4[6], guid->Data4[7] );
136 return MultiByteToWideChar( CP_ACP, 0, xguid, -1, str, cmax );
137}
138
139/*************************************************************************
140 * SHLWAPI_30 [SHLWAPI.30]
141 *
142 * Seems to be an isspaceW.
143 */
144BOOL WINAPI SHLWAPI_30(LPWSTR lpcChar)
145{
146 switch (*lpcChar)
147 {
148 case (WCHAR)'\t':
149 case (WCHAR)' ':
150 case 160:
151 case 12288:
152 case 65279:
153 return TRUE;
154 }
155 return FALSE;
156}
157
158/*************************************************************************
159 * SHLWAPI_32 [SHLWAPI.32]
160 */
161BOOL WINAPI SHLWAPI_32(LPCWSTR lpcChar)
162{
163 if (*lpcChar < (WCHAR)' ')
164 return TRUE;
165
166 /* This is probably a shlwapi bug, but we do it the same for compatability */
167 if (((DWORD)lpcChar & 0xffff) - 127 <= (WCHAR)' ')
168 return TRUE;
169 return FALSE;
170}
171
172/*************************************************************************
173 * SHLWAPI_40 [SHLWAPI.40]
174 *
175 * Get pointer to next Unicode character.
176 */
177LPCWSTR WINAPI SHLWAPI_40(LPCWSTR str)
178{
179 return *str ? str + 1 : str;
180}
181
182/*************************************************************************
183 * SHLWAPI_74 [SHLWAPI.74]
184 *
185 * Get the text from a given dialog item.
186 */
187INT WINAPI SHLWAPI_74(HWND hWnd, INT nItem, LPWSTR lpsDest,INT nDestLen)
188{
189 HWND hItem = GetDlgItem(hWnd, nItem);
190
191 if (hItem)
192 return GetWindowTextW(hItem, lpsDest, nDestLen);
193 if (nDestLen)
194 *lpsDest = (WCHAR)'\0';
195 return 0;
196}
197
198/*************************************************************************
199 * SHLWAPI_151 [SHLWAPI.151]
200 */
201DWORD WINAPI SHLWAPI_151(void)
202{
203 FIXME(": stub\n");
204 return 0;
205}
206
207/*************************************************************************
208 * SHLWAPI_152 [SHLWAPI.152]
209 */
210DWORD WINAPI SHLWAPI_152(LPWSTR str1, LPWSTR str2, INT len)
211{
212 if (!len)
213 return 0;
214
215 while (--len && *str1 && *str1 == *str2)
216 {
217 str1++;
218 str2++;
219 }
220 return *str1 - *str2;
221}
222
223/*************************************************************************
224 * SHLWAPI_153 [SHLWAPI.153]
225 */
226DWORD WINAPI SHLWAPI_153(DWORD dw1, DWORD dw2, DWORD dw3)
227{
228 FIXME("%08lx %08lx %08lx - stub\n", dw1, dw2, dw3);
229 return 0;
230}
231
232/*************************************************************************
233 * SHLWAPI_156 [SHLWAPI.156]
234 *
235 * Case sensitive string compare. Does not SetLastError().
236 */
237DWORD WINAPI SHLWAPI_156 ( LPWSTR str1, LPWSTR str2)
238{
239 while (*str1 && (*str1 == *str2)) { str1++; str2++; }
240 return (INT)(*str1 - *str2);
241}
242
243/*************************************************************************
244 * SHLWAPI_162 [SHLWAPI.162]
245 *
246 * Ensure a multibyte character string doesn't end in a hanging lead byte.
247 */
248DWORD WINAPI SHLWAPI_162(LPSTR lpStr, DWORD size)
249{
250 if (lpStr && size)
251 {
252 LPSTR lastByte = lpStr + size - 1;
253
254 while(lpStr < lastByte)
255 lpStr += IsDBCSLeadByte(*lpStr) ? 2 : 1;
256
257 if(lpStr == lastByte && IsDBCSLeadByte(*lpStr))
258 {
259 *lpStr = '\0';
260 size--;
261 }
262 return size;
263 }
264 return 0;
265}
266
267/*************************************************************************
268 * SHLWAPI_165 [SHLWAPI.165]
269 *
270 * SetWindowLongA with mask.
271 */
272LONG WINAPI SHLWAPI_165(HWND hwnd, INT offset, UINT wFlags, UINT wMask)
273{
274 LONG ret = GetWindowLongA(hwnd, offset);
275 UINT newFlags = (wFlags & wMask) | (ret & ~wFlags);
276
277 if (newFlags != ret)
278 ret = SetWindowLongA(hwnd, offset, newFlags);
279 return ret;
280}
281
282/*************************************************************************
283 * SHLWAPI_169 [SHLWAPI.169]
284 */
285DWORD WINAPI SHLWAPI_169 (IUnknown * lpUnknown)
286{
287 TRACE("(%p)\n",lpUnknown);
288#if 0
289 if(!lpUnknown || !*((LPDWORD)lpUnknown)) return 0;
290 return IUnknown_Release(lpUnknown);
291#endif
292 return 0;
293}
294
295/*************************************************************************
296 * SHLWAPI_170 [SHLWAPI.170]
297 *
298 * Skip URL '//' sequence.
299 */
300LPCSTR WINAPI SHLWAPI_170(LPCSTR lpszSrc)
301{
302 if (lpszSrc && lpszSrc[0] == '/' && lpszSrc[1] == '/')
303 lpszSrc += 2;
304 return lpszSrc;
305}
306
307/*************************************************************************
308 * SHLWAPI_181 [SHLWAPI.181]
309 *
310 * Enable or disable a menu item.
311 */
312UINT WINAPI SHLWAPI_181(HMENU hMenu, UINT wItemID, BOOL bEnable)
313{
314 return EnableMenuItem(hMenu, wItemID, bEnable ? MF_ENABLED : MF_GRAYED);
315}
316
317/*************************************************************************
318 * SHLWAPI_183 [SHLWAPI.183]
319 *
320 * Register a window class if it isn't already.
321 */
322DWORD WINAPI SHLWAPI_183(WNDCLASSA *wndclass)
323{
324 WNDCLASSA wca;
325 if (GetClassInfoA(wndclass->hInstance, wndclass->lpszClassName, &wca))
326 return TRUE;
327 return (DWORD)RegisterClassA(wndclass);
328}
329
330/*************************************************************************
331 * SHLWAPI_193 [SHLWAPI.193]
332 */
333DWORD WINAPI SHLWAPI_193 ()
334{
335 HDC hdc;
336 DWORD ret;
337
338 TRACE("()\n");
339
340 hdc = GetDC(0);
341 ret = GetDeviceCaps(hdc, BITSPIXEL) * GetDeviceCaps(hdc, PLANES);
342 ReleaseDC(0, hdc);
343 return ret;
344}
345
346/*************************************************************************
347 * SHLWAPI_215 [SHLWAPI.215]
348 *
349 * NOTES
350 * check me!
351 */
352LPWSTR WINAPI SHLWAPI_215 (
353 LPWSTR lpStrSrc,
354 LPVOID lpwStrDest,
355 int len)
356{
357 WARN("(%p %p %u)\n",lpStrSrc,lpwStrDest,len);
358 return strncpyW(lpwStrDest, lpStrSrc, len);
359}
360
361/*************************************************************************
362 * SHLWAPI_218 [SHLWAPI.218]
363 *
364 * WideCharToMultiByte with multi language support.
365 */
366INT WINAPI SHLWAPI_218(UINT CodePage, LPCWSTR lpSrcStr, LPSTR lpDstStr,
367 LPINT lpnMultiCharCount)
368{
369#ifdef __WIN32OS2__
370 static HRESULT (* WINAPI pfnFunc)(LPDWORD,DWORD,LPCWSTR,LPINT,LPSTR,LPINT);
371#else
372 static HRESULT (* WINAPI pfnFunc)(LPDWORD,DWORD,LPCWSTR,LPINT,LPSTR,LPINT);
373#endif
374 WCHAR emptyW[] = { '\0' };
375 int len , reqLen;
376 LPSTR mem;
377
378 if (!lpDstStr || !lpnMultiCharCount)
379 return 0;
380
381 if (!lpSrcStr)
382 lpSrcStr = emptyW;
383
384 *lpDstStr = '\0';
385
386 len = strlenW(lpSrcStr) + 1;
387
388 switch (CodePage)
389 {
390 case CP_WINUNICODE:
391 CodePage = CP_UTF8; /* Fall through... */
392 case 0x0000C350: /* FIXME: CP_ #define */
393 case CP_UTF7:
394 case CP_UTF8:
395 {
396 DWORD dwMode = 0;
397 INT nWideCharCount = len - 1;
398
399 GET_FUNC(mlang, "ConvertINetUnicodeToMultiByte", 0);
400 if (!pfnFunc(&dwMode, CodePage, lpSrcStr, &nWideCharCount, lpDstStr,
401 lpnMultiCharCount))
402 return 0;
403
404 if (nWideCharCount < len - 1)
405 {
406 mem = (LPSTR)HeapAlloc(GetProcessHeap(), 0, *lpnMultiCharCount);
407 if (!mem)
408 return 0;
409
410 *lpnMultiCharCount = 0;
411
412 if (pfnFunc(&dwMode, CodePage, lpSrcStr, &len, mem, lpnMultiCharCount))
413 {
414 SHLWAPI_162 (mem, *lpnMultiCharCount);
415 lstrcpynA(lpDstStr, mem, *lpnMultiCharCount + 1);
416 return *lpnMultiCharCount + 1;
417 }
418 HeapFree(GetProcessHeap(), 0, mem);
419 return *lpnMultiCharCount;
420 }
421 lpDstStr[*lpnMultiCharCount] = '\0';
422 return *lpnMultiCharCount;
423 }
424 break;
425 default:
426 break;
427 }
428
429 reqLen = WideCharToMultiByte(CodePage, 0, lpSrcStr, len, lpDstStr,
430 *lpnMultiCharCount, NULL, NULL);
431
432 if (!reqLen && GetLastError() == ERROR_INSUFFICIENT_BUFFER)
433 {
434 reqLen = WideCharToMultiByte(CodePage, 0, lpSrcStr, len, NULL, 0, NULL, NULL);
435 if (reqLen)
436 {
437 mem = (LPSTR)HeapAlloc(GetProcessHeap(), 0, reqLen);
438 if (mem)
439 {
440 reqLen = WideCharToMultiByte(CodePage, 0, lpSrcStr, len, mem,
441 reqLen, NULL, NULL);
442
443 reqLen = SHLWAPI_162(mem, *lpnMultiCharCount);
444 reqLen++;
445
446 lstrcpynA(lpDstStr, mem, *lpnMultiCharCount);
447
448 HeapFree(GetProcessHeap(), 0, mem);
449 }
450 }
451 }
452 return reqLen;
453}
454
455/*************************************************************************
456 * SHLWAPI_217 [SHLWAPI.217]
457 *
458 */
459INT WINAPI SHLWAPI_217(LPCWSTR lpSrcStr, LPSTR lpDstStr, LPINT lpnMultiCharCount)
460{
461 return SHLWAPI_218(CP_ACP, lpSrcStr, lpDstStr, lpnMultiCharCount);
462}
463
464#ifndef __WIN32OS2__
465/*************************************************************************
466 * SHLWAPI_219 [SHLWAPI.219]
467 *
468 * NOTES
469 * error codes: E_POINTER, E_NOINTERFACE
470 */
471HRESULT WINAPI SHLWAPI_219 (
472 LPVOID w, /* [???] NOTE: returned by LocalAlloc, 0x450 bytes, iface */
473 LPVOID x,
474 REFIID riid,
475 LPWSTR z) /* [???] NOTE: OUT: path */
476{
477 FIXME("(%p %p %s %p)stub\n",w,x,debugstr_guid(riid),z);
478 return 0xabba1252;
479}
480#endif
481
482/*************************************************************************
483 * SHLWAPI_222 [SHLWAPI.222]
484 *
485 * NOTES
486 * securityattributes missing
487 */
488HANDLE WINAPI SHLWAPI_222 (LPCLSID guid)
489{
490 char lpstrName[80];
491
492 sprintf( lpstrName, "shell.{%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
493 guid->Data1, guid->Data2, guid->Data3,
494 guid->Data4[0], guid->Data4[1], guid->Data4[2], guid->Data4[3],
495 guid->Data4[4], guid->Data4[5], guid->Data4[6], guid->Data4[7] );
496 FIXME("(%s) stub\n", lpstrName);
497 return CreateSemaphoreA(NULL,0, 0x7fffffff, lpstrName);
498}
499
500/*************************************************************************
501 * SHLWAPI_223 [SHLWAPI.223]
502 *
503 * NOTES
504 * get the count of the semaphore
505 */
506DWORD WINAPI SHLWAPI_223 (HANDLE handle)
507{
508 DWORD oldCount;
509
510 FIXME("(0x%08x) stub\n",handle);
511
512 ReleaseSemaphore( handle, 1, &oldCount); /* +1 */
513 WaitForSingleObject( handle, 0 ); /* -1 */
514 return oldCount;
515}
516
517/*************************************************************************
518 * SHLWAPI_237 [SHLWAPI.237]
519 *
520 * Unicode version of SHLWAPI_183.
521 */
522DWORD WINAPI SHLWAPI_237 (WNDCLASSW * lpWndClass)
523{
524 WNDCLASSW WndClass;
525
526 TRACE("(0x%08x %s)\n",lpWndClass->hInstance, debugstr_w(lpWndClass->lpszClassName));
527
528 if (GetClassInfoW(lpWndClass->hInstance, lpWndClass->lpszClassName, &WndClass))
529 return TRUE;
530 return RegisterClassW(lpWndClass);
531}
532
533/*************************************************************************
534 * SHLWAPI_240 [SHLWAPI.240]
535 *
536 * Calls ASCII or Unicode WindowProc for the given window.
537 */
538LRESULT CALLBACK SHLWAPI_240(HWND hWnd, UINT uMessage, WPARAM wParam, LPARAM lParam)
539{
540 if (IsWindowUnicode(hWnd))
541 return DefWindowProcW(hWnd, uMessage, wParam, lParam);
542 return DefWindowProcA(hWnd, uMessage, wParam, lParam);
543}
544#ifndef __WIN32OS2__
545/*************************************************************************
546 * SHLWAPI_241 [SHLWAPI.241]
547 *
548 */
549DWORD WINAPI SHLWAPI_241 ()
550{
551 FIXME("()stub\n");
552 return 0xabba1243;
553}
554
555/*************************************************************************
556 * SHLWAPI_266 [SHLWAPI.266]
557 */
558DWORD WINAPI SHLWAPI_266 (
559 LPVOID w,
560 LPVOID x,
561 LPVOID y,
562 LPVOID z)
563{
564 FIXME("(%p %p %p %p)stub\n",w,x,y,z);
565 return 0xabba1248;
566}
567
568/*************************************************************************
569 * SHLWAPI_267 [SHLWAPI.267]
570 */
571HRESULT WINAPI SHLWAPI_267 (
572 LPVOID w, /* [???] NOTE: same as 1th parameter of SHLWAPI_219 */
573 LPVOID x, /* [???] NOTE: same as 2nd parameter of SHLWAPI_219 */
574 LPVOID y,
575 LPVOID z)
576{
577 FIXME("(%p %p %p %p)stub\n",w,x,y,z);
578 *((LPDWORD)z) = 0xabba1200;
579 return 0xabba1254;
580}
581
582/*************************************************************************
583 * SHLWAPI_268 [SHLWAPI.268]
584 */
585DWORD WINAPI SHLWAPI_268 (
586 LPVOID w,
587 LPVOID x)
588{
589 FIXME("(%p %p)\n",w,x);
590 return 0xabba1251; /* 0 = failure */
591}
592
593/*************************************************************************
594 * SHLWAPI_276 [SHLWAPI.276]
595 *
596 */
597DWORD WINAPI SHLWAPI_276 ()
598{
599 FIXME("()stub\n");
600 return 0xabba1244;
601}
602#endif
603/*************************************************************************
604 * SHLWAPI_278 [SHLWAPI.278]
605 *
606 */
607DWORD WINAPI SHLWAPI_278 (
608 LONG wndProc,
609 HWND hWndParent,
610 DWORD dwExStyle,
611 DWORD dwStyle,
612 HMENU hMenu,
613 LONG z)
614{
615 WNDCLASSA wndclass;
616 HWND hwnd;
617 HCURSOR hCursor;
618 char * clsname = "WorkerA";
619
620 FIXME("(0x%08lx 0x%08x 0x%08lx 0x%08lx 0x%08x 0x%08lx)stub\n",
621 wndProc,hWndParent,dwExStyle,dwStyle,hMenu,z);
622
623 hCursor = LoadCursorA(0x00000000,IDC_ARROWA);
624
625 if(!GetClassInfoA(shlwapi_hInstance, clsname, &wndclass))
626 {
627 RtlZeroMemory(&wndclass, sizeof(WNDCLASSA));
628 wndclass.lpfnWndProc = DefWindowProcW;
629 wndclass.cbWndExtra = 4;
630 wndclass.hInstance = shlwapi_hInstance;
631 wndclass.hCursor = hCursor;
632 wndclass.hbrBackground = COLOR_BTNSHADOW;
633 wndclass.lpszMenuName = NULL;
634 wndclass.lpszClassName = clsname;
635 RegisterClassA (&wndclass);
636 }
637 hwnd = CreateWindowExA(dwExStyle, clsname, 0,dwStyle,0,0,0,0,hWndParent,
638 hMenu,shlwapi_hInstance,0);
639 SetWindowLongA(hwnd, 0, z);
640 SetWindowLongA(hwnd, GWL_WNDPROC, wndProc);
641 return hwnd;
642}
643
644/*************************************************************************
645 * SHLWAPI_289 [SHLWAPI.289]
646 *
647 * Late bound call to winmm.PlaySoundW
648 */
649BOOL WINAPI SHLWAPI_289(LPCWSTR pszSound, HMODULE hmod, DWORD fdwSound)
650{
651 static BOOL (* WINAPI pfnFunc)(LPCWSTR, HMODULE, DWORD) = NULL;
652
653 GET_FUNC(winmm, "PlaySoundW", FALSE);
654 return pfnFunc(pszSound, hmod, fdwSound);
655}
656
657/*************************************************************************
658 * SHLWAPI_313 [SHLWAPI.313]
659 *
660 * Late bound call to shell32.SHGetFileInfoW
661 */
662DWORD WINAPI SHLWAPI_313(LPCWSTR path, DWORD dwFileAttributes,
663 SHFILEINFOW *psfi, UINT sizeofpsfi, UINT flags)
664{
665 static DWORD (* WINAPI pfnFunc)(LPCWSTR,DWORD,SHFILEINFOW*,UINT,UINT) = NULL;
666
667 GET_FUNC(shell32, "SHGetFileInfoW", 0);
668 return pfnFunc(path, dwFileAttributes, psfi, sizeofpsfi, flags);
669}
670
671/*************************************************************************
672 * SHLWAPI_318 [SHLWAPI.318]
673 *
674 * Late bound call to shell32.DragQueryFileW
675 */
676UINT WINAPI SHLWAPI_318(HDROP hDrop, UINT lFile, LPWSTR lpszFile, UINT lLength)
677{
678 static UINT (* WINAPI pfnFunc)(HDROP, UINT, LPWSTR, UINT) = NULL;
679
680 GET_FUNC(shell32, "DragQueryFileW", 0);
681 return pfnFunc(hDrop, lFile, lpszFile, lLength);
682}
683
684/*************************************************************************
685 * SHLWAPI_333 [SHLWAPI.333]
686 *
687 * Late bound call to shell32.SHBrowseForFolderW
688 */
689LPITEMIDLIST WINAPI SHLWAPI_333(LPBROWSEINFOW lpBi)
690{
691 static LPITEMIDLIST (* WINAPI pfnFunc)(LPBROWSEINFOW) = NULL;
692
693 GET_FUNC(shell32, "SHBrowseForFolderW", NULL);
694 return pfnFunc(lpBi);
695}
696
697/*************************************************************************
698 * SHLWAPI_334 [SHLWAPI.334]
699 *
700 * Late bound call to shell32.SHGetPathFromIDListW
701 */
702BOOL WINAPI SHLWAPI_334(LPCITEMIDLIST pidl,LPWSTR pszPath)
703{
704 static BOOL (* WINAPI pfnFunc)(LPCITEMIDLIST, LPWSTR) = NULL;
705
706 GET_FUNC(shell32, "SHGetPathFromIDListW", 0);
707 return pfnFunc(pidl, pszPath);
708}
709
710/*************************************************************************
711 * SHLWAPI_335 [SHLWAPI.335]
712 *
713 * Late bound call to shell32.ShellExecuteExW
714 */
715BOOL WINAPI SHLWAPI_335(LPSHELLEXECUTEINFOW lpExecInfo)
716{
717 static BOOL (* WINAPI pfnFunc)(LPSHELLEXECUTEINFOW) = NULL;
718
719 GET_FUNC(shell32, "ShellExecuteExW", FALSE);
720 return pfnFunc(lpExecInfo);
721}
722
723/*************************************************************************
724 * SHLWAPI_336 [SHLWAPI.336]
725 *
726 * Late bound call to shell32.SHFileOperationW.
727 */
728DWORD WINAPI SHLWAPI_336(LPSHFILEOPSTRUCTW lpFileOp)
729{
730 static HICON (* WINAPI pfnFunc)(LPSHFILEOPSTRUCTW) = NULL;
731
732 GET_FUNC(shell32, "SHFileOperationW", 0);
733 return pfnFunc(lpFileOp);
734}
735
736/*************************************************************************
737 * SHLWAPI_337 [SHLWAPI.337]
738 *
739 * Late bound call to shell32.ExtractIconExW.
740 */
741HICON WINAPI SHLWAPI_337(LPCWSTR lpszFile, INT nIconIndex, HICON *phiconLarge,
742 HICON *phiconSmall, UINT nIcons)
743{
744 static HICON (* WINAPI pfnFunc)(LPCWSTR, INT,HICON *,HICON *, UINT) = NULL;
745
746 GET_FUNC(shell32, "ExtractIconExW", (HICON)0);
747 return pfnFunc(lpszFile, nIconIndex, phiconLarge, phiconSmall, nIcons);
748}
749#ifndef __WIN32OS2__
750/*************************************************************************
751 * SHLWAPI_342 [SHLWAPI.342]
752 *
753 */
754DWORD WINAPI SHLWAPI_342 (
755 LPVOID w,
756 LPVOID x,
757 LPVOID y,
758 LPVOID z)
759{
760 FIXME("(%p %p %p %p)stub\n",w,x,y,z);
761 return 0xabba1249;
762}
763#endif
764/*************************************************************************
765 * SHLWAPI_346 [SHLWAPI.346]
766 */
767DWORD WINAPI SHLWAPI_346 (
768 LPCWSTR src,
769 LPWSTR dest,
770 int len)
771{
772 FIXME("(%s %p 0x%08x)stub\n",debugstr_w(src),dest,len);
773 lstrcpynW(dest, src, len);
774 return lstrlenW(dest)+1;
775}
776
777/*************************************************************************
778 * SHLWAPI_357 [SHLWAPI.357]
779 *
780 * Late bound call to shell32.SHGetNewLinkInfoW
781 */
782BOOL WINAPI SHLWAPI_357(LPCWSTR pszLinkTo, LPCWSTR pszDir, LPWSTR pszName,
783 BOOL *pfMustCopy, UINT uFlags)
784{
785 static BOOL (* WINAPI pfnFunc)(LPCWSTR, LPCWSTR, LPCWSTR, BOOL*, UINT) = NULL;
786
787 GET_FUNC(shell32, "SHGetNewLinkInfoW", FALSE);
788 return pfnFunc(pszLinkTo, pszDir, pszName, pfMustCopy, uFlags);
789}
790
791/*************************************************************************
792 * SHLWAPI_358 [SHLWAPI.358]
793 *
794 * Late bound call to shell32.SHDefExtractIconW
795 */
796DWORD WINAPI SHLWAPI_358(LPVOID arg1, LPVOID arg2, LPVOID arg3, LPVOID arg4,
797 LPVOID arg5, LPVOID arg6)
798{
799 /* FIXME: Correct args */
800 static DWORD (* WINAPI pfnFunc)(LPVOID, LPVOID, LPVOID, LPVOID, LPVOID, LPVOID) = NULL;
801
802 GET_FUNC(shell32, "SHDefExtractIconW", 0);
803 return pfnFunc(arg1, arg2, arg3, arg4, arg5, arg6);
804}
805
806/*************************************************************************
807 * SHLWAPI_364 [SHLWAPI.364]
808 *
809 * Wrapper for lstrcpynA with src and dst swapped.
810 */
811DWORD WINAPI SHLWAPI_364(LPCSTR src, LPSTR dst, INT n)
812{
813 lstrcpynA(dst, src, n);
814 return TRUE;
815}
816
817/*************************************************************************
818 * SHLWAPI_370 [SHLWAPI.370]
819 *
820 * Late bound call to shell32.ExtractIconW
821 */
822HICON WINAPI SHLWAPI_370(HINSTANCE hInstance, LPCWSTR lpszExeFileName,
823 UINT nIconIndex)
824{
825 static HICON (* WINAPI pfnFunc)(HINSTANCE, LPCWSTR, UINT) = NULL;
826
827 GET_FUNC(shell32, "ExtractIconW", (HICON)0);
828 return pfnFunc(hInstance, lpszExeFileName, nIconIndex);
829}
830
831/*************************************************************************
832 * SHLWAPI_376 [SHLWAPI.376]
833 */
834DWORD WINAPI SHLWAPI_376 (LONG x)
835{
836 FIXME("(0x%08lx)stub\n", x );
837 /* FIXME: This should be a forward in the .spec file to the win2k function
838 * kernel32.GetUserDefaultUILanguage, however that function isn't there yet.
839 */
840 return 0xabba1245;
841}
842#ifndef __WIN32OS2__
843/*************************************************************************
844 * SHLWAPI_377 [SHLWAPI.377]
845 */
846DWORD WINAPI SHLWAPI_377 (LPVOID x, LPVOID y, LPVOID z)
847{
848 FIXME("(%p %p %p)stub\n", x,y,z);
849 return 0xabba1246;
850}
851#endif
852/*************************************************************************
853 * SHLWAPI_378 [SHLWAPI.378]
854 */
855DWORD WINAPI SHLWAPI_378 (
856 LPSTR x,
857 LPVOID y, /* [???] 0x50000000 */
858 LPVOID z) /* [???] 4 */
859{
860 FIXME("(%s %p %p)stub\n", x,y,z);
861 return LoadLibraryA(x);
862}
863
864/*************************************************************************
865 * SHLWAPI_389 [SHLWAPI.389]
866 *
867 * Late bound call to comdlg32.GetSaveFileNameW
868 */
869BOOL WINAPI SHLWAPI_389(LPOPENFILENAMEW ofn)
870{
871 static BOOL (* WINAPI pfnFunc)(LPOPENFILENAMEW) = NULL;
872
873 GET_FUNC(comdlg32, "GetSaveFileNameW", FALSE);
874 return pfnFunc(ofn);
875}
876
877/*************************************************************************
878 * SHLWAPI_390 [SHLWAPI.390]
879 *
880 * Late bound call to mpr.WNetRestoreConnectionW
881 */
882DWORD WINAPI SHLWAPI_390(LPVOID arg1, LPVOID arg2)
883{
884 /* FIXME: Correct args */
885 static DWORD (* WINAPI pfnFunc)(LPVOID, LPVOID) = NULL;
886
887 GET_FUNC(mpr, "WNetRestoreConnectionW", 0);
888 return pfnFunc(arg1, arg2);
889}
890
891/*************************************************************************
892 * SHLWAPI_391 [SHLWAPI.391]
893 *
894 * Late bound call to mpr.WNetGetLastErrorW
895 */
896DWORD WINAPI SHLWAPI_391(LPVOID arg1, LPVOID arg2, LPVOID arg3, LPVOID arg4,
897 LPVOID arg5)
898{
899 /* FIXME: Correct args */
900 static DWORD (* WINAPI pfnFunc)(LPVOID, LPVOID, LPVOID, LPVOID, LPVOID) = NULL;
901
902 GET_FUNC(mpr, "WNetGetLastErrorW", 0);
903 return pfnFunc(arg1, arg2, arg3, arg4, arg5);
904}
905
906/*************************************************************************
907 * SHLWAPI_401 [SHLWAPI.401]
908 *
909 * Late bound call to comdlg32.PageSetupDlgW
910 */
911BOOL WINAPI SHLWAPI_401(LPPAGESETUPDLGW pagedlg)
912{
913 static BOOL (* WINAPI pfnFunc)(LPPAGESETUPDLGW) = NULL;
914
915 GET_FUNC(comdlg32, "PageSetupDlgW", FALSE);
916 return pfnFunc(pagedlg);
917}
918
919/*************************************************************************
920 * SHLWAPI_402 [SHLWAPI.402]
921 *
922 * Late bound call to comdlg32.PrintDlgW
923 */
924BOOL WINAPI SHLWAPI_402(LPPRINTDLGW printdlg)
925{
926 static BOOL (* WINAPI pfnFunc)(LPPRINTDLGW) = NULL;
927
928 GET_FUNC(comdlg32, "PrintDlgW", FALSE);
929 return pfnFunc(printdlg);
930}
931
932/*************************************************************************
933 * SHLWAPI_403 [SHLWAPI.403]
934 *
935 * Late bound call to comdlg32.GetOpenFileNameW
936 */
937BOOL WINAPI SHLWAPI_403(LPOPENFILENAMEW ofn)
938{
939 static BOOL (* WINAPI pfnFunc)(LPOPENFILENAMEW) = NULL;
940
941 GET_FUNC(comdlg32, "GetOpenFileNameW", FALSE);
942 return pfnFunc(ofn);
943}
944
945/* INTERNAL: Map from HLS color space to RGB */
946static WORD ConvertHue(int wHue, WORD wMid1, WORD wMid2)
947{
948 wHue = wHue > 240 ? wHue - 240 : wHue < 0 ? wHue + 240 : wHue;
949
950 if (wHue > 160)
951 return wMid1;
952 else if (wHue > 120)
953 wHue = 160 - wHue;
954 else if (wHue > 40)
955 return wMid2;
956
957 return ((wHue * (wMid2 - wMid1) + 20) / 40) + wMid1;
958}
959
960/* Convert to RGB and scale into RGB range (0..255) */
961#define GET_RGB(h) (ConvertHue(h, wMid1, wMid2) * 255 + 120) / 240
962
963/*************************************************************************
964 * ColorHLSToRGB [SHLWAPI.404]
965 *
966 * Convert from HLS color space into an RGB COLORREF.
967 *
968 * NOTES
969 * Input HLS values are constrained to the range (0..240).
970 */
971COLORREF WINAPI ColorHLSToRGB(WORD wHue, WORD wLuminosity, WORD wSaturation)
972{
973 WORD wRed;
974
975 if (wSaturation)
976 {
977 WORD wGreen, wBlue, wMid1, wMid2;
978
979 if (wLuminosity > 120)
980 wMid2 = wSaturation + wLuminosity - (wSaturation * wLuminosity + 120) / 240;
981 else
982 wMid2 = ((wSaturation + 240) * wLuminosity + 120) / 240;
983
984 wMid1 = wLuminosity * 2 - wMid2;
985
986 wRed = GET_RGB(wHue + 80);
987 wGreen = GET_RGB(wHue);
988 wBlue = GET_RGB(wHue - 80);
989
990 return RGB(wRed, wGreen, wBlue);
991 }
992
993 wRed = wLuminosity * 255 / 240;
994 return RGB(wRed, wRed, wRed);
995}
996
997/*************************************************************************
998 * SHLWAPI_431 [SHLWAPI.431]
999 */
1000DWORD WINAPI SHLWAPI_431 (DWORD x)
1001{
1002 FIXME("(0x%08lx)stub\n", x);
1003 return 0xabba1247;
1004}
1005
1006#ifndef __WIN32OS2__
1007/*************************************************************************
1008 * SHLWAPI_437 [SHLWAPI.437]
1009 *
1010 * NOTES
1011 * In the real shlwapi, One time initilisation calls GetVersionEx and reads
1012 * the registry to determine what O/S & Service Pack level is running, and
1013 * therefore which functions are available. Currently we always run as NT,
1014 * since this means that we don't need extra code to emulate Unicode calls,
1015 * they are forwarded directly to the appropriate API call instead.
1016 * Since the flags for whether to call or emulate Unicode are internal to
1017 * the dll, this function does not need a full implementation.
1018 */
1019DWORD WINAPI SHLWAPI_437 (DWORD functionToCall)
1020{
1021 FIXME("(0x%08lx)stub\n", functionToCall);
1022 return 0xabba1247;
1023}
1024#endif
1025
1026/*************************************************************************
1027 * SHCreateShellPalette [SHLWAPI.@]
1028 */
1029HPALETTE WINAPI SHCreateShellPalette(HDC hdc)
1030{
1031 FIXME("stub\n");
1032 return CreateHalftonePalette(hdc);
1033}
1034
1035/*************************************************************************
1036 * SHGetInverseCMAP
1037 */
1038DWORD WINAPI SHGetInverseCMAP (LPVOID x, DWORD why)
1039{
1040 FIXME("(%p, %#lx)stub\n", x, why);
1041 return 0;
1042}
1043#ifndef __WIN32OS2__
1044/*************************************************************************
1045 * SHIsLowMemoryMachine [SHLWAPI.@]
1046 */
1047DWORD WINAPI SHIsLowMemoryMachine (DWORD x)
1048{
1049 FIXME("0x%08lx\n", x);
1050 return 0;
1051}
1052#endif
1053
1054/*************************************************************************
1055 * GetMenuPosFromID [SHLWAPI.@]
1056 */
1057INT WINAPI GetMenuPosFromID(HMENU hMenu, UINT wID)
1058{
1059 MENUITEMINFOA mi;
1060 INT nCount = GetMenuItemCount(hMenu), nIter = 0;
1061
1062 while (nIter < nCount)
1063 {
1064 mi.wID = 0;
1065 if (!GetMenuItemInfoA(hMenu, nIter, TRUE, &mi) && mi.wID == wID)
1066 return nIter;
1067 nIter++;
1068 }
1069 return -1;
1070}
1071
1072/*************************************************************************
1073 * _SHGetInstanceExplorer [SHLWAPI.@]
1074 *
1075 * Late bound call to shell32.SHGetInstanceExplorer.
1076 */
1077HRESULT WINAPI _SHGetInstanceExplorer (LPUNKNOWN *lpUnknown)
1078{
1079 static HRESULT (* WINAPI pfnFunc)(LPUNKNOWN *) = NULL;
1080
1081 GET_FUNC(shell32, "SHGetInstanceExplorer", E_FAIL);
1082 return pfnFunc(lpUnknown);
1083}
Note: See TracBrowser for help on using the repository browser.