(Merged by Marcus Meissner <marcus@jet.franken.de>)
[wine] / dlls / shlwapi / ordinal.c
1 /*
2  * SHLWAPI ordinal functions
3  * 
4  * Copyright 1997 Marcus Meissner
5  *           1998 Jürgen Schmied
6  */
7
8 #include <stdio.h>
9
10 #include "windef.h"
11 #include "wine/undocshell.h"
12 #include "wine/unicode.h"
13 #include "debugtools.h"
14
15 DEFAULT_DEBUG_CHANNEL(shell);
16
17 extern HINSTANCE shlwapi_hInstance;
18
19 /*
20  NOTES: The most functions exported by ordinal seem to be superflous.
21  The reason for these functions to be there is to provide a wraper
22  for unicode functions to providing these functions on systems without
23  unicode functions eg. win95/win98. Since we have such functions we just
24  call these.
25 */
26
27 /*************************************************************************
28  *      SHLWAPI_1       [SHLWAPI.1]
29  */
30 DWORD WINAPI SHLWAPI_1 (
31         LPSTR lpStr,
32         LPVOID x)
33 {
34         FIXME("(%p %s %p %s)\n",lpStr, debugstr_a(lpStr),x, debugstr_a(x));
35         return 0;
36 }
37
38 /*************************************************************************
39  *      SHLWAPI_16      [SHLWAPI.16]
40  */
41 HRESULT WINAPI SHLWAPI_16 (
42         LPVOID w,
43         LPVOID x,
44         LPVOID y,
45         LPWSTR z)
46 {
47         FIXME("(%p %p %p %p)stub\n",w,x,y,z);
48         return 0xabba1252;
49 }
50
51 /*************************************************************************
52  *      SHLWAPI_23      [SHLWAPI.23]
53  *
54  * NOTES
55  *      converts a guid to a string
56  *      returns strlen(str)
57  */
58 DWORD WINAPI SHLWAPI_23 (
59         REFGUID guid,   /* [in]  clsid */
60         LPSTR str,      /* [out] buffer */
61         INT cmax)       /* [in]  size of buffer */
62 {
63         char xguid[40];
64
65         sprintf( xguid, "{%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
66                  guid->Data1, guid->Data2, guid->Data3,
67                  guid->Data4[0], guid->Data4[1], guid->Data4[2], guid->Data4[3],
68                  guid->Data4[4], guid->Data4[5], guid->Data4[6], guid->Data4[7] );
69         TRACE("(%s %p 0x%08x)stub\n", xguid, str, cmax);
70         if (strlen(xguid)>=cmax) return 0;
71         strcpy(str,xguid);
72         return strlen(xguid) + 1;
73 }
74
75 /*************************************************************************
76  *      SHLWAPI_24      [SHLWAPI.24]
77  *
78  * NOTES
79  *      converts a guid to a string
80  *      returns strlen(str)
81  */
82 DWORD WINAPI SHLWAPI_24 (
83         REFGUID guid,   /* [in]  clsid */
84         LPWSTR str,     /* [out] buffer */
85         INT cmax)       /* [in]  size of buffer */
86 {
87     char xguid[40];
88
89     sprintf( xguid, "{%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
90              guid->Data1, guid->Data2, guid->Data3,
91              guid->Data4[0], guid->Data4[1], guid->Data4[2], guid->Data4[3],
92              guid->Data4[4], guid->Data4[5], guid->Data4[6], guid->Data4[7] );
93     return MultiByteToWideChar( CP_ACP, 0, xguid, -1, str, cmax );
94 }
95
96 /*************************************************************************
97  *      SHLWAPI_156     [SHLWAPI.156]
98  *
99  * FIXME: function guessed
100  */
101 DWORD WINAPI SHLWAPI_156 (
102         LPWSTR str1,    /* "shell32.dll" */
103         LPWSTR str2)    /* "shell32.dll" */
104 {
105         FIXME("(%s %s)stub\n",debugstr_w(str1),debugstr_w(str2));
106         return lstrcmpW(str1,str2);
107 }
108
109 /*************************************************************************
110  *      SHLWAPI_169     [SHLWAPI.169]
111  */
112 DWORD WINAPI SHLWAPI_169 (IUnknown * lpUnknown)
113 {
114         TRACE("(%p)\n",lpUnknown);
115 #if 0
116         if(!lpUnknown || !*((LPDWORD)lpUnknown)) return 0;
117         return IUnknown_Release(lpUnknown);
118 #endif
119         return 0;
120 }
121
122 /*************************************************************************
123  *      SHLWAPI_193     [SHLWAPI.193]
124  */
125 DWORD WINAPI SHLWAPI_193 ()
126 {
127         HDC hdc;
128         DWORD ret;
129
130         TRACE("()\n");
131
132         hdc = GetDC(0);
133         ret = GetDeviceCaps(hdc, BITSPIXEL) * GetDeviceCaps(hdc, PLANES);
134         ReleaseDC(0, hdc);
135         return ret;
136 }
137
138 /*************************************************************************
139  *      SHLWAPI_215     [SHLWAPI.215]
140  *
141  * NOTES
142  *  check me!
143  */
144 LPWSTR WINAPI SHLWAPI_215 (
145         LPWSTR lpStrSrc,
146         LPVOID lpwStrDest,
147         int len)
148 {
149         WARN("(%p %p %u)\n",lpStrSrc,lpwStrDest,len);
150         return strncpyW(lpwStrDest, lpStrSrc, len);
151 }
152
153 /*************************************************************************
154  *      SHLWAPI_219     [SHLWAPI.219]
155  *
156  * NOTES
157  *  error codes: E_POINTER, E_NOINTERFACE
158  */
159 HRESULT WINAPI SHLWAPI_219 (
160         LPVOID w, /* returned by LocalAlloc, 0x450 bytes, iface */
161         LPVOID x,
162         LPVOID y,
163         LPWSTR z) /* OUT: path */
164 {
165         FIXME("(%p %p %p %p)stub\n",w,x,y,z);
166         return 0xabba1252;
167 }
168
169 /*************************************************************************
170  *      SHLWAPI_222     [SHLWAPI.222]
171  *
172  * NOTES
173  *  securityattributes missing
174  */
175 HANDLE WINAPI SHLWAPI_222 (LPCLSID guid)
176 {
177         char lpstrName[80];
178
179         sprintf( lpstrName, "shell.{%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
180                  guid->Data1, guid->Data2, guid->Data3,
181                  guid->Data4[0], guid->Data4[1], guid->Data4[2], guid->Data4[3],
182                  guid->Data4[4], guid->Data4[5], guid->Data4[6], guid->Data4[7] );
183         FIXME("(%s) stub\n", lpstrName);
184         return CreateSemaphoreA(NULL,0, 0x7fffffff, lpstrName);
185 }
186
187 /*************************************************************************
188  *      SHLWAPI_223     [SHLWAPI.223]
189  *
190  * NOTES
191  *  get the count of the semaphore
192  */
193 DWORD WINAPI SHLWAPI_223 (HANDLE handle)
194 {
195         DWORD oldCount;
196         
197         FIXME("(0x%08x) stub\n",handle);
198
199         ReleaseSemaphore( handle, 1, &oldCount);        /* +1 */
200         WaitForSingleObject( handle, 0 );               /* -1 */
201         return oldCount;
202 }
203
204 /*************************************************************************
205  *      SHLWAPI_237     [SHLWAPI.237]
206  *
207  * NOTES
208  *  checks if a class is registered, if not it registers it
209  */
210 DWORD WINAPI SHLWAPI_237 (WNDCLASSW * lpWndClass)
211 {
212         WNDCLASSW WndClass;
213         
214         TRACE("(0x%08x %s)\n",lpWndClass->hInstance, debugstr_w(lpWndClass->lpszClassName));
215
216         if (!GetClassInfoW(lpWndClass->hInstance, lpWndClass->lpszClassName, &WndClass))
217         {
218           return RegisterClassW(lpWndClass);
219         }
220         return TRUE;
221 }
222
223 /*************************************************************************
224  *      SHLWAPI_241     [SHLWAPI.241]
225  *
226  */
227 DWORD WINAPI SHLWAPI_241 ()
228 {
229         FIXME("()stub\n");
230         return 0xabba1243;
231 }
232
233 /*************************************************************************
234  *      SHLWAPI_266     [SHLWAPI.266]
235  */
236 DWORD WINAPI SHLWAPI_266 (
237         LPVOID w,
238         LPVOID x,
239         LPVOID y,
240         LPVOID z)
241 {
242         FIXME("(%p %p %p %p)stub\n",w,x,y,z);
243         return 0xabba1248;
244 }
245
246 /*************************************************************************
247  *      SHLWAPI_267     [SHLWAPI.267]
248  */
249 HRESULT WINAPI SHLWAPI_267 (
250         LPVOID w, /* same as 1th parameter of SHLWAPI_219 */
251         LPVOID x, /* same as 2nd parameter of SHLWAPI_219 */
252         LPVOID y,
253         LPVOID z)
254 {
255         FIXME("(%p %p %p %p)stub\n",w,x,y,z);
256         *((LPDWORD)z) = 0xabba1200;
257         return 0xabba1254;
258 }
259
260 /*************************************************************************
261  *      SHLWAPI_268     [SHLWAPI.268]
262  */
263 DWORD WINAPI SHLWAPI_268 (
264         LPVOID w,
265         LPVOID x)
266 {
267         FIXME("(%p %p)\n",w,x);
268         return 0xabba1251; /* 0 = failure */
269 }
270
271 /*************************************************************************
272  *      SHLWAPI_276     [SHLWAPI.276]
273  *
274  */
275 DWORD WINAPI SHLWAPI_276 ()
276 {
277         FIXME("()stub\n");
278         return 0xabba1244;
279 }
280
281 /*************************************************************************
282  *      SHLWAPI_278     [SHLWAPI.278]
283  *
284  */
285 DWORD WINAPI SHLWAPI_278 (
286         LONG wndProc,
287         HWND hWndParent,
288         DWORD dwExStyle,
289         DWORD dwStyle,
290         HMENU hMenu,
291         LONG z)
292 {
293         WNDCLASSA wndclass;
294         HWND hwnd;
295         HCURSOR hCursor;
296         char * clsname = "WorkerA";
297         
298         FIXME("(0x%08lx 0x%08x 0x%08lx 0x%08lx 0x%08x 0x%08lx)stub\n",
299           wndProc,hWndParent,dwExStyle,dwStyle,hMenu,z);
300
301         hCursor = LoadCursorA(0x00000000,IDC_ARROWA);
302
303         if(!GetClassInfoA(shlwapi_hInstance, clsname, &wndclass))
304         {
305           RtlZeroMemory(&wndclass, sizeof(WNDCLASSA));
306           wndclass.lpfnWndProc = DefWindowProcW;
307           wndclass.cbWndExtra = 4;
308           wndclass.hInstance = shlwapi_hInstance;
309           wndclass.hCursor = hCursor;
310           wndclass.hbrBackground = COLOR_BTNSHADOW;
311           wndclass.lpszMenuName = NULL;
312           wndclass.lpszClassName = clsname;
313           RegisterClassA (&wndclass);
314         }
315         hwnd = CreateWindowExA(dwExStyle, clsname, 0,dwStyle,0,0,0,0,hWndParent,
316                 hMenu,shlwapi_hInstance,0);
317         SetWindowLongA(hwnd, 0, z);
318         SetWindowLongA(hwnd, GWL_WNDPROC, wndProc);
319         return hwnd;
320 }
321
322 /*************************************************************************
323  *      SHLWAPI_342     [SHLWAPI.342]
324  *
325  */
326 DWORD WINAPI SHLWAPI_342 (
327         LPVOID w,
328         LPVOID x,
329         LPVOID y,
330         LPVOID z)
331 {
332         FIXME("(%p %p %p %p)stub\n",w,x,y,z);
333         return 0xabba1249;
334 }
335
336 /*************************************************************************
337  *      SHLWAPI_346     [SHLWAPI.346]
338  */
339 DWORD WINAPI SHLWAPI_346 (
340         LPCWSTR src,
341         LPWSTR dest,
342         int len)
343 {
344         FIXME("(%s %p 0x%08x)stub\n",debugstr_w(src),dest,len);
345         lstrcpynW(dest, src, len);
346         return lstrlenW(dest)+1;
347 }
348
349
350 /*************************************************************************
351  *      SHLWAPI_377     [SHLWAPI.377]
352  */
353 DWORD WINAPI SHLWAPI_377 (LPVOID x, LPVOID y, LPVOID z)
354 {
355         FIXME("(%p %p %p)stub\n", x,y,z);
356         return 0xabba1246;
357 }
358
359 /*************************************************************************
360  *      SHLWAPI_378     [SHLWAPI.378]
361  */
362 DWORD WINAPI SHLWAPI_378 (
363         LPSTR x,
364         LPVOID y, /* 0x50000000 */
365         LPVOID z) /* 4 */
366 {
367         FIXME("(%s %p %p)stub\n", x,y,z);
368         return LoadLibraryA(x);
369 }
370
371 /*************************************************************************
372  *      SHLWAPI_431     [SHLWAPI.431]
373  */
374 DWORD WINAPI SHLWAPI_431 (DWORD x)
375 {
376         FIXME("(0x%08lx)stub\n", x);
377         return 0xabba1247;
378 }
379
380 /*************************************************************************
381  *      SHLWAPI_437     [SHLWAPI.437]
382  *
383  * NOTES
384  *  has to do something with switching the api between ascii and unicode
385  *  observed values: 0 and 5
386  *
387  * accesses
388  * HKLM\System\CurrentControlSet\Control\ProductOptions
389  *
390  */
391 DWORD WINAPI SHLWAPI_437 (DWORD x)
392 {
393         FIXME("(0x%08lx)stub\n", x);
394         return 0xabba1247;
395 }
396
397 /*************************************************************************
398  *      UrlEscapeA      [SHLWAPI]
399  */
400 HRESULT WINAPI UrlEscapeA(
401         LPCSTR pszUrl,
402         LPSTR pszEscaped,
403         LPDWORD pcchEscaped,
404         DWORD dwFlags)
405 {
406         FIXME("(%s %p %p 0x%08lx)stub\n",debugstr_a(pszUrl),
407           pszEscaped, pcchEscaped, dwFlags);
408         return 0;
409 }       
410
411 /*************************************************************************
412  *      UrlEscapeW      [SHLWAPI]
413  */
414 HRESULT WINAPI UrlEscapeW(
415         LPCWSTR pszUrl,
416         LPWSTR pszEscaped,
417         LPDWORD pcchEscaped,
418         DWORD dwFlags)
419 {
420         FIXME("(%s %p %p 0x%08lx)stub\n",debugstr_w(pszUrl),
421           pszEscaped, pcchEscaped, dwFlags);
422         return 0;
423 }       
424
425
426 /*************************************************************************
427  *      SHCreateShellPalette    [SHLWAPI.@]
428  */
429 HPALETTE WINAPI SHCreateShellPalette(HDC hdc)
430 {
431         FIXME("stub\n");
432         return CreateHalftonePalette(hdc);
433 }
434
435 /*************************************************************************
436  *      SHIsLowMemoryMachine    [SHLWAPI.@]
437  */
438 DWORD WINAPI SHIsLowMemoryMachine (DWORD x)
439 {
440         FIXME("0x%08lx\n", x);
441         return 0;
442 }