Implementation for PrivateExtractIcons, PrivateExtractIconEx.
[wine] / win32 / newfns.c
1 /*
2  * Win32 miscellaneous functions
3  *
4  * Copyright 1995 Thomas Sandford (tdgsandf@prds-grn.demon.co.uk)
5  */
6
7 /* Misc. new functions - they should be moved into appropriate files
8 at a later date. */
9
10 #include <string.h>
11 #include <sys/time.h>
12 #include <unistd.h>
13 #include "windef.h"
14 #include "winerror.h"
15 #include "heap.h"
16 #include "debugtools.h"
17
18 DEFAULT_DEBUG_CHANNEL(win32);
19 DECLARE_DEBUG_CHANNEL(debug);
20
21
22 /****************************************************************************
23  *              QueryPerformanceCounter (KERNEL32.564)
24  */
25 BOOL WINAPI QueryPerformanceCounter(PLARGE_INTEGER counter)
26 {
27     struct timeval tv;
28
29     gettimeofday(&tv,NULL);
30     counter->s.LowPart = tv.tv_usec+tv.tv_sec*1000000;
31     counter->s.HighPart = 0;
32     return TRUE;
33 }
34
35 /****************************************************************************
36  *              QueryPerformanceFrequency (KERNEL32.565)
37  */
38 BOOL WINAPI QueryPerformanceFrequency(PLARGE_INTEGER frequency)
39 {
40         frequency->s.LowPart    = 1000000;
41         frequency->s.HighPart   = 0;
42         return TRUE;
43 }
44
45 /****************************************************************************
46  *              FlushInstructionCache (KERNEL32.261)
47  */
48 BOOL WINAPI FlushInstructionCache(DWORD x,DWORD y,DWORD z) {
49         FIXME_(debug)("(0x%08lx,0x%08lx,0x%08lx): stub\n",x,y,z);
50         return TRUE;
51 }
52
53 /***********************************************************************
54  *           CreateNamedPipeA   (KERNEL32.168)
55  */
56 HANDLE WINAPI CreateNamedPipeA (LPCSTR lpName, DWORD dwOpenMode,
57                                   DWORD dwPipeMode, DWORD nMaxInstances,
58                                   DWORD nOutBufferSize, DWORD nInBufferSize,
59                                   DWORD nDefaultTimeOut,
60                                   LPSECURITY_ATTRIBUTES lpSecurityAttributes)
61 {
62   FIXME("(Name=%s, OpenMode=%#08lx, dwPipeMode=%#08lx, MaxInst=%ld, OutBSize=%ld, InBuffSize=%ld, DefTimeOut=%ld, SecAttr=%p): stub\n",
63         debugstr_a(lpName), dwOpenMode, dwPipeMode, nMaxInstances,
64         nOutBufferSize, nInBufferSize, nDefaultTimeOut, lpSecurityAttributes);
65   /* if (nMaxInstances > PIPE_UNLIMITED_INSTANCES) {
66     SetLastError (ERROR_INVALID_PARAMETER);
67     return INVALID_HANDLE_VALUE;
68   } */
69
70   SetLastError (ERROR_UNKNOWN);
71   return INVALID_HANDLE_VALUE;
72 }
73
74 /***********************************************************************
75  *           CreateNamedPipeW   (KERNEL32.169)
76  */
77 HANDLE WINAPI CreateNamedPipeW (LPCWSTR lpName, DWORD dwOpenMode,
78                                   DWORD dwPipeMode, DWORD nMaxInstances,
79                                   DWORD nOutBufferSize, DWORD nInBufferSize,
80                                   DWORD nDefaultTimeOut,
81                                   LPSECURITY_ATTRIBUTES lpSecurityAttributes)
82 {
83   FIXME("(Name=%s, OpenMode=%#08lx, dwPipeMode=%#08lx, MaxInst=%ld, OutBSize=%ld, InBuffSize=%ld, DefTimeOut=%ld, SecAttr=%p): stub\n",
84         debugstr_w(lpName), dwOpenMode, dwPipeMode, nMaxInstances,
85         nOutBufferSize, nInBufferSize, nDefaultTimeOut, lpSecurityAttributes);
86
87   SetLastError (ERROR_UNKNOWN);
88   return INVALID_HANDLE_VALUE;
89 }
90
91 /***********************************************************************
92  *           PeekNamedPipe   (KERNEL32.552)
93  */
94 BOOL WINAPI PeekNamedPipe (HANDLE hPipe,
95                 LPVOID lpvBuffer, DWORD cbBuffer,
96                 LPDWORD lpcbRead, LPDWORD lpcbAvail, LPDWORD lpcbMessage)
97 {
98   FIXME("(%08x, %p, %08lx, %p, %p, %p): stub\n",
99         hPipe, lpvBuffer, cbBuffer, lpcbRead, lpcbAvail, lpcbMessage);
100
101   SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
102   return FALSE;
103 }
104
105
106 /***********************************************************************
107  *           GetSystemPowerStatus      (KERNEL32.621)
108  */
109 BOOL WINAPI GetSystemPowerStatus(LPSYSTEM_POWER_STATUS sps_ptr)
110 {
111     return FALSE;   /* no power management support */
112 }
113
114
115 /***********************************************************************
116  *           SetSystemPowerState      (KERNEL32.630)
117  */
118 BOOL WINAPI SetSystemPowerState(BOOL suspend_or_hibernate,
119                                   BOOL force_flag)
120 {
121     /* suspend_or_hibernate flag: w95 does not support
122        this feature anyway */
123
124     for ( ;0; )
125     {
126         if ( force_flag )
127         {
128         }
129         else
130         {
131         }
132     }
133     return TRUE;
134 }
135
136
137 /******************************************************************************
138  * CreateMailslotA [KERNEL32.164]
139  */
140 HANDLE WINAPI CreateMailslotA( LPCSTR lpName, DWORD nMaxMessageSize,
141                                    DWORD lReadTimeout, LPSECURITY_ATTRIBUTES sa)
142 {
143     FIXME("(%s,%ld,%ld,%p): stub\n", debugstr_a(lpName),
144           nMaxMessageSize, lReadTimeout, sa);
145     return 1;
146 }
147
148
149 /******************************************************************************
150  * CreateMailslotW [KERNEL32.165]  Creates a mailslot with specified name
151  * 
152  * PARAMS
153  *    lpName          [I] Pointer to string for mailslot name
154  *    nMaxMessageSize [I] Maximum message size
155  *    lReadTimeout    [I] Milliseconds before read time-out
156  *    sa              [I] Pointer to security structure
157  *
158  * RETURNS
159  *    Success: Handle to mailslot
160  *    Failure: INVALID_HANDLE_VALUE
161  */
162 HANDLE WINAPI CreateMailslotW( LPCWSTR lpName, DWORD nMaxMessageSize,
163                                    DWORD lReadTimeout, LPSECURITY_ATTRIBUTES sa )
164 {
165     FIXME("(%s,%ld,%ld,%p): stub\n", debugstr_w(lpName), 
166           nMaxMessageSize, lReadTimeout, sa);
167     return 1;
168 }
169
170
171 /******************************************************************************
172  * GetMailslotInfo [KERNEL32.347]  Retrieves info about specified mailslot
173  *
174  * PARAMS
175  *    hMailslot        [I] Mailslot handle
176  *    lpMaxMessageSize [O] Address of maximum message size
177  *    lpNextSize       [O] Address of size of next message
178  *    lpMessageCount   [O] Address of number of messages
179  *    lpReadTimeout    [O] Address of read time-out
180  * 
181  * RETURNS
182  *    Success: TRUE
183  *    Failure: FALSE
184  */
185 BOOL WINAPI GetMailslotInfo( HANDLE hMailslot, LPDWORD lpMaxMessageSize,
186                                LPDWORD lpNextSize, LPDWORD lpMessageCount,
187                                LPDWORD lpReadTimeout )
188 {
189     FIXME("(%04x): stub\n",hMailslot);
190     if (lpMaxMessageSize) *lpMaxMessageSize = (DWORD)NULL;
191     if (lpNextSize) *lpNextSize = (DWORD)NULL;
192     if (lpMessageCount) *lpMessageCount = (DWORD)NULL;
193     if (lpReadTimeout) *lpReadTimeout = (DWORD)NULL;
194     return TRUE;
195 }
196
197
198 /******************************************************************************
199  * GetCompressedFileSizeA [KERNEL32.291]
200  *
201  * NOTES
202  *    This should call the W function below
203  */
204 DWORD WINAPI GetCompressedFileSizeA(
205     LPCSTR lpFileName,
206     LPDWORD lpFileSizeHigh)
207 {
208     FIXME("(...): stub\n");
209     return 0xffffffff;
210 }
211
212
213 /******************************************************************************
214  * GetCompressedFileSizeW [KERNEL32.292]  
215  * 
216  * RETURNS
217  *    Success: Low-order doubleword of number of bytes
218  *    Failure: 0xffffffff
219  */
220 DWORD WINAPI GetCompressedFileSizeW(
221     LPCWSTR lpFileName,     /* [in]  Pointer to name of file */
222     LPDWORD lpFileSizeHigh) /* [out] Receives high-order doubleword of size */
223 {
224     FIXME("(%s,%p): stub\n",debugstr_w(lpFileName),lpFileSizeHigh);
225     return 0xffffffff;
226 }
227
228
229 /******************************************************************************
230  * GetProcessWindowStation [USER32.280]  Returns handle of window station
231  *
232  * NOTES
233  *    Docs say the return value is HWINSTA
234  *
235  * RETURNS
236  *    Success: Handle to window station associated with calling process
237  *    Failure: NULL
238  */
239 DWORD WINAPI GetProcessWindowStation(void)
240 {
241     FIXME("(void): stub\n");
242     return 1;
243 }
244
245
246 /******************************************************************************
247  * GetThreadDesktop [USER32.295]  Returns handle to desktop
248  *
249  * NOTES
250  *    Docs say the return value is HDESK
251  *
252  * PARAMS
253  *    dwThreadId [I] Thread identifier
254  *
255  * RETURNS
256  *    Success: Handle to desktop associated with specified thread
257  *    Failure: NULL
258  */
259 DWORD WINAPI GetThreadDesktop( DWORD dwThreadId )
260 {
261     FIXME("(%lx): stub\n",dwThreadId);
262     return 1;
263 }
264
265
266 /******************************************************************************
267  * SetDebugErrorLevel [USER32.475]
268  * Sets the minimum error level for generating debugging events
269  *
270  * PARAMS
271  *    dwLevel [I] Debugging error level
272  */
273 VOID WINAPI SetDebugErrorLevel( DWORD dwLevel )
274 {
275     FIXME("(%ld): stub\n", dwLevel);
276 }
277
278
279 /******************************************************************************
280  * SetComputerNameA [KERNEL32.621]  
281  */
282 BOOL WINAPI SetComputerNameA( LPCSTR lpComputerName )
283 {
284     LPWSTR lpComputerNameW = HEAP_strdupAtoW(GetProcessHeap(),0,lpComputerName);
285     BOOL ret = SetComputerNameW(lpComputerNameW);
286     HeapFree(GetProcessHeap(),0,lpComputerNameW);
287     return ret;
288 }
289
290
291 /******************************************************************************
292  * SetComputerNameW [KERNEL32.622]
293  *
294  * PARAMS
295  *    lpComputerName [I] Address of new computer name
296  * 
297  * RETURNS STD
298  */
299 BOOL WINAPI SetComputerNameW( LPCWSTR lpComputerName )
300 {
301     FIXME("(%s): stub\n", debugstr_w(lpComputerName));
302     return TRUE;
303 }
304
305 /******************************************************************************
306  *              EnumPortsA
307  */
308 BOOL WINAPI EnumPortsA(LPSTR name,DWORD level,LPBYTE ports,DWORD bufsize,LPDWORD bufneeded,LPDWORD bufreturned) {
309         FIXME("(%s,%ld,%p,%ld,%p,%p), stub!\n",name,level,ports,bufsize,bufneeded,bufreturned);
310         return FALSE;
311 }
312
313 /******************************************************************************
314  * OpenDesktopA [USER32.408]
315  *
316  * NOTES
317  *    Return type should be HDESK
318  *
319  *    Not supported on Win9x - returns NULL and calls SetLastError.
320  */
321 HANDLE WINAPI OpenDesktopA( LPCSTR lpszDesktop, DWORD dwFlags, 
322                                 BOOL fInherit, DWORD dwDesiredAccess )
323 {
324     FIXME("(%s,%lx,%i,%lx): stub\n",debugstr_a(lpszDesktop),dwFlags,
325           fInherit,dwDesiredAccess);
326
327     SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
328     return 0;
329 }
330
331
332 /******************************************************************************
333  *              SetUserObjectInformationA
334  */
335 BOOL WINAPI SetUserObjectInformationA( HANDLE hObj, INT nIndex, 
336                                        LPVOID pvInfo, DWORD nLength )
337 {
338     FIXME("(%x,%d,%p,%lx): stub\n",hObj,nIndex,pvInfo,nLength);
339     return TRUE;
340 }
341
342 /******************************************************************************
343  *              SetThreadDesktop
344  */
345 BOOL WINAPI SetThreadDesktop( HANDLE hDesktop )
346 {
347     FIXME("(%x): stub\n",hDesktop);
348     return TRUE;
349 }
350
351 /******************************************************************************
352  *              CreateIoCompletionPort
353  */
354 HANDLE WINAPI CreateIoCompletionPort(HANDLE hFileHandle,
355 HANDLE hExistingCompletionPort, DWORD dwCompletionKey,
356 DWORD dwNumberOfConcurrentThreads)
357 {
358     FIXME("(%04x, %04x, %08lx, %08lx): stub.\n", hFileHandle, hExistingCompletionPort, dwCompletionKey, dwNumberOfConcurrentThreads);
359     return (HANDLE)NULL;
360 }
361
362
363 /******************************************************************************
364  *                    GetProcessDefaultLayout [USER32.802]
365  *
366  * Gets the default layout for parentless windows.
367  * Right now, just returns 0 (left-to-right).
368  *
369  * RETURNS
370  *    Success: Nonzero
371  *    Failure: Zero
372  *
373  * BUGS
374  *    No RTL
375  */
376 BOOL WINAPI GetProcessDefaultLayout( DWORD *pdwDefaultLayout )
377 {
378     if ( !pdwDefaultLayout ) {
379         SetLastError( ERROR_INVALID_PARAMETER );
380         return FALSE;
381      }
382     FIXME( "( %p ): No BiDi\n", pdwDefaultLayout );
383     *pdwDefaultLayout = 0;
384     return TRUE;
385 }
386
387
388 /******************************************************************************
389  *                    SetProcessDefaultLayout [USER32.803]
390  *
391  * Sets the default layout for parentless windows.
392  * Right now, only accepts 0 (left-to-right).
393  *
394  * RETURNS
395  *    Success: Nonzero
396  *    Failure: Zero
397  *
398  * BUGS
399  *    No RTL
400  */
401 BOOL WINAPI SetProcessDefaultLayout( DWORD dwDefaultLayout )
402 {
403     if ( dwDefaultLayout == 0 )
404         return TRUE;
405     FIXME( "( %08lx ): No BiDi\n", dwDefaultLayout );
406     SetLastError( ERROR_CALL_NOT_IMPLEMENTED );
407     return FALSE;
408 }
409