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

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

restored old version

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