Initialize lpdwNeeded.
[wine/multimedia.git] / documentation / filehandles
blobb0575963b6db38c1adc613daf1881fb142d3a5bd
1 DOS treats the first 5 file handles as special cases.  They map directly
2 to stdin, stdout, stderr, stdaux and stdprn.  Windows 16 inherits this
3 behavoir, and in fact, win16 handles are interchangable with DOS handles.
4 Some nasty windows programs even do this!
6 Windows32 issues file handles starting from 1, on the grounds that
7 most GUI processes don't need a stdin, out, etc.
9 The wine handle code is implemented in the Win32 style, and the Win16
10 functions use two macros to convert to and from the two types.
12 The macros are defined in file.h as follows.:
13 #define HFILE16_TO_HFILE32(handle) \
14 (((handle)==0) ? GetStdHandle(STD_INPUT_HANDLE) : \
15  ((handle)==1) ? GetStdHandle(STD_OUTPUT_HANDLE) : \
16  ((handle)==2) ? GetStdHandle(STD_ERROR_HANDLE) : \
17  ((handle)>0x400) ? handle : \
18  (handle)-5)
20 #define HFILE32_TO_HFILE16(handle) ({ HFILE32 hnd=handle; \
21       ((hnd==HFILE_ERROR32) ? HFILE_ERROR16 : \
22       ((handle>0x400) ? handle : \
23        (HFILE16)hnd+5); })
25 WARNING: be careful not to use the macro HFILE16_TO_HFILE32 on
26 functions with side-effects, as it will cause them to be evaluated
27 several times.  This could be considered a bug, but the use of this
28 macro is limited enough not to need a rewrite.
30 NOTE: The 0x400 special case above deals with LZW filehandles (see 
31 misc/lzexpand.c).