Recovery of release 990110 after disk crash.
See Changelog for changes between 990103 and 990110.

diff --git a/ANNOUNCE b/ANNOUNCE
index 8e1d7d6..960f4a5 100644
--- a/ANNOUNCE
+++ b/ANNOUNCE
@@ -1,4 +1,4 @@
-This is release 990103 of Wine, a free implementation of Windows on
+This is release 990110 of Wine, a free implementation of Windows on
 Unix.  This is still a developers only release.  There are many bugs
 and unimplemented features.  Most applications still do not work
 correctly.
@@ -6,11 +6,9 @@
 Patches should be submitted to "julliard@lrc.epfl.ch".  Please don't
 forget to include a ChangeLog entry.
 
-WHAT'S NEW with Wine-990103: (see ChangeLog for details)
-	- Improved console support.
-	- Tons of new stubs.
-	- Improvements to header files compatibility.
-	- More features in Wine server.
+WHAT'S NEW with Wine-990110: (see ChangeLog for details)
+	- Many more COM interfaces definitions.
+	- Improvements to the resource compiler.
 	- Lots of bug fixes.
 
 See the README file in the distribution for installation instructions.
@@ -19,10 +17,10 @@
 the release is available at the ftp sites.  The sources will be available
 from the following locations:
 
-  ftp://metalab.unc.edu/pub/Linux/ALPHA/wine/development/Wine-990103.tar.gz
-  ftp://tsx-11.mit.edu/pub/linux/ALPHA/Wine/development/Wine-990103.tar.gz
-  ftp://ftp.infomagic.com/pub/mirrors/linux/sunsite/ALPHA/wine/development/Wine-990103.tar.gz
-  ftp://ftp.progsoc.uts.edu.au/pub/Wine/development/Wine-990103.tar.gz
+  ftp://metalab.unc.edu/pub/Linux/ALPHA/wine/development/Wine-990110.tar.gz
+  ftp://tsx-11.mit.edu/pub/linux/ALPHA/Wine/development/Wine-990110.tar.gz
+  ftp://ftp.infomagic.com/pub/mirrors/linux/sunsite/ALPHA/wine/development/Wine-990110.tar.gz
+  ftp://ftp.progsoc.uts.edu.au/pub/Wine/development/Wine-990110.tar.gz
 
 It should also be available from any site that mirrors tsx-11 or sunsite.
 
diff --git a/ChangeLog b/ChangeLog
index 96c9e11..feec784 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,244 @@
+Sun Jan 10 14:40:34 1999  Alexandre Julliard  <julliard@winehq.com>
+
+	* include/miscemu.h, include/msdos.h, loader/main.c, msdos/Makefile.in, msdos/dosconf.c, msdos/int21.c:
+	Andreas Mohr <a.mohr@mailto.de>
+	Added config.sys parser.
+
+	* controls/listbox.c: Pascal Cuoq <Pascal.Cuoq@inria.fr>
+	Small change in LB_SETCURSEL32 handling (the caret should be moved as
+	well).
+
+	* configure, configure.in, files/async.c, include/config.h.in, misc/winsock_dns.c, msdos/int21.c, ole/compobj.c:
+	Marcus Meissner <marcus@jet.franken.de>
+	Use autoconf check for presence of sys/file.h.
+
+	* dlls/ntdll/rtl.c, relay32/ntdll.spec:
+	Marcus Meissner <marcus@jet.franken.de>
+	Implemented DbgPrint, added ultoa.
+
+	* win32/console.c: Peter Hunnisett <hunnise@nortelnetworks.com>
+	PeekConsoleInput & ReadConsoleInput need to return 0 records read in
+	the case of an invalid handle.
+
+	* console/ncurses.c, loader/main.c:
+	Joseph Pranevich <jpranevich@lycos.com>
+	More verbose debugging output.
+	Remove compilation warning.
+
+	* msdos/int10.c: Joseph Pranevich <jpranevich@lycos.com>
+	Fix up some interrupt calls to return at the data that they are supposed
+	to. Also increase comment verbosity to help debug things later.
+
+	* include/options.h, misc/main.c, misc/version.c:
+	Andreas Mohr <a.mohr@mailto.de>
+	Added switch -dosver.
+	Cleanup for OaBuildVersion().
+
+	* libtest/.cvsignore: Added vartest and volinfo
+
+	* dlls/shell32/contmenu.c, dlls/shell32/pidl.c, dlls/shell32/pidl.h, dlls/shell32/shelllink.c, dlls/shell32/shellord.c, dlls/shell32/shlfolder.c, dlls/shell32/shlview.c, include/shell.h:
+	Juergen Schmied <juergen.schmied@metronet.de>
+	Many bugfixes, code cleanup.
+	Removed a few glitches from the COM patch.
+
+	* windows/dialog.c: Lawson Whitney <lawson_whitney@juno.com>
+	Only destroy window once.
+
+	* graphics/ddraw.c, include/ddraw.h:
+	Marcus Meissner <marcus@jet.franken.de>
+	- moved drawable to common since it is used by both DGA and Xlib.
+	  (fixes one bad memory corruption bug in DGA (StarCraft and Diablo)
+	- added BltFast sanity checks.
+
+	* windows/queue.c, loader/task.c:
+	Ulrich Weigand <weigand@informatik.uni-erlangen.de>
+	InitApp() call removed from 32-bit application startup;
+	create task message queue in InitThreadInput() instead.
+
+	* loader/ne/convert.c:
+	Ulrich Weigand <weigand@informatik.uni-erlangen.de>
+	Added accelerator table PE->NE resource conversion.
+
+	* debugger/editline.c:
+	Ulrich Weigand <weigand@informatik.uni-erlangen.de>
+	Restart read() in case of EINTR in TTYget().
+
+	* dlls/shell32/shellole.c: Marcus Meissner <marcus@jet.franken.de>
+	Ptr ref wrong.
+
+	* tools/wrc/CHANGES, tools/wrc/dumpres.c, tools/wrc/genres.c, tools/wrc/newstruc.c, tools/wrc/newstruc.h, tools/wrc/parser.l, tools/wrc/parser.y, tools/wrc/readres.c, tools/wrc/utils.c, tools/wrc/utils.h, tools/wrc/wrc.h, tools/wrc/wrctypes.h, tools/wrc/writeres.c:
+	Bertho Stultiens <bertho@panter.soci.aau.dk>
+	Wrc version 1.0.8. Toolbar resources are now supported. A couple of
+	other fixes are also included. See file tools/wrc/CHANGES for details.
+
+	* ole/compobj.c: Marcus Meissner <marcus@jet.franken.de>
+	Missing WINAPI.
+
+	* include/x11drv.h, loader/dos/module.c, objects/dc.c, relay32/builtin32.c, relay32/relay386.c, scheduler/k32obj.c, files/async.c, if1632/relay.c, include/main.h, include/multimedia.h, include/windows.h:
+	James Juran <jrj120@psu.edu>
+	Add missing #includes and prototypes to eliminate some implicit
+	function declaration warnings and 'extern's in .c files.
+
+	* configure, configure.in, console/ncurses.c, include/acconfig.h, include/config.h.in:
+	Ove Kaaven <ovek@arcticnet.no>
+	Check for resizeterm in ncurses.
+
+	* libtest/Makefile.in, libtest/vartest-Win32.log, libtest/vartest.c, libtest/vartest.readme:
+	Francis Beaudet <francis@macadamian.com>
+	New test program for VARIANT functions.
+
+	* debugger/msc.c: Eric Pouech <Eric.Pouech@wanadoo.fr>
+	Some debug information (PDB) was not mapped when loading a module,
+	which caused a core in the debugger when it tried to access it.
+
+	* Makefile.in: Ove Kaaven <ovek@arcticnet.no>
+	Links libwine.so.1.0 to libwine.so in Wine's main directory.
+	Makes Wine compile with --enable-dll again.
+
+Sat Jan  9 09:12:40 1999  Alexandre Julliard  <julliard@winehq.com>
+
+	* relay32/ole32.spec, windows/dinput.c, include/storage.h, include/unknwn.h, include/windows.h, include/wine/obj_base.h, include/wine/obj_channel.h, include/wine/obj_clientserver.h, include/wine/obj_dataobject.h, include/wine/obj_marshal.h, include/wine/obj_misc.h, include/wine/obj_moniker.h, include/wine/obj_propertystorage.h, include/wine/obj_storage.h, include/winerror.h, include/wtypes.h, misc/shell.c, multimedia/dplay.c, multimedia/dsound.c, objects/font.c, ole/compobj.c, ole/ifs.c, ole/moniker.c, ole/ole2.c, ole/ole2disp.c, ole/oledlg.c, ole/oleobj.c, ole/storage.c, ole/typelib.c, dlls/shell32/dataobject.c, dlls/shell32/enumidlist.c, dlls/shell32/folders.c, dlls/shell32/pidl.c, dlls/shell32/shell32_main.c, dlls/shell32/shelllink.c, dlls/shell32/shellole.c, dlls/shell32/shellord.c, dlls/shell32/shlfolder.c, dlls/shell32/shlview.c, graphics/ddraw.c, graphics/vga.c, if1632/compobj.spec, include/compobj.h, include/ddraw.h, include/dinput.h, include/dplay.h, include/dsound.h, include/interfaces.h, include/objbase.h, include/objidl.h, include/ole.h, include/ole2.h, include/oleobj.h, include/servprov.h, include/shell.h, include/shlguid.h, include/shlobj.h, dlls/comctl32/imagelist.c, dlls/shell32/contmenu.c:
+	Francois Gouget <fgouget@multimania.com>
+	Added a lot of COM interfaces definitions.
+	Restructured COM header files for better compatibility and clarity.
+
+Fri Jan  8 16:37:03 1999  Alexandre Julliard  <julliard@winehq.com>
+
+	* files/file.c: Set GENERIC_READ|GENERIC_WRITE access for OF_CREATE.
+	Make GetFileType work for all handle types.
+
+	* win32/device.c: Avoid crash on NULL dev->info.
+
+	* include/flatsb.h, relay32/comctl32.spec, dlls/comctl32/Makefile.in, dlls/comctl32/commctrl.c, dlls/comctl32/flatsb.c, include/commctrl.h:
+	Alex Priem <alexp@sci.kun.nl>
+	Added stubs and defines for the flat scrollbar common control.
+
+	* include/commctrl.h, dlls/comctl32/datetime.c:
+	Alex Priem <alexp@sci.kun.nl>
+	Added some defines needed for custom draw'ing and datetime common
+	controls.
+
+	* dlls/shell32/iconcache.c: Eddie Carpenter <ecarpenter@itex.co.za>
+	Fixed a small bug in function ExtractIconEx32A.
+
+	* windows/winproc.c: Juergen Schmied <juergen.schmied@metronet.de>
+	HTASK16 -> threadID mapping of WM_ACTIVATEAPP.
+
+	* files/file.c: Bertho Stultiens <bertho@panter.soci.aau.dk>
+	Make DeleteFile fail for empty path.
+
+	* msdos/ioports.c: Gerald Pfeifer <pfeifer@dbai.tuwien.ac.at>
+	Fix dummy_ctr stuff to work even without DIRECT_IO_ACCESS.
+
+	* loader/ne/segment.c: Marcus Meissner <marcus@jet.franken.de>
+	Fixed wrong buffer which caused fixups to fail.
+
+	* graphics/d3dcommon.c, graphics/d3ddevices.c, graphics/d3dtexture.c, include/d3d.h:
+	Lionel Ulmer <ulmer@directprovider.net>
+	- added all the Direct3D error codes
+	- added 8bit palettized texture support
+
+	* msdos/cdrom.c: Marcus Meissner <marcus@jet.franken.de>
+	ifdefs for defines not in linux 2.0.
+
+	* relay32/winspool.spec, misc/printdrv.c:
+	Uwe Bonnes <bon@elektron.ikp.physik.tu-darmstadt.de>
+	Added two stubs for AddPrinterDriver.
+
+	* include/dosexe.h, loader/dos/dosmod.c, loader/dos/dosmod.h, loader/dos/dosvm.c:
+	Ove Kaaven <ovek@arcticnet.no>
+	Queue SIGALRM to reduce the "signal 14 lost" complaints.
+	Added support for reprogramming the DOS timer, and reading back the
+	current value.
+
+	* misc/registry.c: Marcus Meissner <marcus@jet.franken.de>
+	Wine hangs when registry (corrupted) has lone \ at end of file.
+
+	* dlls/shell32/shell32_main.h, dlls/shell32/shell32_main.c:
+	Kostya Ivanov <kostya@warmcat.excom.spb.su>
+	Small patch that enables Clarion for Windows not to trap while
+	loading.
+
+	* ole/variant.c: Marcus Meissner <marcus@jet.franken.de>
+	Replace troublesome assignments by memset for whole struct.
+
+	* graphics/ddraw.c: Lionel Ulmer <ulmer@directprovider.net>
+	Added handling of the 'palent' field of the CreatePalette procedure.
+
+	* documentation/wine.man:
+	Uwe Bonnes <bon@elektron.ikp.physik.tu-darmstadt.de>
+	Added description about including/excluding functions from relay
+	trace.
+
+	* win32/console.c: Marcus Meissner <marcus@jet.franken.de>
+	Read at least 1 input record in ReadConsoleInputA.
+
+	* memory/virtual.c:
+	Fixed CreateMapping when a mapping with the same name already exists.
+
+Wed Jan  6 10:37:29 1999  Alexandre Julliard  <julliard@winehq.com>
+
+	* server/file.c: Fixed file destruction when file has no name.
+
+Tue Jan  5 18:38:59 1999  Alexandre Julliard  <julliard@winehq.com>
+
+	* misc/main.c: Eric Pouech <Eric.Pouech@wanadoo.fr>
+	Warns user if multiple -dll switches are used on command line.
+
+	* dlls/comctl32/trackbar.c: Alex Priem <alexp@sci.kun.nl>
+	Fixed a leftover HeapFree in the trackbar common control.
+
+	* include/commctrl.h, include/debug.h, include/debugdefs.h, include/tab.h, dlls/comctl32/tab.c:
+	Alex Priem <alexp@sci.kun.nl>
+	Fixed some problems with the tab common control (with thanks to Anders
+	Carlsson <anders.carlsson@linux.nu>).
+
+	* dlls/comctl32/commctrl.c, dlls/comctl32/propsheet.c, include/commctrl.h, include/propsheet.h, relay32/comctl32.spec:
+	Alex Priem <alexp@sci.kun.nl>
+	Added a missing PropertySheet32AW and CreatePropertySheetPage stub,
+	and some missing defines.
+
+	* misc/main.c, scheduler/syslevel.c, graphics/vga.c:
+	Ulrich Weigand <weigand@informatik.uni-erlangen.de>
+	Use MakeCriticalSectionGlobal on all critical sections used across
+	process boundaries.
+
+	* include/winbase.h, include/windows.h:
+	Ulrich Weigand <weigand@informatik.uni-erlangen.de>
+	Added prototypes for MakeCriticalSectionGlobal, ConvertToGlobalHandle.
+
+	* documentation/wine.man:
+	Uwe Bonnes <bon@elektron.ikp.physik.tu-darmstadt.de>
+	Added environment variables in the man page.
+
+	* loader/dos/module.c: Gerald Pfeifer <pfeifer@dbai.tuwien.ac.at>
+	Fixed args of MZ_CreateProcess.
+
+	* programs/clock/language.c, programs/notepad/language.c, programs/progman/main.c:
+	Andreas Mohr <a.mohr@mailto.de>
+	Fixed string bug in programs/.
+
+	* msdos/ioports.c: Andreas Mohr <a.mohr@mailto.de>
+	Added stupid "action" emulation for hardware timers in ioports.c.
+
+	* dlls/winaspi/winaspi16.c: Andreas Mohr <a.mohr@mailto.de>
+	Again a small DOSASPI patch.
+
+	* documentation/bugreports, documentation/fonts, windows/sysmetrics.c, windows/win.c, windows/winpos.c:
+	Andreas Mohr <a.mohr@mailto.de>
+	Documentation updates.
+
+	* graphics/ddraw.c: Lionel Ulmer <ulmer@directprovider.net>
+	- check if palette is not null when setting a palette
+	- check if window handle is valid before getting its 'drawable'
+
+	* graphics/x11drv/xfont.c: Eric Pouech <Eric.Pouech@wanadoo.fr>
+	Prevent core dump with some TTF (when X11 runs with a true type
+	server).
+
+	* server/console.c: Marcus Meissner <marcus@jet.franken.de>
+	Use stdout for default console output.
+
 ----------------------------------------------------------------
 Sun Jan  3 17:00:20 1999  Alexandre Julliard  <julliard@winehq.com>
 
diff --git a/Makefile.in b/Makefile.in
index 4a07ba4..3c8de43 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -170,6 +170,7 @@
 
 libwine.so.1.0: $(LIBOBJS) $(X11OBJS)
 	$(LDSHARED) -o$@ $(LIBOBJS) $(X11OBJS) $(LDOPTIONS)
+	ln -sf $@ libwine.so
 
 install_emu: install_lib
 	[ -d $(bindir) ] || $(MKDIR) $(bindir)
@@ -230,7 +231,7 @@
 clean::
 	for i in $(ALLSUBDIRS); do (cd $$i; $(MAKE) clean) || exit 1; done
 	for i in include; do (cd $$i; $(RM) *.o \#*\# .#* *~ *% *.bak *.orig *.rej *.flc); done
-	$(RM) wine wine.sym libwine.a libwine.so.1.0 TAGS .#*
+	$(RM) wine wine.sym libwine.a libwine.so.1.0 libwine.so TAGS .#*
 
 distclean: clean
 	$(RM) config.* Make.rules include/config.h
diff --git a/configure b/configure
index 6f2682e..da1da01 100755
--- a/configure
+++ b/configure
@@ -2548,10 +2548,53 @@
 fi
 
 if test "$ac_cv_lib_ncurses_waddch" = "yes"
-then :
+then
+    echo $ac_n "checking for resizeterm in -lncurses""... $ac_c" 1>&6
+echo "configure:2554: checking for resizeterm in -lncurses" >&5
+ac_lib_var=`echo ncurses'_'resizeterm | sed 'y%./+-%__p_%'`
+if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  ac_save_LIBS="$LIBS"
+LIBS="-lncurses  $LIBS"
+cat > conftest.$ac_ext <<EOF
+#line 2562 "configure"
+#include "confdefs.h"
+/* Override any gcc2 internal prototype to avoid an error.  */
+/* We use char because int might match the return type of a gcc2
+    builtin and then its argument prototype would still apply.  */
+char resizeterm();
+
+int main() {
+resizeterm()
+; return 0; }
+EOF
+if { (eval echo configure:2573: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+  rm -rf conftest*
+  eval "ac_cv_lib_$ac_lib_var=yes"
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  eval "ac_cv_lib_$ac_lib_var=no"
+fi
+rm -f conftest*
+LIBS="$ac_save_LIBS"
+
+fi
+if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
+  echo "$ac_t""yes" 1>&6
+  cat >> confdefs.h <<\EOF
+#define HAVE_RESIZETERM 1
+EOF
+
+else
+  echo "$ac_t""no" 1>&6
+fi
+
 else
     echo $ac_n "checking for waddch in -lcurses""... $ac_c" 1>&6
-echo "configure:2555: checking for waddch in -lcurses" >&5
+echo "configure:2598: checking for waddch in -lcurses" >&5
 ac_lib_var=`echo curses'_'waddch | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -2559,7 +2602,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lcurses  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 2563 "configure"
+#line 2606 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -2570,7 +2613,7 @@
 waddch()
 ; return 0; }
 EOF
-if { (eval echo configure:2574: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2617: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -2597,15 +2640,58 @@
   echo "$ac_t""no" 1>&6
 fi
 
+    echo $ac_n "checking for resizeterm in -lcurses""... $ac_c" 1>&6
+echo "configure:2645: checking for resizeterm in -lcurses" >&5
+ac_lib_var=`echo curses'_'resizeterm | sed 'y%./+-%__p_%'`
+if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  ac_save_LIBS="$LIBS"
+LIBS="-lcurses  $LIBS"
+cat > conftest.$ac_ext <<EOF
+#line 2653 "configure"
+#include "confdefs.h"
+/* Override any gcc2 internal prototype to avoid an error.  */
+/* We use char because int might match the return type of a gcc2
+    builtin and then its argument prototype would still apply.  */
+char resizeterm();
+
+int main() {
+resizeterm()
+; return 0; }
+EOF
+if { (eval echo configure:2664: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+  rm -rf conftest*
+  eval "ac_cv_lib_$ac_lib_var=yes"
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  eval "ac_cv_lib_$ac_lib_var=no"
+fi
+rm -f conftest*
+LIBS="$ac_save_LIBS"
+
+fi
+if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
+  echo "$ac_t""yes" 1>&6
+  cat >> confdefs.h <<\EOF
+#define HAVE_RESIZETERM 1
+EOF
+
+else
+  echo "$ac_t""no" 1>&6
+fi
+
 fi
 
 echo $ac_n "checking "for GNU style IPX support"""... $ac_c" 1>&6
-echo "configure:2604: checking "for GNU style IPX support"" >&5
+echo "configure:2690: checking "for GNU style IPX support"" >&5
 if eval "test \"`echo '$''{'ac_cv_c_ipx_gnu'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 2609 "configure"
+#line 2695 "configure"
 #include "confdefs.h"
 #include <sys/socket.h>
     #include <netipx/ipx.h>
@@ -2613,7 +2699,7 @@
 ((struct sockaddr_ipx *)0)->sipx_family == AF_IPX
 ; return 0; }
 EOF
-if { (eval echo configure:2617: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2703: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   cat >> confdefs.h <<\EOF
 #define HAVE_IPX_GNU 1
@@ -2635,12 +2721,12 @@
 if test "$ac_cv_c_ipx_gnu" = "no"
 then
  echo $ac_n "checking "for linux style IPX support"""... $ac_c" 1>&6
-echo "configure:2639: checking "for linux style IPX support"" >&5
+echo "configure:2725: checking "for linux style IPX support"" >&5
 if eval "test \"`echo '$''{'ac_cv_c_ipx_linux'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 2644 "configure"
+#line 2730 "configure"
 #include "confdefs.h"
 #include <sys/socket.h>
      #include <asm/types.h>
@@ -2649,7 +2735,7 @@
 ((struct sockaddr_ipx *)0)->sipx_family == AF_IPX
 ; return 0; }
 EOF
-if { (eval echo configure:2653: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2739: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   cat >> confdefs.h <<\EOF
 #define HAVE_IPX_LINUX 1
@@ -2673,17 +2759,17 @@
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:2677: checking for $ac_hdr" >&5
+echo "configure:2763: checking for $ac_hdr" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 2682 "configure"
+#line 2768 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:2687: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:2773: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -2711,12 +2797,12 @@
 
 
 echo $ac_n "checking "for Open Sound System"""... $ac_c" 1>&6
-echo "configure:2715: checking "for Open Sound System"" >&5
+echo "configure:2801: checking "for Open Sound System"" >&5
 if eval "test \"`echo '$''{'ac_cv_c_opensoundsystem'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 2720 "configure"
+#line 2806 "configure"
 #include "confdefs.h"
 
 	#if defined(HAVE_SYS_SOUNDCARD_H)
@@ -2737,7 +2823,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:2741: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2827: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_c_opensoundsystem="yes"
 else
@@ -2761,12 +2847,12 @@
 
 
 echo $ac_n "checking "for union semun"""... $ac_c" 1>&6
-echo "configure:2765: checking "for union semun"" >&5
+echo "configure:2851: checking "for union semun"" >&5
 if eval "test \"`echo '$''{'ac_cv_c_union_semun'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 2770 "configure"
+#line 2856 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/sem.h>
@@ -2774,7 +2860,7 @@
 union semun foo
 ; return 0; }
 EOF
-if { (eval echo configure:2778: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2864: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_c_union_semun="yes"
 else
@@ -2802,7 +2888,7 @@
 then
   CFLAGS="$CFLAGS -Wall"
   echo $ac_n "checking "for gcc strength-reduce bug"""... $ac_c" 1>&6
-echo "configure:2806: checking "for gcc strength-reduce bug"" >&5
+echo "configure:2892: checking "for gcc strength-reduce bug"" >&5
 if eval "test \"`echo '$''{'ac_cv_c_gcc_strength_bug'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -2810,7 +2896,7 @@
   ac_cv_c_gcc_strength_bug="yes"
 else
   cat > conftest.$ac_ext <<EOF
-#line 2814 "configure"
+#line 2900 "configure"
 #include "confdefs.h"
 
 int main(void) {
@@ -2821,7 +2907,7 @@
   exit( Array[1] != -2 );
 }
 EOF
-if { (eval echo configure:2825: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:2911: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
 then
   ac_cv_c_gcc_strength_bug="no"
 else
@@ -2844,7 +2930,7 @@
 
 
 echo $ac_n "checking "whether external symbols need an underscore prefix"""... $ac_c" 1>&6
-echo "configure:2848: checking "whether external symbols need an underscore prefix"" >&5
+echo "configure:2934: checking "whether external symbols need an underscore prefix"" >&5
 if eval "test \"`echo '$''{'ac_cv_c_extern_prefix'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -2856,14 +2942,14 @@
 	.long 0
 EOF
 cat > conftest.$ac_ext <<EOF
-#line 2860 "configure"
+#line 2946 "configure"
 #include "confdefs.h"
 extern int ac_test;
 int main() {
 if (ac_test) return 1
 ; return 0; }
 EOF
-if { (eval echo configure:2867: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2953: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   ac_cv_c_extern_prefix="yes"
 else
@@ -2887,7 +2973,7 @@
 
 
 echo $ac_n "checking "whether assembler accepts .string"""... $ac_c" 1>&6
-echo "configure:2891: checking "whether assembler accepts .string"" >&5
+echo "configure:2977: checking "whether assembler accepts .string"" >&5
 if eval "test \"`echo '$''{'ac_cv_c_asm_string'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -2897,14 +2983,14 @@
 	.string "test"
 EOF
 cat > conftest.$ac_ext <<EOF
-#line 2901 "configure"
+#line 2987 "configure"
 #include "confdefs.h"
 
 int main() {
 
 ; return 0; }
 EOF
-if { (eval echo configure:2908: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2994: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   ac_cv_c_asm_string="yes"
 else
@@ -2932,21 +3018,21 @@
 if test "$LIB_TARGET" = "libwine.so.1.0"
 then
   echo $ac_n "checking "whether we can build a Linux dll"""... $ac_c" 1>&6
-echo "configure:2936: checking "whether we can build a Linux dll"" >&5
+echo "configure:3022: checking "whether we can build a Linux dll"" >&5
 if eval "test \"`echo '$''{'ac_cv_c_dll_linux'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   saved_cflags=$CFLAGS
   CFLAGS="$CFLAGS -fPIC -shared -Wl,-soname,conftest.so.1.0"
   cat > conftest.$ac_ext <<EOF
-#line 2943 "configure"
+#line 3029 "configure"
 #include "confdefs.h"
 
 int main() {
 return 1
 ; return 0; }
 EOF
-if { (eval echo configure:2950: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:3036: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   ac_cv_c_dll_linux="yes"
 else
@@ -2967,21 +3053,21 @@
     LDSHARED="\$(CC) -shared -Wl,-soname,libwine.so"
   else
     echo $ac_n "checking "whether we can build a NetBSD dll"""... $ac_c" 1>&6
-echo "configure:2971: checking "whether we can build a NetBSD dll"" >&5
+echo "configure:3057: checking "whether we can build a NetBSD dll"" >&5
 if eval "test \"`echo '$''{'ac_cv_c_dll_netbsd'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   saved_cflags=$CFLAGS
     CFLAGS="$CFLAGS -fPIC -Bshareable -Bforcearchive"
     cat > conftest.$ac_ext <<EOF
-#line 2978 "configure"
+#line 3064 "configure"
 #include "confdefs.h"
 
 int main() {
 return 1
 ; return 0; }
 EOF
-if { (eval echo configure:2985: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:3071: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   ac_cv_c_dll_netbsd="yes"
 else
@@ -3012,7 +3098,7 @@
 
 
 echo $ac_n "checking "for reentrant libc"""... $ac_c" 1>&6
-echo "configure:3016: checking "for reentrant libc"" >&5
+echo "configure:3102: checking "for reentrant libc"" >&5
 if eval "test \"`echo '$''{'wine_cv_libc_reentrant'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -3020,14 +3106,14 @@
   wine_cv_libc_reentrant=yes 
 else
   cat > conftest.$ac_ext <<EOF
-#line 3024 "configure"
+#line 3110 "configure"
 #include "confdefs.h"
 int myerrno = 0;
 char buf[256];
 int *__errno_location(){return &myerrno;}
 main(){connect(0,buf,255); exit(!myerrno);}
 EOF
-if { (eval echo configure:3031: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:3117: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
 then
   wine_cv_libc_reentrant=yes
 else
@@ -3052,7 +3138,7 @@
 
 
 echo $ac_n "checking "for reentrant X libraries"""... $ac_c" 1>&6
-echo "configure:3056: checking "for reentrant X libraries"" >&5
+echo "configure:3142: checking "for reentrant X libraries"" >&5
 if eval "test \"`echo '$''{'wine_cv_x_reentrant'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -3097,12 +3183,12 @@
 for ac_func in clone getpagesize memmove sendmsg sigaltstack strerror stricmp tcgetattr timegm usleep wait4 waitpid vfscanf
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:3101: checking for $ac_func" >&5
+echo "configure:3187: checking for $ac_func" >&5
 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 3106 "configure"
+#line 3192 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -3125,7 +3211,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:3129: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:3215: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -3149,21 +3235,21 @@
 fi
 done
 
-for ac_hdr in wctype.h sys/syscall.h syscall.h sys/param.h sys/vfs.h sys/mount.h sys/statfs.h float.h linux/cdrom.h linux/ucdrom.h sys/cdio.h sys/filio.h sys/modem.h strings.h sys/strtio.h dlfcn.h unistd.h sys/sockio.h net/if.h netinet/in.h
+for ac_hdr in wctype.h sys/syscall.h syscall.h sys/param.h sys/vfs.h sys/mount.h sys/statfs.h float.h linux/cdrom.h linux/ucdrom.h sys/cdio.h sys/filio.h sys/modem.h strings.h sys/strtio.h dlfcn.h unistd.h sys/sockio.h net/if.h netinet/in.h sys/file.h
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:3157: checking for $ac_hdr" >&5
+echo "configure:3243: checking for $ac_hdr" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 3162 "configure"
+#line 3248 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:3167: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:3253: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -3190,12 +3276,12 @@
 done
 
 echo $ac_n "checking whether stat file-mode macros are broken""... $ac_c" 1>&6
-echo "configure:3194: checking whether stat file-mode macros are broken" >&5
+echo "configure:3280: checking whether stat file-mode macros are broken" >&5
 if eval "test \"`echo '$''{'ac_cv_header_stat_broken'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 3199 "configure"
+#line 3285 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -3246,12 +3332,12 @@
 fi
 
 echo $ac_n "checking for working const""... $ac_c" 1>&6
-echo "configure:3250: checking for working const" >&5
+echo "configure:3336: checking for working const" >&5
 if eval "test \"`echo '$''{'ac_cv_c_const'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 3255 "configure"
+#line 3341 "configure"
 #include "confdefs.h"
 
 int main() {
@@ -3300,7 +3386,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:3304: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3390: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_c_const=yes
 else
@@ -3321,12 +3407,12 @@
 fi
 
 echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6
-echo "configure:3325: checking for ANSI C header files" >&5
+echo "configure:3411: checking for ANSI C header files" >&5
 if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 3330 "configure"
+#line 3416 "configure"
 #include "confdefs.h"
 #include <stdlib.h>
 #include <stdarg.h>
@@ -3334,7 +3420,7 @@
 #include <float.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:3338: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:3424: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -3351,7 +3437,7 @@
 if test $ac_cv_header_stdc = yes; then
   # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
 cat > conftest.$ac_ext <<EOF
-#line 3355 "configure"
+#line 3441 "configure"
 #include "confdefs.h"
 #include <string.h>
 EOF
@@ -3369,7 +3455,7 @@
 if test $ac_cv_header_stdc = yes; then
   # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
 cat > conftest.$ac_ext <<EOF
-#line 3373 "configure"
+#line 3459 "configure"
 #include "confdefs.h"
 #include <stdlib.h>
 EOF
@@ -3390,7 +3476,7 @@
   :
 else
   cat > conftest.$ac_ext <<EOF
-#line 3394 "configure"
+#line 3480 "configure"
 #include "confdefs.h"
 #include <ctype.h>
 #define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
@@ -3401,7 +3487,7 @@
 exit (0); }
 
 EOF
-if { (eval echo configure:3405: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:3491: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
 then
   :
 else
@@ -3425,12 +3511,12 @@
 fi
 
 echo $ac_n "checking for size_t""... $ac_c" 1>&6
-echo "configure:3429: checking for size_t" >&5
+echo "configure:3515: checking for size_t" >&5
 if eval "test \"`echo '$''{'ac_cv_type_size_t'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 3434 "configure"
+#line 3520 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #if STDC_HEADERS
@@ -3458,7 +3544,7 @@
 fi
 
 echo $ac_n "checking size of long long""... $ac_c" 1>&6
-echo "configure:3462: checking size of long long" >&5
+echo "configure:3548: checking size of long long" >&5
 if eval "test \"`echo '$''{'ac_cv_sizeof_long_long'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -3466,7 +3552,7 @@
   ac_cv_sizeof_long_long=0
 else
   cat > conftest.$ac_ext <<EOF
-#line 3470 "configure"
+#line 3556 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 main()
@@ -3477,7 +3563,7 @@
   exit(0);
 }
 EOF
-if { (eval echo configure:3481: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:3567: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
 then
   ac_cv_sizeof_long_long=`cat conftestval`
 else
@@ -3500,7 +3586,7 @@
 
 if test $ac_cv_func_sendmsg = no; then
     echo $ac_n "checking for sendmsg in -lsocket""... $ac_c" 1>&6
-echo "configure:3504: checking for sendmsg in -lsocket" >&5
+echo "configure:3590: checking for sendmsg in -lsocket" >&5
 ac_lib_var=`echo socket'_'sendmsg | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -3508,7 +3594,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lsocket  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 3512 "configure"
+#line 3598 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -3519,7 +3605,7 @@
 sendmsg()
 ; return 0; }
 EOF
-if { (eval echo configure:3523: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:3609: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -3552,12 +3638,12 @@
 if test "$ac_cv_header_sys_vfs_h" = "yes"
 then
     echo $ac_n "checking "whether sys/vfs.h defines statfs"""... $ac_c" 1>&6
-echo "configure:3556: checking "whether sys/vfs.h defines statfs"" >&5
+echo "configure:3642: checking "whether sys/vfs.h defines statfs"" >&5
 if eval "test \"`echo '$''{'wine_cv_sys_vfs_has_statfs'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 3561 "configure"
+#line 3647 "configure"
 #include "confdefs.h"
 
 	#include <sys/types.h>
@@ -3574,7 +3660,7 @@
 	
 ; return 0; }
 EOF
-if { (eval echo configure:3578: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3664: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   wine_cv_sys_vfs_has_statfs=yes
 else
@@ -3601,12 +3687,12 @@
 if test "$ac_cv_header_sys_statfs_h" = "yes"
 then
     echo $ac_n "checking "whether sys/statfs.h defines statfs"""... $ac_c" 1>&6
-echo "configure:3605: checking "whether sys/statfs.h defines statfs"" >&5
+echo "configure:3691: checking "whether sys/statfs.h defines statfs"" >&5
 if eval "test \"`echo '$''{'wine_cv_sys_statfs_has_statfs'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 3610 "configure"
+#line 3696 "configure"
 #include "confdefs.h"
 
 	#include <sys/types.h>
@@ -3621,7 +3707,7 @@
 	
 ; return 0; }
 EOF
-if { (eval echo configure:3625: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3711: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   wine_cv_sys_statfs_has_statfs=yes
 else
@@ -3648,12 +3734,12 @@
 if test "$ac_cv_header_sys_mount_h" = "yes"
 then
     echo $ac_n "checking "whether sys/mount.h defines statfs"""... $ac_c" 1>&6
-echo "configure:3652: checking "whether sys/mount.h defines statfs"" >&5
+echo "configure:3738: checking "whether sys/mount.h defines statfs"" >&5
 if eval "test \"`echo '$''{'wine_cv_sys_mount_has_statfs'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 3657 "configure"
+#line 3743 "configure"
 #include "confdefs.h"
 
 	#include <sys/types.h>
@@ -3668,7 +3754,7 @@
 	
 ; return 0; }
 EOF
-if { (eval echo configure:3672: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3758: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   wine_cv_sys_mount_has_statfs=yes
 else
@@ -3694,7 +3780,7 @@
 
 
 echo $ac_n "checking "for statfs.f_bfree"""... $ac_c" 1>&6
-echo "configure:3698: checking "for statfs.f_bfree"" >&5
+echo "configure:3784: checking "for statfs.f_bfree"" >&5
 if eval "test \"`echo '$''{'wine_cv_statfs_bfree'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -3703,7 +3789,7 @@
         wine_cv_statfs_bfree=no
     else
     	cat > conftest.$ac_ext <<EOF
-#line 3707 "configure"
+#line 3793 "configure"
 #include "confdefs.h"
 
 	#include <sys/types.h>
@@ -3730,7 +3816,7 @@
 	
 ; return 0; }
 EOF
-if { (eval echo configure:3734: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3820: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   wine_cv_statfs_bfree=yes
 else
@@ -3754,7 +3840,7 @@
 fi
 
 echo $ac_n "checking "for statfs.f_bavail"""... $ac_c" 1>&6
-echo "configure:3758: checking "for statfs.f_bavail"" >&5
+echo "configure:3844: checking "for statfs.f_bavail"" >&5
 if eval "test \"`echo '$''{'wine_cv_statfs_bavail'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -3763,7 +3849,7 @@
         wine_cv_statfs_bavail=no
     else
     	cat > conftest.$ac_ext <<EOF
-#line 3767 "configure"
+#line 3853 "configure"
 #include "confdefs.h"
 
 	#include <sys/types.h>
@@ -3790,7 +3876,7 @@
 	
 ; return 0; }
 EOF
-if { (eval echo configure:3794: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3880: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   wine_cv_statfs_bavail=yes
 else
@@ -3815,7 +3901,7 @@
 
 
 echo $ac_n "checking "for working sigaltstack"""... $ac_c" 1>&6
-echo "configure:3819: checking "for working sigaltstack"" >&5
+echo "configure:3905: checking "for working sigaltstack"" >&5
 if eval "test \"`echo '$''{'ac_cv_c_working_sigaltstack'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -3824,7 +3910,7 @@
 
 else
   cat > conftest.$ac_ext <<EOF
-#line 3828 "configure"
+#line 3914 "configure"
 #include "confdefs.h"
 
 	#include <stdio.h>
@@ -3862,7 +3948,7 @@
 	}
 	
 EOF
-if { (eval echo configure:3866: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:3952: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
 then
   ac_cv_c_working_sigaltstack="yes"
 else
@@ -3889,12 +3975,12 @@
 
 
 echo $ac_n "checking "for msg_accrights in struct msghdr"""... $ac_c" 1>&6
-echo "configure:3893: checking "for msg_accrights in struct msghdr"" >&5
+echo "configure:3979: checking "for msg_accrights in struct msghdr"" >&5
 if eval "test \"`echo '$''{'ac_cv_c_msg_accrights'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 3898 "configure"
+#line 3984 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/socket.h>
@@ -3902,7 +3988,7 @@
 struct msghdr hdr; hdr.msg_accrights=0
 ; return 0; }
 EOF
-if { (eval echo configure:3906: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3992: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_c_msg_accrights="yes"
 else
@@ -4420,6 +4506,14 @@
 test "$no_create" = yes || ${CONFIG_SHELL-/bin/sh} $CONFIG_STATUS || exit 1
 
 
+if test "$ac_cv_lib_ncurses_resizeterm" = "no" -a "$ac_cv_lib_ncurses_waddch" = "yes"
+then
+  echo
+  echo "*** Warning: resizeterm not found in ncurses. Wine will be built without"
+  echo "*** terminal resize support. Consider upgrading ncurses."
+  echo
+fi
+
 if test "$wine_cv_libc_reentrant" = "no" 
 then
   echo
diff --git a/configure.in b/configure.in
index 194029b..65c19c1 100644
--- a/configure.in
+++ b/configure.in
@@ -117,9 +117,11 @@
 dnl **** Check which curses lib to use ***
 AC_CHECK_LIB(ncurses,waddch)
 if test "$ac_cv_lib_ncurses_waddch" = "yes"
-then :
+then
+    AC_CHECK_LIB(ncurses,resizeterm,AC_DEFINE(HAVE_RESIZETERM))
 else
     AC_CHECK_LIB(curses,waddch)
+    AC_CHECK_LIB(curses,resizeterm,AC_DEFINE(HAVE_RESIZETERM))
 fi
 
 dnl **** Check for IPX (currently Linux only) ****
@@ -342,7 +344,7 @@
 dnl **** Check for functions and header files ****
 
 AC_CHECK_FUNCS(clone getpagesize memmove sendmsg sigaltstack strerror stricmp tcgetattr timegm usleep wait4 waitpid vfscanf)
-AC_CHECK_HEADERS(wctype.h sys/syscall.h syscall.h sys/param.h sys/vfs.h sys/mount.h sys/statfs.h float.h linux/cdrom.h linux/ucdrom.h sys/cdio.h sys/filio.h sys/modem.h strings.h sys/strtio.h dlfcn.h unistd.h sys/sockio.h net/if.h netinet/in.h)
+AC_CHECK_HEADERS(wctype.h sys/syscall.h syscall.h sys/param.h sys/vfs.h sys/mount.h sys/statfs.h float.h linux/cdrom.h linux/ucdrom.h sys/cdio.h sys/filio.h sys/modem.h strings.h sys/strtio.h dlfcn.h unistd.h sys/sockio.h net/if.h netinet/in.h sys/file.h)
 AC_HEADER_STAT()
 AC_C_CONST()
 AC_TYPE_SIZE_T()
@@ -617,6 +619,14 @@
 windows/ttydrv/Makefile
 windows/x11drv/Makefile ])
 
+if test "$ac_cv_lib_ncurses_resizeterm" = "no" -a "$ac_cv_lib_ncurses_waddch" = "yes"
+then
+  echo
+  echo "*** Warning: resizeterm not found in ncurses. Wine will be built without"
+  echo "*** terminal resize support. Consider upgrading ncurses."
+  echo
+fi
+
 if test "$wine_cv_libc_reentrant" = "no" 
 then
   echo
diff --git a/console/ncurses.c b/console/ncurses.c
index 8bdc09a..b5b5fc6 100644
--- a/console/ncurses.c
+++ b/console/ncurses.c
@@ -39,7 +39,9 @@
    driver.getCursorPosition = NCURSES_GetCursorPosition;
    driver.getCharacterAtCursor = NCURSES_GetCharacterAtCursor;
    driver.clearScreen = NCURSES_ClearScreen;
+#ifdef HAVE_RESIZETERM
    driver.notifyResizeScreen = NCURSES_NotifyResizeScreen;
+#endif
 
    driver.checkForKeystroke = NCURSES_CheckForKeystroke;
    driver.getKeystroke = NCURSES_GetKeystroke;
@@ -62,9 +64,14 @@
 
 void NCURSES_Write(char output, int fg, int bg, int attribute)
 {
+   char row, col;
+
    /* We can discard all extended information. */
    if (waddch(stdscr, output) == ERR)
-      FIXME(console, "NCURSES: waddch() failed.\n");
+   {
+      NCURSES_GetCursorPosition(&row, &col);
+      FIXME(console, "NCURSES: waddch() failed at %d, %d.\n", row, col);
+   }
 }
 
 void NCURSES_Close()
@@ -137,6 +144,8 @@
    werase(stdscr);
 }
 
+#ifdef HAVE_RESIZETERM
+
 void NCURSES_NotifyResizeScreen(int x, int y)
 {
    /* Note: This function gets called *after* another driver in the chain
@@ -146,4 +155,6 @@
    resizeterm(y, x);
 }
 
+#endif
+
 #endif /* WINE_NCURSES */
diff --git a/controls/listbox.c b/controls/listbox.c
index 3405121..74b16eb 100644
--- a/controls/listbox.c
+++ b/controls/listbox.c
@@ -1186,23 +1186,26 @@
 
 /***********************************************************************
  *           LISTBOX_SetCaretIndex
+ *
+ * NOTES
+ *   index must be between 0 and descr->nb_items-1, or LB_ERR is returned.
+ *
  */
 static LRESULT LISTBOX_SetCaretIndex( WND *wnd, LB_DESCR *descr, INT32 index,
                                       BOOL32 fully_visible )
 {
-    INT32 oldfocus = descr->focus_item;
+    INT32 oldfocus = descr->focus_item;          
 
-    if ((index < -1) || (index >= descr->nb_items)) return LB_ERR;
+    if ((index < 0) || (index >= descr->nb_items)) return LB_ERR;
     if (index == oldfocus) return LB_OKAY;
     descr->focus_item = index;
     if ((oldfocus != -1) && descr->caret_on && (GetFocus32() == wnd->hwndSelf))
         LISTBOX_RepaintItem( wnd, descr, oldfocus, ODA_FOCUS );
-    if (index != -1)
-    {
-        LISTBOX_MakeItemVisible( wnd, descr, index, fully_visible );
-        if (descr->caret_on && (GetFocus32() == wnd->hwndSelf))
-            LISTBOX_RepaintItem( wnd, descr, index, ODA_FOCUS );
-    }
+
+    LISTBOX_MakeItemVisible( wnd, descr, index, fully_visible );
+    if (descr->caret_on && (GetFocus32() == wnd->hwndSelf))
+        LISTBOX_RepaintItem( wnd, descr, index, ODA_FOCUS );
+
     return LB_OKAY;
 }
 
@@ -2284,7 +2287,7 @@
         wParam = (INT32)(INT16)wParam;
         /* fall through */
     case LB_SETCURSEL32:
-        if (wParam != -1) LISTBOX_MakeItemVisible( wnd, descr, wParam, TRUE );
+        LISTBOX_SetCaretIndex( wnd, descr, wParam, TRUE );  
         return LISTBOX_SetSelection( wnd, descr, wParam, TRUE, FALSE );
 
     case LB_GETSELCOUNT16:
diff --git a/debugger/editline.c b/debugger/editline.c
index 51e7046..68645fc 100644
--- a/debugger/editline.c
+++ b/debugger/editline.c
@@ -28,6 +28,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <errno.h>
 #include <sys/ioctl.h>
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -279,6 +280,7 @@
 TTYget()
 {
     CHAR	c;
+    int retv;
 
     TTYflush();
     if (Pushed) {
@@ -287,7 +289,14 @@
     }
     if (*Input)
 	return *Input++;
-    return read(0, &c, (size_t)1) == 1 ? c : EOF;
+
+    while ( ( retv = read( 0, &c, (size_t)1 ) ) == -1 )
+    {
+        if ( errno != EINTR )
+            perror( "read" );
+    }
+
+    return retv == 1 ? c : EOF;
 }
 
 #define TTYback()	(backspace ? TTYputs((CHAR *)backspace) : TTYput('\b'))
diff --git a/debugger/msc.c b/debugger/msc.c
index 9b9b56e..80ed6cb 100644
--- a/debugger/msc.c
+++ b/debugger/msc.c
@@ -33,7 +33,7 @@
 #include "debugger.h"
 #include "peexe.h"
 #include "xmalloc.h"
-
+#include "file.h"
 
 /*
  * This is an index we use to keep track of the debug information
@@ -888,7 +888,6 @@
   int			  rtn = FALSE;
   int			  orig_size;
   PIMAGE_DEBUG_DIRECTORY dbgptr;
-  struct deferred_debug_info * deefer;
 
   orig_size = size;
   dbgptr = (PIMAGE_DEBUG_DIRECTORY) (hModule + v_addr);
@@ -934,35 +933,72 @@
 	   * means that this entry points to a .DBG file.  Otherwise,
 	   * it just points to itself, and we can ignore this.
 	   */
-	  if(    (dbgptr->Type == IMAGE_DEBUG_TYPE_MISC)
-	      && (PE_HEADER(hModule)->FileHeader.Characteristics & IMAGE_FILE_DEBUG_STRIPPED) == 0 )
-	    {
-	      break;
-	    }
 
-	  deefer = (struct deferred_debug_info *) xmalloc(sizeof(*deefer));
-	  deefer->module    = hModule;
-	  deefer->load_addr = (char *)hModule;
-	  deefer->dbg_info  = NULL;
-	  deefer->dbg_size  = 0;
 
-	  /*
-	   * Read the important bits.  What we do after this depends
-	   * upon the type, but this is always enough so we are able
-	   * to proceed if we know what we need to do next.
-	   */
-	  deefer->dbg_size = dbgptr->SizeOfData;
-	  deefer->dbg_info = (char *)(hModule + dbgptr->PointerToRawData);
-	  deefer->dbgdir = dbgptr;
-	  deefer->next = dbglist;
-	  deefer->loaded = FALSE;
-	  deefer->dbg_index = DEBUG_next_index;
-	  deefer->module_name = xstrdup(module_name);
 
-	  deefer->sectp = PE_SECTIONS(hModule);
-	  deefer->nsect = PE_HEADER(hModule)->FileHeader.NumberOfSections;
 
-	  dbglist = deefer;
+
+
+          if(   (dbgptr->Type != IMAGE_DEBUG_TYPE_MISC) ||
+                (PE_HEADER(hModule)->FileHeader.Characteristics & IMAGE_FILE_DEBUG_STRIPPED) != 0 )
+            {
+                struct deferred_debug_info*      deefer = (struct deferred_debug_info *) xmalloc(sizeof(*deefer));
+ 
+                deefer->module    = hModule;
+                deefer->load_addr = (char *)hModule;
+ 
+                /*
+                 * Read the important bits.  What we do after this depends
+                 * upon the type, but this is always enough so we are able
+                 * to proceed if we know what we need to do next.
+                 */                  
+                /* in some cases, debug information has not been mapped, so load it...
+                 * basically, the PE loader maps all sections (data, resources...), but doesn't map
+                 * the DataDirectory array's content. One its entry contains the *beloved*
+                 * debug information. (Note the DataDirectory is mapped, not its content)
+                 */
+                if (IsBadReadPtr32((void*)hModule, dbgptr->PointerToRawData + dbgptr->SizeOfData))
+                {
+                    char                 fn[PATH_MAX];
+                    int                  fd = -1;
+                    DOS_FULL_NAME        full_name;
+ 
+                    if (GetModuleFileName32A(hModule, fn, sizeof(fn)) > 0 &&
+                        DOSFS_GetFullName(fn, TRUE, &full_name) &&
+                        (fd = open(full_name.long_name, O_RDONLY)) > 0)
+                    {
+                        deefer->dbg_info = mmap(NULL, dbgptr->SizeOfData,
+                                                PROT_READ, MAP_PRIVATE, fd, dbgptr->PointerToRawData);
+                        close(fd);
+                        if( deefer->dbg_info == (char *) 0xffffffff )
+                        {
+                            free(deefer);
+                            break;
+                        }
+                    }
+                    else
+                    {
+                        free(deefer);
+                        fprintf(stderr, " (not mapped: fn=%s, lfn=%s, fd=%d)", fn, full_name.long_name, fd);
+                        break;
+                    }
+                }
+                else
+                {
+                    deefer->dbg_info = (char *)(hModule + dbgptr->PointerToRawData);
+                }
+                deefer->dbg_size = dbgptr->SizeOfData;
+                deefer->dbgdir = dbgptr;
+                deefer->next = dbglist;
+                deefer->loaded = FALSE;
+                deefer->dbg_index = DEBUG_next_index;
+                deefer->module_name = xstrdup(module_name);
+
+                deefer->sectp = PE_SECTIONS(hModule);
+                deefer->nsect = PE_HEADER(hModule)->FileHeader.NumberOfSections;
+
+                dbglist = deefer;
+            }
 	  break;
 	default:
 	}
@@ -1813,7 +1849,7 @@
   status = stat(filename, &statbuf);
   if( status == -1 )
     {
-      fprintf(stderr, "Unable to open .PDB file %s\n", filename);
+      fprintf(stderr, "-Unable to open .PDB file %s\n", filename);
       goto leave;
     }
 
@@ -1823,7 +1859,7 @@
   fd = open(filename, O_RDONLY);
   if( fd == -1 )
     {
-      fprintf(stderr, "Unable to open .DBG file %s\n", filename);
+      fprintf(stderr, "-Unable to open .DBG file %s\n", filename);
       goto leave;
     }
 
@@ -1835,7 +1871,7 @@
 	      MAP_PRIVATE, fd, 0);
   if( addr == (char *) 0xffffffff )
     {
-      fprintf(stderr, "Unable to mmap .DBG file %s\n", filename);
+      fprintf(stderr, "-Unable to mmap .DBG file %s\n", filename);
       goto leave;
     }
 
@@ -2141,7 +2177,7 @@
   status = stat(filename, &statbuf);
   if( status == -1 )
     {
-      fprintf(stderr, "Unable to open .DBG file %s\n", filename);
+      fprintf(stderr, "-Unable to open .DBG file %s\n", filename);
       goto leave;
     }
 
diff --git a/dlls/comctl32/Makefile.in b/dlls/comctl32/Makefile.in
index 5bd0b5a..a753752 100644
--- a/dlls/comctl32/Makefile.in
+++ b/dlls/comctl32/Makefile.in
@@ -11,6 +11,7 @@
 	comctl32undoc.c \
 	commctrl.c \
 	datetime.c \
+	flatsb.c \
 	header.c \
 	hotkey.c \
 	imagelist.c \
diff --git a/dlls/comctl32/commctrl.c b/dlls/comctl32/commctrl.c
index f579b6c..463b07f 100644
--- a/dlls/comctl32/commctrl.c
+++ b/dlls/comctl32/commctrl.c
@@ -12,6 +12,7 @@
 #include "animate.h"
 #include "comboex.h"
 #include "datetime.h"
+#include "flatsb.h"
 #include "header.h"
 #include "hotkey.h"
 #include "ipaddress.h"
@@ -20,6 +21,7 @@
 #include "nativefont.h"
 #include "pager.h"
 #include "progress.h"
+#include "propsheet.h"
 #include "rebar.h"
 #include "status.h"
 #include "tab.h"
@@ -70,9 +72,11 @@
 
 		/* register all Win95 common control classes */
 		ANIMATE_Register ();
+		FLATSB_Register ();
 		HEADER_Register ();
 		HOTKEY_Register ();
 		LISTVIEW_Register ();
+		PROPSHEET_Register ();
 		PROGRESS_Register ();
 		STATUS_Register ();
 		TAB_Register ();
@@ -92,6 +96,7 @@
 		ANIMATE_Unregister ();
 		COMBOEX_Unregister ();
 		DATETIME_Unregister ();
+		FLATSB_Unregister ();
 		HEADER_Unregister ();
 		HOTKEY_Unregister ();
 		IPADDRESS_Unregister ();
@@ -99,6 +104,7 @@
 		MONTHCAL_Unregister ();
 		NATIVEFONT_Unregister ();
 		PAGER_Unregister ();
+		PROPSHEET_UnRegister ();
 		PROGRESS_Unregister ();
 		REBAR_Unregister ();
 		STATUS_Unregister ();
diff --git a/dlls/comctl32/datetime.c b/dlls/comctl32/datetime.c
index d9f816a..79963a8 100644
--- a/dlls/comctl32/datetime.c
+++ b/dlls/comctl32/datetime.c
@@ -60,12 +60,7 @@
 {
     DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr(wndPtr);
 
-
-
-
-
-
-    /* free ipaddress info data */
+    /* free datetime info data */
     COMCTL32_Free (infoPtr);
 
     return 0;
@@ -82,6 +77,49 @@
     switch (uMsg)
     {
 
+    case DTM_GETSYSTEMTIME:
+        FIXME (datetime, "Unimplemented msg DTM_GETSYSTEMTIME\n");
+        return GDT_VALID;
+
+    case DTM_SETSYSTEMTIME:
+        FIXME (datetime, "Unimplemented msg DTM_SETSYSTEMTIME\n");
+        return 1;
+
+    case DTM_GETRANGE:
+        FIXME (datetime, "Unimplemented msg DTM_GETRANGE\n");
+        return 0;
+
+    case DTM_SETRANGE:
+        FIXME (datetime, "Unimplemented msg DTM_SETRANGE\n");
+        return 1;
+
+    case DTM_SETFORMAT32A:
+        FIXME (datetime, "Unimplemented msg DTM_SETFORMAT32A\n");
+        return 1;
+
+    case DTM_SETFORMAT32W:
+        FIXME (datetime, "Unimplemented msg DTM_SETFORMAT32W\n");
+        return 1;
+
+    case DTM_SETMCCOLOR:
+        FIXME (datetime, "Unimplemented msg DTM_SETMCCOLOR\n");
+        return 0;
+
+    case DTM_GETMCCOLOR:
+        FIXME (datetime, "Unimplemented msg DTM_GETMCCOLOR\n");
+        return 0;
+
+    case DTM_GETMONTHCAL:
+        FIXME (datetime, "Unimplemented msg DTM_GETMONTHCAL\n");
+        return 0;
+
+    case DTM_SETMCFONT:
+        FIXME (datetime, "Unimplemented msg DTM_SETMCFONT\n");
+        return 0;
+
+    case DTM_GETMCFONT:
+        FIXME (datetime, "Unimplemented msg DTM_GETMCFONT\n");
+        return 0;
 
 	case WM_CREATE:
 	    return DATETIME_Create (wndPtr, wParam, lParam);
diff --git a/dlls/comctl32/flatsb.c b/dlls/comctl32/flatsb.c
new file mode 100644
index 0000000..c61eb08
--- /dev/null
+++ b/dlls/comctl32/flatsb.c
@@ -0,0 +1,179 @@
+/*
+ * Flat Scrollbar control
+ *
+ * Copyright 1998 Eric Kohl
+ *
+ * NOTES
+ *   This is just a dummy control. An author is needed! Any volunteers?
+ *   I will only improve this control once in a while.
+ *     Eric <ekohl@abo.rhein-zeitung.de>
+ *
+ * TODO:
+ *   - All messages.
+ *   - All notifications.
+ *
+ */
+
+#include "windows.h"
+#include "commctrl.h"
+#include "flatsb.h" 
+#include "win.h"
+#include "debug.h"
+
+
+#define FlatSB_GetInfoPtr(wndPtr) ((FLATSB_INFO*)wndPtr->wExtra[0])
+
+
+BOOL32 WINAPI 
+FlatSB_EnableScrollBar(HWND32 hwnd, INT32 dummy, UINT32 dummy2)
+{
+    FIXME(commctrl,"stub\n");
+    return 0;
+}
+
+BOOL32 WINAPI 
+FlatSB_ShowScrollBar(HWND32 hwnd, INT32 code, BOOL32 flag)
+{
+    FIXME(commctrl,"stub\n");
+    return 0;
+}
+
+BOOL32 WINAPI 
+FlatSB_GetScrollRange(HWND32 hwnd, INT32 code, LPINT32 min, LPINT32 max)
+{
+    FIXME(commctrl,"stub\n");
+    return 0;
+}
+
+BOOL32 WINAPI 
+FlatSB_GetScrollInfo(HWND32 hwnd, INT32 code, LPSCROLLINFO info)
+{
+    FIXME(commctrl,"stub\n");
+    return 0;
+}
+
+INT32 WINAPI 
+FlatSB_GetScrollPos(HWND32 hwnd, INT32 code)
+{
+    FIXME(commctrl,"stub\n");
+    return 0;
+}
+
+BOOL32 WINAPI 
+FlatSB_GetScrollProp(HWND32 hwnd, INT32 propIndex, LPINT32 prop)
+{
+    FIXME(commctrl,"stub\n");
+    return 0;
+}
+
+
+INT32 WINAPI 
+FlatSB_SetScrollPos(HWND32 hwnd, INT32 code, INT32 pos, BOOL32 fRedraw)
+{
+    FIXME(commctrl,"stub\n");
+    return 0;
+}
+
+INT32 WINAPI 
+FlatSB_SetScrollInfo(HWND32 hwnd, INT32 code, LPSCROLLINFO info, BOOL32 fRedraw)
+{
+    FIXME(commctrl,"stub\n");
+    return 0;
+}
+
+INT32 WINAPI 
+FlatSB_SetScrollRange(HWND32 hwnd, INT32 code, INT32 min, INT32 max, BOOL32 fRedraw)
+{
+    FIXME(commctrl,"stub\n");
+    return 0;
+}
+
+BOOL32 WINAPI 
+FlatSB_SetScrollProp(HWND32 hwnd, UINT32 index, INT32 newValue, BOOL32 flag)
+{
+    FIXME(commctrl,"stub\n");
+    return 0;
+}
+
+
+BOOL32 WINAPI InitializeFlatSB(HWND32 hwnd)
+{
+    FIXME(commctrl,"stub\n");
+    return 0;
+}
+
+HRESULT WINAPI UninitializeFlatSB(HWND32 hwnd)
+{
+    FIXME(commctrl,"stub\n");
+    return 0;
+}
+
+
+
+static LRESULT
+FlatSB_Create (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
+{
+    return 0;
+}
+
+
+static LRESULT
+FlatSB_Destroy (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
+{
+    return 0;
+}
+
+
+
+
+LRESULT WINAPI
+FlatSB_WindowProc (HWND32 hwnd, UINT32 uMsg, WPARAM32 wParam, LPARAM lParam)
+{
+    WND *wndPtr = WIN_FindWndPtr(hwnd);
+
+    switch (uMsg)
+    {
+
+	case WM_CREATE:
+	    return FlatSB_Create (wndPtr, wParam, lParam);
+
+	case WM_DESTROY:
+	    return FlatSB_Destroy (wndPtr, wParam, lParam);
+
+	default:
+	    if (uMsg >= WM_USER)
+		ERR (datetime, "unknown msg %04x wp=%08x lp=%08lx\n",
+		     uMsg, wParam, lParam);
+	    return DefWindowProc32A (hwnd, uMsg, wParam, lParam);
+    }
+    return 0;
+}
+
+
+VOID
+FLATSB_Register (VOID)
+{
+    WNDCLASS32A wndClass;
+
+    if (GlobalFindAtom32A (FLATSB_CLASS32A)) return;
+
+    ZeroMemory (&wndClass, sizeof(WNDCLASS32A));
+    wndClass.style         = CS_GLOBALCLASS;
+    wndClass.lpfnWndProc   = (WNDPROC32)FlatSB_WindowProc;
+    wndClass.cbClsExtra    = 0;
+    wndClass.cbWndExtra    = sizeof(FLATSB_INFO *);
+    wndClass.hCursor       = LoadCursor32A (0, IDC_ARROW32A);
+    wndClass.hbrBackground = (HBRUSH32)(COLOR_WINDOW + 1);
+    wndClass.lpszClassName = FLATSB_CLASS32A;
+ 
+    RegisterClass32A (&wndClass);
+}
+
+
+VOID
+FLATSB_Unregister (VOID)
+{
+    if (GlobalFindAtom32A (FLATSB_CLASS32A))
+	UnregisterClass32A (FLATSB_CLASS32A, (HINSTANCE32)NULL);
+}
+
diff --git a/dlls/comctl32/imagelist.c b/dlls/comctl32/imagelist.c
index 993d35b..70404fd 100644
--- a/dlls/comctl32/imagelist.c
+++ b/dlls/comctl32/imagelist.c
@@ -32,8 +32,8 @@
  
 #include "windows.h"
 #include "winversion.h"
-#include "compobj.h"
-#include "storage.h"
+#include "wine/obj_base.h"
+#include "wine/obj_storage.h"
 #include "imagelist.h"
 #include "commctrl.h"
 #include "debug.h"
diff --git a/dlls/comctl32/propsheet.c b/dlls/comctl32/propsheet.c
index 4bfd3af..19341bf 100644
--- a/dlls/comctl32/propsheet.c
+++ b/dlls/comctl32/propsheet.c
@@ -9,18 +9,50 @@
  */
 
 #include "windows.h"
+#include "winversion.h"
 #include "commctrl.h"
+#include "propsheet.h"
 #include "win.h"
 #include "debug.h"
 
+LRESULT WINAPI
+PROPSHEET_WindowProc (HWND32 hwnd, UINT32 uMsg, WPARAM32 wParam, LPARAM lParam);
+
+
+
+
+
+/*****************************************************************
+ *            PropertySheet32AW   (COMCTL32.83)
+ */  
+INT32 WINAPI PropertySheet32AW(LPVOID propertySheetHeader)
+{   
+	if (VERSION_OsIsUnicode())
+		return PropertySheet32W ((LPCPROPSHEETHEADER32W) propertySheetHeader);
+	return PropertySheet32A ((LPCPROPSHEETHEADER32A) propertySheetHeader);
+}
+ 
+
+
+
 /*****************************************************************
  *            PropertySheet32A   (COMCTL32.84)
  */
-INT32 WINAPI PropertySheet32A(LPCPROPSHEETHEADER32A propertySheetHeader)
+INT32 WINAPI PropertySheet32A(LPCPROPSHEETHEADER32A lppsh)
 {
-    FIXME(commctrl, "(%p): stub\n", propertySheetHeader);
+	HWND32 hwnd;
 
-    return -1;
+    FIXME(propsheet, "(%p): stub\n", lppsh);
+
+	if (lppsh->dwFlags & PSH_MODELESS) {
+        hwnd = CreateDialogParam32A ( lppsh->hInstance, WC_PROPSHEET32A,
+                    lppsh->hwndParent, PROPSHEET_WindowProc, (LPARAM) lppsh );
+		ShowWindow32 (hwnd, TRUE);
+	} else {
+		hwnd =  DialogBoxParam32A ( lppsh->hInstance, WC_PROPSHEET32A,
+                    lppsh->hwndParent, PROPSHEET_WindowProc, (LPARAM) lppsh );
+	}
+    return hwnd;
 }
 
 /*****************************************************************
@@ -28,17 +60,33 @@
  */
 INT32 WINAPI PropertySheet32W(LPCPROPSHEETHEADER32W propertySheetHeader)
 {
-    FIXME(commctrl, "(%p): stub\n", propertySheetHeader);
+    FIXME(propsheet, "(%p): stub\n", propertySheetHeader);
 
     return -1;
 }
 
+
+
+
+
+/*****************************************************************
+ *            CreatePropertySheet32AW   (COMCTL32.83)
+ */  
+HPROPSHEETPAGE WINAPI CreatePropertySheetPage32AW (LPVOID lpPropSheetPage)
+{   
+	if (VERSION_OsIsUnicode())
+	return CreatePropertySheetPage32W((LPCPROPSHEETPAGE32W) lpPropSheetPage);
+	return CreatePropertySheetPage32A((LPCPROPSHEETPAGE32A) lpPropSheetPage);
+
+}
+
+
 /*****************************************************************
  *            CreatePropertySheetPage32A   (COMCTL32.19)
  */
 HPROPSHEETPAGE WINAPI CreatePropertySheetPage32A(LPCPROPSHEETPAGE32A lpPropSheetPage)
 {
-    FIXME(commctrl, "(%p): stub\n", lpPropSheetPage);
+    FIXME(propsheet, "(%p): stub\n", lpPropSheetPage);
 
     return 0;
 }
@@ -48,7 +96,7 @@
  */
 HPROPSHEETPAGE WINAPI CreatePropertySheetPage32W(LPCPROPSHEETPAGE32W lpPropSheetPage)
 {
-    FIXME(commctrl, "(%p): stub\n", lpPropSheetPage);
+    FIXME(propsheet, "(%p): stub\n", lpPropSheetPage);
 
     return 0;
 }
@@ -58,8 +106,115 @@
  */
 BOOL32 WINAPI DestroyPropertySheetPage32(HPROPSHEETPAGE hPropPage)
 {
-    FIXME(commctrl, "(0x%x): stub\n", hPropPage);
+    FIXME(propsheet, "(0x%x): stub\n", hPropPage);
 
     return FALSE;
 }
 
+
+
+LRESULT WINAPI
+PROPSHEET_WindowProc (HWND32 hwnd, UINT32 uMsg, WPARAM32 wParam, LPARAM lParam)
+{
+   WND *wndPtr = WIN_FindWndPtr(hwnd);
+
+  switch (uMsg) {
+       case PSM_SETCURSEL:
+           FIXME (propsheet, "Unimplemented msg PSM_SETCURSEL\n");
+           return 0;
+       case PSM_REMOVEPAGE:
+           FIXME (propsheet, "Unimplemented msg PSM_REMOVEPAGE\n");
+           return 0;
+       case PSM_ADDPAGE:
+           FIXME (propsheet, "Unimplemented msg PSM_ADDPAGE\n");
+           return 0;
+       case PSM_CHANGED:
+           FIXME (propsheet, "Unimplemented msg PSM_CHANGED\n");
+           return 0;
+       case PSM_RESTARTWINDOWS:
+           FIXME (propsheet, "Unimplemented msg PSM_RESTARTWINDOWS\n");
+           return 0;
+       case PSM_REBOOTSYSTEM:
+           FIXME (propsheet, "Unimplemented msg PSM_REBOOTSYSTEM\n");
+           return 0;
+       case PSM_CANCELTOCLOSE:
+           FIXME (propsheet, "Unimplemented msg PSM_CANCELTOCLOSE\n");
+           return 0;
+       case PSM_QUERYSIBLINGS:
+           FIXME (propsheet, "Unimplemented msg PSM_QUERYSIBLINGS\n");
+           return 0;
+       case PSM_UNCHANGED:
+           FIXME (propsheet, "Unimplemented msg PSM_UNCHANGED\n");
+           return 0;
+       case PSM_APPLY:
+           FIXME (propsheet, "Unimplemented msg PSM_APPLY\n");
+           return 0;
+       case PSM_SETTITLE32A:
+           FIXME (propsheet, "Unimplemented msg PSM_SETTITLE32A\n");
+           return 0;
+       case PSM_SETTITLE32W:
+           FIXME (propsheet, "Unimplemented msg PSM_SETTITLE32W\n");
+           return 0;
+       case PSM_SETWIZBUTTONS:
+           FIXME (propsheet, "Unimplemented msg PSM_SETWIZBUTTONS\n");
+           return 0;
+       case PSM_PRESSBUTTON:
+           FIXME (propsheet, "Unimplemented msg PSM_PRESSBUTTON\n");
+           return 0;
+       case PSM_SETCURSELID:
+           FIXME (propsheet, "Unimplemented msg PSM_SETCURSELID\n");
+           return 0;
+       case PSM_SETFINISHTEXT32A:
+           FIXME (propsheet, "Unimplemented msg PSM_SETFINISHTEXT32A\n");
+           return 0;
+       case PSM_SETFINISHTEXT32W:
+           FIXME (propsheet, "Unimplemented msg PSM_SETFINISHTEXT32W\n");
+           return 0;
+       case PSM_GETTABCONTROL:
+           FIXME (propsheet, "Unimplemented msg PSM_GETTABCONTROL\n");
+           return 0;
+       case PSM_ISDIALOGMESSAGE:
+           FIXME (propsheet, "Unimplemented msg PSM_ISDIALOGMESSAGE\n");
+           return 0;
+       case PSM_GETCURRENTPAGEHWND:
+           FIXME (propsheet, "Unimplemented msg PSM_GETCURRENTPAGEHWND\n");
+           return 0;
+
+	  default:
+        if (uMsg >= WM_USER)
+        ERR (propsheet, "unknown msg %04x wp=%08x lp=%08lx\n",
+             uMsg, wParam, lParam);
+        return DefWindowProc32A (hwnd, uMsg, wParam, lParam);
+	}
+		
+	
+}
+
+
+VOID
+PROPSHEET_Register (VOID)
+{
+    WNDCLASS32A wndClass;
+
+    if (GlobalFindAtom32A (WC_PROPSHEET32A)) return;
+
+    ZeroMemory (&wndClass, sizeof(WNDCLASS32A));
+    wndClass.style         = CS_GLOBALCLASS | CS_DBLCLKS | CS_SAVEBITS;
+    wndClass.lpfnWndProc   = (WNDPROC32)PROPSHEET_WindowProc;
+    wndClass.cbClsExtra    = 0;
+    wndClass.cbWndExtra    = sizeof(PROPSHEET_INFO *);
+    wndClass.hCursor       = LoadCursor32A (0, IDC_ARROW32A);
+    wndClass.hbrBackground = 0;
+    wndClass.lpszClassName = WC_PROPSHEET32A;
+
+    RegisterClass32A (&wndClass);
+}
+
+
+VOID
+PROPSHEET_UnRegister (VOID)
+{
+    if (GlobalFindAtom32A (WC_PROPSHEET32A))
+    UnregisterClass32A (WC_PROPSHEET32A, (HINSTANCE32)NULL);
+}
+
diff --git a/dlls/comctl32/tab.c b/dlls/comctl32/tab.c
index 9ca0bba..3013065 100644
--- a/dlls/comctl32/tab.c
+++ b/dlls/comctl32/tab.c
@@ -16,13 +16,17 @@
 #include "windows.h"
 #include "commctrl.h"
 #include "tab.h"
-#include "heap.h"
 #include "win.h"
 #include "debug.h"
 
 
 #define TAB_GetInfoPtr(wndPtr) ((TAB_INFO *)wndPtr->wExtra[0])
 
+
+
+
+
+
 static BOOL32
 TAB_SendSimpleNotify (WND *wndPtr, UINT32 code)
 {
@@ -44,6 +48,22 @@
     return infoPtr->iSelected;
 }
 
+
+static LRESULT
+TAB_SetCurSel (WND *wndPtr,WPARAM32 wParam)
+{
+    TAB_INFO *infoPtr = TAB_GetInfoPtr(wndPtr);
+	INT32 iItem=(INT32) wParam;
+	INT32 prevItem;
+ 
+	prevItem=-1;
+	if ((iItem >= 0) && (iItem < infoPtr->uNumItem)) {
+		prevItem=infoPtr->iSelected;
+    	infoPtr->iSelected=iItem;
+	}
+	return prevItem;
+}
+
 static LRESULT
 TAB_LButtonUp (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
 {
@@ -78,6 +98,20 @@
     return 0;
 }
 
+
+static LRESULT
+TAB_AdjustRect (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
+{
+
+	if (wParam==TRUE) {
+		FIXME (tab,"Should set display rectangle\n");
+	} else {
+		FIXME (tab,"Should set window rectangle\n");
+	}
+	
+	return 0;
+}
+
 static void 
 TAB_SetItemBounds (WND *wndPtr)
 {
@@ -129,9 +163,9 @@
     RECT32 r;
     INT32 oldBkMode;
    
-    HPEN32	hwPen = CreatePen32 (PS_SOLID, 1, RGB (255, 255, 255 ));
-    HPEN32	hbPen = CreatePen32 (PS_SOLID, 1, GetSysColor32 (COLOR_BTNSHADOW));
-    HPEN32	hsdPen = CreatePen32(PS_SOLID, 1, GetSysColor32 (COLOR_BTNTEXT));
+    HPEN32	hwPen  = GetSysColorPen32 (COLOR_3DHILIGHT);
+    HPEN32	hbPen  = GetSysColorPen32 (COLOR_BTNSHADOW);
+    HPEN32	hsdPen = GetSysColorPen32 (COLOR_BTNTEXT);
     HPEN32	htmpPen = (HPEN32)NULL;
 
     CopyRect32(&r, &pti->rect);
@@ -152,9 +186,6 @@
     MoveToEx32 (hdc, r.right, r.top+1, NULL);
     LineTo32(hdc, r.right,r.bottom);
     hsdPen = SelectObject32(hdc,htmpPen); 
-    DeleteObject32(hwPen);
-    DeleteObject32(hbPen);
-    DeleteObject32(hsdPen);
 
     oldBkMode = SetBkMode32(hdc, TRANSPARENT);
     r.left += 3;
@@ -170,9 +201,10 @@
 TAB_DrawBorder (WND *wndPtr, HDC32 hdc)
 {
     HPEN32 htmPen;
-    HPEN32 hwPen = GetStockObject32(WHITE_PEN);
-    HPEN32 hbPen = GetStockObject32(BLACK_PEN);
-    HPEN32 hShade = CreatePen32 ( PS_SOLID, 1, GetSysColor32 (COLOR_BTNSHADOW));
+    HPEN32 hwPen  = GetSysColorPen32 (COLOR_3DHILIGHT);
+    HPEN32 hbPen  = GetSysColorPen32 (COLOR_3DDKSHADOW);
+    HPEN32 hShade = GetSysColorPen32 (COLOR_BTNSHADOW);
+
     RECT32 rect;
 
     htmPen = SelectObject32 (hdc, hwPen);
@@ -191,7 +223,6 @@
     LineTo32 (hdc, rect.right-1, rect.bottom-1);
     LineTo32 (hdc, rect.left, rect.bottom-1);
     hShade = SelectObject32(hdc, hShade);
-    DeleteObject32 (hShade);
 }
 
     
@@ -199,17 +230,16 @@
 TAB_Refresh (WND *wndPtr, HDC32 hdc)
 {
     TAB_INFO *infoPtr = TAB_GetInfoPtr(wndPtr);
-    HFONT32 hFont, hOldFont;
-    RECT32 rect;
-    HBRUSH32 hbrBk;
+    HFONT32 hOldFont;
     INT32 i;
 
     TAB_DrawBorder (wndPtr, hdc);
 
+	hOldFont = SelectObject32 (hdc, infoPtr->hFont);
     for (i = 0; i < infoPtr->uNumItem; i++) {
 	TAB_DrawItem (wndPtr, hdc, i);
     }
-
+	SelectObject32 (hdc, hOldFont);
 }
 
 static LRESULT
@@ -230,11 +260,11 @@
 TAB_InsertItem (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
 {
     TAB_INFO *infoPtr = TAB_GetInfoPtr(wndPtr);
-    TCITEM *pti;
+    TCITEM32A *pti;
     HDC32  hdc;
     INT32 iItem, len;
 
-    pti = (TCITEM*)lParam;
+    pti = (TCITEM32A *)lParam;
     iItem = (INT32)wParam;
 
     if (iItem < 0) return -1;
@@ -242,16 +272,14 @@
 	iItem = infoPtr->uNumItem;
 
     if (infoPtr->uNumItem == 0) {
-	infoPtr->items = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY,
-				    sizeof (TAB_ITEM));
+	infoPtr->items = COMCTL32_Alloc (sizeof (TAB_ITEM));
 	infoPtr->uNumItem++;
     }
     else {
 	TAB_ITEM *oldItems = infoPtr->items;
 
 	infoPtr->uNumItem++;
-	infoPtr->items = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY,
-				    sizeof (TAB_ITEM) * infoPtr->uNumItem);
+	infoPtr->items = COMCTL32_Alloc (sizeof (TAB_ITEM) * infoPtr->uNumItem);
 	
 	/* pre insert copy */
 	if (iItem > 0) {
@@ -266,20 +294,17 @@
 
 	}
 	
-	HeapFree (GetProcessHeap (), 0, oldItems);
+	COMCTL32_Free (oldItems);
     }
 
     infoPtr->items[iItem].mask = pti->mask;
     if (pti->mask & TCIF_TEXT) {
 	len = lstrlen32A (pti->pszText);
-	infoPtr->items[iItem].pszText = 
-	    HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, len+1);
+	infoPtr->items[iItem].pszText = COMCTL32_Alloc (len+1);
 	lstrcpy32A (infoPtr->items[iItem].pszText, pti->pszText);
 	infoPtr->items[iItem].cchTextMax = pti->cchTextMax;
     }
 
-    
-
     if (pti->mask & TCIF_IMAGE)
 	infoPtr->items[iItem].iImage = pti->iImage;
 
@@ -298,12 +323,168 @@
 }
 
 static LRESULT 
+TAB_SetItem32A (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
+{
+  TAB_INFO *infoPtr = TAB_GetInfoPtr(wndPtr);
+  TCITEM32A *tabItem; 
+  TAB_ITEM *wineItem; 
+  INT32    iItem,len;
+
+  iItem=(INT32) wParam;
+  tabItem=(LPTCITEM32A ) lParam;
+  TRACE (tab,"%d %p\n",iItem, tabItem);
+  if ((iItem<0) || (iItem>infoPtr->uNumItem)) return FALSE;
+
+  wineItem=& infoPtr->items[iItem];
+
+  if (tabItem->mask & TCIF_IMAGE) 
+		wineItem->iImage=tabItem->iImage;
+
+  if (tabItem->mask & TCIF_PARAM) 
+		wineItem->lParam=tabItem->lParam;
+
+  if (tabItem->mask & TCIF_RTLREADING) 
+		FIXME (tab,"TCIF_RTLREADING\n");
+
+  if (tabItem->mask & TCIF_STATE) 
+		wineItem->dwState=tabItem->dwState;
+
+  if (tabItem->mask & TCIF_TEXT) {
+	 len=lstrlen32A (tabItem->pszText);
+	 if (len>wineItem->cchTextMax) 
+		 wineItem->pszText= COMCTL32_ReAlloc (wineItem->pszText, len+1);
+	 lstrcpyn32A (wineItem->pszText, tabItem->pszText, len);
+  }
+
+	return TRUE;
+}
+
+static LRESULT 
+TAB_GetItemCount (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
+{
+   TAB_INFO *infoPtr = TAB_GetInfoPtr(wndPtr);
+
+   return infoPtr->uNumItem;
+}
+
+
+static LRESULT 
+TAB_GetItem32A (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
+{
+   TAB_INFO *infoPtr = TAB_GetInfoPtr(wndPtr);
+   TCITEM32A *tabItem;
+   TAB_ITEM *wineItem;
+   INT32    iItem;
+
+  iItem=(INT32) wParam;
+  tabItem=(LPTCITEM32A) lParam;
+  TRACE (tab,"\n");
+  if ((iItem<0) || (iItem>infoPtr->uNumItem)) return FALSE;
+
+  wineItem=& infoPtr->items[iItem];
+
+  if (tabItem->mask & TCIF_IMAGE) 
+		tabItem->iImage=wineItem->iImage;
+
+  if (tabItem->mask & TCIF_PARAM) 
+		tabItem->lParam=wineItem->lParam;
+
+  if (tabItem->mask & TCIF_RTLREADING) 
+		FIXME (tab, "TCIF_RTLREADING\n");
+
+  if (tabItem->mask & TCIF_STATE) 
+		tabItem->dwState=wineItem->dwState;
+
+  if (tabItem->mask & TCIF_TEXT) 
+	 lstrcpyn32A (tabItem->pszText, wineItem->pszText, tabItem->cchTextMax);
+
+	return TRUE;
+}
+
+static LRESULT 
+TAB_DeleteItem (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
+{
+   TAB_INFO *infoPtr = TAB_GetInfoPtr(wndPtr);
+
+	FIXME (tab,"stub \n");
+	return TRUE;
+}
+static LRESULT 
+TAB_DeleteAllItems (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
+{
+   TAB_INFO *infoPtr = TAB_GetInfoPtr(wndPtr);
+
+	COMCTL32_Free (infoPtr->items);
+	infoPtr->uNumItem=0;
+	
+	return TRUE;
+}
+
+
+static LRESULT
+TAB_GetFont (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
+{
+  TAB_INFO *infoPtr = TAB_GetInfoPtr(wndPtr);
+
+  TRACE (tab,"\n");
+  return (LRESULT)infoPtr->hFont;
+}
+
+static LRESULT
+TAB_SetFont (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
+
+{
+ TAB_INFO *infoPtr = TAB_GetInfoPtr(wndPtr);
+ TEXTMETRIC32A tm;
+ HFONT32 hFont, hOldFont;
+ HDC32 hdc;
+
+ TRACE (tab,"%x %lx\n",wParam, lParam);
+
+ infoPtr->hFont = (HFONT32)wParam;
+
+ hFont = infoPtr->hFont ? infoPtr->hFont : GetStockObject32 (SYSTEM_FONT);
+
+ hdc = GetDC32 (0);
+ hOldFont = SelectObject32 (hdc, hFont);
+ GetTextMetrics32A (hdc, &tm);
+ infoPtr->nHeight= tm.tmHeight + tm.tmExternalLeading;
+ SelectObject32 (hdc, hOldFont);
+
+ if (lParam) TAB_Refresh (wndPtr,hdc);
+ ReleaseDC32 (0, hdc);
+
+ return 0;
+}
+
+
+static LRESULT
+TAB_GetImageList (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
+{
+  TAB_INFO *infoPtr = TAB_GetInfoPtr(wndPtr);
+
+  TRACE (tab,"\n");
+  return (LRESULT)infoPtr->himl;
+}
+
+static LRESULT
+TAB_SetImageList (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
+{
+    TAB_INFO *infoPtr = TAB_GetInfoPtr(wndPtr);
+    HIMAGELIST himlPrev;
+
+    TRACE (tab,"\n");
+    himlPrev = infoPtr->himl;
+  	infoPtr->himl= (HIMAGELIST)lParam;
+    return (LRESULT)himlPrev;
+}
+
+static LRESULT 
 TAB_Create (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
 {
     TAB_INFO *infoPtr;
 
-    infoPtr = (TAB_INFO *)HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY,
-				     sizeof(TAB_INFO));
+    infoPtr = (TAB_INFO *)COMCTL32_Alloc (sizeof(TAB_INFO));
     wndPtr->wExtra[0] = (DWORD)infoPtr;
    
     infoPtr->uNumItem = 0;
@@ -325,12 +506,12 @@
     if (infoPtr->items) {
 	for (iItem = 0; iItem < infoPtr->uNumItem; iItem++) {
 	    if (infoPtr->items[iItem].pszText)
-		HeapFree (GetProcessHeap (), 0, infoPtr->items[iItem].pszText);
+		COMCTL32_Free (infoPtr->items[iItem].pszText);
 	}
-	HeapFree (GetProcessHeap (), 0, infoPtr->items);
+	COMCTL32_Free (infoPtr->items);
     }
 
-    HeapFree (GetProcessHeap (), 0, infoPtr);
+    COMCTL32_Free (infoPtr);
  
     return 0;
 }
@@ -343,20 +524,117 @@
     switch (uMsg)
     {
 
+	case TCM_GETIMAGELIST:
+	   return TAB_GetImageList (wndPtr, wParam, lParam);
+
+	case TCM_SETIMAGELIST:
+	   return TAB_SetImageList (wndPtr, wParam, lParam);
+	
+	case TCM_GETITEMCOUNT:
+	    return TAB_GetItemCount (wndPtr, wParam, lParam);
+
+	case TCM_GETITEM32A:
+	   return TAB_GetItem32A (wndPtr, wParam, lParam);
+
+	case TCM_GETITEM32W:
+	   FIXME (tab, "Unimplemented msg TCM_GETITEM32W\n");
+	   return 0;
+
+	case TCM_SETITEM32A:
+	   return TAB_SetItem32A (wndPtr, wParam, lParam);
+
+	case TCM_SETITEM32W:
+	   FIXME (tab, "Unimplemented msg TCM_GETITEM32W\n");
+	   return 0;
+
+	case TCM_DELETEITEM:
+	   return TAB_DeleteItem (wndPtr, wParam, lParam);
+
+	case TCM_DELETEALLITEMS:
+	   return TAB_DeleteAllItems (wndPtr, wParam, lParam);
+
+	case TCM_GETITEMRECT:
+	   FIXME (tab, "Unimplemented msg TCM_GETITEMRECT\n");
+	   return 0;
+
 	case TCM_GETCURSEL:
 	   return TAB_GetCurSel (wndPtr);
 
-	case TCM_INSERTITEM:
+	case TCM_SETCURSEL:
+	   return TAB_SetCurSel (wndPtr, wParam);
+
+	case TCM_INSERTITEM32A:
 	   return TAB_InsertItem (wndPtr, wParam, lParam);
 
+	case TCM_INSERTITEM32W:
+	   FIXME (tab, "Unimplemented msg TCM_INSERTITEM32W\n");
+	   return 0;
+
+	case TCM_SETITEMEXTRA:
+	   FIXME (tab, "Unimplemented msg TCM_SETITEMEXTRA\n");
+	   return 0;
+
+	case TCM_ADJUSTRECT:
+	   return TAB_AdjustRect (wndPtr, wParam, lParam);
+
+	case TCM_SETITEMSIZE:
+	   FIXME (tab, "Unimplemented msg TCM_SETITEMSIZE\n");
+	   return 0;
+
+	case TCM_REMOVEIMAGE:
+	   FIXME (tab, "Unimplemented msg TCM_REMOVEIMAGE\n");
+	   return 0;
+
+	case TCM_SETPADDING:
+	   FIXME (tab, "Unimplemented msg TCM_SETPADDING\n");
+	   return 0;
+
+	case TCM_GETROWCOUNT:
+	   FIXME (tab, "Unimplemented msg TCM_GETROWCOUNT\n");
+	   return 0;
+
+	case TCM_GETTOOLTIPS:
+	   FIXME (tab, "Unimplemented msg TCM_GETTOOLTIPS\n");
+	   return 0;
+
+	case TCM_SETTOOLTIPS:
+	   FIXME (tab, "Unimplemented msg TCM_SETTOOLTIPS\n");
+	   return 0;
+
+	case TCM_GETCURFOCUS:
+	   FIXME (tab, "Unimplemented msg TCM_GETCURFOCUS\n");
+	   return 0;
+
+	case TCM_SETCURFOCUS:
+	   FIXME (tab, "Unimplemented msg TCM_SETCURFOCUS\n");
+	   return 0;
+
+	case TCM_SETMINTTABWIDTH:
+	   FIXME (tab, "Unimplemented msg TCM_SETMINTTABWIDTH\n");
+	   return 0;
+
+	case TCM_DESELECTALL:
+	   FIXME (tab, "Unimplemented msg TCM_DESELECTALL\n");
+	   return 0;
+
+	case WM_GETFONT:
+	    return TAB_GetFont (wndPtr, wParam, lParam);
+
+	case WM_SETFONT:
+	    return TAB_SetFont (wndPtr, wParam, lParam);
+
 	case WM_CREATE:
 	    return TAB_Create (wndPtr, wParam, lParam);
 
 	case WM_DESTROY:
 	    return TAB_Destroy (wndPtr, wParam, lParam);
 
+    case WM_GETDLGCODE:
+            return DLGC_WANTARROWS | DLGC_WANTCHARS;
+
 	case WM_LBUTTONUP:
 	    return TAB_LButtonUp (wndPtr, wParam, lParam);
+
 	case WM_PAINT:
 	    return TAB_Paint (wndPtr, wParam);
 	
diff --git a/dlls/comctl32/trackbar.c b/dlls/comctl32/trackbar.c
index c04b432..65863b4 100644
--- a/dlls/comctl32/trackbar.c
+++ b/dlls/comctl32/trackbar.c
@@ -2,7 +2,7 @@
  * Trackbar control
  *
  * Copyright 1998 Eric Kohl <ekohl@abo.rhein-zeitung.de>
- * Copyright 1998 Alex Priem <alexp@sci.kun.nl>
+ * Copyright 1998,1999 Alex Priem <alexp@sci.kun.nl>
  *
  *
  * TODO:
@@ -11,7 +11,7 @@
  *   - handle dragging slider better
  *   - better tic handling.
  *   - more notifications.
- *   - tooltips
+ *   
  */
 
 /* known bugs:
@@ -27,7 +27,6 @@
 #include "windows.h"
 #include "commctrl.h"
 #include "trackbar.h"
-#include "heap.h"
 #include "win.h"
 #include "debug.h"
 
@@ -68,7 +67,7 @@
     	nrTics=(infoPtr->nRangeMax - infoPtr->nRangeMin)/infoPtr->uTicFreq;
 	else {
 		nrTics=0;
-		HeapFree (SystemHeap,0,infoPtr->tics);
+		COMCTL32_Free (infoPtr->tics);
 		infoPtr->tics=NULL;
 		infoPtr->uNumTics=0;
 		return;
diff --git a/dlls/ntdll/rtl.c b/dlls/ntdll/rtl.c
index 1b1537d..e35464d 100644
--- a/dlls/ntdll/rtl.c
+++ b/dlls/ntdll/rtl.c
@@ -842,3 +842,14 @@
 	FIXME(ntdll,"(0x%08lx,0x%08lx,0x%08lx),stub!\n",debugstr_w(x1->Buffer),debugstr_w(x2->Buffer),x3);
 	return 0;
 }
+
+/******************************************************************************
+ *	DbgPrint	[NTDLL] 
+ */
+void __cdecl DbgPrint(LPCSTR fmt,LPVOID args) {
+	char buf[512];
+
+	wvsprintf32A(buf,fmt,&args);
+	MSG("DbgPrint says: %s",buf);
+	/* hmm, raise exception? */
+}
diff --git a/dlls/shell32/contmenu.c b/dlls/shell32/contmenu.c
index 504cc6c..da45f8a 100644
--- a/dlls/shell32/contmenu.c
+++ b/dlls/shell32/contmenu.c
@@ -8,6 +8,7 @@
 #include "debug.h"
 #include "pidl.h"
 #include "shlobj.h"
+#include "objbase.h"
 #include "shell32_main.h"
 #include "shresdef.h"
 #include "if_macros.h"
@@ -52,8 +53,7 @@
   { *ppvObj = (LPCONTEXTMENU)this;
   }   
   else if(IsEqualIID(riid, &IID_IShellExtInit))  /*IShellExtInit*/
-  { *ppvObj = (LPSHELLEXTINIT)this;
-    WARN(shell,"-- LPSHELLEXTINIT pointer requested\n");  
+  { FIXME (shell,"-- LPSHELLEXTINIT pointer requested\n");
   }   
 
   if(*ppvObj)
@@ -270,7 +270,7 @@
 *  IContextMenu_GetCommandString()
 */
 static HRESULT WINAPI IContextMenu_GetCommandString( LPCONTEXTMENU this, UINT32 idCommand,
-						UINT32 uFlags,LPUINT32 lpReserved,LPSTR lpszName,UINT32 uMaxNameLen)
+		UINT32 uFlags,LPUINT32 lpReserved,LPSTR lpszName,UINT32 uMaxNameLen)
 {	HRESULT  hr = E_INVALIDARG;
 
 	TRACE(shell,"(%p)->(idcom=%x flags=%x %p name=%p len=%x)\n",this, idCommand, uFlags, lpReserved, lpszName, uMaxNameLen);
@@ -321,8 +321,9 @@
 *  IContextMenu_AllocPidlTable()
 */
 BOOL32 IContextMenu_AllocPidlTable(LPCONTEXTMENU this, DWORD dwEntries)
-{	/*add one for NULL terminator */
-	TRACE(shell,"(%p)->(entrys=%lu)\n",this, dwEntries);
+{	TRACE(shell,"(%p)->(entrys=%lu)\n",this, dwEntries);
+
+	/*add one for NULL terminator */
 	dwEntries++;
 
 	this->aPidls = (LPITEMIDLIST*)SHAlloc(dwEntries * sizeof(LPITEMIDLIST));
diff --git a/dlls/shell32/dataobject.c b/dlls/shell32/dataobject.c
index 0bc6bf5..849a92d 100644
--- a/dlls/shell32/dataobject.c
+++ b/dlls/shell32/dataobject.c
@@ -7,7 +7,11 @@
  */
 #include "debug.h"
 #include "wintypes.h"
-#include "shlobj.h"
+#include "wine/obj_base.h"
+#include "wine/obj_storage.h"
+#include "wine/obj_moniker.h"
+#include "wine/obj_dataobject.h"
+#include "objbase.h"
 #include "pidl.h"
 #include "winerror.h"
 #include "shell32_main.h"
@@ -19,29 +23,44 @@
 /***********************************************************************
 *   IEnumFORMATETC implementation
 */
-static HRESULT WINAPI IEnumFORMATETC_QueryInterface (LPENUMFORMATETC this, REFIID riid, LPVOID * ppvObj);
-static ULONG WINAPI IEnumFORMATETC_AddRef (LPENUMFORMATETC this);
-static ULONG WINAPI IEnumFORMATETC_Release (LPENUMFORMATETC this);
-static HRESULT WINAPI IEnumFORMATETC_Next(LPENUMFORMATETC this, ULONG celt, FORMATETC32 *rgelt, ULONG *pceltFethed);
-static HRESULT WINAPI IEnumFORMATETC_Skip(LPENUMFORMATETC this, ULONG celt);
-static HRESULT WINAPI IEnumFORMATETC_Reset(LPENUMFORMATETC this);
-static HRESULT WINAPI IEnumFORMATETC_Clone(LPENUMFORMATETC this, LPENUMFORMATETC* ppenum);
+typedef struct _IEnumFORMATETC
+{
+    /* IUnknown fields */
+    ICOM_VTABLE(IEnumFORMATETC)* lpvtbl;
+    DWORD                        ref;
+    /* IEnumFORMATETC fields */
+    UINT32        posFmt;
+    UINT32        countFmt;
+    LPFORMATETC32 pFmt;
+} _IEnumFORMATETC;
 
-static struct IEnumFORMATETC_VTable efvt = 
-{	IEnumFORMATETC_QueryInterface,
-	IEnumFORMATETC_AddRef,
-	IEnumFORMATETC_Release,
-	IEnumFORMATETC_Next,
-	IEnumFORMATETC_Skip,
-	IEnumFORMATETC_Reset,
-	IEnumFORMATETC_Clone
+static HRESULT WINAPI IEnumFORMATETC_fnQueryInterface(LPUNKNOWN iface, REFIID riid, LPVOID* ppvObj);
+static ULONG WINAPI IEnumFORMATETC_fnAddRef(LPUNKNOWN iface);
+static ULONG WINAPI IEnumFORMATETC_fnRelease(LPUNKNOWN iface);
+static HRESULT WINAPI IEnumFORMATETC_fnNext(LPENUMFORMATETC iface, ULONG celt, FORMATETC32* rgelt, ULONG* pceltFethed);
+static HRESULT WINAPI IEnumFORMATETC_fnSkip(LPENUMFORMATETC iface, ULONG celt);
+static HRESULT WINAPI IEnumFORMATETC_fnReset(LPENUMFORMATETC iface);
+static HRESULT WINAPI IEnumFORMATETC_fnClone(LPENUMFORMATETC iface, LPENUMFORMATETC* ppenum);
+
+static struct ICOM_VTABLE(IEnumFORMATETC) efvt = 
+{
+    {
+        IEnumFORMATETC_fnQueryInterface,
+        IEnumFORMATETC_fnAddRef,
+        IEnumFORMATETC_fnRelease
+    },
+    IEnumFORMATETC_fnNext,
+    IEnumFORMATETC_fnSkip,
+    IEnumFORMATETC_fnReset,
+    IEnumFORMATETC_fnClone
 };
 
-extern LPENUMFORMATETC IEnumFORMATETC_Constructor(UINT32 cfmt, const FORMATETC32 afmt[])
-{	LPENUMFORMATETC ef;
+LPENUMFORMATETC IEnumFORMATETC_Constructor(UINT32 cfmt, const FORMATETC32 afmt[])
+{
+	_IEnumFORMATETC* ef;
 	DWORD size=cfmt * sizeof(FORMATETC32);
 	
-	ef=(LPENUMFORMATETC)HeapAlloc(GetProcessHeap(),0,sizeof(IEnumFORMATETC));
+	ef=(_IEnumFORMATETC*)HeapAlloc(GetProcessHeap(),0,sizeof(_IEnumFORMATETC));
 	ef->ref=1;
 	ef->lpvtbl=&efvt;
 
@@ -54,10 +73,12 @@
 	}
 
 	TRACE(shell,"(%p)->()\n",ef);
-	return ef;
+	return (LPENUMFORMATETC)ef;
 }
-static HRESULT WINAPI IEnumFORMATETC_QueryInterface (LPENUMFORMATETC this, REFIID riid, LPVOID * ppvObj)
-{	char    xriid[50];
+static HRESULT WINAPI IEnumFORMATETC_fnQueryInterface(LPUNKNOWN iface, REFIID riid, LPVOID* ppvObj)
+{
+	ICOM_THIS(IEnumFORMATETC,iface);
+	char    xriid[50];
 	WINE_StringFromCLSID((LPCLSID)riid,xriid);
 	TRACE(shell,"(%p)->(\n\tIID:\t%s,%p)\n",this,xriid,ppvObj);
 
@@ -71,7 +92,7 @@
 	}   
 
 	if(*ppvObj)
-	{ (*(LPENUMFORMATETC*)ppvObj)->lpvtbl->fnAddRef(this);      
+	{ IEnumFORMATETC_AddRef((IEnumFORMATETC*)*ppvObj);
 	  TRACE(shell,"-- Interface: (%p)->(%p)\n",ppvObj,*ppvObj);
 	  return S_OK;
 	}
@@ -79,12 +100,16 @@
 	return E_NOINTERFACE;
 
 }
-static ULONG WINAPI IEnumFORMATETC_AddRef (LPENUMFORMATETC this)
-{	TRACE(shell,"(%p)->(count=%lu)\n",this,(this->ref)+1);
+static ULONG WINAPI IEnumFORMATETC_fnAddRef(LPUNKNOWN iface)
+{
+	ICOM_THIS(IEnumFORMATETC,iface);
+	TRACE(shell,"(%p)->(count=%lu)\n",this,(this->ref)+1);
 	return ++(this->ref);
 }
-static ULONG WINAPI IEnumFORMATETC_Release (LPENUMFORMATETC this)
-{	TRACE(shell,"(%p)->()\n",this);
+static ULONG WINAPI IEnumFORMATETC_fnRelease(LPUNKNOWN iface)
+{
+	ICOM_THIS(IEnumFORMATETC,iface);
+	TRACE(shell,"(%p)->()\n",this);
 	if (!--(this->ref)) 
 	{ TRACE(shell," destroying IEnumFORMATETC(%p)\n",this);
 	  if (this->pFmt)
@@ -95,8 +120,10 @@
 	}
 	return this->ref;
 }
-static HRESULT WINAPI IEnumFORMATETC_Next(LPENUMFORMATETC this, ULONG celt, FORMATETC32 *rgelt, ULONG *pceltFethed)
-{	UINT32 cfetch;
+static HRESULT WINAPI IEnumFORMATETC_fnNext(LPENUMFORMATETC iface, ULONG celt, FORMATETC32 *rgelt, ULONG *pceltFethed)
+{
+	ICOM_THIS(IEnumFORMATETC,iface);
+	UINT32 cfetch;
 	HRESULT hres = S_FALSE;
 
 	TRACE (shell, "(%p)->()\n", this);
@@ -120,8 +147,10 @@
 
         return hres;
 }
-static HRESULT WINAPI IEnumFORMATETC_Skip(LPENUMFORMATETC this, ULONG celt)
-{	FIXME (shell, "(%p)->(num=%lu)\n", this, celt);
+static HRESULT WINAPI IEnumFORMATETC_fnSkip(LPENUMFORMATETC iface, ULONG celt)
+{
+	ICOM_THIS(IEnumFORMATETC,iface);
+	FIXME (shell, "(%p)->(num=%lu)\n", this, celt);
 
 	this->posFmt += celt;
 	if (this->posFmt > this->countFmt)
@@ -130,55 +159,73 @@
 	}
 	return S_OK;
 }
-static HRESULT WINAPI IEnumFORMATETC_Reset(LPENUMFORMATETC this)
-{	FIXME (shell, "(%p)->()\n", this);
+static HRESULT WINAPI IEnumFORMATETC_fnReset(LPENUMFORMATETC iface)
+{
+	ICOM_THIS(IEnumFORMATETC,iface);
+	FIXME (shell, "(%p)->()\n", this);
 
         this->posFmt = 0;
         return S_OK;
 }
-static HRESULT WINAPI IEnumFORMATETC_Clone(LPENUMFORMATETC this, LPENUMFORMATETC* ppenum)
-{	FIXME (shell, "(%p)->(ppenum=%p)\n", this, ppenum);
+static HRESULT WINAPI IEnumFORMATETC_fnClone(LPENUMFORMATETC iface, LPENUMFORMATETC* ppenum)
+{
+	ICOM_THIS(IEnumFORMATETC,iface);
+	FIXME (shell, "(%p)->(ppenum=%p)\n", this, ppenum);
 	return E_NOTIMPL;
 }
 
 /***********************************************************************
 *   IDataObject implementation
 */
+typedef struct _IDataObject
+{
+    /* IUnknown fields */
+    ICOM_VTABLE(IDataObject)* lpvtbl;
+    DWORD                     ref;
+    /* IDataObject fields */
+    LPSHELLFOLDER psf;
+    LPIDLLIST     lpill;       /* the data of the dataobject */
+    LPITEMIDLIST  pidl;     
+} _IDataObject;
 
-static HRESULT WINAPI IDataObject_QueryInterface (LPDATAOBJECT, REFIID riid, LPVOID * ppvObj);
-static ULONG WINAPI IDataObject_AddRef (LPDATAOBJECT);
-static ULONG WINAPI IDataObject_Release (LPDATAOBJECT);
-static HRESULT WINAPI IDataObject_GetData (LPDATAOBJECT, LPFORMATETC32 pformatetcIn, STGMEDIUM32 *pmedium);
-static HRESULT WINAPI IDataObject_GetDataHere(LPDATAOBJECT, LPFORMATETC32 pformatetc, STGMEDIUM32 *pmedium);
-static HRESULT WINAPI IDataObject_QueryGetData(LPDATAOBJECT, LPFORMATETC32 pformatetc);
-static HRESULT WINAPI IDataObject_GetCanonicalFormatEtc(LPDATAOBJECT, LPFORMATETC32 pformatectIn, LPFORMATETC32 pformatetcOut);
-static HRESULT WINAPI IDataObject_SetData(LPDATAOBJECT, LPFORMATETC32 pformatetc, STGMEDIUM32 *pmedium, BOOL32 fRelease);
-static HRESULT WINAPI IDataObject_EnumFormatEtc(LPDATAOBJECT, DWORD dwDirection, IEnumFORMATETC **ppenumFormatEtc);
-static HRESULT WINAPI IDataObject_DAdvise (LPDATAOBJECT, LPFORMATETC32 *pformatetc, DWORD advf, IAdviseSink *pAdvSink, DWORD *pdwConnection);
-static HRESULT WINAPI IDataObject_DUnadvise(LPDATAOBJECT, DWORD dwConnection);
-static HRESULT WINAPI IDataObject_EnumDAdvise(LPDATAOBJECT, IEnumSTATDATA **ppenumAdvise);
+static HRESULT WINAPI IDataObject_fnQueryInterface(LPUNKNOWN iface, REFIID riid, LPVOID* ppvObj);
+static ULONG WINAPI IDataObject_fnAddRef(LPUNKNOWN iface);
+static ULONG WINAPI IDataObject_fnRelease(LPUNKNOWN iface);
+static HRESULT WINAPI IDataObject_fnGetData(LPDATAOBJECT iface, LPFORMATETC32 pformatetcIn, STGMEDIUM32* pmedium);
+static HRESULT WINAPI IDataObject_fnGetDataHere(LPDATAOBJECT iface, LPFORMATETC32 pformatetc, STGMEDIUM32* pmedium);
+static HRESULT WINAPI IDataObject_fnQueryGetData(LPDATAOBJECT iface, LPFORMATETC32 pformatetc);
+static HRESULT WINAPI IDataObject_fnGetCanonicalFormatEtc(LPDATAOBJECT iface, LPFORMATETC32 pformatectIn, LPFORMATETC32 pformatetcOut);
+static HRESULT WINAPI IDataObject_fnSetData(LPDATAOBJECT iface, LPFORMATETC32 pformatetc, STGMEDIUM32* pmedium, BOOL32 fRelease);
+static HRESULT WINAPI IDataObject_fnEnumFormatEtc(LPDATAOBJECT iface, DWORD dwDirection, IEnumFORMATETC** ppenumFormatEtc);
+static HRESULT WINAPI IDataObject_fnDAdvise(LPDATAOBJECT iface, LPFORMATETC32* pformatetc, DWORD advf, IAdviseSink* pAdvSink, DWORD* pdwConnection);
+static HRESULT WINAPI IDataObject_fnDUnadvise(LPDATAOBJECT iface, DWORD dwConnection);
+static HRESULT WINAPI IDataObject_fnEnumDAdvise(LPDATAOBJECT iface, IEnumSTATDATA **ppenumAdvise);
 
-static struct IDataObject_VTable dtovt = 
-{	IDataObject_QueryInterface,
-	IDataObject_AddRef,
-	IDataObject_Release,
-	IDataObject_GetData,
-	IDataObject_GetDataHere,
-	IDataObject_QueryGetData,
-	IDataObject_GetCanonicalFormatEtc,
-	IDataObject_SetData,
-	IDataObject_EnumFormatEtc,
-	IDataObject_DAdvise,
-	IDataObject_DUnadvise,
-	IDataObject_EnumDAdvise
+static struct ICOM_VTABLE(IDataObject) dtovt = 
+{
+    {
+        IDataObject_fnQueryInterface,
+        IDataObject_fnAddRef,
+        IDataObject_fnRelease
+    },
+    IDataObject_fnGetData,
+    IDataObject_fnGetDataHere,
+    IDataObject_fnQueryGetData,
+    IDataObject_fnGetCanonicalFormatEtc,
+    IDataObject_fnSetData,
+    IDataObject_fnEnumFormatEtc,
+    IDataObject_fnDAdvise,
+    IDataObject_fnDUnadvise,
+    IDataObject_fnEnumDAdvise
 };
 
 /**************************************************************************
 *  IDataObject_Constructor
 */
 LPDATAOBJECT IDataObject_Constructor(HWND32 hwndOwner, LPSHELLFOLDER psf, LPITEMIDLIST * apidl, UINT32 cidl)
-{	LPDATAOBJECT dto;
-	if (!(dto = (LPDATAOBJECT)HeapAlloc(GetProcessHeap(),0,sizeof(IDataObject))))
+{
+	_IDataObject* dto;
+	if (!(dto = (_IDataObject*)HeapAlloc(GetProcessHeap(),0,sizeof(_IDataObject))))
 	  return NULL;
 	  
 	dto->ref=1;
@@ -194,13 +241,15 @@
 	dto->lpill->lpvtbl->fnAddItems(dto->lpill, apidl, cidl); 
 	
 	TRACE(shell,"(%p)->(sf=%p apidl=%p cidl=%u)\n",dto, psf, apidl, cidl);
-	return dto;
+	return (LPDATAOBJECT)dto;
 }
 /***************************************************************************
 *  IDataObject_QueryInterface
 */
-static HRESULT WINAPI IDataObject_QueryInterface (LPDATAOBJECT this, REFIID riid, LPVOID * ppvObj)
-{	char    xriid[50];
+static HRESULT WINAPI IDataObject_fnQueryInterface (LPUNKNOWN iface, REFIID riid, LPVOID * ppvObj)
+{
+	ICOM_THIS(IDataObject,iface);
+	char    xriid[50];
 	WINE_StringFromCLSID((LPCLSID)riid,xriid);
 	TRACE(shell,"(%p)->(\n\tIID:\t%s,%p)\n",this,xriid,ppvObj);
 
@@ -214,7 +263,7 @@
 	}   
 
 	if(*ppvObj)
-	{ (*(LPDATAOBJECT*)ppvObj)->lpvtbl->fnAddRef(this);      
+	{ IDataObject_AddRef((IDataObject*)*ppvObj);      
 	  TRACE(shell,"-- Interface: (%p)->(%p)\n",ppvObj,*ppvObj);
 	  return S_OK;
 	}
@@ -224,15 +273,19 @@
 /**************************************************************************
 *  IDataObject_AddRef
 */
-static ULONG WINAPI IDataObject_AddRef(LPDATAOBJECT this)
-{	TRACE(shell,"(%p)->(count=%lu)\n",this,(this->ref)+1);
+static ULONG WINAPI IDataObject_fnAddRef(LPUNKNOWN iface)
+{
+	ICOM_THIS(IDataObject,iface);
+	TRACE(shell,"(%p)->(count=%lu)\n",this,(this->ref)+1);
 	return ++(this->ref);
 }
 /**************************************************************************
 *  IDataObject_Release
 */
-static ULONG WINAPI IDataObject_Release(LPDATAOBJECT this)
-{	TRACE(shell,"(%p)->()\n",this);
+static ULONG WINAPI IDataObject_fnRelease(LPUNKNOWN iface)
+{
+	ICOM_THIS(IDataObject,iface);
+	TRACE(shell,"(%p)->()\n",this);
 	if (!--(this->ref)) 
 	{ TRACE(shell," destroying IDataObject(%p)\n",this);
 	  IDLList_Destructor(this->lpill);
@@ -262,6 +315,7 @@
 * NOTES
 *  get or register the "FileGroupDescriptor" clipformat
 */
+/* FIXME: DATAOBJECT_InitFileGroupDesc is not used (19981226)
 static BOOL32 DATAOBJECT_InitFileGroupDesc(void)
 {	if (cfFileGroupDesc)
         { return(TRUE);
@@ -270,12 +324,14 @@
         cfFileGroupDesc = RegisterClipboardFormat32A(CFSTR_FILEDESCRIPTORA);
         return(cfFileGroupDesc != 0);
 }
+*/
 /**************************************************************************
 * DATAOBJECT_InitFileContents (internal)
 * 
 * NOTES
  * get or register the "FileContents" clipformat
 */
+/* FIXME: DATAOBJECT_InitFileContents is not used (19981226)
 static BOOL32 DATAOBJECT_InitFileContents(void)
 {	if (cfFileContents)
         { return(TRUE);
@@ -284,13 +340,15 @@
         cfFileContents = RegisterClipboardFormat32A(CFSTR_FILECONTENTS);
         return(cfFileContents != 0);
 }
-
+*/
 
 /**************************************************************************
 * interface implementation
 */
-static HRESULT WINAPI IDataObject_GetData (LPDATAOBJECT this, LPFORMATETC32 pformatetcIn, STGMEDIUM32 *pmedium)
-{	char	temp[256];
+static HRESULT WINAPI IDataObject_fnGetData(LPDATAOBJECT iface, LPFORMATETC32 pformatetcIn, STGMEDIUM32 *pmedium)
+{
+	ICOM_THIS(IDataObject,iface);
+	char	temp[256];
 	UINT32	cItems;
 	DWORD	size, size1, size2;
 	LPITEMIDLIST pidl;
@@ -353,35 +411,51 @@
 	FIXME (shell, "-- clipformat not implemented\n");
 	return (E_INVALIDARG);
 }
-static HRESULT WINAPI IDataObject_GetDataHere(LPDATAOBJECT this, LPFORMATETC32 pformatetc, STGMEDIUM32 *pmedium)
-{	FIXME (shell, "(%p)->()\n", this);
+static HRESULT WINAPI IDataObject_fnGetDataHere(LPDATAOBJECT iface, LPFORMATETC32 pformatetc, STGMEDIUM32 *pmedium)
+{
+	ICOM_THIS(IDataObject,iface);
+	FIXME (shell, "(%p)->()\n", this);
 	return E_NOTIMPL;
 }
-static HRESULT WINAPI IDataObject_QueryGetData(LPDATAOBJECT this, LPFORMATETC32 pformatetc)
-{	FIXME (shell, "(%p)->()\n", this);
+static HRESULT WINAPI IDataObject_fnQueryGetData(LPDATAOBJECT iface, LPFORMATETC32 pformatetc)
+{
+	ICOM_THIS(IDataObject,iface);
+	FIXME (shell, "(%p)->()\n", this);
 	return E_NOTIMPL;
 }
-static HRESULT WINAPI IDataObject_GetCanonicalFormatEtc(LPDATAOBJECT this, LPFORMATETC32 pformatectIn, LPFORMATETC32 pformatetcOut)
-{	FIXME (shell, "(%p)->()\n", this);
+static HRESULT WINAPI IDataObject_fnGetCanonicalFormatEtc(LPDATAOBJECT iface, LPFORMATETC32 pformatectIn, LPFORMATETC32 pformatetcOut)
+{
+	ICOM_THIS(IDataObject,iface);
+	FIXME (shell, "(%p)->()\n", this);
 	return E_NOTIMPL;
 }
-static HRESULT WINAPI IDataObject_SetData(LPDATAOBJECT this, LPFORMATETC32 pformatetc, STGMEDIUM32 *pmedium, BOOL32 fRelease)
-{	FIXME (shell, "(%p)->()\n", this);
+static HRESULT WINAPI IDataObject_fnSetData(LPDATAOBJECT iface, LPFORMATETC32 pformatetc, STGMEDIUM32 *pmedium, BOOL32 fRelease)
+{
+	ICOM_THIS(IDataObject,iface);
+	FIXME (shell, "(%p)->()\n", this);
 	return E_NOTIMPL;
 }
-static HRESULT WINAPI IDataObject_EnumFormatEtc(LPDATAOBJECT this, DWORD dwDirection, IEnumFORMATETC **ppenumFormatEtc)
-{	FIXME (shell, "(%p)->()\n", this);
+static HRESULT WINAPI IDataObject_fnEnumFormatEtc(LPDATAOBJECT iface, DWORD dwDirection, IEnumFORMATETC **ppenumFormatEtc)
+{
+	ICOM_THIS(IDataObject,iface);
+	FIXME (shell, "(%p)->()\n", this);
 	return E_NOTIMPL;
 }
-static HRESULT WINAPI IDataObject_DAdvise (LPDATAOBJECT this, LPFORMATETC32 *pformatetc, DWORD advf, IAdviseSink *pAdvSink, DWORD *pdwConnection)
-{	FIXME (shell, "(%p)->()\n", this);
+static HRESULT WINAPI IDataObject_fnDAdvise(LPDATAOBJECT iface, LPFORMATETC32 *pformatetc, DWORD advf, IAdviseSink *pAdvSink, DWORD *pdwConnection)
+{
+	ICOM_THIS(IDataObject,iface);
+	FIXME (shell, "(%p)->()\n", this);
 	return E_NOTIMPL;
 }
-static HRESULT WINAPI IDataObject_DUnadvise(LPDATAOBJECT this, DWORD dwConnection)
-{	FIXME (shell, "(%p)->()\n", this);
+static HRESULT WINAPI IDataObject_fnDUnadvise(LPDATAOBJECT iface, DWORD dwConnection)
+{
+	ICOM_THIS(IDataObject,iface);
+	FIXME (shell, "(%p)->()\n", this);
 	return E_NOTIMPL;
 }
-static HRESULT WINAPI IDataObject_EnumDAdvise(LPDATAOBJECT this, IEnumSTATDATA **ppenumAdvise)
-{	FIXME (shell, "(%p)->()\n", this);
+static HRESULT WINAPI IDataObject_fnEnumDAdvise(LPDATAOBJECT iface, IEnumSTATDATA **ppenumAdvise)
+{
+	ICOM_THIS(IDataObject,iface);
+	FIXME (shell, "(%p)->()\n", this);
 	return E_NOTIMPL;
 }
diff --git a/dlls/shell32/enumidlist.c b/dlls/shell32/enumidlist.c
index 45cb0cf..118d839 100644
--- a/dlls/shell32/enumidlist.c
+++ b/dlls/shell32/enumidlist.c
@@ -10,9 +10,8 @@
 #include "ole.h"
 #include "ole2.h"
 #include "debug.h"
-#include "compobj.h"
-#include "interfaces.h"
 #include "shlobj.h"
+#include "objbase.h"
 #include "shell.h"
 #include "winerror.h"
 #include "winnls.h"
diff --git a/dlls/shell32/folders.c b/dlls/shell32/folders.c
index eb9082a..a3e86ed 100644
--- a/dlls/shell32/folders.c
+++ b/dlls/shell32/folders.c
@@ -10,9 +10,8 @@
 #include "ole.h"
 #include "ole2.h"
 #include "debug.h"
-#include "compobj.h"
-#include "interfaces.h"
 #include "shlobj.h"
+#include "objbase.h"
 #include "shell.h"
 #include "winerror.h"
 #include "winnls.h"
diff --git a/dlls/shell32/iconcache.c b/dlls/shell32/iconcache.c
index 2aae5e8..aad6a79 100644
--- a/dlls/shell32/iconcache.c
+++ b/dlls/shell32/iconcache.c
@@ -741,7 +741,7 @@
 	if (phiconSmall)
 	{ ret = ICO_ExtractIconEx(lpszFile, phiconSmall, nIconIndex, nIcons, 16, 16  );
 	  if ( nIcons==1 )
-	  { ret = phiconLarge[0];
+	  { ret = phiconSmall[0];
 	  }
 	}
 
diff --git a/dlls/shell32/pidl.c b/dlls/shell32/pidl.c
index 5819b6a..0f014b3 100644
--- a/dlls/shell32/pidl.c
+++ b/dlls/shell32/pidl.c
@@ -14,8 +14,6 @@
 #include "ole.h"
 #include "ole2.h"
 #include "debug.h"
-#include "compobj.h"
-#include "interfaces.h"
 #include "shlobj.h"
 #include "shell.h"
 #include "winerror.h"
@@ -556,8 +554,8 @@
 	return _ILCreate(PT_DESKTOP, NULL, 0);
 }
 LPITEMIDLIST WINAPI _ILCreateMyComputer()
-{ TRACE(pidl,"()\n");
-  return _ILCreate(PT_MYCOMP, (void *)"My Computer", strlen ("My Computer")+1);
+{	TRACE(pidl,"()\n");
+	return _ILCreate(PT_MYCOMP, (void *)"My Computer", strlen ("My Computer")+1);
 }
 LPITEMIDLIST WINAPI _ILCreateDrive( LPCSTR lpszNew)
 {	char sTemp[4];
@@ -568,47 +566,58 @@
 	return _ILCreate(PT_DRIVE,(LPVOID)&sTemp[0],4);
 }
 LPITEMIDLIST WINAPI _ILCreateFolder( LPCSTR lpszNew)
-{ TRACE(pidl,"(%s)\n",lpszNew);
-  return _ILCreate(PT_FOLDER, (LPVOID)lpszNew, strlen(lpszNew)+1);
+{	TRACE(pidl,"(%s)\n",lpszNew);
+	return _ILCreate(PT_FOLDER, (LPVOID)lpszNew, strlen(lpszNew)+1);
 }
 LPITEMIDLIST WINAPI _ILCreateValue(LPCSTR lpszNew)
-{ TRACE(pidl,"(%s)\n",lpszNew);
-  return _ILCreate(PT_VALUE, (LPVOID)lpszNew, strlen(lpszNew)+1);
+{	TRACE(pidl,"(%s)\n",lpszNew);
+	return _ILCreate(PT_VALUE, (LPVOID)lpszNew, strlen(lpszNew)+1);
 }
 
 /**************************************************************************
  *  _ILGetDrive()
  *
- *  FIXME: quick hack
+ *  Gets the text for the drive eg. 'c:\'
+ *
+ * RETURNS
+ *  strlen (lpszText)
  */
-BOOL32 WINAPI _ILGetDrive(LPCITEMIDLIST pidl,LPSTR pOut, UINT16 uSize)
-{	LPITEMIDLIST   pidlTemp=NULL;
+DWORD WINAPI _ILGetDrive(LPCITEMIDLIST pidl,LPSTR pOut, UINT16 uSize)
+{	TRACE(pidl,"(%p,%p,%u)\n",pidl,pOut,uSize);
 
-	TRACE(pidl,"(%p,%p,%u)\n",pidl,pOut,uSize);
 	if(_ILIsMyComputer(pidl))
-	{ pidlTemp = ILGetNext(pidl);
-	}
-	else if (pidlTemp && _ILIsDrive(pidlTemp))
-	{ return (BOOL32)_ILGetData(PT_DRIVE, pidlTemp, (LPVOID)pOut, uSize);
-	}
-	return FALSE;
+	  pidl = ILGetNext(pidl);
+
+	if (pidl && _ILIsDrive(pidl))
+	  return _ILGetData(PT_DRIVE, pidl, (LPVOID)pOut, uSize)-1;
+
+	return 0;
 }
 /**************************************************************************
  *  _ILGetItemText()
- *  Gets the text for only this item
+ *  Gets the text for only the first item
+ *
+ * RETURNS
+ *  strlen (lpszText)
  */
 DWORD WINAPI _ILGetItemText(LPCITEMIDLIST pidl, LPSTR lpszText, UINT16 uSize)
-{	TRACE(pidl,"(pidl=%p %p %x)\n",pidl,lpszText,uSize);
+{	DWORD ret = 0;
+
+	TRACE(pidl,"(pidl=%p %p %d)\n",pidl,lpszText,uSize);
 	if (_ILIsMyComputer(pidl))
-	{ return _ILGetData(PT_MYCOMP, pidl, (LPVOID)lpszText, uSize);
+	{ ret = _ILGetData(PT_MYCOMP, pidl, (LPVOID)lpszText, uSize)-1;
 	}
-	if (_ILIsDrive(pidl))
-	{ return _ILGetData(PT_DRIVE, pidl, (LPVOID)lpszText, uSize);
+	else if (_ILIsDrive(pidl))
+	{ ret = _ILGetData(PT_DRIVE, pidl, (LPVOID)lpszText, uSize)-1;
 	}
-	if (_ILIsFolder (pidl))
-	{ return _ILGetData(PT_FOLDER, pidl, (LPVOID)lpszText, uSize);
+	else if (_ILIsFolder (pidl))
+	{ ret = _ILGetData(PT_FOLDER, pidl, (LPVOID)lpszText, uSize)-1;
 	}
-	return _ILGetData(PT_VALUE, pidl, (LPVOID)lpszText, uSize);	
+	else if (_ILIsValue (pidl))
+	{ ret = _ILGetData(PT_VALUE, pidl, (LPVOID)lpszText, uSize)-1;
+	}
+	TRACE(pidl,"(-- %s)\n",debugstr_a(lpszText));
+	return ret;
 }
 /**************************************************************************
  *  _ILIsDesktop()
@@ -617,82 +626,38 @@
  *  _ILIsValue()
  */
 BOOL32 WINAPI _ILIsDesktop(LPCITEMIDLIST pidl)
-{ TRACE(pidl,"(%p)\n",pidl);
-
-  if (! pidl)
-    return TRUE;
-
-  return (  pidl->mkid.cb == 0x00 );
+{	TRACE(pidl,"(%p)\n",pidl);
+	return ( !pidl || (pidl && pidl->mkid.cb == 0x00) );
 }
 
 BOOL32 WINAPI _ILIsMyComputer(LPCITEMIDLIST pidl)
-{ LPPIDLDATA  pData;
-  TRACE(pidl,"(%p)\n",pidl);
-
-  if (! pidl)
-    return FALSE;
-
-  pData = _ILGetDataPointer(pidl);
-  return (PT_MYCOMP == pData->type);
+{	TRACE(pidl,"(%p)\n",pidl);
+	return (pidl && PT_MYCOMP == _ILGetDataPointer(pidl)->type);
 }
 
 BOOL32 WINAPI _ILIsDrive(LPCITEMIDLIST pidl)
-{ LPPIDLDATA  pData;
-  TRACE(pidl,"(%p)\n",pidl);
-
-  if (! pidl)
-    return FALSE;
-
-  pData = _ILGetDataPointer(pidl);
-  return (PT_DRIVE == pData->type);
+{	TRACE(pidl,"(%p)\n",pidl);
+	return (pidl && PT_DRIVE == _ILGetDataPointer(pidl)->type);
 }
 
 BOOL32 WINAPI _ILIsFolder(LPCITEMIDLIST pidl)
-{ LPPIDLDATA  pData;
-  TRACE(pidl,"(%p)\n",pidl);
-
-  if (! pidl)
-    return FALSE;
-
-  pData = _ILGetDataPointer(pidl);
-  return (PT_FOLDER == pData->type);
+{	TRACE(pidl,"(%p)\n",pidl);
+	return (pidl && PT_FOLDER == _ILGetDataPointer(pidl)->type);
 }
 
 BOOL32 WINAPI _ILIsValue(LPCITEMIDLIST pidl)
-{ LPPIDLDATA  pData;
-  TRACE(pidl,"(%p)\n",pidl);
-
-  if (! pidl)
-    return FALSE;
-
-  pData = _ILGetDataPointer(pidl);
-  return (PT_VALUE == pData->type);
-}
-/**************************************************************************
- * _ILHasFolders()
- * fixme: quick hack
- */
-BOOL32 WINAPI _ILHasFolders( LPSTR pszPath, LPCITEMIDLIST pidl)
-{	BOOL32 bResult= FALSE;
-	WIN32_FIND_DATA32A stffile;	
-	HANDLE32 hFile;
-
-	TRACE(pidl,"%p %p\n", pszPath, pidl);
-	
-	hFile = FindFirstFile32A(pszPath,&stffile);
-	do
-	{ if (! (stffile.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) )
-	  {  bResult= TRUE;	  
-	  }
-	} while( FindNextFile32A(hFile,&stffile));
-	FindClose32 (hFile);
-	
-	return bResult;
+{	TRACE(pidl,"(%p)\n",pidl);
+	return (pidl && PT_VALUE == _ILGetDataPointer(pidl)->type);
 }
 
 /**************************************************************************
  *  _ILGetFolderText()
- *  Creates a Path string from a PIDL, filtering out the special Folders 
+ *  Creates a Path string from a PIDL, filtering out the special Folders and values
+ *  There is no trailing backslash
+ *  When lpszPath is NULL the needed size is returned
+ * 
+ * RETURNS
+ *  strlen(lpszPath)
  */
 DWORD WINAPI _ILGetFolderText(LPCITEMIDLIST pidl,LPSTR lpszPath, DWORD dwSize)
 {	LPITEMIDLIST	pidlTemp;
@@ -702,8 +667,7 @@
 	TRACE(pidl,"(%p path=%p)\n",pidl, lpszPath);
  
 	if(!pidl)
-	{ return 0;
-	}
+	  return 0;
 
 	if(_ILIsMyComputer(pidl))
 	{ pidlTemp = ILGetNext(pidl);
@@ -713,49 +677,36 @@
 	{ pidlTemp = (LPITEMIDLIST)pidl;
 	}
 
-	/*if this is NULL, return the required size of the buffer */
-	if(!lpszPath)
-	{ while(pidlTemp->mkid.cb)
-	  { LPPIDLDATA  pData = _ILGetDataPointer(pidlTemp);
-	    pText = _ILGetTextPointer(pData->type,pData);         
+	if(lpszPath)
+	  *lpszPath = 0;
 
-	    /*add the length of this item plus one for the backslash
-	    fixme: is one to much, drive has its own backslash*/
-	    dwCopied += strlen(pText) + 1;  	    
-	    pidlTemp = ILGetNext(pidlTemp);
-	  }
-
-	  /*add one for the NULL terminator */
-	  TRACE(pidl,"-- (size=%lu)\n",dwCopied);
-	  return dwCopied + 1;
-	}
-
-	*lpszPath = 0;
-
-	while(pidlTemp->mkid.cb && (dwCopied < dwSize))
+	while(pidlTemp->mkid.cb)
 	{ LPPIDLDATA  pData = _ILGetDataPointer(pidlTemp);
 
 	  /*if this item is a value, then skip it and finish */
 	  if(PT_VALUE == pData->type)
 	  { break;
 	  }
-	  pText = _ILGetTextPointer(pData->type,pData);   
-	  strcat(lpszPath, pText);
-	  PathAddBackslash32A(lpszPath);
-	  dwCopied += strlen(pText) + 1;
+
+	  pText = _ILGetTextPointer(pData->type,pData);
 	  pidlTemp = ILGetNext(pidlTemp);
+	  dwCopied += strlen(pText);
 
-	  TRACE(pidl,"-- (size=%lu,%s)\n",dwCopied,lpszPath);
-	}
-
-	/*remove the last backslash if necessary */
-	if(dwCopied)
-	{ if(*(lpszPath + strlen(lpszPath) - 1) == '\\')
-	  { *(lpszPath + strlen(lpszPath) - 1) = 0;
-	    dwCopied--;
+	  if (lpszPath)
+	  { strcat(lpszPath, pText);
+	    if (pidlTemp && lpszPath[dwCopied-1]!='\\')
+	    { lpszPath[dwCopied] = '\\';
+	      lpszPath[dwCopied+1] = '\0';
+	      dwCopied++;
+	    }
+	  }
+	  else						/* only length */
+	  { if (pidlTemp && !_ILIsDrive (pidlTemp))	/* backslash between elements */
+	      dwCopied++;
 	  }
 	}
-	TRACE(pidl,"-- (path=%s)\n",lpszPath);
+
+	TRACE(pidl,"-- (size=%lu path=%s)\n",dwCopied, debugstr_a(lpszPath));
 	return dwCopied;
 }
 
@@ -764,8 +715,7 @@
  *  _ILGetValueText()
  *  Gets the text for the last item in the list
  */
-DWORD WINAPI _ILGetValueText(
-    LPCITEMIDLIST pidl, LPSTR lpszValue, DWORD dwSize)
+DWORD WINAPI _ILGetValueText(LPCITEMIDLIST pidl, LPSTR lpszValue, DWORD dwSize)
 {	LPITEMIDLIST  pidlTemp=pidl;
 	CHAR          szText[MAX_PATH];
 
@@ -786,99 +736,53 @@
 	_ILGetItemText( pidlTemp, szText, sizeof(szText));
 
 	if(!lpszValue)
-	{ return strlen(szText) + 1;
+	{ return strlen(szText);
 	}
+	
 	strcpy(lpszValue, szText);
+
 	TRACE(pidl,"-- (pidl=%p %p=%s 0x%08lx)\n",pidl,lpszValue,lpszValue,dwSize);
 	return strlen(lpszValue);
 }
-/**************************************************************************
- *  _ILGetDataText()
- * NOTES
- *  used from ShellView
- */
-DWORD WINAPI _ILGetDataText( LPCITEMIDLIST pidlPath, LPCITEMIDLIST pidlValue, LPSTR lpszOut, DWORD dwOutSize)
-{ LPSTR    lpszFolder,
-           lpszValueName;
-  DWORD    dwNameSize;
-
-  FIXME(pidl,"(pidl=%p pidl=%p) stub\n",pidlPath,pidlValue);
-
-  if(!lpszOut || !pidlPath || !pidlValue)
-  { return FALSE;
-	}
-
-  /* fixme: get the driveletter*/
-
-  /*assemble the Folder string */
-  dwNameSize = _ILGetFolderText(pidlPath, NULL, 0);
-  lpszFolder = (LPSTR)HeapAlloc(GetProcessHeap(),0,dwNameSize);
-  if(!lpszFolder)
-  {  return FALSE;
-	}
-  _ILGetFolderText(pidlPath, lpszFolder, dwNameSize);
-
-  /*assemble the value name */
-  dwNameSize = _ILGetValueText(pidlValue, NULL, 0);
-  lpszValueName = (LPSTR)HeapAlloc(GetProcessHeap(),0,dwNameSize);
-  if(!lpszValueName)
-  { HeapFree(GetProcessHeap(),0,lpszFolder);
-    return FALSE;
-  }
-  _ILGetValueText(pidlValue, lpszValueName, dwNameSize);
-
-  /* fixme: we've got the path now do something with it*/
-	
-  HeapFree(GetProcessHeap(),0,lpszFolder);
-  HeapFree(GetProcessHeap(),0,lpszValueName);
-
-  TRACE(pidl,"-- (%p=%s 0x%08lx)\n",lpszOut,lpszOut,dwOutSize);
-
-	return TRUE;
-}
 
 /**************************************************************************
  *  _ILGetPidlPath()
  *  Create a string that includes the Drive name, the folder text and 
  *  the value text.
+ *
+ * RETURNS
+ *  strlen(lpszOut)
  */
 DWORD WINAPI _ILGetPidlPath( LPCITEMIDLIST pidl, LPSTR lpszOut, DWORD dwOutSize)
-{ LPSTR lpszTemp;
-  WORD	len;
+{	WORD  len = 0;
 
-  TRACE(pidl,"(%p,%lu)\n",lpszOut,dwOutSize);
+	TRACE(pidl,"(%p,%lu)\n",lpszOut,dwOutSize);
 
-  if(!lpszOut)
-  { return 0;
+	if(!lpszOut)
+	{ return 0;
 	}
 
-  *lpszOut = 0;
-  lpszTemp = lpszOut;
+	*lpszOut = 0;
 
-  dwOutSize -= _ILGetFolderText(pidl, lpszTemp, dwOutSize);
+	len = _ILGetFolderText(pidl, lpszOut, dwOutSize);
 
-  /*add a backslash if necessary */
-  len = strlen(lpszTemp);
-  if (len && lpszTemp[len-1]!='\\')
-	{ lpszTemp[len+0]='\\';
-    lpszTemp[len+1]='\0';
-		dwOutSize--;
-  }
+	lpszOut += len;
+	strcpy (lpszOut,"\\");
+	lpszOut++;
 
-  lpszTemp = lpszOut + strlen(lpszOut);
+	dwOutSize -= len+1;;
 
-  /*add the value string */
-  _ILGetValueText(pidl, lpszTemp, dwOutSize);
+	len += _ILGetValueText(pidl, lpszOut, dwOutSize );
 
-  /*remove the last backslash if necessary */
-  if(*(lpszOut + strlen(lpszOut) - 1) == '\\')
-  { *(lpszOut + strlen(lpszOut) - 1) = 0;
-  }
+	/*remove the last backslash if necessary */
+	if( lpszOut[len-1]=='\\')
+	{ lpszOut[len-1] = 0;
+	  len--;
+	}
 
-  TRACE(pidl,"-- (%p=%s,%lu)\n",lpszOut,lpszOut,dwOutSize);
+	TRACE(pidl,"-- (%p=%s,%lu)\n",lpszOut,lpszOut,dwOutSize);
 
-  return strlen(lpszOut);
-
+	return len;
 }
 
 /**************************************************************************
@@ -886,7 +790,7 @@
  *  Creates a new PIDL
  *  type = PT_DESKTOP | PT_DRIVE | PT_FOLDER | PT_VALUE
  *  pIn = data
- *  uInSize = size of data
+ *  uInSize = size of data (raw)
  */
 
 LPITEMIDLIST WINAPI _ILCreate(PIDLTYPE type, LPVOID pIn, UINT16 uInSize)
@@ -950,6 +854,9 @@
 }
 /**************************************************************************
  *  _ILGetData(PIDLTYPE, LPCITEMIDLIST, LPVOID, UINT16)
+ *
+ * RETURNS
+ *  length of data (raw)
  */
 DWORD WINAPI _ILGetData(PIDLTYPE type, LPCITEMIDLIST pidl, LPVOID pOut, UINT32 uOutSize)
 {	LPPIDLDATA  pData;
@@ -976,20 +883,20 @@
 	    if(uOutSize < 1)
 	      return 0;
 	    strncpy((LPSTR)pOut, "My Computer", uOutSize);
-	    dwReturn = strlen((LPSTR)pOut);
+	    dwReturn = strlen((LPSTR)pOut)+1;
 	    break;
 
 	  case PT_DRIVE:
 	    if(uOutSize < 1)
 	      return 0;
 	    strncpy((LPSTR)pOut, pszSrc, uOutSize);
-	    dwReturn = strlen((LPSTR)pOut);
+	    dwReturn = strlen((LPSTR)pOut)+1;
 	    break;
 
 	  case PT_FOLDER:
 	  case PT_VALUE: 
 	     strncpy((LPSTR)pOut, pszSrc, uOutSize);
-	     dwReturn = strlen((LPSTR)pOut);
+	     dwReturn = strlen((LPSTR)pOut)+1;
 	     break;
 	  default:
 	    ERR(pidl,"-- unknown type\n");
diff --git a/dlls/shell32/pidl.h b/dlls/shell32/pidl.h
index 4ef4891..d2cf699 100644
--- a/dlls/shell32/pidl.h
+++ b/dlls/shell32/pidl.h
@@ -22,7 +22,7 @@
 *
 * a pidl of NULL means the desktop
 *
-* The structure of the pidl seens to be a union. The first byte of the
+* The structure of the pidl seems to be a union. The first byte of the
 * PIDLDATA desribes the type of pidl.
 *
 * first byte - 	my Computer	0x1F
@@ -35,67 +35,92 @@
 * file: see the PIDLDATA structure	 
 */
 
-#define PT_DESKTOP	0x00 /*fixme*/
+#define PT_DESKTOP	0x00 /* internal */
 #define PT_MYCOMP	0x1F
 #define PT_SPECIAL	0x2E
 #define PT_DRIVE	0x23
 #define PT_FOLDER	0x31
-#define PT_VALUE	0x33 /*fixme*/
+#define PT_VALUE	0x32
 
 #pragma pack(1)
 typedef BYTE PIDLTYPE;
 
 typedef struct tagPIDLDATA
-{	PIDLTYPE type;
+{	PIDLTYPE type;			/*00*/
 	union
 	{ struct
-	  { CHAR szDriveName[4];
+	  { CHAR szDriveName[4];	/*01*/
 	    /* end of MS compatible*/
-	    DWORD dwSFGAO;
+	    DWORD dwSFGAO;		/*05*/
+	    /* the drive seems to be 19 bytes every time */
 	  } drive;
 	  struct 
-	  { BYTE dummy;
-	    DWORD dwFileSize;
-	    WORD uFileDate;
-	    WORD uFileTime;
-	    WORD uFileAttribs;
-	    /* end of MS compatible*/
-	    DWORD dwSFGAO;
+	  { BYTE dummy;			/*01 is 0x00 for files or dirs */
+	    DWORD dwFileSize;		/*02*/
+	    WORD uFileDate;		/*06*/
+	    WORD uFileTime;		/*08*/
+	    WORD uFileAttribs;		/*10*/
+	    /* end of MS compatible. Here are comming just one or two
+	    strings. The first is the long name. The second the dos name
+	    when needed. */
+	    DWORD dwSFGAO;		/*12*/
 	    CHAR  szAlternateName[14];	/* the 8.3 Name*/
-	    CHAR szText[1];		/* last entry, variable size */
+	    CHAR  szText[1];		/* last entry, variable size */
 	  } file, folder, generic; 
 	}u;
 } PIDLDATA, *LPPIDLDATA;
 #pragma pack(4)
 
-LPITEMIDLIST WINAPI _ILCreateDesktop(void);
-LPITEMIDLIST WINAPI _ILCreateMyComputer(void);
-LPITEMIDLIST WINAPI _ILCreateDrive(LPCSTR);
-LPITEMIDLIST WINAPI _ILCreateFolder(LPCSTR);
-LPITEMIDLIST WINAPI _ILCreateValue(LPCSTR);
-LPITEMIDLIST WINAPI _ILCreate(PIDLTYPE,LPVOID,UINT16);
-
-BOOL32 WINAPI _ILGetDrive(LPCITEMIDLIST,LPSTR,UINT16);
+/*
+ * getting string values from pidls
+ *
+ * return value is strlen()
+ */
+DWORD WINAPI _ILGetDrive(LPCITEMIDLIST,LPSTR,UINT16);
 DWORD WINAPI _ILGetItemText(LPCITEMIDLIST,LPSTR,UINT16);
 DWORD WINAPI _ILGetFolderText(LPCITEMIDLIST,LPSTR,DWORD);
 DWORD WINAPI _ILGetValueText(LPCITEMIDLIST,LPSTR,DWORD);
-DWORD WINAPI _ILGetDataText(LPCITEMIDLIST,LPCITEMIDLIST,LPSTR,DWORD);
 DWORD WINAPI _ILGetPidlPath(LPCITEMIDLIST,LPSTR,DWORD);
-DWORD WINAPI _ILGetData(PIDLTYPE,LPCITEMIDLIST,LPVOID,UINT32);
 
+/*
+ * getting special values from simple pidls
+ */
+BOOL32 WINAPI _ILGetFileDate (LPCITEMIDLIST pidl, LPSTR pOut, UINT32 uOutSize);
+BOOL32 WINAPI _ILGetFileSize (LPCITEMIDLIST pidl, LPSTR pOut, UINT32 uOutSize);
+BOOL32 WINAPI _ILGetExtension (LPCITEMIDLIST pidl, LPSTR pOut, UINT32 uOutSize);
+
+
+/*
+ * testing simple pidls
+ */
 BOOL32 WINAPI _ILIsDesktop(LPCITEMIDLIST);
 BOOL32 WINAPI _ILIsMyComputer(LPCITEMIDLIST);
 BOOL32 WINAPI _ILIsDrive(LPCITEMIDLIST);
 BOOL32 WINAPI _ILIsFolder(LPCITEMIDLIST);
 BOOL32 WINAPI _ILIsValue(LPCITEMIDLIST);
 
-BOOL32 WINAPI _ILHasFolders(LPSTR,LPCITEMIDLIST);
+/*
+ * simple pidls from strings
+ */
+LPITEMIDLIST WINAPI _ILCreateDesktop(void);
+LPITEMIDLIST WINAPI _ILCreateMyComputer(void);
+LPITEMIDLIST WINAPI _ILCreateDrive(LPCSTR);
+LPITEMIDLIST WINAPI _ILCreateFolder(LPCSTR);
+LPITEMIDLIST WINAPI _ILCreateValue(LPCSTR);
 
+/*
+ * raw pidl handling (binary) 
+ *
+ * data is binary / sizes are bytes
+ */
+DWORD WINAPI _ILGetData(PIDLTYPE,LPCITEMIDLIST,LPVOID,UINT32);
+LPITEMIDLIST WINAPI _ILCreate(PIDLTYPE,LPVOID,UINT16);
+
+/*
+ * helper functions (getting struct-pointer)
+ */
 LPPIDLDATA WINAPI _ILGetDataPointer(LPCITEMIDLIST);
 LPSTR WINAPI _ILGetTextPointer(PIDLTYPE type, LPPIDLDATA pidldata);
-BOOL32 WINAPI _ILGetFileDate (LPCITEMIDLIST pidl, LPSTR pOut, UINT32 uOutSize);
-BOOL32 WINAPI _ILGetFileSize (LPCITEMIDLIST pidl, LPSTR pOut, UINT32 uOutSize);
-BOOL32 WINAPI _ILGetExtension (LPCITEMIDLIST pidl, LPSTR pOut, UINT32 uOutSize);
 
 void pdump (LPCITEMIDLIST pidl);
 #endif
diff --git a/dlls/shell32/shell32_main.c b/dlls/shell32/shell32_main.c
index 5acf03c..78ca810 100644
--- a/dlls/shell32/shell32_main.c
+++ b/dlls/shell32/shell32_main.c
@@ -21,7 +21,6 @@
 #include "dlgs.h"
 #include "win.h"
 #include "cursoricon.h"
-#include "interfaces.h"
 #include "sysmetrics.h"
 #include "shlobj.h"
 #include "debug.h"
@@ -382,30 +381,29 @@
   LPCLASSFACTORY lpclf;
 	TRACE(shell,"%p->(%p)\n",shellfolder,*shellfolder);
 
-  if (pdesktopfolder)
-	{	hres = NOERROR;
-	}
-	else
-  { lpclf = IClassFactory_Constructor();
+  if (pdesktopfolder) {
+    hres = NOERROR;
+  } else {
+    lpclf = IClassFactory_Constructor();
     /* fixme: the buildin IClassFactory_Constructor is at the moment only 
  		for rclsid=CLSID_ShellDesktop, so we get the right Interface (jsch)*/
-    if(lpclf)
-    { hres = lpclf->lpvtbl->fnCreateInstance(lpclf,NULL,(REFIID)&IID_IShellFolder, (void*)&pdesktopfolder);
-	 	  lpclf->lpvtbl->fnRelease(lpclf);
+    if(lpclf) {
+      hres = IClassFactory_CreateInstance(lpclf,NULL,(REFIID)&IID_IShellFolder, (void*)&pdesktopfolder);
+      IClassFactory_Release(lpclf);
 	  }  
   }
 	
-  if (pdesktopfolder)
-	{ *shellfolder = pdesktopfolder;
+  if (pdesktopfolder) {
+    *shellfolder = pdesktopfolder;
     pdesktopfolder->lpvtbl->fnAddRef(pdesktopfolder);
+  } else {
+    *shellfolder=NULL;
 	}
-  else
-	{ *shellfolder=NULL;
-	}	
 
   TRACE(shell,"-- %p->(%p)\n",shellfolder, *shellfolder);
 	return hres;
 }
+
 /*************************************************************************
  *			 SHGetPathFromIDList		[SHELL32.221][NT 4.0: SHELL32.219]
  */
@@ -962,7 +960,7 @@
 }
 
 
-void	(CALLBACK* pDLLInitComctl)(void);
+void	(CALLBACK* pDLLInitComctl)(LPVOID);
 INT32	(CALLBACK* pImageList_AddIcon) (HIMAGELIST himl, HICON32 hIcon);
 INT32	(CALLBACK* pImageList_ReplaceIcon) (HIMAGELIST, INT32, HICON32);
 HIMAGELIST (CALLBACK * pImageList_Create) (INT32,INT32,UINT32,INT32,INT32);
@@ -1000,7 +998,7 @@
     if (hComctl32)
     { pDLLInitComctl=GetProcAddress32(hComctl32,"InitCommonControlsEx");
       if (pDLLInitComctl)
-      { pDLLInitComctl();
+      { pDLLInitComctl(NULL);
       }
       pImageList_Create=GetProcAddress32(hComctl32,"ImageList_Create");
       pImageList_AddIcon=GetProcAddress32(hComctl32,"ImageList_AddIcon");
diff --git a/dlls/shell32/shell32_main.h b/dlls/shell32/shell32_main.h
index 280e269..ff64d05 100644
--- a/dlls/shell32/shell32_main.h
+++ b/dlls/shell32/shell32_main.h
@@ -16,7 +16,7 @@
 /*******************************************
 * pointer to functions dynamically loaded
 */
-extern void	(CALLBACK* pDLLInitComctl)(void);
+extern void	(CALLBACK* pDLLInitComctl)(LPVOID);
 extern INT32	(CALLBACK* pImageList_AddIcon) (HIMAGELIST himl, HICON32 hIcon);
 extern INT32	(CALLBACK* pImageList_ReplaceIcon) (HIMAGELIST, INT32, HICON32);
 extern HIMAGELIST (CALLBACK* pImageList_Create) (INT32,INT32,UINT32,INT32,INT32);
diff --git a/dlls/shell32/shelllink.c b/dlls/shell32/shelllink.c
index cb2fcae..ddba978 100644
--- a/dlls/shell32/shelllink.c
+++ b/dlls/shell32/shelllink.c
@@ -11,9 +11,9 @@
 #include "ole.h"
 #include "ole2.h"
 #include "debug.h"
-#include "compobj.h"
-#include "interfaces.h"
-#include "shlobj.h"
+#include "objbase.h"
+#include "wine/obj_base.h"
+#include "wine/obj_storage.h"
 #include "shell.h"
 #include "winerror.h"
 #include "winnls.h"
@@ -24,48 +24,38 @@
 #include "shell32_main.h"
 
 /* IPersistFile Implementation */
-static HRESULT WINAPI IPersistFile_QueryInterface(LPPERSISTFILE this, REFIID riid, LPVOID * ppvObj);
-static ULONG WINAPI IPersistFile_AddRef(LPPERSISTFILE this);
-static ULONG WINAPI IPersistFile_Release(LPPERSISTFILE this);
+typedef struct _IPersistFile {
+    /* IUnknown fields */
+    ICOM_VTABLE(IPersistFile)* lpvtbl;
+    DWORD                       ref;
+} _IPersistFile;
 
-static HRESULT WINAPI IPersistFile_GetClassID (LPPERSISTFILE this, CLSID *pClassID);
-static HRESULT WINAPI IPersistFile_IsDirty (LPPERSISTFILE this);
-static HRESULT WINAPI IPersistFile_Load (LPPERSISTFILE this, LPCOLESTR32 pszFileName, DWORD dwMode);
-static HRESULT WINAPI IPersistFile_Save (LPPERSISTFILE this, LPCOLESTR32 pszFileName, BOOL32 fRemember);
-static HRESULT WINAPI IPersistFile_SaveCompleted (LPPERSISTFILE this, LPCOLESTR32 pszFileName);
-static HRESULT WINAPI IPersistFile_GetCurFile (LPPERSISTFILE this, LPOLESTR32 *ppszFileName);
+static struct ICOM_VTABLE(IPersistFile) pfvt;
 
-static struct IPersistFile_VTable pfvt = 
-{	IPersistFile_QueryInterface,
-	IPersistFile_AddRef,
-	IPersistFile_Release,
-	IPersistFile_GetClassID,
-	IPersistFile_IsDirty,
-	IPersistFile_Load,
-	IPersistFile_Save,
-	IPersistFile_SaveCompleted,
-	IPersistFile_GetCurFile
-};
+
 /**************************************************************************
  *	  IPersistFile_Constructor
  */
 LPPERSISTFILE IPersistFile_Constructor(void) 
-{	LPPERSISTFILE sl;
+{
+	_IPersistFile* sl;
 
-	sl = (LPPERSISTFILE)HeapAlloc(GetProcessHeap(),0,sizeof(IPersistFile));
+	sl = (_IPersistFile*)HeapAlloc(GetProcessHeap(),0,sizeof(_IPersistFile));
 	sl->ref = 1;
 	sl->lpvtbl = &pfvt;
 
 	TRACE(shell,"(%p)->()\n",sl);
-	return sl;
+	return (LPPERSISTFILE)sl;
 }
 
 /**************************************************************************
  *  IPersistFile_QueryInterface
  */
-static HRESULT WINAPI IPersistFile_QueryInterface(
-  LPPERSISTFILE this, REFIID riid, LPVOID *ppvObj)
-{	char    xriid[50];
+static HRESULT WINAPI IPersistFile_fnQueryInterface(
+  LPUNKNOWN iface, REFIID riid, LPVOID *ppvObj)
+{
+	ICOM_THIS(IPersistFile,iface);
+	char    xriid[50];
 	WINE_StringFromCLSID((LPCLSID)riid,xriid);
 	TRACE(shell,"(%p)->(\n\tIID:\t%s)\n",this,xriid);
 
@@ -79,7 +69,7 @@
 	}   
 
 	if(*ppvObj)
-	{ (*(LPPERSISTFILE*)ppvObj)->lpvtbl->fnAddRef(this);      
+	{ IPersistFile_AddRef((IPersistFile*)*ppvObj);      
 	  TRACE(shell,"-- Interface: (%p)->(%p)\n",ppvObj,*ppvObj);
 	  return S_OK;
 	}
@@ -89,15 +79,19 @@
 /******************************************************************************
  * IPersistFile_AddRef
  */
-static ULONG WINAPI IPersistFile_AddRef(LPPERSISTFILE this)
-{	TRACE(shell,"(%p)->(count=%lu)\n",this,this->ref);
+static ULONG WINAPI IPersistFile_fnAddRef(LPUNKNOWN iface)
+{
+	ICOM_THIS(IPersistFile,iface);
+	TRACE(shell,"(%p)->(count=%lu)\n",this,this->ref);
 	return ++(this->ref);
 }
 /******************************************************************************
  * IPersistFile_Release
  */
-static ULONG WINAPI IPersistFile_Release(LPPERSISTFILE this)
-{	TRACE(shell,"(%p)->(count=%lu)\n",this,this->ref);
+static ULONG WINAPI IPersistFile_fnRelease(LPUNKNOWN iface)
+{
+	ICOM_THIS(IPersistFile,iface);
+	TRACE(shell,"(%p)->(count=%lu)\n",this,this->ref);
 	if (!--(this->ref)) 
 	{ TRACE(shell,"-- destroying IPersistFile(%p)\n",this);
 	  HeapFree(GetProcessHeap(),0,this);
@@ -106,70 +100,89 @@
 	return this->ref;
 }
 
-static HRESULT WINAPI IPersistFile_GetClassID (LPPERSISTFILE this, CLSID *pClassID)
-{	FIXME(shell,"(%p)\n",this);
+static HRESULT WINAPI IPersistFile_fnGetClassID(const IPersist* iface, CLSID *pClassID)
+{
+	ICOM_CTHIS(IPersistFile,iface);
+	FIXME(shell,"(%p)\n",this);
 	return NOERROR;
 }
-static HRESULT WINAPI IPersistFile_IsDirty (LPPERSISTFILE this)
-{	FIXME(shell,"(%p)\n",this);
+static HRESULT WINAPI IPersistFile_fnIsDirty(const IPersistFile* iface)
+{
+	ICOM_CTHIS(IPersistFile,iface);
+	FIXME(shell,"(%p)\n",this);
 	return NOERROR;
 }
-static HRESULT WINAPI IPersistFile_Load (LPPERSISTFILE this, LPCOLESTR32 pszFileName, DWORD dwMode)
-{	FIXME(shell,"(%p)->(%s)\n",this,debugstr_w(pszFileName));
+static HRESULT WINAPI IPersistFile_fnLoad(LPPERSISTFILE iface, LPCOLESTR32 pszFileName, DWORD dwMode)
+{
+	ICOM_THIS(IPersistFile,iface);
+	FIXME(shell,"(%p)->(%s)\n",this,debugstr_w(pszFileName)); 
 	return E_FAIL;
 }
-static HRESULT WINAPI IPersistFile_Save (LPPERSISTFILE this, LPCOLESTR32 pszFileName, BOOL32 fRemember)
-{	FIXME(shell,"(%p)->(%s)\n",this,debugstr_w(pszFileName));
+static HRESULT WINAPI IPersistFile_fnSave(LPPERSISTFILE iface, LPCOLESTR32 pszFileName, BOOL32 fRemember)
+{
+	ICOM_THIS(IPersistFile,iface);
+	FIXME(shell,"(%p)->(%s)\n",this,debugstr_w(pszFileName));
+       	return NOERROR;
+}
+static HRESULT WINAPI IPersistFile_fnSaveCompleted(LPPERSISTFILE iface, LPCOLESTR32 pszFileName)
+{
+	ICOM_THIS(IPersistFile,iface);
+	FIXME(shell,"(%p)->(%s)\n",this,debugstr_w(pszFileName));
+        return NOERROR;
+}
+static HRESULT WINAPI IPersistFile_fnGetCurFile(const IPersistFile* iface, LPOLESTR32 *ppszFileName)
+{
+	ICOM_CTHIS(IPersistFile,iface);
+	FIXME(shell,"(%p)\n",this);
 	return NOERROR;
 }
-static HRESULT WINAPI IPersistFile_SaveCompleted (LPPERSISTFILE this, LPCOLESTR32 pszFileName)
-{	FIXME(shell,"(%p)->(%s)\n",this,debugstr_w(pszFileName));
-	return NOERROR;
-}
-static HRESULT WINAPI IPersistFile_GetCurFile (LPPERSISTFILE this, LPOLESTR32 *ppszFileName)
-{	FIXME(shell,"(%p)\n",this);
-	return NOERROR;
-}
-
-
-/**************************************************************************
-*  IClassFactory Implementation
-*/
-static HRESULT WINAPI IShellLink_CF_QueryInterface(LPCLASSFACTORY,REFIID,LPVOID*);
-static ULONG WINAPI IShellLink_CF_AddRef(LPCLASSFACTORY);
-static ULONG WINAPI IShellLink_CF_Release(LPCLASSFACTORY);
-static HRESULT WINAPI IShellLink_CF_CreateInstance(LPCLASSFACTORY, LPUNKNOWN, REFIID, LPVOID *);
-static HRESULT WINAPI IShellLink_CF_LockServer(LPCLASSFACTORY, BOOL32);
-/**************************************************************************
- *  IShellLink_CF_VTable
- */
-static IClassFactory_VTable slcfvt = 
-{	IShellLink_CF_QueryInterface,
-	IShellLink_CF_AddRef,
-	IShellLink_CF_Release,
-	IShellLink_CF_CreateInstance,
-	IShellLink_CF_LockServer
+  
+static struct ICOM_VTABLE(IPersistFile) pfvt = 
+{
+    {
+        {
+            IPersistFile_fnQueryInterface,
+            IPersistFile_fnAddRef,
+            IPersistFile_fnRelease
+        },
+        IPersistFile_fnGetClassID
+    },
+    IPersistFile_fnIsDirty,
+    IPersistFile_fnLoad,
+    IPersistFile_fnSave,
+    IPersistFile_fnSaveCompleted,
+    IPersistFile_fnGetCurFile
 };
 
+
+/**************************************************************************
+*  IShellLink's IClassFactory implementation
+ */
+
+static ICOM_VTABLE(IClassFactory) slcfvt;
+
 /**************************************************************************
  *  IShellLink_CF_Constructor
  */
 
 LPCLASSFACTORY IShellLink_CF_Constructor(void)
-{	LPCLASSFACTORY	lpclf;
+{
+	_IClassFactory* lpclf;
 
-	lpclf= (LPCLASSFACTORY)HeapAlloc(GetProcessHeap(),0,sizeof(IClassFactory));
+	lpclf= (_IClassFactory*)HeapAlloc(GetProcessHeap(),0,sizeof(_IClassFactory));
 	lpclf->ref = 1;
 	lpclf->lpvtbl = &slcfvt;
 	TRACE(shell,"(%p)->()\n",lpclf);
-	return lpclf;
+	return (LPCLASSFACTORY)lpclf;
 }
 /**************************************************************************
  *  IShellLink_CF_QueryInterface
  */
 static HRESULT WINAPI IShellLink_CF_QueryInterface(
-  LPCLASSFACTORY this, REFIID riid, LPVOID *ppvObj)
-{	char	xriid[50];
+  LPUNKNOWN iface, REFIID riid, LPVOID *ppvObj)
+{
+	ICOM_THIS(IClassFactory,iface);
+	char	xriid[50];
 	WINE_StringFromCLSID((LPCLSID)riid,xriid);
 	TRACE(shell,"(%p)->(\n\tIID:\t%s)\n",this,xriid);
 
@@ -183,7 +196,7 @@
 	}   
 
 	if(*ppvObj)
-	{ (*(LPCLASSFACTORY*)ppvObj)->lpvtbl->fnAddRef(this);  	
+	{ IUnknown_AddRef((IUnknown*)*ppvObj);  	
 	  TRACE(shell,"-- Interface: (%p)->(%p)\n",ppvObj,*ppvObj);
 	  return S_OK;
 	}
@@ -193,15 +206,19 @@
 /******************************************************************************
  * IShellLink_CF_AddRef
  */
-static ULONG WINAPI IShellLink_CF_AddRef(LPCLASSFACTORY this)
-{ TRACE(shell,"(%p)->(count=%lu)\n",this,this->ref);
+static ULONG WINAPI IShellLink_CF_AddRef(LPUNKNOWN iface)
+{
+	ICOM_THIS(IClassFactory,iface);
+	TRACE(shell,"(%p)->(count=%lu)\n",this,this->ref);
 	return ++(this->ref);
 }
 /******************************************************************************
  * IShellLink_CF_Release
  */
-static ULONG WINAPI IShellLink_CF_Release(LPCLASSFACTORY this)
-{	TRACE(shell,"(%p)->(count=%lu)\n",this,this->ref);
+static ULONG WINAPI IShellLink_CF_Release(LPUNKNOWN iface)
+{
+	ICOM_THIS(IClassFactory,iface);
+	TRACE(shell,"(%p)->(count=%lu)\n",this,this->ref);
 	if (!--(this->ref)) 
 	{ TRACE(shell,"-- destroying IClassFactory(%p)\n",this);
 		HeapFree(GetProcessHeap(),0,this);
@@ -213,8 +230,10 @@
  * IShellLink_CF_CreateInstance
  */
 static HRESULT WINAPI IShellLink_CF_CreateInstance(
-  LPCLASSFACTORY this, LPUNKNOWN pUnknown, REFIID riid, LPVOID *ppObject)
-{	IUnknown *pObj = NULL;
+  LPCLASSFACTORY iface, LPUNKNOWN pUnknown, REFIID riid, LPVOID *ppObject)
+{
+	ICOM_THIS(IClassFactory,iface);
+	IUnknown *pObj = NULL;
 	HRESULT hres;
 	char	xriid[50];
 
@@ -239,8 +258,8 @@
 	{ return(E_OUTOFMEMORY);
 	}
 	 
-	hres = pObj->lpvtbl->fnQueryInterface(pObj,riid, ppObject);
-	pObj->lpvtbl->fnRelease(pObj);
+	hres = IUnknown_QueryInterface(pObj,riid, ppObject);
+	IUnknown_Release(pObj);
 	TRACE(shell,"-- Object created: (%p)->%p\n",this,*ppObject);
 
 	return hres;
@@ -248,10 +267,22 @@
 /******************************************************************************
  * IShellLink_CF_LockServer
  */
-static HRESULT WINAPI IShellLink_CF_LockServer(LPCLASSFACTORY this, BOOL32 fLock)
-{	TRACE(shell,"%p->(0x%x), not implemented\n",this, fLock);
+static HRESULT WINAPI IShellLink_CF_LockServer(LPCLASSFACTORY iface, BOOL32 fLock)
+{
+	ICOM_THIS(IClassFactory,iface);
+	TRACE(shell,"%p->(0x%x), not implemented\n",this, fLock);
 	return E_NOTIMPL;
 }
+static ICOM_VTABLE(IClassFactory) slcfvt = 
+{
+  {
+    IShellLink_CF_QueryInterface,
+    IShellLink_CF_AddRef,
+    IShellLink_CF_Release
+  },
+  IShellLink_CF_CreateInstance,
+  IShellLink_CF_LockServer
+};
 
 /* IShellLink Implementation */
 static HRESULT WINAPI IShellLink_QueryInterface(LPSHELLLINK,REFIID,LPVOID*);
@@ -280,6 +311,7 @@
 * IShellLink Implementation
 */
 
+
 static struct IShellLink_VTable slvt = 
 {	IShellLink_QueryInterface,
 	IShellLink_AddRef,
@@ -363,7 +395,7 @@
 {	TRACE(shell,"(%p)->(count=%lu)\n",this,this->ref);
 	if (!--(this->ref)) 
 	{ TRACE(shell,"-- destroying IShellLink(%p)\n",this);
-	  this->lppf->lpvtbl->fnRelease(this->lppf);	/* IPersistFile*/
+	  IPersistFile_Release(this->lppf);	/* IPersistFile*/
 	  HeapFree(GetProcessHeap(),0,this);
 	  return 0;
 	}
@@ -453,43 +485,33 @@
 }
 
 /**************************************************************************
-*  IClassFactory for IShellLinkW 
+*  IShellLink's IClassFactory implementation
 */
-static HRESULT WINAPI IShellLinkW_CF_QueryInterface(LPCLASSFACTORY,REFIID,LPVOID*);
-static ULONG WINAPI IShellLinkW_CF_AddRef(LPCLASSFACTORY);
-static ULONG WINAPI IShellLinkW_CF_Release(LPCLASSFACTORY);
-static HRESULT WINAPI IShellLinkW_CF_CreateInstance(LPCLASSFACTORY, LPUNKNOWN, REFIID, LPVOID *);
-static HRESULT WINAPI IShellLinkW_CF_LockServer(LPCLASSFACTORY, BOOL32);
-/**************************************************************************
- *  IShellLinkW_CF_VTable
- */
-static IClassFactory_VTable slwcfvt = 
-{	IShellLinkW_CF_QueryInterface,
-	IShellLinkW_CF_AddRef,
-	IShellLinkW_CF_Release,
-	IShellLinkW_CF_CreateInstance,
-	IShellLinkW_CF_LockServer
-};
+
+static ICOM_VTABLE(IClassFactory) slwcfvt;
 
 /**************************************************************************
  *  IShellLinkW_CF_Constructor
  */
 
 LPCLASSFACTORY IShellLinkW_CF_Constructor(void)
-{	LPCLASSFACTORY	lpclf;
+{
+	_IClassFactory* lpclf;
 
-	lpclf= (LPCLASSFACTORY)HeapAlloc(GetProcessHeap(),0,sizeof(IClassFactory));
+	lpclf= (_IClassFactory*)HeapAlloc(GetProcessHeap(),0,sizeof(_IClassFactory));
 	lpclf->ref = 1;
 	lpclf->lpvtbl = &slwcfvt;
 	TRACE(shell,"(%p)->()\n",lpclf);
-	return lpclf;
+	return (LPCLASSFACTORY)lpclf;
 }
 /**************************************************************************
  *  IShellLinkW_CF_QueryInterface
  */
 static HRESULT WINAPI IShellLinkW_CF_QueryInterface(
-  LPCLASSFACTORY this, REFIID riid, LPVOID *ppvObj)
-{	char	xriid[50];
+  LPUNKNOWN iface, REFIID riid, LPVOID *ppvObj)
+{
+	ICOM_THIS(IClassFactory,iface);
+	char	xriid[50];
 	WINE_StringFromCLSID((LPCLSID)riid,xriid);
 	TRACE(shell,"(%p)->(\n\tIID:\t%s)\n",this,xriid);
 
@@ -502,8 +524,8 @@
 	{ *ppvObj = (LPCLASSFACTORY)this;
 	}   
 
-	if(*ppvObj)
-	{ (*(LPCLASSFACTORY*)ppvObj)->lpvtbl->fnAddRef(this);  	
+	if(*ppvObj) {
+	  IUnknown_AddRef((IUnknown*)*ppvObj);  	
 	  TRACE(shell,"-- Interface: (%p)->(%p)\n",ppvObj,*ppvObj);
 	  return S_OK;
 	}
@@ -513,15 +535,19 @@
 /******************************************************************************
  * IShellLinkW_CF_AddRef
  */
-static ULONG WINAPI IShellLinkW_CF_AddRef(LPCLASSFACTORY this)
-{ TRACE(shell,"(%p)->(count=%lu)\n",this,this->ref);
+static ULONG WINAPI IShellLinkW_CF_AddRef(LPUNKNOWN iface)
+{
+	ICOM_THIS(IClassFactory,iface);
+	TRACE(shell,"(%p)->(count=%lu)\n",this,this->ref);
 	return ++(this->ref);
 }
 /******************************************************************************
  * IShellLinkW_CF_Release
  */
-static ULONG WINAPI IShellLinkW_CF_Release(LPCLASSFACTORY this)
-{	TRACE(shell,"(%p)->(count=%lu)\n",this,this->ref);
+static ULONG WINAPI IShellLinkW_CF_Release(LPUNKNOWN iface)
+{
+	ICOM_THIS(IClassFactory,iface);
+	TRACE(shell,"(%p)->(count=%lu)\n",this,this->ref);
 	if (!--(this->ref)) 
 	{ TRACE(shell,"-- destroying IClassFactory(%p)\n",this);
 		HeapFree(GetProcessHeap(),0,this);
@@ -533,8 +559,10 @@
  * IShellLinkW_CF_CreateInstance
  */
 static HRESULT WINAPI IShellLinkW_CF_CreateInstance(
-  LPCLASSFACTORY this, LPUNKNOWN pUnknown, REFIID riid, LPVOID *ppObject)
-{	IUnknown *pObj = NULL;
+  LPCLASSFACTORY iface, LPUNKNOWN pUnknown, REFIID riid, LPVOID *ppObject)
+{
+	ICOM_THIS(IClassFactory,iface);
+	IUnknown *pObj = NULL;
 	HRESULT hres;
 	char	xriid[50];
 
@@ -569,11 +597,24 @@
  * IShellLinkW_CF_LockServer
  */
 
-static HRESULT WINAPI IShellLinkW_CF_LockServer(LPCLASSFACTORY this, BOOL32 fLock)
-{	TRACE(shell,"%p->(0x%x), not implemented\n",this, fLock);
+static HRESULT WINAPI IShellLinkW_CF_LockServer(LPCLASSFACTORY iface, BOOL32 fLock)
+{
+	ICOM_THIS(IClassFactory,iface);
+	TRACE(shell,"%p->(0x%x), not implemented\n",this, fLock);
 	return E_NOTIMPL;
 }
 
+static ICOM_VTABLE(IClassFactory) slwcfvt = 
+{
+  {
+    IShellLinkW_CF_QueryInterface,
+    IShellLinkW_CF_AddRef,
+    IShellLinkW_CF_Release
+  },
+  IShellLinkW_CF_CreateInstance,
+  IShellLinkW_CF_LockServer
+};
+
 /* IShellLinkW Implementation */
 static HRESULT WINAPI IShellLinkW_QueryInterface(LPSHELLLINKW,REFIID,LPVOID*);
 static ULONG WINAPI IShellLinkW_AddRef(LPSHELLLINKW);
@@ -684,7 +725,7 @@
 { TRACE(shell,"(%p)->(count=%lu)\n",this,this->ref);
   if (!--(this->ref)) 
   { TRACE(shell,"-- destroying IShellLinkW(%p)\n",this);
-    this->lppf->lpvtbl->fnRelease(this->lppf);	/* IPersistFile*/
+    IPersistFile_Release(this->lppf);	/* IPersistFile*/
     HeapFree(GetProcessHeap(),0,this);
     return 0;
   }
diff --git a/dlls/shell32/shellole.c b/dlls/shell32/shellole.c
index 0d8efa1..b63f7d8 100644
--- a/dlls/shell32/shellole.c
+++ b/dlls/shell32/shellole.c
@@ -12,9 +12,8 @@
 #include "ole.h"
 #include "ole2.h"
 #include "debug.h"
-#include "compobj.h"
-#include "interfaces.h"
 #include "shlobj.h"
+#include "objbase.h"
 #include "shell.h"
 #include "winerror.h"
 #include "winnls.h"
@@ -84,8 +83,8 @@
 	{ FIXME(shell,"no classfactory, but hres is 0x%ld!\n",hres);
 	  return E_FAIL;
 	}
-	classfac->lpvtbl->fnCreateInstance(classfac,unknownouter,refiid,inst);
-	classfac->lpvtbl->fnRelease(classfac);
+	IClassFactory_CreateInstance(classfac,unknownouter,refiid,inst);
+	IClassFactory_Release(classfac);
 	return 0;
 }
 
@@ -185,9 +184,9 @@
 	  { lpclf = IClassFactory_Constructor();
 	  }
 
-	  if(lpclf)
-	  { hres = lpclf->lpvtbl->fnQueryInterface(lpclf,iid, ppv);
-		lpclf->lpvtbl->fnRelease(lpclf);
+	  if(lpclf) {
+	    hres = IClassFactory_QueryInterface(lpclf,iid, ppv);
+	    IClassFactory_Release(lpclf);
 	  }
 	}
 	else
@@ -216,41 +215,31 @@
 /**************************************************************************
 *  IClassFactory Implementation
 */
-static HRESULT WINAPI IClassFactory_QueryInterface(LPCLASSFACTORY,REFIID,LPVOID*);
-static ULONG WINAPI IClassFactory_AddRef(LPCLASSFACTORY);
-static ULONG WINAPI IClassFactory_Release(LPCLASSFACTORY);
-static HRESULT WINAPI IClassFactory_CreateInstance(LPCLASSFACTORY, LPUNKNOWN, REFIID, LPVOID *);
-static HRESULT WINAPI IClassFactory_LockServer(LPCLASSFACTORY, BOOL32);
-/**************************************************************************
- *  IClassFactory_VTable
- */
-static IClassFactory_VTable clfvt = 
-{	IClassFactory_QueryInterface,
-	IClassFactory_AddRef,
-	IClassFactory_Release,
-	IClassFactory_CreateInstance,
-	IClassFactory_LockServer
-};
+
+static ICOM_VTABLE(IClassFactory) clfvt;
 
 /**************************************************************************
  *  IClassFactory_Constructor
  */
 
 LPCLASSFACTORY IClassFactory_Constructor(void)
-{	LPCLASSFACTORY	lpclf;
+{
+	_IClassFactory* lpclf;
 
-	lpclf= (LPCLASSFACTORY)HeapAlloc(GetProcessHeap(),0,sizeof(IClassFactory));
+	lpclf= (_IClassFactory*)HeapAlloc(GetProcessHeap(),0,sizeof(_IClassFactory));
 	lpclf->ref = 1;
 	lpclf->lpvtbl = &clfvt;
   TRACE(shell,"(%p)->()\n",lpclf);
-	return lpclf;
+	return (LPCLASSFACTORY)lpclf;
 }
 /**************************************************************************
  *  IClassFactory_QueryInterface
  */
-static HRESULT WINAPI IClassFactory_QueryInterface(
-  LPCLASSFACTORY this, REFIID riid, LPVOID *ppvObj)
-{	char	xriid[50];
+static HRESULT WINAPI IClassFactory_fnQueryInterface(
+  LPUNKNOWN iface, REFIID riid, LPVOID *ppvObj)
+{
+	ICOM_THIS(IClassFactory,iface);
+	char	xriid[50];
 	WINE_StringFromCLSID((LPCLSID)riid,xriid);
 	TRACE(shell,"(%p)->(\n\tIID:\t%s)\n",this,xriid);
 
@@ -264,7 +253,7 @@
 	}   
 
 	if(*ppvObj)
-	{ (*(LPCLASSFACTORY*)ppvObj)->lpvtbl->fnAddRef(this);  	
+	{ IUnknown_AddRef((LPUNKNOWN)*ppvObj);  	
 	  TRACE(shell,"-- Interface: (%p)->(%p)\n",ppvObj,*ppvObj);
 	  return S_OK;
 	}
@@ -274,15 +263,19 @@
 /******************************************************************************
  * IClassFactory_AddRef
  */
-static ULONG WINAPI IClassFactory_AddRef(LPCLASSFACTORY this)
-{ TRACE(shell,"(%p)->(count=%lu)\n",this,this->ref);
+static ULONG WINAPI IClassFactory_fnAddRef(LPUNKNOWN iface)
+{
+	ICOM_THIS(IClassFactory,iface);
+	TRACE(shell,"(%p)->(count=%lu)\n",this,this->ref);
 	return ++(this->ref);
 }
 /******************************************************************************
  * IClassFactory_Release
  */
-static ULONG WINAPI IClassFactory_Release(LPCLASSFACTORY this)
-{	TRACE(shell,"(%p)->(count=%lu)\n",this,this->ref);
+static ULONG WINAPI IClassFactory_fnRelease(LPUNKNOWN iface)
+{
+	ICOM_THIS(IClassFactory,iface);
+	TRACE(shell,"(%p)->(count=%lu)\n",this,this->ref);
 	if (!--(this->ref)) 
 	{ TRACE(shell,"-- destroying IClassFactory(%p)\n",this);
 		HeapFree(GetProcessHeap(),0,this);
@@ -293,9 +286,11 @@
 /******************************************************************************
  * IClassFactory_CreateInstance
  */
-static HRESULT WINAPI IClassFactory_CreateInstance(
-  LPCLASSFACTORY this, LPUNKNOWN pUnknown, REFIID riid, LPVOID *ppObject)
-{	IUnknown *pObj = NULL;
+static HRESULT WINAPI IClassFactory_fnCreateInstance(
+  LPCLASSFACTORY iface, LPUNKNOWN pUnknown, REFIID riid, LPVOID *ppObject)
+{
+	ICOM_THIS(IClassFactory,iface);
+	IUnknown *pObj = NULL;
 	HRESULT hres;
 	char	xriid[50];
 
@@ -341,7 +336,20 @@
 /******************************************************************************
  * IClassFactory_LockServer
  */
-static HRESULT WINAPI IClassFactory_LockServer(LPCLASSFACTORY this, BOOL32 fLock)
-{	TRACE(shell,"%p->(0x%x), not implemented\n",this, fLock);
+static HRESULT WINAPI IClassFactory_fnLockServer(LPCLASSFACTORY iface, BOOL32 fLock)
+{
+	ICOM_THIS(IClassFactory,iface);
+	TRACE(shell,"%p->(0x%x), not implemented\n",this, fLock);
 	return E_NOTIMPL;
 }
+
+static ICOM_VTABLE(IClassFactory) clfvt = 
+{
+  {
+    IClassFactory_fnQueryInterface,
+    IClassFactory_fnAddRef,
+    IClassFactory_fnRelease
+  },
+  IClassFactory_fnCreateInstance,
+  IClassFactory_fnLockServer
+};
diff --git a/dlls/shell32/shellord.c b/dlls/shell32/shellord.c
index cf2b4a8..2edd0df 100644
--- a/dlls/shell32/shellord.c
+++ b/dlls/shell32/shellord.c
@@ -25,7 +25,6 @@
 #include "dlgs.h"
 #include "win.h"
 #include "cursoricon.h"
-#include "interfaces.h"
 #include "shlobj.h"
 #include "debug.h"
 #include "winreg.h"
@@ -311,7 +310,9 @@
  */
 DWORD WINAPI SHFree(LPVOID x) {
   TRACE(shell,"%p\n",x);
-  /*return LocalFree32((HANDLE32)x);*/ /* crashes */
+  if (!HIWORD(x))
+  { *(LPDWORD)0xdeaf0000 = 0;
+  }
   return HeapFree(GetProcessHeap(),0,x);
 }
 
diff --git a/dlls/shell32/shlfolder.c b/dlls/shell32/shlfolder.c
index 969ce17..3fff67d 100644
--- a/dlls/shell32/shlfolder.c
+++ b/dlls/shell32/shlfolder.c
@@ -1,5 +1,5 @@
 /*
- *	Shell Folder stuff (...and all the OLE-Objects of SHELL32.DLL)
+ *	Shell Folder stuff
  *
  *	Copyright 1997	Marcus Meissner
  *	Copyright 1998	Juergen Schmied
@@ -12,9 +12,8 @@
 #include "ole.h"
 #include "ole2.h"
 #include "debug.h"
-#include "compobj.h"
-#include "interfaces.h"
 #include "shlobj.h"
+#include "objbase.h"
 #include "shell.h"
 #include "winerror.h"
 #include "winnls.h"
@@ -115,11 +114,11 @@
 	if(sf->mpidl)        /* do we have a pidl? */
 	{ dwSize = 0;
 	  if(sf->mpSFParent->sMyPath)		/* get the size of the parents path */
-	  { dwSize += strlen(sf->mpSFParent->sMyPath) + 1;
+	  { dwSize += strlen(sf->mpSFParent->sMyPath) ;
 	    TRACE(shell,"-- (%p)->(parent's path=%s)\n",sf, debugstr_a(sf->mpSFParent->sMyPath));
 	  }   
 	  dwSize += _ILGetFolderText(sf->mpidl,NULL,0); /* add the size of the foldername*/
-	  sf->sMyPath = SHAlloc(dwSize);
+	  sf->sMyPath = SHAlloc(dwSize+1);
 	  if(sf->sMyPath)
 	  { *(sf->sMyPath)=0x00;
 	    if(sf->mpSFParent->sMyPath)		/* if the parent has a path, get it*/
@@ -141,24 +140,24 @@
 */
 static HRESULT WINAPI IShellFolder_QueryInterface(
   LPSHELLFOLDER this, REFIID riid, LPVOID *ppvObj)
-{  char	xriid[50];
-   WINE_StringFromCLSID((LPCLSID)riid,xriid);
-   TRACE(shell,"(%p)->(\n\tIID:\t%s,%p)\n",this,xriid,ppvObj);
+{	char	xriid[50];
+	WINE_StringFromCLSID((LPCLSID)riid,xriid);
+	TRACE(shell,"(%p)->(\n\tIID:\t%s,%p)\n",this,xriid,ppvObj);
 
-  *ppvObj = NULL;
+	*ppvObj = NULL;
 
-  if(IsEqualIID(riid, &IID_IUnknown))          /*IUnknown*/
-  { *ppvObj = this; 
-  }
-  else if(IsEqualIID(riid, &IID_IShellFolder))  /*IShellFolder*/
-  {    *ppvObj = (IShellFolder*)this;
-  }   
+	if(IsEqualIID(riid, &IID_IUnknown))          /*IUnknown*/
+	{ *ppvObj = this; 
+	}
+	else if(IsEqualIID(riid, &IID_IShellFolder))  /*IShellFolder*/
+	{    *ppvObj = (IShellFolder*)this;
+	}   
 
-  if(*ppvObj)
-  { (*(LPSHELLFOLDER*)ppvObj)->lpvtbl->fnAddRef(this);  	
-    TRACE(shell,"-- Interface: (%p)->(%p)\n",ppvObj,*ppvObj);
-		return S_OK;
-  }
+	if(*ppvObj)
+ 	{ (*(LPSHELLFOLDER*)ppvObj)->lpvtbl->fnAddRef(this);  	
+	  TRACE(shell,"-- Interface: (%p)->(%p)\n",ppvObj,*ppvObj);
+	  return S_OK;
+	}
 	TRACE(shell,"-- Interface: E_NOINTERFACE\n");
 	return E_NOINTERFACE;
 }   
@@ -223,36 +222,40 @@
 	DWORD *pdwAttributes)
 {	HRESULT        hr=E_OUTOFMEMORY;
 	LPITEMIDLIST   pidlFull=NULL, pidlTemp = NULL, pidlOld = NULL;
-	LPSTR          pszTemp, pszNext=NULL;
-	CHAR           szElement[MAX_PATH];
+	LPSTR          pszNext=NULL;
+	CHAR           szTemp[MAX_PATH],szElement[MAX_PATH];
 	BOOL32         bIsFile;
-	DWORD          dwChars;
        
 	TRACE(shell,"(%p)->(HWND=0x%08x,%p,%p=%s,%p,pidl=%p,%p)\n",
 		this,hwndOwner,pbcReserved,lpszDisplayName,
 		debugstr_w(lpszDisplayName),pchEaten,ppidl,pdwAttributes);
 
-	dwChars=lstrlen32W(lpszDisplayName) + 1;
-	pszTemp=(LPSTR)HeapAlloc(GetProcessHeap(),0,dwChars);
-
-	if(pszTemp)
 	{ hr = E_FAIL;
-	  WideCharToLocal32(pszTemp, lpszDisplayName, dwChars);
-	  if(*pszTemp)
-	  { if (strcmp(pszTemp,"Desktop")==0)
-	    { pidlFull = (LPITEMIDLIST)HeapAlloc(GetProcessHeap(),0,2);
-	      pidlFull->mkid.cb = 0;
+	  WideCharToLocal32(szTemp, lpszDisplayName, lstrlen32W(lpszDisplayName) + 1);
+	  if(szTemp[0])
+	  { if (strcmp(szTemp,"Desktop")==0)
+	    { pidlFull = _ILCreateDesktop();
 	    }
-	    else if (strcmp(pszTemp,"My Computer")==0)
+	    else if (strcmp(szTemp,"My Computer")==0)
 	    { pidlFull = _ILCreateMyComputer();
 	    }
 	    else
-	    { pidlFull = _ILCreateMyComputer();
-
+	    { if (!PathIsRoot32A(szTemp))
+	      { if (this->sMyPath && strlen (this->sMyPath))
+	        { if (strcmp(this->sMyPath,"My Computer"))
+	          { strcpy (szElement,this->sMyPath);
+	            PathAddBackslash32A (szElement);
+		    strcat (szElement, szTemp);
+		    strcpy (szTemp, szElement);
+	          }
+	        }
+	      }
+	      
 	      /* check if the lpszDisplayName is Folder or File*/
-	      bIsFile = ! (GetFileAttributes32A(pszTemp) & FILE_ATTRIBUTE_DIRECTORY);
-	      pszNext = GetNextElement(pszTemp, szElement, MAX_PATH);
+	      bIsFile = ! (GetFileAttributes32A(szTemp) & FILE_ATTRIBUTE_DIRECTORY);
+	      pszNext = GetNextElement(szTemp, szElement, MAX_PATH);
 
+	      pidlFull = _ILCreateMyComputer();
 	      pidlTemp = _ILCreateDrive(szElement);			
 	      pidlOld = pidlFull;
 	      pidlFull = ILCombine(pidlFull,pidlTemp);
@@ -275,7 +278,6 @@
 	    }
 	  }
 	}
-	HeapFree(GetProcessHeap(),0,pszTemp);
 	*ppidl = pidlFull;
 	return hr;
 }
@@ -358,19 +360,15 @@
 *  REFIID        riid,       //[in ] Initial storage interface 
 *  LPVOID*       ppvObject   //[out] Interface* returned
 */
-static HRESULT WINAPI IShellFolder_BindToStorage(
-  	LPSHELLFOLDER this,
-    LPCITEMIDLIST pidl, /*simple/complex pidl*/
-    LPBC pbcReserved, 
-    REFIID riid, 
-    LPVOID *ppvOut)
+static HRESULT WINAPI IShellFolder_BindToStorage(LPSHELLFOLDER this,
+	    LPCITEMIDLIST pidl,LPBC pbcReserved, REFIID riid, LPVOID *ppvOut)
 {	char xriid[50];
 	WINE_StringFromCLSID(riid,xriid);
 
 	FIXME(shell,"(%p)->(pidl=%p,%p,\n\tIID:%s,%p) stub\n",this,pidl,pbcReserved,xriid,ppvOut);
 
-  *ppvOut = NULL;
-  return E_NOTIMPL;
+	*ppvOut = NULL;
+	return E_NOTIMPL;
 }
 
 /**************************************************************************
@@ -463,8 +461,10 @@
 	*ppvOut = NULL;
 
 	pShellView = IShellView_Constructor(this, this->mpidl);
+
 	if(!pShellView)
 	  return E_OUTOFMEMORY;
+	  
 	hr = pShellView->lpvtbl->fnQueryInterface(pShellView, riid, ppvOut);
 	pShellView->lpvtbl->fnRelease(pShellView);
 	TRACE(shell,"-- (%p)->(interface=%p)\n",this, ppvOut);
@@ -617,54 +617,56 @@
 
 	szSpecial[0]=0x00; 
 	szDrive[0]=0x00;
+	szText[0]=0x00;
 
 	/* test if simple(relative) or complex(absolute) pidl */
 	pidlTemp = ILGetNext(pidl);
 	if (pidlTemp && pidlTemp->mkid.cb==0x00)
 	{ bSimplePidl = TRUE;
 	  TRACE(shell,"-- simple pidl\n");
+
 	}
+
 	if (_ILIsDesktop( pidl))
 	{ strcpy (szText,"Desktop");
-	}
+	}	
 	else
-	{ if (_ILIsMyComputer( pidl))
-	  { _ILGetItemText( pidl, szSpecial, MAX_PATH);
+	{ if (_ILIsMyComputer(pidl))
+	  { _ILGetItemText(pidl, szSpecial, MAX_PATH);
+	    pidl = ILGetNext(pidl);
 	  }
-	  if (_ILIsDrive( pidl))
-	  { pidlTemp = ILFindLastID(pidl);
-	    if (pidlTemp)
-	    { _ILGetItemText( pidlTemp, szTemp, MAX_PATH);
-	    }
-	    if ( dwFlags==SHGDN_NORMAL || dwFlags==SHGDN_INFOLDER)
+
+	  if (_ILIsDrive(pidl))
+	  { _ILGetDrive( pidl, szTemp, MAX_PATH);
+
+	    if ( dwFlags==SHGDN_NORMAL || dwFlags==SHGDN_INFOLDER)	/* like "A1-dos (C:)" */
 	    { GetVolumeInformation32A(szTemp,szDrive,MAX_PATH,&dwVolumeSerialNumber,&dwMaximumComponetLength,&dwFileSystemFlags,NULL,0);
-	      if (szTemp[2]=='\\')
-	      { szTemp[2]=0x00;
-	      }
+	      szTemp[2]=0x00;						/* overwrite '\' */
 	      strcat (szDrive," (");
 	      strcat (szDrive,szTemp);
 	      strcat (szDrive,")"); 
 	    }
-	    else
+	    else							/* like "C:\" */
 	    {  PathAddBackslash32A (szTemp);
 	       strcpy(szDrive,szTemp);
 	    }
 	  }
+
 		
 	  switch(dwFlags)
-	  { case SHGDN_NORMAL:
+	  { case SHGDN_NORMAL:				/* 0x0000 */
 	      _ILGetPidlPath( pidl, szText, MAX_PATH);
 	      break;
 
-	    case SHGDN_INFOLDER | SHGDN_FORPARSING: /*fall thru*/
-	    case SHGDN_INFOLDER:
+	    case SHGDN_INFOLDER | SHGDN_FORPARSING:	/* 0x8001 */
+	    case SHGDN_INFOLDER:			/* 0x0001 */
 	      pidlTemp = ILFindLastID(pidl);
 	      if (pidlTemp)
 	      { _ILGetItemText( pidlTemp, szText, MAX_PATH);
 	      }
 	      break;				
 
-	    case SHGDN_FORPARSING:
+	    case SHGDN_FORPARSING:			/* 0x8000 */
 	      if (bSimplePidl)
 	      { /* if the IShellFolder has parents, get the path from the
 	        parent and add the ItemName*/
@@ -681,9 +683,8 @@
 	        } 
 	        strcat(szText,szTemp);
 	      }
-	      else					
-	      { /* if the pidl is absolute, get everything from the pidl*/
-	        _ILGetPidlPath( pidl, szText, MAX_PATH);
+	      else	/* if the pidl is absolute, get everything from the pidl*/					
+	      {	_ILGetPidlPath( pidl, szText, MAX_PATH);
 	      }
 	      break;
 	    default:
diff --git a/dlls/shell32/shlview.c b/dlls/shell32/shlview.c
index 403c337..95a60b1 100644
--- a/dlls/shell32/shlview.c
+++ b/dlls/shell32/shlview.c
@@ -10,9 +10,9 @@
 #include "ole.h"
 #include "ole2.h"
 #include "debug.h"
-#include "compobj.h"
-#include "interfaces.h"
+#include "servprov.h"
 #include "shlobj.h"
+#include "objbase.h"
 #include "shell.h"
 #include "winerror.h"
 #include "winnls.h"
@@ -666,7 +666,7 @@
 	hr = IShellBrowser_QueryInterface(this->pShellBrowser, (REFIID)&IID_IServiceProvider, (LPVOID*)&pSP);
 	if(SUCCEEDED(hr))
 	{ /*get the IDockingWindowFrame pointer*/
-	  hr = pSP->lpvtbl->fnQueryService(pSP, (REFGUID)&SID_SShellBrowser, (REFIID)&IID_IDockingWindowFrame, (LPVOID*)&pFrame);
+	  hr = IServiceProvider_QueryService(pSP, (REFGUID)&SID_SShellBrowser, (REFIID)&IID_IDockingWindowFrame, (LPVOID*)&pFrame);
 	  if(SUCCEEDED(hr))
 	  { if(bAdd)
 	    { hr = S_OK;
@@ -706,7 +706,7 @@
 	    }
 	    pFrame->lpvtbl->fnRelease(pFrame);
 	  }
-	  pSP->lpvtbl->fnRelease(pSP);
+	  IServiceProvider_Release(pSP);
 	}
 	return bReturn;
 }
@@ -725,12 +725,12 @@
 	/*get the browser's IServiceProvider*/
 	hr = IShellBrowser_QueryInterface(this->pShellBrowser, (REFIID)&IID_IServiceProvider, (LPVOID*)&pSP);
 	if(hr==S_OK)
-	{ hr = pSP->lpvtbl->fnQueryService(pSP, (REFGUID)&SID_SShellBrowser, (REFIID)&IID_IDockingWindowFrame, (LPVOID*)&pFrame);
+	{ hr = IServiceProvider_QueryService(pSP, (REFGUID)&SID_SShellBrowser, (REFIID)&IID_IDockingWindowFrame, (LPVOID*)&pFrame);
    	  if(SUCCEEDED(hr))
 	  { bReturn = TRUE;
 	    pFrame->lpvtbl->fnRelease(pFrame);
 	  }
-	  pSP->lpvtbl->fnRelease(pSP);
+	  IServiceProvider_Release(pSP);
 	}
 	return bReturn;
 }
@@ -843,6 +843,11 @@
 {	LVITEM32A	lvItem;
 	UINT32	i;
 
+
+	if (this->aSelectedItems)
+	{ SHFree(this->aSelectedItems);
+	}
+
 	this->uSelected = ListView_GetSelectedCount(this->hWndList);
 	this->aSelectedItems = (LPITEMIDLIST*)SHAlloc(this->uSelected * sizeof(LPITEMIDLIST));
 
@@ -949,9 +954,6 @@
 	    if (pContextMenu)
 	      pContextMenu->lpvtbl->fnRelease(pContextMenu);
 	  }
-	  SHFree(this->aSelectedItems);
-	  this->aSelectedItems=NULL;
-	  this->uSelected=0;
 	}
 	else	/* background context menu */
 	{ hMenu = LoadMenuIndirect32A(&_Resource_Men_MENU_002_0_data);
@@ -1321,17 +1323,20 @@
 *  IShellView_Release
 */
 static ULONG WINAPI IShellView_Release(LPSHELLVIEW this)
-{ TRACE(shell,"(%p)->()\n",this);
-  if (!--(this->ref)) 
-  { TRACE(shell," destroying IShellView(%p)\n",this);
+{ 	TRACE(shell,"(%p)->()\n",this);
+	if (!--(this->ref)) 
+	{ TRACE(shell," destroying IShellView(%p)\n",this);
 
-    if(this->pSFParent)
-       this->pSFParent->lpvtbl->fnRelease(this->pSFParent);
+	  if(this->pSFParent)
+	    this->pSFParent->lpvtbl->fnRelease(this->pSFParent);
 
-    HeapFree(GetProcessHeap(),0,this);
-    return 0;
-  }
-  return this->ref;
+	  if (this->aSelectedItems)
+	    SHFree(this->aSelectedItems);
+
+	  HeapFree(GetProcessHeap(),0,this);
+	  return 0;
+	}
+	return this->ref;
 }
 /**************************************************************************
 *  ShellView_GetWindow
@@ -1516,14 +1521,12 @@
 
 	*ppvOut = NULL;
 	if(IsEqualIID(riid, &IID_IContextMenu))
-	{ pObj =(LPUNKNOWN)IContextMenu_Constructor(this->pSFParent,this->aSelectedItems,this->uSelected);	
+	{ ShellView_GetSelections(this);
+	  pObj =(LPUNKNOWN)IContextMenu_Constructor(this->pSFParent,this->aSelectedItems,this->uSelected);	
 	}
 	else if (IsEqualIID(riid, &IID_IDataObject))
 	{ ShellView_GetSelections(this);
 	  pObj =(LPUNKNOWN)IDataObject_Constructor(this->hWndParent, this->pSFParent,this->aSelectedItems,this->uSelected);
-	  SHFree(this->aSelectedItems);
-	  this->aSelectedItems=NULL;
-	  this->uSelected=0;
 	}
 
 	TRACE(shell,"-- (%p)->(interface=%p)\n",this, ppvOut);
diff --git a/dlls/winaspi/winaspi16.c b/dlls/winaspi/winaspi16.c
index a9eb055..0dc0cbc 100644
--- a/dlls/winaspi/winaspi16.c
+++ b/dlls/winaspi/winaspi16.c
@@ -490,8 +490,14 @@
 {
 #ifdef linux
 	FARPROC16 *p = (FARPROC16 *)CTX_SEG_OFF_TO_LIN(context, DS_reg(context), EDX_reg(context));
+	if ((CX_reg(context) == 4) || (CX_reg(context) == 5))
+	{
 	*p = DPMI_AllocInternalRMCB(ASPI_DOS_func);
 	TRACE(aspi, "allocated real mode proc %p\n", *p);
+	    AX_reg(context) = CX_reg(context);
+	}
+	else
+	SET_CFLAG(context);
 #else
        SET_CFLAG(context);
 #endif
diff --git a/documentation/bugreports b/documentation/bugreports
index 52c28bc..b20be06 100644
--- a/documentation/bugreports
+++ b/documentation/bugreports
@@ -1,4 +1,4 @@
-How to Report a Bug
+How To Report A Bug
 -------------------
 
 Some simple advice on making your bug report more useful (and thus more
@@ -6,21 +6,23 @@
 
 1) Post as much information as possible.  
 
-	This means we need more information than,
-	"MS Word crashes whenever I run it.  Do you know why?"  Include at 
-	least the following information:
+	This means we need more information than a simple
+	"MS Word crashes whenever I run it.  Do you know why?"
+	Include at least the following information:
 
 	- Version of Wine you're using (run 'wine -v')
 	- Operating system you're using, what distribution (if any), and what
-		version.
+		version
 	- Compiler and version (run 'gcc -v')
+	- Windows version, if installed
 	- Program you're trying to run, its version number, and a URL for 
-		where the program can be obtained (if available).
+		where the program can be obtained (if available)
 	- Command line you used to start wine
-	- Any other information you think may be relevant or helpful.
+	- Any other information you think may be relevant or helpful, such as
+		X server version in case of X problems, libc version etc.
 
-2) Re-run the program with the -debugmsg +relay option 
-   (i.e., 'wine -debugmsg +relay sol.exe').
+2) Re-run the program with the -debugmsg +relay,+snoop option 
+   (i.e., 'wine -debugmsg +relay,+snoop sol.exe').
 
 	If Wine crashes while running your program, it is important that we
 	have this information to have a chance at figuring out what is causing
@@ -32,7 +34,7 @@
 
 	tcsh and other csh-like shells:
 
-	    wine -debugmsg +relay [other_options] program_name |& tee filename.out
+	    wine -debugmsg +relay,+snoop [other_options] program_name |& tee filename.out
 	    tail -100 filename.out > report_file
 
 	bash and other sh-like shells:
diff --git a/documentation/fonts b/documentation/fonts
index 32ac06c..b3a6c2e 100644
--- a/documentation/fonts
+++ b/documentation/fonts
@@ -169,6 +169,5 @@
 
 The most likely cause is a broken fonts.dir file in one of your font
 directories. You need to rerun 'mkfontdir' to rebuild this file. Read
-its manpage for more information.
-
-
+its manpage for more information. If you can't run mkfontdir on this machine
+as you are not root, use "xset -fp xxx" to remove the broken font path.
diff --git a/documentation/wine.man b/documentation/wine.man
index 4ce56b7..f43f1cf 100644
--- a/documentation/wine.man
+++ b/documentation/wine.man
@@ -94,7 +94,7 @@
 .I -debug
 Enter the debugger before starting application
 .TP
-.I -debugmsg [xxx]#name[,[xxx1]#name1]
+.I -debugmsg [xxx]#name[,[xxx1]#name1][,<+|->relay=yyy1[:yyy2]]
 Turn debugging messages on or off.  
 .RS +7
 .PP
@@ -107,7 +107,10 @@
 If xxx is not specified, all debugging messages for the specified
 channel are turned on.  Each channel will print messages about a particular
 component of Wine.  # is required and can be either + or -.  Note that 
-there is not a space after the comma between names.
+there is not a space after the comma between names. yyy are either the
+name of a whole DLL or a single API entry by Name you either
+want to include or exclude from the relay listing. These names must be in
+the case as names used in the relaylisting. You can do the same for snoop.
 .PP
 For instance:
 .PP
@@ -117,6 +120,13 @@
 .I -debugmsg fixme-all,warn+cursor,+relay
 will turn off all FIXME messages, turn on cursor warning messages, and turn
 on all relay messages (API calls).
+.br 
+.I -debugmsg -relay=LeaveCriticalSection:EnterCriticalSection
+will turn on all relay messages except for LeaveCriticalSection and
+EnterCriticalSection.
+.br 
+.I -debugmsg +relay=ADVAPI32
+will only turn on relay messages into the ADVAPI32 code.
 .PP
 The full list of names is: all, accel, advapi, animate, aspi, atom, 
 bitblt, bitmap, caret, cd, cdaudio, class, clipboard, clipping, combo, 
@@ -234,6 +244,12 @@
 .B WINE_INI
 pointing to a configuration file, or use the -config option on the command 
 line.
+.SH ENVIRONMENT VARIABLES
+.B wine
+makes the environment variables of the shell from which 
+.B wine
+is started accesible to the windows/dos processes started. So use the
+appropriate syntax for your shell to enter environment variables you need. 
 .SH CONFIGURATION FILE FORMAT
 All entries are grouped in sections; a section begins with the line
 .br
diff --git a/files/async.c b/files/async.c
index 7f1c69f..c22da8e 100644
--- a/files/async.c
+++ b/files/async.c
@@ -18,6 +18,7 @@
 
 #include <assert.h>
 #include <stdlib.h>
+#include <string.h>
 #include <unistd.h>
 #include <sys/types.h>
 #include <sys/time.h>
@@ -29,7 +30,7 @@
 #ifdef HAVE_SYS_FILIO_H
 # include <sys/filio.h>
 #endif
-#ifdef __svr4__
+#ifdef HAVE_SYS_FILE_H
 # include <sys/file.h>
 #endif
 
diff --git a/files/file.c b/files/file.c
index dc17b99..fddb304 100644
--- a/files/file.c
+++ b/files/file.c
@@ -911,9 +911,9 @@
 
     if (mode & OF_CREATE)
     {
-        if ((hFileRet = CreateFile32A( name, access, sharing, NULL,
-                                       CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL,
-                                       -1 ))== INVALID_HANDLE_VALUE32)
+        if ((hFileRet = CreateFile32A( name, GENERIC_READ | GENERIC_WRITE,
+                                       sharing, NULL, CREATE_ALWAYS,
+                                       FILE_ATTRIBUTE_NORMAL, -1 ))== INVALID_HANDLE_VALUE32)
             goto error;
         goto success;
     }
@@ -1452,6 +1452,11 @@
 
     TRACE(file, "'%s'\n", path );
 
+    if (!*path)
+    {
+        ERR(file, "Empty path passed\n");
+        return FALSE;
+    }
     if (DOSFS_GetDevice( path ))
     {
         WARN(file, "cannot remove DOS device '%s'!\n", path);
@@ -1581,7 +1586,7 @@
     struct get_file_info_reply reply;
 
     if ((req.handle = HANDLE_GetServerHandle( PROCESS_Current(), hFile,
-                                              K32OBJ_FILE, 0 )) == -1)
+                                              K32OBJ_UNKNOWN, 0 )) == -1)
         return FILE_TYPE_UNKNOWN;
     CLIENT_SendRequest( REQ_GET_FILE_INFO, -1, 1, &req, sizeof(req) );
     if (CLIENT_WaitSimpleReply( &reply, sizeof(reply), NULL ))
diff --git a/graphics/d3dcommon.c b/graphics/d3dcommon.c
index 8fa6c8b..b71351a 100644
--- a/graphics/d3dcommon.c
+++ b/graphics/d3dcommon.c
@@ -121,6 +121,24 @@
   } else {
     /* All others state variables */
     switch (dwRenderStateType) {
+
+    case D3DRENDERSTATE_TEXTUREHANDLE: {
+      LPDIRECT3DTEXTURE2 tex = (LPDIRECT3DTEXTURE2) dwRenderState;
+      
+      if (tex == NULL) {
+	glBindTexture(GL_TEXTURE_2D, 0);
+	glDisable(GL_TEXTURE_2D);
+      } else {
+	TRACE(ddraw, "setting OpenGL texture handle : %d\n", tex->tex_name);
+	glEnable(GL_TEXTURE_2D);
+	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+	glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
+	glBindTexture(GL_TEXTURE_2D, tex->tex_name);
+      }
+    } break;
+
+      
     case D3DRENDERSTATE_ZENABLE:          /*  7 */
       if (dwRenderState)
 	glEnable(GL_DEPTH_TEST);
diff --git a/graphics/d3ddevices.c b/graphics/d3ddevices.c
index dcbdc0c..a53f6db 100644
--- a/graphics/d3ddevices.c
+++ b/graphics/d3ddevices.c
@@ -884,11 +884,12 @@
       glColor3f(((col >> 16) & 0xFF) / 255.0,
 		((col >>  8) & 0xFF) / 255.0,
 		((col >>  0) & 0xFF) / 255.0);
-      
+      glTexCoord2f(vx->u.tu, vx->v.tv);
       glVertex3f(vx->x.sx, vx->y.sy, vx->z.sz);
-      TRACE(ddraw, " TLV: %f %f %f (%02lx %02lx %02lx)\n",
+      TRACE(ddraw, " TLV: %f %f %f (%02lx %02lx %02lx) (%f %f)\n",
 	    vx->x.sx, vx->y.sy, vx->z.sz,
-	    ((col >> 16) & 0xFF), ((col >>  8) & 0xFF), ((col >>  0) & 0xFF));
+	    ((col >> 16) & 0xFF), ((col >>  8) & 0xFF), ((col >>  0) & 0xFF),
+	    vx->u.tu, vx->v.tv);
     } break;
       
     default:
diff --git a/graphics/d3dtexture.c b/graphics/d3dtexture.c
index f79ba15..14bc4c4 100644
--- a/graphics/d3dtexture.c
+++ b/graphics/d3dtexture.c
@@ -98,9 +98,9 @@
 {
   FIXME(ddraw, "(%p)->(%p,%p): stub\n", this, lpD3DDevice, lpHandle);
 
-  *lpHandle = (DWORD) this->surface;
+  *lpHandle = (DWORD) this;
   
-  return DD_OK;
+  return D3D_OK;
 }
 
 static HRESULT WINAPI IDirect3DTexture_Initialize(LPDIRECT3DTEXTURE this,
@@ -116,7 +116,7 @@
 {
   FIXME(ddraw, "(%p)->(): stub\n", this);
 
-  return DD_OK;
+  return D3D_OK;
 }
 
 /*** IDirect3DTexture2 methods ***/
@@ -124,11 +124,19 @@
 						  LPDIRECT3DDEVICE2 lpD3DDevice2,
 						  LPD3DTEXTUREHANDLE lpHandle)
 {
-  FIXME(ddraw, "(%p)->(%p,%p): stub\n", this, lpD3DDevice2, lpHandle);
+  TRACE(ddraw, "(%p)->(%p,%p)\n", this, lpD3DDevice2, lpHandle);
 
-  *lpHandle = (DWORD) this->surface; /* lpD3DDevice2->store_texture(this); */
+  /* For 32 bits OSes, handles = pointers */
+  *lpHandle = (DWORD) this;
   
-  return DD_OK;
+  /* Now, bind a new texture */
+  lpD3DDevice2->set_context(lpD3DDevice2);
+  this->D3Ddevice = (void *) lpD3DDevice2;
+  glGenTextures(1, &(this->tex_name));
+
+  TRACE(ddraw, "OpenGL texture handle is : %d\n", this->tex_name);
+  
+  return D3D_OK;
 }
 
 /* Common methods */
@@ -138,17 +146,74 @@
 {
   FIXME(ddraw, "(%p)->(%8ld,%8ld): stub\n", this, dwStart, dwCount);
 
-  return DD_OK;
+  return D3D_OK;
 }
 
 static HRESULT WINAPI IDirect3DTexture2_Load(LPDIRECT3DTEXTURE2 this,
 					     LPDIRECT3DTEXTURE2 lpD3DTexture2)
 {
-  FIXME(ddraw, "(%p)->(%p): stub\n", this, lpD3DTexture2);
+  DDSURFACEDESC	*src_d, *dst_d;
+  TRACE(ddraw, "(%p)->(%p)\n", this, lpD3DTexture2);
 
   /* Hack ? */
-  FIXME(ddraw, "Sthis %p / Sload %p\n", this->surface, lpD3DTexture2->surface);
+  TRACE(ddraw, "Copied to surface %p, surface %p\n", this->surface, lpD3DTexture2->surface);
   this->surface->s.surface_desc.ddsCaps.dwCaps &= ~DDSCAPS_ALLOCONLOAD;
+
+  /* Copy one surface on the other */
+  dst_d = &(this->surface->s.surface_desc);
+  src_d = &(lpD3DTexture2->surface->s.surface_desc);
+
+  if ((src_d->dwWidth != dst_d->dwWidth) || (src_d->dwHeight != dst_d->dwHeight)) {
+    /* Should also check for same pixel format, lPitch, ... */
+    ERR(ddraw, "Error in surface sizes\n");
+    return D3DERR_TEXTURE_LOAD_FAILED;
+  } else {
+    LPDIRECT3DDEVICE2 d3dd = (LPDIRECT3DDEVICE2) this->D3Ddevice;
+    /* I should put a macro for the calculus of bpp */
+    int bpp = (src_d->ddpfPixelFormat.dwFlags & DDPF_PALETTEINDEXED8 ?
+	       1 /* 8 bit of palette index */:
+	       src_d->ddpfPixelFormat.x.dwRGBBitCount / 8 /* RGB bits for each colors */ );
+
+    /* Not sure if this is usefull ! */
+    memcpy(dst_d->y.lpSurface, src_d->y.lpSurface, src_d->dwWidth * src_d->dwHeight * bpp);
+
+    /* Now, load the texture */
+    d3dd->set_context(d3dd);
+    glBindTexture(GL_TEXTURE_2D, this->tex_name);
+
+    if (src_d->ddpfPixelFormat.dwFlags & DDPF_PALETTEINDEXED8) {
+      LPDIRECTDRAWPALETTE pal = this->surface->s.palette;
+      BYTE table[256][4];
+      int i;
+      
+      /* Get the surface's palette */
+      for (i = 0; i < 256; i++) {
+	table[i][0] = pal->palents[i].peRed;
+	table[i][1] = pal->palents[i].peGreen;
+	table[i][2] = pal->palents[i].peBlue;
+	table[i][3] = 0xFF;
+      }
+      
+      /* Use Paletted Texture Extension */
+      glColorTableEXT(GL_TEXTURE_2D,    /* target */
+		      GL_RGBA,          /* internal format */
+		      256,              /* table size */
+		      GL_RGBA,          /* table format */
+		      GL_UNSIGNED_BYTE, /* table type */
+		      table);           /* the color table */
+
+      glTexImage2D(GL_TEXTURE_2D,       /* target */
+		   0,                   /* level */
+		   GL_COLOR_INDEX8_EXT, /* internal format */
+		   src_d->dwWidth, src_d->dwHeight, /* width, height */
+		   0,                   /* border */
+		   GL_COLOR_INDEX,      /* texture format */
+		   GL_UNSIGNED_BYTE,    /* texture type */
+		   src_d->y.lpSurface); /* the texture */
+    } else {
+      ERR(ddraw, "Unhandled texture format\n");
+    }
+  }
   
   return DD_OK;
 }
diff --git a/graphics/ddraw.c b/graphics/ddraw.c
index e0a61b3..f297b9f 100644
--- a/graphics/ddraw.c
+++ b/graphics/ddraw.c
@@ -33,7 +33,6 @@
 #endif
 
 #include "winerror.h"
-#include "interfaces.h"
 #include "gdi.h"
 #include "heap.h"
 #include "ldt.h"
@@ -43,7 +42,6 @@
 #include "ddraw.h"
 #include "d3d.h"
 #include "debug.h"
-#include "compobj.h"
 #include "spy.h"
 #include "message.h"
 #include "x11drv.h"
@@ -426,7 +424,7 @@
 #ifdef HAVE_LIBXXSHM
     if (this->s.ddraw->e.xlib.xshm_active)
       TSXShmPutImage(display,
-		     this->s.ddraw->e.xlib.drawable,
+		     this->s.ddraw->d.drawable,
 		     DefaultGCOfScreen(screen),
 		     this->t.xlib.image,
 		     0, 0, 0, 0,
@@ -436,7 +434,7 @@
     else
 #endif
 	TSXPutImage(		display,
-				this->s.ddraw->e.xlib.drawable,
+				this->s.ddraw->d.drawable,
 				DefaultGCOfScreen(screen),
 				this->t.xlib.image,
 				0, 0, 0, 0,
@@ -444,7 +442,7 @@
 		  this->t.xlib.image->height);
   
 	if (this->s.palette && this->s.palette->cm)
-		TSXSetWindowColormap(display,this->s.ddraw->e.xlib.drawable,this->s.palette->cm);
+		TSXSetWindowColormap(display,this->s.ddraw->d.drawable,this->s.palette->cm);
 	}
 
 	return DD_OK;
@@ -503,7 +501,7 @@
 #ifdef HAVE_LIBXXSHM
 	if (this->s.ddraw->e.xlib.xshm_active) {
 	  TSXShmPutImage(display,
-			 this->s.ddraw->e.xlib.drawable,
+			 this->s.ddraw->d.drawable,
 			 DefaultGCOfScreen(screen),
 			 flipto->t.xlib.image,
 			 0, 0, 0, 0,
@@ -513,7 +511,7 @@
 	} else
 #endif
 	TSXPutImage(display,
-				this->s.ddraw->e.xlib.drawable,
+				this->s.ddraw->d.drawable,
 				DefaultGCOfScreen(screen),
 				flipto->t.xlib.image,
 				0, 0, 0, 0,
@@ -521,7 +519,7 @@
 				flipto->t.xlib.image->height);
 	
 	if (flipto->s.palette && flipto->s.palette->cm) {
-	  TSXSetWindowColormap(display,this->s.ddraw->e.xlib.drawable,flipto->s.palette->cm);
+	  TSXSetWindowColormap(display,this->s.ddraw->d.drawable,flipto->s.palette->cm);
 	}
 	if (flipto!=this) {
 		XImage *tmp;
@@ -547,12 +545,17 @@
 	int i;
 	TRACE(ddraw,"(%p)->(%p)\n",this,pal);
 
+	if (pal == NULL) {
+          if( this->s.palette != NULL )
+            this->s.palette->lpvtbl->fnRelease( this->s.palette );
+	  this->s.palette = pal;
+
+	  return DD_OK;
+	}
+	
 	if( !(pal->cm) && (this->s.ddraw->d.depth<=8)) 
 	{
-		pal->cm = TSXCreateColormap(display,this->s.ddraw->e.xlib.drawable,DefaultVisualOfScreen(screen),AllocAll);
-
-		/* FIXME: this is not correct, when using -managed (XSetWindowColormap??) */
-		TSXInstallColormap(display,pal->cm);
+		pal->cm = TSXCreateColormap(display,this->s.ddraw->d.drawable,DefaultVisualOfScreen(screen),AllocAll);
 
 		for (i=0;i<256;i++) {
 			XColor xc;
@@ -587,7 +590,7 @@
                 pal->lpvtbl->fnAddRef( pal );
            }
           /* Perform the refresh */
-          TSXSetWindowColormap(display,this->s.ddraw->e.xlib.drawable,this->s.palette->cm);
+          TSXSetWindowColormap(display,this->s.ddraw->d.drawable,this->s.palette->cm);
         }
 	return DD_OK;
 }
@@ -697,6 +700,7 @@
 	    if (dwFlags) {
 	      TRACE(ddraw,"\t(src=NULL):Unsupported flags: ");_dump_DDBLT(dwFlags);fprintf(stderr,"\n");
 	    }
+	    this->lpvtbl->fnUnlock(this,ddesc.y.lpSurface);
 	    return DD_OK;
 	}
 
@@ -768,24 +772,33 @@
 static HRESULT WINAPI IDirectDrawSurface3_BltFast(
 	LPDIRECTDRAWSURFACE3 this,DWORD dstx,DWORD dsty,LPDIRECTDRAWSURFACE3 src,LPRECT32 rsrc,DWORD trans
 ) {
-	int		i,bpp;
+	int		i,bpp,w,h;
 	DDSURFACEDESC	ddesc,sdesc;
 
-	if (TRACE_ON(ddraw)) {
-	    TRACE(ddraw,"(%p)->(%ld,%ld,%p,%p,%08lx)\n",
+	if (1  || TRACE_ON(ddraw)) {
+	    FIXME(ddraw,"(%p)->(%ld,%ld,%p,%p,%08lx)\n",
 		    this,dstx,dsty,src,rsrc,trans
 	    );
-	    TRACE(ddraw,"	trans:");_dump_DDBLTFAST(trans);fprintf(stderr,"\n");
-	    TRACE(ddraw,"	srcrect: %dx%d-%dx%d\n",rsrc->left,rsrc->top,rsrc->right,rsrc->bottom);
+	    FIXME(ddraw,"	trans:");_dump_DDBLTFAST(trans);fprintf(stderr,"\n");
+	    FIXME(ddraw,"	srcrect: %dx%d-%dx%d\n",rsrc->left,rsrc->top,rsrc->right,rsrc->bottom);
 	}
 	/* We need to lock the surfaces, or we won't get refreshes when done. */
 	src ->lpvtbl->fnLock(src, NULL,&sdesc,DDLOCK_READONLY, 0);
 	this->lpvtbl->fnLock(this,NULL,&ddesc,DDLOCK_WRITEONLY,0);
 	bpp = this->s.surface_desc.ddpfPixelFormat.x.dwRGBBitCount / 8;
-	for (i=0;i<rsrc->bottom-rsrc->top;i++) {
+	h=rsrc->bottom-rsrc->top;
+	if (h>ddesc.dwHeight-dsty) h=ddesc.dwHeight-dsty;
+	if (h>sdesc.dwHeight-rsrc->top) h=sdesc.dwHeight-rsrc->top;
+	if (h<0) h=0;
+	w=rsrc->right-rsrc->left;
+	if (w>ddesc.dwWidth-dstx) w=ddesc.dwWidth-dstx;
+	if (w>sdesc.dwWidth-rsrc->left) w=sdesc.dwWidth-rsrc->left;
+	if (w<0) w=0;
+
+	for (i=0;i<h;i++) {
 		memcpy(	ddesc.y.lpSurface+(dsty     +i)*ddesc.lPitch+dstx*bpp,
 			sdesc.y.lpSurface+(rsrc->top+i)*sdesc.lPitch+rsrc->left*bpp,
-			(rsrc->right-rsrc->left)*bpp
+			w*bpp
 		);
 	}
 	this->lpvtbl->fnUnlock(this,ddesc.y.lpSurface);
@@ -2247,7 +2260,8 @@
 
 	/* This will be overwritten in the case of Full Screen mode.
 	   Windowed games could work with that :-) */
-	this->e.xlib.drawable  = ((X11DRV_WND_DATA *) WIN_FindWndPtr(hwnd)->pDriverData)->window;
+	if (hwnd)
+	this->d.drawable  = ((X11DRV_WND_DATA *) WIN_FindWndPtr(hwnd)->pDriverData)->window;
 
 	return DD_OK;
 }
@@ -2414,10 +2428,10 @@
 	_common_IDirectDraw_SetDisplayMode(this);
 
 	this->e.xlib.paintable = 1;
-        this->e.xlib.drawable  = ((X11DRV_WND_DATA *) WIN_FindWndPtr(this->d.window)->pDriverData)->window;  
+        this->d.drawable  = ((X11DRV_WND_DATA *) WIN_FindWndPtr(this->d.window)->pDriverData)->window;  
         /* We don't have a context for this window. Host off the desktop */
-        if( !this->e.xlib.drawable )
-           this->e.xlib.drawable = ((X11DRV_WND_DATA *) WIN_GetDesktop()->pDriverData)->window;
+        if( !this->d.drawable )
+           this->d.drawable = ((X11DRV_WND_DATA *) WIN_GetDesktop()->pDriverData)->window;
 	return DD_OK;
 }
 
@@ -2495,7 +2509,7 @@
 }
 
 static HRESULT WINAPI common_IDirectDraw2_CreatePalette(
-	LPDIRECTDRAW2 this,DWORD x,LPPALETTEENTRY palent,LPDIRECTDRAWPALETTE *lpddpal,LPUNKNOWN lpunk
+	LPDIRECTDRAW2 this,DWORD dwFlags,LPPALETTEENTRY palent,LPDIRECTDRAWPALETTE *lpddpal,LPUNKNOWN lpunk
 ) {
 	*lpddpal = (LPDIRECTDRAWPALETTE)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(IDirectDrawPalette));
 	if (*lpddpal == NULL) return E_OUTOFMEMORY;
@@ -2511,8 +2525,20 @@
 
         if (palent)
         {
-                /* Initialize the palette based on the passed palent struct */
-                FIXME(ddraw,"needs to handle palent (%p)\n",palent);
+ 	  int size = 0;
+	  
+	  if (dwFlags & DDPCAPS_1BIT)
+	    size = 2;
+	  else if (dwFlags & DDPCAPS_2BIT)
+	    size = 4;
+	  else if (dwFlags & DDPCAPS_4BIT)
+	    size = 16;
+	  else if (dwFlags & DDPCAPS_8BIT)
+	    size = 256;
+	  else
+	    ERR(ddraw, "unhandled palette format\n");
+	  
+	  memcpy((*lpddpal)->palents, palent, size * sizeof(PALETTEENTRY));
         }
 	return DD_OK;
 }
@@ -2529,11 +2555,13 @@
 }
 
 static HRESULT WINAPI Xlib_IDirectDraw2_CreatePalette(
-	LPDIRECTDRAW2 this,DWORD x,LPPALETTEENTRY palent,LPDIRECTDRAWPALETTE *lpddpal,LPUNKNOWN lpunk
+	LPDIRECTDRAW2 this,DWORD dwFlags,LPPALETTEENTRY palent,LPDIRECTDRAWPALETTE *lpddpal,LPUNKNOWN lpunk
 ) {
-	TRACE(ddraw,"(%p)->(%08lx,%p,%p,%p)\n",this,x,palent,lpddpal,lpunk);
+	TRACE(ddraw,"(%p)->(%08lx,%p,%p,%p)\n",this,dwFlags,palent,lpddpal,lpunk);
 	*lpddpal = (LPDIRECTDRAWPALETTE)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(IDirectDrawPalette));
 
+	TRACE(ddraw, "Palette created : %p\n", *lpddpal);
+	
 	if (*lpddpal == NULL) 
 		return E_OUTOFMEMORY;
 
@@ -2544,8 +2572,22 @@
 	(*lpddpal)->ddraw = (LPDIRECTDRAW)this;
         this->lpvtbl->fnAddRef(this);
 
-	if (palent)
-		FIXME(ddraw,"needs to handle palent (%p)\n",palent);
+	if (palent) {
+	  int size = 0;
+
+	  if (dwFlags & DDPCAPS_1BIT)
+	    size = 2;
+	  else if (dwFlags & DDPCAPS_2BIT)
+	    size = 4;
+	  else if (dwFlags & DDPCAPS_4BIT)
+	    size = 16;
+	  else if (dwFlags & DDPCAPS_8BIT)
+	    size = 256;
+	  else
+	    ERR(ddraw, "unhandled palette format\n");
+	  
+	  memcpy((*lpddpal)->palents, palent, size * sizeof(PALETTEENTRY));
+	}
 
 	return DD_OK;
 }
@@ -3215,7 +3257,7 @@
 	*lplpDD = (LPDIRECTDRAW)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(IDirectDraw));
 	(*lplpDD)->lpvtbl = &xlib_ddvt;
 	(*lplpDD)->ref = 1;
-	(*lplpDD)->e.xlib.drawable = 0; /* in SetDisplayMode */
+	(*lplpDD)->d.drawable = 0; /* in SetDisplayMode */
 
 	(*lplpDD)->d.depth = DefaultDepthOfScreen(screen);
 	(*lplpDD)->d.height = screenHeight;
diff --git a/graphics/vga.c b/graphics/vga.c
index 3f9480e..490074d 100644
--- a/graphics/vga.c
+++ b/graphics/vga.c
@@ -10,8 +10,6 @@
 #include "winbase.h"
 #include "miscemu.h"
 #include "vga.h"
-#include "compobj.h"
-#include "interfaces.h"
 #include "ddraw.h"
 #include "debug.h"
 
@@ -49,6 +47,7 @@
         }
         vga_refresh=0;
         InitializeCriticalSection(&vga_crit);
+        MakeCriticalSectionGlobal(&vga_crit);
         /* poll every 20ms (50fps should provide adequate responsiveness) */
         poll_timer = CreateSystemTimer( 20, VGA_Poll );
     }
diff --git a/graphics/x11drv/xfont.c b/graphics/x11drv/xfont.c
index c0b7fda..a36a5c0 100644
--- a/graphics/x11drv/xfont.c
+++ b/graphics/x11drv/xfont.c
@@ -1806,6 +1806,7 @@
   HeapFree(SystemHeap, 0, buffer);
 
   InitializeCriticalSection( &crtsc_fonts_X11 );
+  MakeCriticalSectionGlobal( &crtsc_fonts_X11 );
 
   /* fontList initialization is over, allocate X font cache */
 
@@ -1935,7 +1936,7 @@
        d = (h = pfi->df.dfPoints) + plf->lfHeight;
    else d = h = 0;	
 
-   if( d && plf->lfHeight )
+   if( d && h && plf->lfHeight )
    {
        UINT16	height = ( plf->lfHeight > 0 ) ? plf->lfHeight
 			 : ((-plf->lfHeight * pfi->df.dfPixHeight) / h);
@@ -1959,7 +1960,8 @@
            pfm->height = pfi->df.dfPixHeight;
            penalty += (d > 0)? d * 0x8 : -d * 0x10;
        }
-   } else pfm->height = pfi->df.dfPixHeight;
+   }
+   else pfm->height = pfi->df.dfPixHeight;
 
    if((pfm->flags & FO_MATCH_PAF) &&
       (plf->lfPitchAndFamily & FF_FAMILY) != (pfi->df.dfPitchAndFamily & FF_FAMILY) )
diff --git a/if1632/compobj.spec b/if1632/compobj.spec
index 3f245a4..072204a 100644
--- a/if1632/compobj.spec
+++ b/if1632/compobj.spec
@@ -18,7 +18,7 @@
 15 pascal CoDisconnectObject(ptr long) CoDisconnectObject
 16 stub CORELEASEMARSHALDATA
 17 pascal16 COFREEUNUSEDLIBRARIES() CoFreeUnusedLibraries
-18 pascal16 IsEqualGUID(ptr ptr) IsEqualGUID
+18 pascal16 IsEqualGUID(ptr ptr) IsEqualGUID16
 19 pascal StringFromCLSID(ptr ptr) StringFromCLSID16
 20 pascal CLSIDFromString(str ptr) CLSIDFromString16
 21 stub ISVALIDPTRIN
@@ -208,12 +208,12 @@
 207 stub ADDAPPCOMPATFLAG
 
 # WINE internal relays (for Win16 interfaces)
-500 cdecl IMalloc16_QueryInterface(ptr ptr ptr) IMalloc16_QueryInterface
-501 cdecl IMalloc16_AddRef(ptr) IMalloc16_AddRef
-502 cdecl IMalloc16_Release(ptr) IMalloc16_Release
-503 cdecl IMalloc16_Alloc(ptr long) IMalloc16_Alloc
-504 cdecl IMalloc16_Realloc(ptr segptr long) IMalloc16_Realloc
-505 cdecl IMalloc16_Free(ptr segptr) IMalloc16_Free
-506 cdecl IMalloc16_GetSize(ptr segptr) IMalloc16_GetSize
-507 cdecl IMalloc16_DidAlloc(ptr segptr) IMalloc16_DidAlloc
-508 cdecl IMalloc16_HeapMinimize(ptr) IMalloc16_HeapMinimize
+500 cdecl IMalloc16_QueryInterface(ptr ptr ptr) IMalloc16_fnQueryInterface
+501 cdecl IMalloc16_AddRef(ptr) IMalloc16_fnAddRef
+502 cdecl IMalloc16_Release(ptr) IMalloc16_fnRelease
+503 cdecl IMalloc16_Alloc(ptr long) IMalloc16_fnAlloc
+504 cdecl IMalloc16_Realloc(ptr segptr long) IMalloc16_fnRealloc
+505 cdecl IMalloc16_Free(ptr segptr) IMalloc16_fnFree
+506 cdecl IMalloc16_GetSize(ptr segptr) IMalloc16_fnGetSize
+507 cdecl IMalloc16_DidAlloc(ptr segptr) IMalloc16_fnDidAlloc
+508 cdecl IMalloc16_HeapMinimize(ptr) IMalloc16_fnHeapMinimize
diff --git a/if1632/relay.c b/if1632/relay.c
index 35da94b..cc7c2e3 100644
--- a/if1632/relay.c
+++ b/if1632/relay.c
@@ -14,6 +14,7 @@
 #include "task.h"
 #include "debugstr.h"
 #include "debug.h"
+#include "main.h"
 
 
 /***********************************************************************
@@ -22,7 +23,6 @@
 BOOL32 RELAY_Init(void)
 {
     WORD codesel;
-    extern BOOL32 THUNK_Init(void);
 
       /* Allocate the code selector for CallTo16 routines */
 
@@ -74,8 +74,6 @@
     char *args16;
     const char *funstr;
     int i;
-    /* from relay32/relay386.c */
-    extern int RELAY_ShowDebugmsgRelay(const char *);
 
     if (!TRACE_ON(relay)) return;
 
@@ -196,8 +194,6 @@
     STACK16FRAME *frame;
     WORD ordinal;
     const char *funstr;
-    /* from relay32/relay386.c */
-    extern int RELAY_ShowDebugmsgRelay(const char *);
 
     if (!TRACE_ON(relay)) return;
     frame = CURRENT_STACK16;
diff --git a/include/acconfig.h b/include/acconfig.h
index 35c7acf..19e6bba 100644
--- a/include/acconfig.h
+++ b/include/acconfig.h
@@ -63,6 +63,9 @@
 /* Define if we can use curses (if no ncurses) for full-screen access */
 #undef HAVE_LIBCURSES
 
+/* Define if ncurses have the new resizeterm function */
+#undef HAVE_RESIZETERM
+
 /* Define if we can a compatible xterm program */
 #undef XTERM_PROGRAM
 
diff --git a/include/commctrl.h b/include/commctrl.h
index 00e0953..49c888b 100644
--- a/include/commctrl.h
+++ b/include/commctrl.h
@@ -93,6 +93,7 @@
 
 #define I_IMAGECALLBACK          (-1)
 #define I_INDENTCALLBACK         (-1)
+#define I_CHILDRENCALLBACK       (-1)
 
 
 /* owner drawn types */
@@ -117,6 +118,66 @@
 #define SNDMSG WINELIB_NAME_AW(SendMessage)
 
 
+
+/* Custom Draw messages */
+
+#define CDRF_DODEFAULT          0x0
+#define CDRF_NEWFONT            0x00000002
+#define CDRF_SKIPDEFAULT        0x00000004
+#define CDRF_NOTIFYPOSTPAINT    0x00000010
+#define CDRF_NOTIFYITEMDRAW     0x00000020
+#define CDRF_NOTIFYSUBITEMDRAW  0x00000020
+#define CDRF_NOTIFYPOSTERASE    0x00000040
+/* #define CDRF_NOTIFYITEMERASE    0x00000080          obsolete ? */
+
+
+/* drawstage flags */
+
+#define CDDS_PREPAINT           1
+#define CDDS_POSTPAINT          2
+#define CDDS_PREERASE           3
+#define CDDS_POSTERASE          4
+
+#define CDDS_ITEM				0x00010000
+#define CDDS_ITEMPREPAINT		(CDDS_ITEM | CDDS_PREPAINT)
+#define CDDS_ITEMPOSTPAINT		(CDDS_ITEM | CDDS_POSTPAINT)
+#define CDDS_ITEMPREERASE		(CDDS_ITEM | CDDS_PREERASE)
+#define CDDS_ITEMPOSTERASE		(CDDS_ITEM | CDDS_POSTERASE)
+#define CDDS_SUBITEM            0x00020000
+
+/* itemState flags */
+
+#define CDIS_SELECTED	 	0x0001
+#define CDIS_GRAYED			0x0002
+#define CDIS_DISABLED		0x0004
+#define CDIS_CHECKED		0x0008
+#define CDIS_FOCUS			0x0010
+#define CDIS_DEFAULT		0x0020
+#define CDIS_HOT			0x0040
+#define CDIS_MARKED         0x0080
+#define CDIS_INDETERMINATE  0x0100
+
+
+typedef struct tagNMCUSTOMDRAWINFO
+{
+	NMHDR	hdr;
+	DWORD	dwDrawStage;
+	HDC32	hdc;
+	RECT32	rc;
+	DWORD	dwItemSpec; 
+	UINT32	uItemState;
+	LPARAM	lItemlParam;
+} NMCUSTOMDRAW, *LPNMCUSTOMDRAW;
+
+typedef struct tagNMTTCUSTOMDRAW
+{
+	NMCUSTOMDRAW nmcd;
+	UINT32		 uDrawFlags;
+} NMTTCUSTOMDRAW, *LPNMTTCUSTOMDRAW;
+
+
+
+
 /* StatusWindow */
 
 #define STATUSCLASSNAME16	"msctls_statusbar"
@@ -395,6 +456,28 @@
 #define ImageList_RemoveAll(himl) ImageList_Remove(himl,-1)
 
 
+/* Flat Scrollbar control */
+
+#define FLATSB_CLASS16        "flatsb_class"
+#define FLATSB_CLASS32A       "flatsb_class32"
+#define FLATSB_CLASS32W       L"flatsb_class32"
+#define FLATSB_CLASS          WINELIB_NAME_AW(FLATSB_CLASS)
+
+BOOL32  WINAPI FlatSB_EnableScrollBar(HWND32, INT32, UINT32);
+BOOL32  WINAPI FlatSB_ShowScrollBar(HWND32, INT32, BOOL32);
+BOOL32  WINAPI FlatSB_GetScrollRange(HWND32, INT32, LPINT32, LPINT32);
+BOOL32  WINAPI FlatSB_GetScrollInfo(HWND32, INT32, LPSCROLLINFO);
+INT32   WINAPI FlatSB_GetScrollPos(HWND32, INT32);
+BOOL32  WINAPI FlatSB_GetScrollProp(HWND32, INT32, LPINT32);
+INT32   WINAPI FlatSB_SetScrollPos(HWND32, INT32, INT32, BOOL32);
+INT32   WINAPI FlatSB_SetScrollInfo(HWND32, INT32, LPSCROLLINFO, BOOL32);
+INT32   WINAPI FlatSB_SetScrollRange(HWND32, INT32, INT32, INT32, BOOL32);
+BOOL32  WINAPI FlatSB_SetScrollProp(HWND32, UINT32, INT32, BOOL32);
+BOOL32  WINAPI InitializeFlatSB(HWND32);
+HRESULT WINAPI UninitializeFlatSB(HWND32);
+
+
+
 /* Header control */
 
 #define WC_HEADER16		"SysHeader" 
@@ -2307,9 +2390,15 @@
 #define TCM_GETIMAGELIST        (TCM_FIRST + 2)
 #define TCM_SETIMAGELIST        (TCM_FIRST + 3)
 #define TCM_GETITEMCOUNT	(TCM_FIRST + 4)
-#define TCM_GETITEM             (TCM_FIRST + 5)
-#define TCM_SETITEM             (TCM_FIRST + 6)
-#define	TCM_INSERTITEM		(TCM_FIRST + 7)
+#define TCM_GETITEM				WINELIB_NAME_AW(TCM_GETITEM)
+#define TCM_GETITEM32A			(TCM_FIRST + 5)
+#define TCM_GETITEM32W			(TCM_FIRST + 60)
+#define TCM_SETITEM32A			(TCM_FIRST + 6)
+#define TCM_SETITEM32W			(TCM_FIRST + 61)
+#define TCM_SETITEM				WINELIB_NAME_AW(TCM_SETITEM)
+#define TCM_INSERTITEM32A		(TCM_FIRST + 7)
+#define TCM_INSERTITEM32W		(TCM_FIRST + 62)
+#define TCM_INSERTITEM			WINELIB_NAME_AW(TCM_INSERTITEM)
 #define TCM_DELETEITEM          (TCM_FIRST + 8)
 #define TCM_DELETEALLITEMS      (TCM_FIRST + 9)
 #define TCM_GETITEMRECT         (TCM_FIRST + 10)
@@ -2328,27 +2417,51 @@
 #define TCM_SETCURFOCUS         (TCM_FIRST + 48)
 #define TCM_SETMINTTABWIDTH     (TCM_FIRST + 49)
 #define TCM_DESELECTALL         (TCM_FIRST + 50)
+#define TCM_HIGHLIGHTITEM		(TCM_FIRST + 51)
+#define TCM_SETEXTENDEDSTYLE	(TCM_FIRST + 52)
+#define TCM_GETEXTENDEDSTYLE	(TCM_FIRST + 53)
+#define TCM_SETUNICODEFORMAT	CCM_SETUNICODEFORMAT
+#define TCM_GETUNICODEFORMAT	CCM_GETUNICODEFORMAT
+
 
 #define TCIF_TEXT		0x0001
 #define TCIF_IMAGE		0x0002
 #define TCIF_RTLREADING		0x0004
 #define TCIF_PARAM		0x0008
+#define TCIF_STATE		0x0010
 
-typedef struct tagTCITEM {
+
+typedef struct tagTCITEM32A {
     UINT32 mask;
-    UINT32 lpReserved1;
-    UINT32 lpReserved2;
+    UINT32 dwState;
+    UINT32 dwStateMask;
     LPSTR  pszText;
     int    cchTextMax;
     int    iImage;
     LPARAM lParam;
-} TCITEM, *LPTCITEM;
+} TCITEM32A, *LPTCITEM32A;
+
+typedef struct tagTCITEM32W
+{
+    UINT32 mask;
+    DWORD  dwState;
+    DWORD  dwStateMask;
+    LPWSTR pszText;
+    INT32  cchTextMax;
+    INT32  iImage;
+    LPARAM lParam;
+} TCITEM32W, *LPTCITEM32W;
+
+#define TCITEM   WINELIB_NAME_AW(TCITEM)
+#define LPTCITEM WINELIB_NAME_AW(LPTCITEM)
+
 
 #define TCN_FIRST               (0U-550U)
 #define TCN_LAST                (0U-580U)
 #define TCN_KEYDOWN             (TCN_FIRST - 0)
 #define TCN_SELCHANGE		(TCN_FIRST - 1)
 #define TCN_SELCHANGING         (TCN_FIRST - 2)
+#define TCN_GETOBJECT      (TCN_FIRST - 3)
 
 
 /* ComboBoxEx control */
@@ -2522,6 +2635,36 @@
 #define DATETIMEPICK_CLASS32W	L"SysDateTimePick32"
 #define DATETIMEPICK_CLASS	WINELIB_NAME_AW(DATETIMEPICK_CLASS)
 
+#define DTM_FIRST        0x1000
+
+#define DTM_GETSYSTEMTIME	(DTM_FIRST+1)
+#define DTM_SETSYSTEMTIME	(DTM_FIRST+2)
+#define DTM_GETRANGE		(DTM_FIRST+3)
+#define DTM_SETRANGE		(DTM_FIRST+4)
+#define DTM_SETFORMAT32A	(DTM_FIRST+5)
+#define DTM_SETFORMAT32W	(DTM_FIRST + 50)
+#define DTM_SETFORMAT		WINELIB_NAME_AW(DTM_SETFORMAT)
+#define DTM_SETMCCOLOR		(DTM_FIRST+6)
+#define DTM_GETMCCOLOR		(DTM_FIRST+7)
+
+#define DTM_GETMONTHCAL		(DTM_FIRST+8)
+
+#define DTM_SETMCFONT		(DTM_FIRST+9)
+#define DTM_GETMCFONT		(DTM_FIRST+10)
+
+
+
+
+#define GDT_ERROR    -1
+#define GDT_VALID    0
+#define GDT_NONE     1
+
+#define GDTR_MIN     0x0001
+#define GDTR_MAX     0x0002
+
+
+
+
 
 /**************************************************************************
  *  UNDOCUMENTED functions
@@ -2624,6 +2767,13 @@
 /*
  * Property sheet support (callback procs)
  */
+
+
+#define WC_PROPSHEET32A      "SysPager"
+#define WC_PROPSHEET32W      L"SysPager"
+#define WC_PROPSHEET         WINELIB_NAME_AW(WC_PROPSHEET)
+
+
 struct _PROPSHEETPAGE32A;  /** need to forward declare those structs **/
 struct _PROPSHEETPAGE32W;
 struct _PSP;
diff --git a/include/compobj.h b/include/compobj.h
index ecd57eb..e1b372b 100644
--- a/include/compobj.h
+++ b/include/compobj.h
@@ -1,43 +1,8 @@
-#ifndef COMPOBJ_H
-#define COMPOBJ_H
+#ifndef __WINE_COMPOBJ_H
+#define __WINE_COMPOBJ_H
 
-#include "ole.h"
+/* "compobj.h" is obsolete, you should include "objbase.h" instead */
 
-struct tagGUID
-{
-    DWORD Data1;
-    WORD  Data2;
-    WORD  Data3;
-    BYTE  Data4[8];
-};
+#include "objbase.h"
 
-typedef struct tagGUID	GUID,*LPGUID,*REFGUID;
-typedef struct tagGUID	CLSID,*LPCLSID,*REFCLSID;
-typedef struct tagGUID	IID,*REFIID,*LPIID;
-
-OLESTATUS WINAPI StringFromCLSID16(const CLSID *id, LPOLESTR16*);
-OLESTATUS WINAPI StringFromCLSID32(const CLSID *id, LPOLESTR32*);
-#define StringFromCLSID WINELIB_NAME(StringFromCLSID)
-OLESTATUS WINAPI CLSIDFromString16(LPCOLESTR16, CLSID *);
-OLESTATUS WINAPI CLSIDFromString32(LPCOLESTR32, CLSID *);
-#define CLSIDFromString WINELIB_NAME(CLSIDFromString)
-
-OLESTATUS WINAPI WINE_StringFromCLSID(const CLSID *id, LPSTR);
-
-INT32 WINAPI StringFromGUID2(REFGUID id, LPOLESTR32 str, INT32 cmax);
-
-
-#ifdef INITGUID
-#define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
-        const GUID name =\
-	{ l, w1, w2, { b1, b2,  b3,  b4,  b5,  b6,  b7,  b8 } }
-#else
-#define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
-    extern const GUID name
-#endif
-
-#define DEFINE_OLEGUID(name, l, w1, w2) \
-	DEFINE_GUID(name, l, w1, w2, 0xC0,0,0,0,0,0,0,0x46)
-
-#define DEFINE_SHLGUID(name, l, w1, w2) DEFINE_OLEGUID(name,l,w1,w2)
-#endif
+#endif /* __WINE_COMPOBJ_H */
diff --git a/include/config.h.in b/include/config.h.in
index 75367e9..9f12234 100644
--- a/include/config.h.in
+++ b/include/config.h.in
@@ -69,6 +69,9 @@
 /* Define if the struct statfs is defined by <sys/mount.h> */
 #undef STATFS_DEFINED_BY_SYS_MOUNT
 
+/* Define if ncurses have the new resizeterm function */
+#undef HAVE_RESIZETERM
+
 /* Define if IPX should use netipx/ipx.h from libc */
 #undef HAVE_IPX_GNU
 
@@ -153,6 +156,9 @@
 /* Define if you have the <sys/cdio.h> header file.  */
 #undef HAVE_SYS_CDIO_H
 
+/* Define if you have the <sys/file.h> header file.  */
+#undef HAVE_SYS_FILE_H
+
 /* Define if you have the <sys/filio.h> header file.  */
 #undef HAVE_SYS_FILIO_H
 
diff --git a/include/d3d.h b/include/d3d.h
index d572933..34e0cac 100644
--- a/include/d3d.h
+++ b/include/d3d.h
@@ -41,6 +41,65 @@
 typedef struct IDirect3DExecuteBuffer IDirect3DExecuteBuffer, *LPDIRECT3DEXECUTEBUFFER;
 
 /* ********************************************************************
+   Error Codes
+   ******************************************************************** */
+#define D3D_OK                          DD_OK
+#define D3DERR_BADMAJORVERSION          MAKE_DDHRESULT(700)
+#define D3DERR_BADMINORVERSION          MAKE_DDHRESULT(701)
+#define D3DERR_INVALID_DEVICE           MAKE_DDHRESULT(705)
+#define D3DERR_INITFAILED               MAKE_DDHRESULT(706)
+#define D3DERR_DEVICEAGGREGATED         MAKE_DDHRESULT(707)
+#define D3DERR_EXECUTE_CREATE_FAILED    MAKE_DDHRESULT(710)
+#define D3DERR_EXECUTE_DESTROY_FAILED   MAKE_DDHRESULT(711)
+#define D3DERR_EXECUTE_LOCK_FAILED      MAKE_DDHRESULT(712)
+#define D3DERR_EXECUTE_UNLOCK_FAILED    MAKE_DDHRESULT(713)
+#define D3DERR_EXECUTE_LOCKED           MAKE_DDHRESULT(714)
+#define D3DERR_EXECUTE_NOT_LOCKED       MAKE_DDHRESULT(715)
+#define D3DERR_EXECUTE_FAILED           MAKE_DDHRESULT(716)
+#define D3DERR_EXECUTE_CLIPPED_FAILED   MAKE_DDHRESULT(717)
+#define D3DERR_TEXTURE_NO_SUPPORT       MAKE_DDHRESULT(720)
+#define D3DERR_TEXTURE_CREATE_FAILED    MAKE_DDHRESULT(721)
+#define D3DERR_TEXTURE_DESTROY_FAILED   MAKE_DDHRESULT(722)
+#define D3DERR_TEXTURE_LOCK_FAILED      MAKE_DDHRESULT(723)
+#define D3DERR_TEXTURE_UNLOCK_FAILED    MAKE_DDHRESULT(724)
+#define D3DERR_TEXTURE_LOAD_FAILED      MAKE_DDHRESULT(725)
+#define D3DERR_TEXTURE_SWAP_FAILED      MAKE_DDHRESULT(726)
+#define D3DERR_TEXTURE_LOCKED           MAKE_DDHRESULT(727)
+#define D3DERR_TEXTURE_NOT_LOCKED       MAKE_DDHRESULT(728)
+#define D3DERR_TEXTURE_GETSURF_FAILED   MAKE_DDHRESULT(729)
+#define D3DERR_MATRIX_CREATE_FAILED     MAKE_DDHRESULT(730)
+#define D3DERR_MATRIX_DESTROY_FAILED    MAKE_DDHRESULT(731)
+#define D3DERR_MATRIX_SETDATA_FAILED    MAKE_DDHRESULT(732)
+#define D3DERR_MATRIX_GETDATA_FAILED    MAKE_DDHRESULT(733)
+#define D3DERR_SETVIEWPORTDATA_FAILED   MAKE_DDHRESULT(734)
+#define D3DERR_INVALIDCURRENTVIEWPORT   MAKE_DDHRESULT(735)
+#define D3DERR_INVALIDPRIMITIVETYPE     MAKE_DDHRESULT(736)
+#define D3DERR_INVALIDVERTEXTYPE        MAKE_DDHRESULT(737)
+#define D3DERR_TEXTURE_BADSIZE          MAKE_DDHRESULT(738)
+#define D3DERR_INVALIDRAMPTEXTURE       MAKE_DDHRESULT(739)
+#define D3DERR_MATERIAL_CREATE_FAILED   MAKE_DDHRESULT(740)
+#define D3DERR_MATERIAL_DESTROY_FAILED  MAKE_DDHRESULT(741)
+#define D3DERR_MATERIAL_SETDATA_FAILED  MAKE_DDHRESULT(742)
+#define D3DERR_MATERIAL_GETDATA_FAILED  MAKE_DDHRESULT(743)
+#define D3DERR_INVALIDPALETTE           MAKE_DDHRESULT(744)
+#define D3DERR_ZBUFF_NEEDS_SYSTEMMEMORY MAKE_DDHRESULT(745)
+#define D3DERR_ZBUFF_NEEDS_VIDEOMEMORY  MAKE_DDHRESULT(746)
+#define D3DERR_SURFACENOTINVIDMEM       MAKE_DDHRESULT(747)
+#define D3DERR_LIGHT_SET_FAILED         MAKE_DDHRESULT(750)
+#define D3DERR_LIGHTHASVIEWPORT         MAKE_DDHRESULT(751)
+#define D3DERR_LIGHTNOTINTHISVIEWPORT   MAKE_DDHRESULT(752)
+#define D3DERR_SCENE_IN_SCENE           MAKE_DDHRESULT(760)
+#define D3DERR_SCENE_NOT_IN_SCENE       MAKE_DDHRESULT(761)
+#define D3DERR_SCENE_BEGIN_FAILED       MAKE_DDHRESULT(762)
+#define D3DERR_SCENE_END_FAILED         MAKE_DDHRESULT(763)
+#define D3DERR_INBEGIN                  MAKE_DDHRESULT(770)
+#define D3DERR_NOTINBEGIN               MAKE_DDHRESULT(771)
+#define D3DERR_NOVIEWPORTS              MAKE_DDHRESULT(772)
+#define D3DERR_VIEWPORTDATANOTSET       MAKE_DDHRESULT(773)
+#define D3DERR_VIEWPORTHASNODEVICE      MAKE_DDHRESULT(774)
+#define D3DERR_NOCURRENTVIEWPORT        MAKE_DDHRESULT(775)
+
+/* ********************************************************************
    Enums
    ******************************************************************** */
 #define D3DNEXT_NEXT 0x01l
@@ -1202,7 +1261,12 @@
 struct IDirect3DTexture2 {
   LPDIRECT3DTEXTURE2_VTABLE  lpvtbl;
   DWORD                      ref;
-  
+
+  void *D3Ddevice; /* I put (void *) to use the same pointer for both
+		      Direct3D and Direct3D2 */
+#ifdef HAVE_MESAGL
+  GLuint tex_name;
+#endif  
   LPDIRECTDRAWSURFACE3       surface;
 };
 
diff --git a/include/ddraw.h b/include/ddraw.h
index 4b5e917..fdb74dc 100644
--- a/include/ddraw.h
+++ b/include/ddraw.h
@@ -1,6 +1,8 @@
 #ifndef __WINE_DDRAW_H
 #define __WINE_DDRAW_H
 
+#include "wine/obj_base.h"
+
 #include "config.h"
 
 #ifndef X_DISPLAY_MISSING
@@ -14,7 +16,6 @@
 #define	DIRECTDRAW_VERSION	0x0500
 #endif /* DIRECTDRAW_VERSION */
 
-
 DEFINE_GUID( CLSID_DirectDraw,		0xD7B70EE0,0x4340,0x11CF,0xB0,0x63,0x00,0x20,0xAF,0xC2,0xCD,0x35 );
 DEFINE_GUID( CLSID_DirectDrawClipper,	0x593817A0,0x7DB3,0x11CF,0xA2,0xDE,0x00,0xAA,0x00,0xb9,0x33,0x56 );
 DEFINE_GUID( IID_IDirectDraw,		0x6C14DB80,0xA733,0x11CE,0xA5,0x21,0x00,0x20,0xAF,0x0B,0xE5,0x60 );
@@ -900,6 +901,7 @@
        We need it also in DGA mode to make some games (for example Monkey Island III work) */
     ATOM		winclass;
     HWND32		window;
+    Window		drawable;
     PAINTSTRUCT32	ps;
 };
 
@@ -910,7 +912,6 @@
 };
 
 struct _xlib_directdrawdata {
-    Window		drawable;
     int			paintable;
 
 #ifdef HAVE_LIBXXSHM
diff --git a/include/debug.h b/include/debug.h
index f5e6447..8d0ea7a 100644
--- a/include/debug.h
+++ b/include/debug.h
@@ -101,57 +101,58 @@
 #define dbch_profile 93
 #define dbch_progress 94
 #define dbch_prop 95
-#define dbch_psapi 96
-#define dbch_psdrv 97
-#define dbch_ras 98
-#define dbch_rebar 99
-#define dbch_reg 100
-#define dbch_region 101
-#define dbch_relay 102
-#define dbch_resource 103
-#define dbch_scroll 104
-#define dbch_security 105
-#define dbch_segment 106
-#define dbch_selector 107
-#define dbch_sem 108
-#define dbch_sendmsg 109
-#define dbch_server 110
-#define dbch_shell 111
-#define dbch_shm 112
-#define dbch_snoop 113
-#define dbch_sound 114
-#define dbch_static 115
-#define dbch_statusbar 116
-#define dbch_stress 117
-#define dbch_string 118
-#define dbch_syscolor 119
-#define dbch_system 120
-#define dbch_tab 121
-#define dbch_task 122
-#define dbch_text 123
-#define dbch_thread 124
-#define dbch_thunk 125
-#define dbch_timer 126
-#define dbch_toolbar 127
-#define dbch_toolhelp 128
-#define dbch_tooltips 129
-#define dbch_trackbar 130
-#define dbch_treeview 131
-#define dbch_tweak 132
-#define dbch_uitools 133
-#define dbch_updown 134
-#define dbch_ver 135
-#define dbch_virtual 136
-#define dbch_vxd 137
-#define dbch_wave 138
-#define dbch_win 139
-#define dbch_win16drv 140
-#define dbch_win32 141
-#define dbch_wing 142
-#define dbch_winsock 143
-#define dbch_wnet 144
-#define dbch_x11 145
-#define dbch_x11drv 146
+#define dbch_propsheet 96
+#define dbch_psapi 97
+#define dbch_psdrv 98
+#define dbch_ras 99
+#define dbch_rebar 100
+#define dbch_reg 101
+#define dbch_region 102
+#define dbch_relay 103
+#define dbch_resource 104
+#define dbch_scroll 105
+#define dbch_security 106
+#define dbch_segment 107
+#define dbch_selector 108
+#define dbch_sem 109
+#define dbch_sendmsg 110
+#define dbch_server 111
+#define dbch_shell 112
+#define dbch_shm 113
+#define dbch_snoop 114
+#define dbch_sound 115
+#define dbch_static 116
+#define dbch_statusbar 117
+#define dbch_stress 118
+#define dbch_string 119
+#define dbch_syscolor 120
+#define dbch_system 121
+#define dbch_tab 122
+#define dbch_task 123
+#define dbch_text 124
+#define dbch_thread 125
+#define dbch_thunk 126
+#define dbch_timer 127
+#define dbch_toolbar 128
+#define dbch_toolhelp 129
+#define dbch_tooltips 130
+#define dbch_trackbar 131
+#define dbch_treeview 132
+#define dbch_tweak 133
+#define dbch_uitools 134
+#define dbch_updown 135
+#define dbch_ver 136
+#define dbch_virtual 137
+#define dbch_vxd 138
+#define dbch_wave 139
+#define dbch_win 140
+#define dbch_win16drv 141
+#define dbch_win32 142
+#define dbch_wing 143
+#define dbch_winsock 144
+#define dbch_wnet 145
+#define dbch_x11 146
+#define dbch_x11drv 147
 /* Definitions for classes identifiers */
 #define dbcl_fixme 0
 #define dbcl_err 1
diff --git a/include/debugdefs.h b/include/debugdefs.h
index ea469b5..cd1a472 100644
--- a/include/debugdefs.h
+++ b/include/debugdefs.h
@@ -4,7 +4,7 @@
 #include "debugtools.h"
 #endif
 
-#define DEBUG_CHANNEL_COUNT 147
+#define DEBUG_CHANNEL_COUNT 148
 #ifdef DEBUG_RUNTIME
 short debug_msg_enabled[][DEBUG_CLASS_COUNT] = {
 {1, 1, 0, 0},
@@ -154,6 +154,7 @@
 {1, 1, 0, 0},
 {1, 1, 0, 0},
 {1, 1, 0, 0},
+{1, 1, 0, 0},
 };
 const char* debug_ch_name[] = {
 "accel",
@@ -252,6 +253,7 @@
 "profile",
 "progress",
 "prop",
+"propsheet",
 "psapi",
 "psdrv",
 "ras",
diff --git a/include/dinput.h b/include/dinput.h
index 03978e2..0bf86c3 100644
--- a/include/dinput.h
+++ b/include/dinput.h
@@ -1,6 +1,8 @@
 #ifndef _WINE_DINPUT_H
 #define _WINE_DINPUT_H
 
+#include "unknwn.h"
+
 #define STDMETHOD(xfn) HRESULT (CALLBACK *fn##xfn)
 #define STDMETHOD_(ret,xfn) ret (CALLBACK *fn##xfn)
 #define PURE
diff --git a/include/dosexe.h b/include/dosexe.h
index 4f5c16b..530cdd7 100644
--- a/include/dosexe.h
+++ b/include/dosexe.h
@@ -51,5 +51,7 @@
 extern HINSTANCE16 MZ_CreateProcess( LPCSTR name, LPCSTR cmdline, LPCSTR env, BOOL32 inherit,
                                      LPSTARTUPINFO32A startup, LPPROCESS_INFORMATION info );
 extern int DOSVM_Enter( PCONTEXT context );
+extern void DOSVM_SetTimer( unsigned ticks );
+extern unsigned DOSVM_GetTimer( void );
 
 #endif /* __WINE_DOSEXE_H */
diff --git a/include/dplay.h b/include/dplay.h
index fd9552e..d6d5506 100644
--- a/include/dplay.h
+++ b/include/dplay.h
@@ -2,6 +2,8 @@
 #ifndef __WINE_DPLAY_H
 #define __WINE_DPLAY_H
 
+#include "unknwn.h"
+
 #pragma pack(1)
 
 /* Return Values for Direct Play */
diff --git a/include/dsound.h b/include/dsound.h
index 2b2bcca..e944fab 100644
--- a/include/dsound.h
+++ b/include/dsound.h
@@ -3,7 +3,6 @@
 
 #include "windows.h"
 #include "winbase.h"
-#include "compobj.h"
 #include "mmsystem.h"
 #include "d3d.h"			/*FIXME: Need to break out d3dtypes.h */
 
diff --git a/include/flatsb.h b/include/flatsb.h
new file mode 100644
index 0000000..2103ada
--- /dev/null
+++ b/include/flatsb.h
@@ -0,0 +1,20 @@
+/*
+ * Date and time picker class extra info
+ *
+ * Copyright 1998 Eric Kohl
+ */
+
+#ifndef __WINE_FLATSB_H
+#define __WINE_FLATSB_H
+
+typedef struct tagFLATSB_INFO
+{
+    DWORD dwDummy;  /* just to keep the compiler happy ;-) */
+
+} FLATSB_INFO, *LPFLATSB_INFO;
+
+
+extern VOID FLATSB_Register (VOID);
+extern VOID FLATSB_Unregister (VOID);
+
+#endif  /* __WINE_FLATSB_H */
diff --git a/include/interfaces.h b/include/interfaces.h
index 26f28d5..a7621f6 100644
--- a/include/interfaces.h
+++ b/include/interfaces.h
@@ -48,7 +48,6 @@
 #include "objbase.h"
 
 #define THIS LPCLASSFACTORY this
-typedef struct IClassFactory *LPCLASSFACTORY,IClassFactory;
 typedef struct {
 	STDMETHOD(QueryInterface) (THIS_ REFIID riid,LPVOID FAR* ppvObj) PURE;
 	STDMETHOD_(ULONG,AddRef) (THIS) PURE;
@@ -57,14 +56,9 @@
 	STDMETHOD(LockServer) (THIS_ BOOL32) PURE;
 } *LPCLASSFACTORY_VTABLE,IClassFactory_VTable;
 
-struct IClassFactory {
-	LPCLASSFACTORY_VTABLE	lpvtbl;
-	DWORD			ref;
-};
 #undef THIS
 
 #define THIS LPMALLOC32 this
-typedef struct IMalloc32 *LPMALLOC32,IMalloc32;
 typedef struct {
 	STDMETHOD(QueryInterface) (THIS_ REFIID riid,LPVOID FAR* ppvObj) PURE;
 	STDMETHOD_(ULONG,AddRef) (THIS) PURE;
@@ -78,14 +72,9 @@
 	STDMETHOD_(LPVOID,HeapMinimize) ( THIS );
 } *LPMALLOC32_VTABLE,IMalloc32_VTable;
 
-struct IMalloc32 {
-	LPMALLOC32_VTABLE	lpvtbl;
-	DWORD			ref;
-};
 #undef THIS
 
 #define THIS LPMALLOC16 this
-typedef struct IMalloc16 *LPMALLOC16,IMalloc16;
 typedef struct {
 	STDMETHOD(QueryInterface) (THIS_ REFIID riid,LPVOID FAR* ppvObj) PURE;
 	STDMETHOD_(ULONG,AddRef) (THIS) PURE;
@@ -99,14 +88,6 @@
 	STDMETHOD_(LPVOID,HeapMinimize) ( THIS );
 } *LPMALLOC16_VTABLE,IMalloc16_VTable;
 
-struct IMalloc16 {
-	LPMALLOC16_VTABLE	lpvtbl;
-	DWORD			ref;
-	/* Gmm, I think one is not enough, we should probably manage a list of
-	 * heaps
-	 */
-	HGLOBAL16		heap;
-};
 #undef THIS
 
 /* private prototypes for the constructors */
diff --git a/include/main.h b/include/main.h
index dc0762a..8e4af75 100644
--- a/include/main.h
+++ b/include/main.h
@@ -12,6 +12,9 @@
 extern int MAIN_GetLanguageID(char*lang, char*country, char*charset, char*dialect);
 
 extern BOOL32 RELAY_Init(void);
+extern int RELAY_ShowDebugmsgRelay(const char *func);
 extern void* CALL32_Init(void);
 
+extern BOOL32 THUNK_Init(void);
+
 #endif  /* __WINE_MAIN_H */
diff --git a/include/miscemu.h b/include/miscemu.h
index 9b2598b..558f841 100644
--- a/include/miscemu.h
+++ b/include/miscemu.h
@@ -11,7 +11,10 @@
 #include "winnt.h"
 #include "ldt.h"
 
-  /* msdos/dosmem.c */
+/* msdos/dosconf.c */
+extern int DOSCONF_ReadConfig(void);
+
+/* msdos/dosmem.c */
 extern HANDLE16 DOSMEM_BiosSeg;
 extern DWORD DOSMEM_CollateTable;
 
diff --git a/include/msdos.h b/include/msdos.h
index dccb072..ca68cf2 100644
--- a/include/msdos.h
+++ b/include/msdos.h
@@ -196,4 +196,25 @@
 void do_mscdex( CONTEXT *context );
 void do_mscdex_dd (CONTEXT * context, int dorealmode);
 
+#define DOSCONF_MEM_HIGH        0x0001
+#define DOSCONF_MEM_UMB         0x0002
+#define DOSCONF_NUMLOCK         0x0004
+#define DOSCONF_KEYB_CONV       0x0008
+
+typedef struct {
+        char lastdrive;
+        int brk_flag;
+        int files;
+        int stacks_nr;
+        int stacks_sz;
+        int buf;
+        int buf2;
+        int fcbs;
+        int flags;
+        char *shell;
+        char *country;
+} DOSCONF;
+
+extern DOSCONF DOSCONF_config;
+
 #endif /* __WINE_MSDOS_H */
diff --git a/include/multimedia.h b/include/multimedia.h
index 4d97843..11ac6a4 100644
--- a/include/multimedia.h
+++ b/include/multimedia.h
@@ -58,8 +58,8 @@
 extern UINT16 		MCI_NextDevID(UINT16 wDevID);
 extern BOOL32 		MCI_DevIDValid(UINT16 wDevID);
 
-extern int			MCI_MapMsg16To32A(WORD uDevType, WORD wMsg, DWORD* lParam);
-extern int			MCI_UnMapMsg16To32A(WORD uDevTyp, WORD wMsg, DWORD lParam);
+extern int		MCI_MapMsg16To32A(WORD uDevType, WORD wMsg, DWORD* lParam);
+extern int		MCI_UnMapMsg16To32A(WORD uDevTyp, WORD wMsg, DWORD lParam);
 
 typedef LONG		(*MCIPROC16)(DWORD, HDRVR16,  WORD, DWORD, DWORD);
 typedef LONG		(*MCIPROC32)(DWORD, HDRVR16, DWORD, DWORD, DWORD);
@@ -69,7 +69,9 @@
 extern DWORD		MCI_WriteString(LPSTR lpDstStr, DWORD dstSize, LPCSTR lpSrcStr);
 extern const char* MCI_CommandToString(UINT16 wMsg);
 
-extern DWORD		MCI_SendCommandAsync32(UINT32 wDevID, UINT32 wMsg, DWORD dwParam1, DWORD dwParam2);
+
+extern DWORD MCI_SendCommand32(UINT32 wDevID, UINT16 wMsg, DWORD dwParam1, DWORD dwParam2);
+extern DWORD MCI_SendCommandAsync32(UINT32 wDevID, UINT32 wMsg, DWORD dwParam1, DWORD dwParam2);
 
 LONG MCIWAVE_DriverProc32(DWORD dwDevID, HDRVR16 hDriv, DWORD wMsg, 
 			  DWORD dwParam1, DWORD dwParam2);
diff --git a/include/objbase.h b/include/objbase.h
index f7c5697..38a540c 100644
--- a/include/objbase.h
+++ b/include/objbase.h
@@ -2,467 +2,115 @@
 #define __WINE_OBJBASE_H
 
 
-/*
- * The goal of the following set of definitions is to provide a way to use the same 
- * header file definitions to provide both a C interface and a C++ object oriented 
- * interface to COM interfaces. The type of interface is selected automatically 
- * depending on the language but it is always possible to get the C interface in C++ 
- * by defining CINTERFACE.
- *
- * It is based on the following assumptions:
- *  - all COM interfaces derive from IUnknown, this should not be a problem.
- *  - the header file only defines the interface, the actual fields are defined 
- *    separately in the C file implementing the interface.
- *  - no COM method returns void. This seems to be the case but otherwise we could support this 
- *    case by having one more set of macros.
- *
- * The natural approach to this problem would be to make sure we get a C++ class and 
- * virtual methods in C++ and a structure with a table of pointer to functions in C.
- * Unfortunately the layout of the virtual table is compiler specific, the layout of 
- * g++ virtual tables is not the same as that of an egcs virtual table which is not the 
- * same as that generated by Visual C+. There are workarounds to make the virtual tables 
- * compatible via padding but unfortunately the one which is imposed to the WINE emulator
- * by the Windows binaries, i.e. the Visual C++ one, is the most compact of all.
- *
- * So the solution I finally adopted does not use virtual tables. Instead I use inline 
- * non virtual methods that dereference the method pointer themselves and perform the call.
- *
- * Let's take Direct3D as an example:
- *
- *    #define ICOM_INTERFACE IDirect3D
- *    ICOM_BEGIN(IDirect3D,IUnknown)
- *        ICOM_METHOD1(HRESULT,Initialize,    REFIID,);
- *        ICOM_METHOD2(HRESULT,EnumDevices,   LPD3DENUMDEVICESCALLBACK,, LPVOID,);
- *        ICOM_METHOD2(HRESULT,CreateLight,   LPDIRECT3DLIGHT*,, IUnknown*,);
- *        ICOM_METHOD2(HRESULT,CreateMaterial,LPDIRECT3DMATERIAL*,, IUnknown*,);
- *        ICOM_METHOD2(HRESULT,CreateViewport,LPDIRECT3DVIEWPORT*,, IUnknown*,);
- *        ICOM_METHOD2(HRESULT,FindDevice,    LPD3DFINDDEVICESEARCH,, LPD3DFINDDEVICERESULT,);
- *    ICOM_END(IDirect3D)
- *    #undef ICOM_INTERFACE
- *
- *    #if !defined(__cplusplus) || defined(CINTERFACE)
- *    // *** IUnknown methods *** //
- *    #define IDirect3D_QueryInterface(p,a,b) ICOM_ICALL2(IUnknown,QueryInterface,p,a,b)
- *    #define IDirect3D_AddRef(p)             ICOM_ICALL (IUnknown,AddRef,p)
- *    #define IDirect3D_Release(p)            ICOM_ICALL (IUnknown,Release,p)
- *    // *** IDirect3D methods *** //
- *    #define IDirect3D_Initialize(p,a)       ICOM_CALL1(Initialize,p,a)
- *    #define IDirect3D_EnumDevices(p,a,b)    ICOM_CALL2(EnumDevice,p,a,b)
- *    #define IDirect3D_CreateLight(p,a,b)    ICOM_CALL2(CreateLight,p,a,b)
- *    #define IDirect3D_CreateMaterial(p,a,b) ICOM_CALL2(CreateMaterial,p,a,b)
- *    #define IDirect3D_CreateViewport(p,a,b) ICOM_CALL2(CreateViewport,p,a,b)
- *    #define IDirect3D_FindDevice(p,a,b)     ICOM_CALL2(FindDevice,p,a,b)
- *    #endif
- *
- * Comments:
- *  - The ICOM_INTERFACE is used in the ICOM_METHOD macros for the 'this' pointer and to cast 
- *    pointers. Defining this macro here saves us the trouble of having to repeat the interface 
- *    name everywhere. Note haowever that because of the way macros work a macro like ICOM_METHOD1 
- *    cannot use 'ICOM_INTERFACE##_VTABLE' because this would give 'ICOM_INTERFACE_VTABLE' and not 
- *    'IDirect3D_VTABLE'.
- *  - ICOM_BEGIN and ICOM_END are responsible for generating whatever structure is appropriate for 
- *    representing the interface in the current language. In C this is a couple of structs in C++ 
- *    it's a class. The first parameter is the interface name and the second one is the interface 
- *    we inherit from. The reason why you have to repeat the interface name is because that's the 
- *    only way these macro can successfully output "IDirect3D_VTABLE'. Trying to use ICOM_INTERFACE 
- *    would, as in ICOM_METHOD, only yield 'ICOM_INTERFACE_VTABLE'.
- *  - With the way ICOM_BEGIN works you don't have to repeat the definitions of the methods of the 
- *    parent interface. They are automatically inherited both in C and in C++.
- *  - In C++ the ICOM_METHOD macros generate a function prototype and a call to a function pointer 
- *    method. This means using once 't1 p1, t2 p2, ...' and once 'p1, p2' without the types. The 
- *    only way I found to handle this is to have one ICOM_METHOD macro per number of parameters and 
- *    to have it take only the type information (with const if necessary) as parameters.
- *    The 'undef ICOM_INTERFACE' is here to remind you that using ICOM_INTERFACE in the following 
- *    macros will not work. This time it's because the ICOM_CALL macro expansion is done only once 
- *    the 'IDirect3D_Xxx' macro is expanded. And by that time ICOM_INTERFACE will be long gone 
- *    anyway.
- *  - You may have noticed the double commas after each parameter type. This allows you to put the 
- *    name of that parameter which I think is good for documentation. It is not required and since 
- *    I did not know what to put there for this example (I could only find doc about IDirect3D2), 
- *    I left them blank.
- *  - Finally the set of 'IDirect3D_Xxx' macros is a standard set of macros defined to ease access 
- *    to the interface methods in C. Unfortunately I don't see any way to avoid having to duplicate 
- *    the inherited method definitions there. We must use ICOM_ICALL to invoke inherited methods, 
- *    because in C we have to cast the virtual table pointer, and we should use the ICOM_CALL 
- *    method in the other cases. This time I could have used a trick to use only one macro whatever 
- *    the number of parameters but I prefered to have it work the same way as above.
- *  - You probably have noticed that we don't define the fields we need to actually implement this 
- *    interface: reference count, pointer to other resources and miscellaneous fields. That's 
- *    because it's not needed, and the user will anyway only manipulate pointers to this structure
- *    so he does not need to know its real size. Of course on the implementation side we have the 
- *    real definition of the interface structure and they should match what the macros yield in 
- *    each language (or conversely).
- *
- *
- * In C this gives:
- *    typedef struct IDirect3D_VTABLE IDirect3D_VTABLE;
- *    struct IDirect3D {
- *        IDirect3D_VTABLE* lpvtbl;
- *    };
- *    struct IDirect3D_VTABLE {
- *        IUnknown_VTABLE bvt;
- *        HRESULT (*fnInitialize)(IDirect3D* me, REFIID a);
- *        HRESULT (*fnEnumDevices)(IDirect3D* me, LPD3DENUMDEVICESCALLBACK a, LPVOID b);
- *        HRESULT (*fnCreateLight)(IDirect3D* me, LPDIRECT3DLIGHT* a, IUnknown* b);
- *        HRESULT (*fnCreateMaterial)(IDirect3D* me, LPDIRECT3DMATERIAL* a, IUnknown* b);
- *        HRESULT (*fnCreateViewport)(IDirect3D* me, LPDIRECT3DVIEWPORT* a, IUnknown* b);
- *        HRESULT (*fnFindDevice)(IDirect3D* me, LPD3DFINDDEVICESEARCH a, LPD3DFINDDEVICERESULT b);
- *    }; 
- *
- *    #if !defined(__cplusplus) || defined(CINTERFACE)
- *    // *** IUnknown methods *** //
- *    #define IDirect3D_QueryInterface(p,a,b) ((IUnknown_VTABLE*)(p)->lpvtbl)->fnQueryInterface((IUnknown*)p,a,b)
- *    #define IDirect3D_AddRef(p)             ((IUnknown_VTABLE*)(p)->lpvtbl)->fnAddRef((IUnknown*)p)
- *    #define IDirect3D_Release(p)            ((IUnknown_VTABLE*)(p)->lpvtbl)->fnRelease((IUnknown*)p)
- *    // *** IDirect3D methods *** //
- *    #define IDirect3D_Initialize(p,a)       (p)->lpvtbl->fnInitialize(p,a)
- *    #define IDirect3D_EnumDevices(p,a,b)    (p)->lpvtbl->fnEnumDevice(p,a,b)
- *    #define IDirect3D_CreateLight(p,a,b)    (p)->lpvtbl->fnCreateLight(p,a,b)
- *    #define IDirect3D_CreateMaterial(p,a,b) (p)->lpvtbl->fnCreateMaterial(p,a,b)
- *    #define IDirect3D_CreateViewport(p,a,b) (p)->lpvtbl->fnCreateViewport(p,a,b)
- *    #define IDirect3D_FindDevice(p,a,b)     (p)->lpvtbl->fnFindDevice(p,a,b)
- *    #endif
- *
- * Comments:
- *  - IDirect3D only contains a pointer to the IDirect3D virtual/jump table. This is the only thing 
- *    the user needs to know to use the interface. Of course the structure we will define to 
- *    implement this interface will have more fields but the first one will match this pointer.
- *  - The code generated by ICOM_BEGIN goes up to the bvt field in the IDirect3D virtual table. 
- *    This bvt field is what saves us from having to duplicate the inherited method definitions.
- *    It's a shame that C (gcc) will not allow unnamed structs. If this was possible we could 
- *    seamlessly inherit and use the parent's interface function pointers.
- *  - What follows is just a bunch of function pointer definitions generated by the ICOM_METHOD 
- *    macros. The implementation will fill this jump table with appropriate values in a static 
- *    variable and initialize the lpvtbl field to point to this variable.
- *  - The IDirect3D_Xxx macros then just derefence the lpvtbl pointer and use the function pointer 
- *    corresponding to the macro name. This emulates the behavior of a virtual table and should be 
- *    about as fast. In the case of inherited methods we have some additional casting to do to 
- *    because the inherited methods are defined in the bvt field or maybe further imbricated. Since 
- *    the effect of the bvt field is that we inherit the parent virtual table fields this cast is 
- *    relatively inocuous. A similar cast must be performed on the interface pointer before the 
- *    invoked method will accept it. Despite all these casts there is little chance that you call a 
- *    method on the wrong type of interface because the function names still have to match. But this 
- *    is the only thing that will make the compilation fail.
- *
- *
- * And in C++ (with gcc's g++):
- *
- *    typedef struct IDirect3D: public IUnknown {
- *        private: HRESULT (*fnInitialize)(IDirect3D* me, REFIID a);
- *        public: inline HRESULT Initialize(REFIID a) { return ((IDirect3D*)t.lpvtbl)->fnInitialize(this,a); };
- *        private: HRESULT (*fnEnumDevices)(IDirect3D* me, LPD3DENUMDEVICESCALLBACK a, LPVOID b);
- *        public: inline HRESULT EnumDevices(LPD3DENUMDEVICESCALLBACK a, LPVOID b)
- *            { return ((IDirect3D*)t.lpvtbl)->fnEnumDevices(this,a,b); };
- *        private: HRESULT (*fnCreateLight)(IDirect3D* me, LPDIRECT3DLIGHT* a, IUnknown* b);
- *        public: inline HRESULT CreateLight(LPDIRECT3DLIGHT* a, IUnknown* b)
- *            { return ((IDirect3D*)t.lpvtbl)->fnCreateLight(this,a,b); };
- *        private: HRESULT (*fnCreateMaterial)(IDirect3D* me, LPDIRECT3DMATERIAL* a, IUnknown* b);
- *        public: inline HRESULT CreateMaterial(LPDIRECT3DMATERIAL* a, IUnknown* b)
- *            { return ((IDirect3D*)t.lpvtbl)->fnCreateMaterial(this,a,b); };
- *        private: HRESULT (*fnCreateViewport)(IDirect3D* me, LPDIRECT3DVIEWPORT* a, IUnknown* b);
- *        public: inline HRESULT CreateViewport(LPDIRECT3DVIEWPORT* a, IUnknown* b)
- *            { return ((IDirect3D*)t.lpvtbl)->fnCreateViewport(this,a,b); };
- *        private:  HRESULT (*fnFindDevice)(IDirect3D* me, LPD3DFINDDEVICESEARCH a, LPD3DFINDDEVICERESULT b);
- *        public: inline HRESULT FindDevice(LPD3DFINDDEVICESEARCH a, LPD3DFINDDEVICERESULT b)
- *            { return ((IDirect3D*)t.lpvtbl)->fnFindDevice(this,a,b); };
- *    }; 
- *
- * Comments:
- *  - In C++ IDirect3D does double duty as both the virtual/jump table and as the interface 
- *    definition. The reason for this is to avoid having to duplicate the mehod definitions: once 
- *    to have the function pointers in the jump table and once to have the methods in the interface 
- *    class. Here one macro can generate both. This means though that the first pointer, t.lpvtbl 
- *    defined in IUnknown,  must be interpreted as the jump table pointer if we interpret the 
- *    structure as the the interface class, and as the function pointer to the QueryInterface 
- *    method, t.fnQueryInterface, if we interpret the structure as the jump table. Fortunately this 
- *    gymnastic is entirely taken care of in the header of IUnknown.
- *  - Of course in C++ we use inheritance so that we don't have to duplicate the method definitions. 
- *  - Since IDirect3D does double duty, each ICOM_METHOD macro defines both a function pointer and 
- *    a non-vritual inline method which dereferences it and calls it. This way this method behaves 
- *    just like a virtual method but does not create a true C++ virtual table which would break the 
- *    structure layout. If you look at the implementation of these methods you'll notice that they 
- *    would not work for void functions. We have to return something and fortunately this seems to 
- *    be what all the COM methods do (otherwise we would need another set of macros).
- *  - Note how the ICOM_METHOD generates both function prototypes mixing types and formal parameter 
- *    names and the method invocation using only the formal parameter name. This is the reason why 
- *    we need different macros to handle different numbers of parameters.
- *  - Finally there is no IDirect3D_Xxx macro. These are not needed in C++ unless the CINTERFACE 
- *    macro is defined in which case we would not be here.
- *
- *
- * Implementing a COM interface.
- *
- * This continues the above example.I assume the implementation is in C but it would probably 
- * be similar in C++.
- *
- *    typedef struct _IDirect3D {
- *        void* lpvtbl;
- *        // ...
- *
- *    } _IDirect3D;
- *
- *    static ICOM_VTABLE(IDirect3D) d3dvt;
- *
- *    // implement the IDirect3D methods here
- *
- *    int IDirect3D_fnQueryInterface(LPUNKNOWN me)
- *    {
- *        ICOM_THIS(IDirect3D,me);
- *        // ...
- *    }
- *
- *    // ...
- *
- *    static ICOM_VTABLE(IDirect3D) d3dvt = {
- *        {
- *            IDirect3D_fnQueryInterface,
- *            IUnknown_fnAdd,
- *            IUnknown_fnAdd2
- *        },
- *        IDirect3D_fnInitialize,
- *        IDirect3D_fnSetWidth
- *    };
- *
- * Comments:
- *  - We first define what the interface really contains. This is th e_IDirect3D structure. The 
- *    first field must of course be the virtual table pointer. Everything else is free.
- *  - Then we predeclare our static virtual table variable, we will need its address in some 
- *    methods to initialize the virtual table pointer of the returned interface objects.
- *  - Then we implement the interface methods. To match what has been declared in the header file 
- *    they must take a pointer to a IDirect3D structure so we must cast it to an _IDirect3D so that 
- *    we can manipulate the fields. This is performed by the ICOM_THIS macro.
- *  - Finally we initialize the virtual table. The inherited methods must be in curly brackets to 
- *    match the parent interface's virtual table definition.
+#include "wine/obj_base.h"
+
+/* the following depend only on obj_base.h */
+#include "wine/obj_misc.h"
+#include "wine/obj_channel.h"
+#include "wine/obj_clientserver.h"
+#include "wine/obj_marshal.h"
+#include "wine/obj_storage.h"
+
+/* the following depend on obj_storage.h */
+#include "wine/obj_moniker.h"
+#include "wine/obj_propertystorage.h"
+
+/* the following depend on obj_moniker.h */
+#include "wine/obj_dataobject.h"
+
+/* FIXME: the following should be moved to one of the wine/obj_XXX.h headers */
+
+/*****************************************************************************
+ * CoXXX API
+ */
+/* FIXME: more CoXXX functions are missing */
+DWORD WINAPI CoBuildVersion(void);
+
+typedef enum tagCOINIT
+{
+    COINIT_APARTMENTTHREADED  = 0x2, /* Apartment model */
+    COINIT_MULTITHREADED      = 0x0, /* OLE calls objects on any thread */
+    COINIT_DISABLE_OLE1DDE    = 0x4, /* Don't use DDE for Ole1 support */
+    COINIT_SPEED_OVER_MEMORY  = 0x8  /* Trade memory for speed */
+} COINIT;
+
+HRESULT WINAPI CoInitialize16(LPVOID lpReserved);
+HRESULT WINAPI CoInitialize32(LPVOID lpReserved);
+#define CoInitialize WINELIB_NAME(CoInitialize)
+
+HRESULT WINAPI CoInitializeEx32(LPVOID lpReserved, DWORD dwCoInit);
+#define CoInitializeEx WINELIB_NAME(CoInitializeEx)
+
+void WINAPI CoUninitialize(void);
+
+
+HRESULT WINAPI CoCreateGuid(GUID *pguid);
+
+/* class registration flags; passed to CoRegisterClassObject */
+typedef enum tagREGCLS
+{
+    REGCLS_SINGLEUSE = 0,
+    REGCLS_MULTIPLEUSE = 1,
+    REGCLS_MULTI_SEPARATE = 2,
+    REGCLS_SUSPENDED = 4
+} REGCLS;
+
+HRESULT WINAPI CoRegisterClassObject16(REFCLSID rclsid, LPUNKNOWN pUnk, DWORD dwClsContext, DWORD flags, LPDWORD lpdwRegister);
+HRESULT WINAPI CoRegisterClassObject32(REFCLSID rclsid,LPUNKNOWN pUnk,DWORD dwClsContext,DWORD flags,LPDWORD lpdwRegister);
+#define CoRegisterClassObject WINELIB_NAME(CoRegisterClassObject)
+
+HRESULT WINAPI CoRevokeClassObject(DWORD dwRegister);
+HRESULT WINAPI CoGetClassObject(REFCLSID rclsid, DWORD dwClsContext,LPVOID pvReserved, const REFIID iid, LPVOID *ppv);
+
+
+HRESULT WINAPI CoCreateInstance(REFCLSID rclsid,LPUNKNOWN pUnkOuter,DWORD dwClsContext,REFIID iid,LPVOID *ppv);
+void WINAPI CoFreeLibrary(HINSTANCE32 hLibrary);
+void WINAPI CoFreeAllLibraries(void);
+void WINAPI CoFreeUnusedLibraries(void);
+HRESULT WINAPI CoFileTimeNow(FILETIME *lpFileTime);
+LPVOID WINAPI CoTaskMemAlloc(ULONG size);
+void WINAPI CoTaskMemFree(LPVOID ptr);
+HINSTANCE32 WINAPI CoLoadLibrary(LPOLESTR16 lpszLibName, BOOL32 bAutoFree);
+
+HRESULT WINAPI CoLockObjectExternal16(LPUNKNOWN pUnk,BOOL16 fLock,BOOL16 fLastUnlockReleases);
+HRESULT WINAPI CoLockObjectExternal32(LPUNKNOWN pUnk,BOOL32 fLock,BOOL32 fLastUnlockReleases);
+#define CoLockObjectExternal WINELIB_NAME(CoLockObjectExternal)
+
+
+/* internal Wine stuff */
+
+
+/*****************************************************************************
+ * IClassFactory interface
  */
 
+typedef struct _IClassFactory {
+    /* IUnknown fields */
+    ICOM_VTABLE(IClassFactory)* lpvtbl;
+    DWORD                       ref;
+} _IClassFactory;
 
-#define ICOM_VTABLE(iface)       iface##_VTABLE
+HRESULT WINE_StringFromCLSID(const CLSID *id, LPSTR);
 
 
-#if defined(__cplusplus) && !defined(CINTERFACE)
-/* C++ interface */
-
-#define ICOM_BEGIN(iface,ibase) \
-    typedef struct iface: public ibase {
-
-#define ICOM_METHOD(ret,xfn) \
-    private: ret (CALLBACK *fn##xfn)(ICOM_INTERFACE* me); \
-    public: inline ret (CALLBACK xfn)(void) { return ((ICOM_INTERFACE*)t.lpvtbl)->fn##xfn(this); };
-
-#define ICOM_METHOD1(ret,xfn,ta,na) \
-    private: ret (CALLBACK *fn##xfn)(ICOM_INTERFACE* me,ta a); \
-    public: inline ret (CALLBACK xfn)(ta a) { return ((ICOM_INTERFACE*)t.lpvtbl)->fn##xfn(this,a); };
-
-#define ICOM_METHOD2(ret,xfn,ta,na,tb,nb) \
-    private: ret (CALLBACK *fn##xfn)(ICOM_INTERFACE* me,ta a,tb b); \
-    public: inline ret (CALLBACK xfn)(ta a,tb b) { return ((ICOM_INTERFACE*)t.lpvtbl)->fn##xfn(this,a,b); };
-
-#define ICOM_METHOD3(ret,xfn,ta,na,tb,nb,tc,nc) \
-    private: ret (CALLBACK *fn##xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c); \
-    public: inline ret (CALLBACK xfn)(ta a,tb b,tc c) { return ((ICOM_INTERFACE*)t.lpvtbl)->fn##xfn(this,a,b,c); };
-
-#define ICOM_METHOD4(ret,xfn,ta,na,tb,nb,tc,nc,td,nd) \
-    private: ret (CALLBACK *fn##xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d); \
-    public: inline ret (CALLBACK xfn)(ta a,tb b,tc c,td d) { return ((ICOM_INTERFACE*)t.lpvtbl)->fn##xfn(this,a,b,c,d); };
-
-#define ICOM_METHOD5(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne) \
-    private: ret (CALLBACK *fn##xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e); \
-    public: inline ret (CALLBACK xfn)(ta a,tb b,tc c,td d,te e) { return ((ICOM_INTERFACE*)t.lpvtbl)->fn##xfn(this,a,b,c,d,e); };
-
-#define ICOM_METHOD6(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf) \
-    private: ret (CALLBACK *fn##xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f); \
-    public: inline ret (CALLBACK xfn)(ta a,tb b,tc c,td d,te e,tf f) { return ((ICOM_INTERFACE*)t.lpvtbl)->fn##xfn(this,a,b,c,d,e,f); };
-
-#define ICOM_METHOD7(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng) \
-    private: ret (CALLBACK *fn##xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f,tg g); \
-    public: inline ret (CALLBACK xfn)(ta a,tb b,tc c,td d,te e,tf f,tg g) { return ((ICOM_INTERFACE*)t.lpvtbl)->fn##xfn(this,a,b,c,d,e,f,g); };
-
-
-#define ICOM_CMETHOD(ret,xfn) \
-    private: ret (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me); \
-    public: inline ret (CALLBACK xfn)(void) const { return ((ICOM_INTERFACE*)t.lpvtbl)->fn##xfn(this); };
-
-#define ICOM_CMETHOD1(ret,xfn,ta,na) \
-    private: ret (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me,ta a); \
-    public: inline ret (CALLBACK xfn)(ta a) const { return ((ICOM_INTERFACE*)t.lpvtbl)->fn##xfn(this,a); };
-
-#define ICOM_CMETHOD2(ret,xfn,ta,na,tb,nb) \
-    private: ret (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me,ta a,tb b); \
-    public: inline ret (CALLBACK xfn)(ta a,tb b) const { return ((ICOM_INTERFACE*)t.lpvtbl)->fn##xfn(this,a,b); };
-
-#define ICOM_CMETHOD3(ret,xfn,ta,na,tb,nb,tc,nc) \
-    private: ret (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me,ta a,tb b,tc c); \
-    public: inline ret (CALLBACK xfn)(ta a,tb b,tc c) const { return ((ICOM_INTERFACE*)t.lpvtbl)->fn##xfn(this,a,b,c); };
-
-#define ICOM_CMETHOD4(ret,xfn,ta,na,tb,nb,tc,nc,td,nd) \
-    private: ret (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me,ta a,tb b,tc c,td d); \
-    public: inline ret (CALLBACK xfn)(ta a,tb b,tc c,td d) const { return ((ICOM_INTERFACE*)t.lpvtbl)->fn##xfn(this,a,b,c,d); };
-
-#define ICOM_CMETHOD5(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne) \
-    private: ret (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e); \
-    public: inline ret (CALLBACK xfn)(ta a,tb b,tc c,td d,te e) const { return ((ICOM_INTERFACE*)t.lpvtbl)->fn##xfn(this,a,b,c,d,e); };
-
-#define ICOM_CMETHOD6(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf) \
-    private: ret (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f); \
-    public: inline ret (CALLBACK xfn)(ta a,tb b,tc c,td d,te e,tf f) const { return ((ICOM_INTERFACE*)t.lpvtbl)->fn##xfn(this,a,b,c,d,e,f); };
-
-#define ICOM_CMETHOD7(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng) \
-    private: ret (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f,tg g); \
-    public: inline ret (CALLBACK xfn)(ta a,tb b,tc c,td d,te e,tf f,tg g) const { return ((ICOM_INTERFACE*)t.lpvtbl)->fn##xfn(this,a,b,c,d,e,f,g); };
-
-
-#define ICOM_END(iface) \
-    };
-
-#define ICOM_ICALL(ibase, xfn, p)                this_is_a_syntax_error
-#define ICOM_ICALL1(ibase, xfn, p,a)             this_is_a_syntax_error
-#define ICOM_ICALL2(ibase, xfn, p,a,b)           this_is_a_syntax_error
-#define ICOM_ICALL3(ibase, xfn, p,a,b,c)         this_is_a_syntax_error
-#define ICOM_ICALL4(ibase, xfn, p,a,b,c,d)       this_is_a_syntax_error
-#define ICOM_ICALL5(ibase, xfn, p,a,b,c,d,e)     this_is_a_syntax_error
-#define ICOM_ICALL6(ibase, xfn, p,a,b,c,d,e,f)   this_is_a_syntax_error
-#define ICOM_ICALL7(ibase, xfn, p,a,b,c,d,e,f,g) this_is_a_syntax_error
-
-#define ICOM_CALL(xfn, p)                        this_is_a_syntax_error
-#define ICOM_CALL1(xfn, p,a)                     this_is_a_syntax_error
-#define ICOM_CALL2(xfn, p,a,b)                   this_is_a_syntax_error
-#define ICOM_CALL3(xfn, p,a,b,c)                 this_is_a_syntax_error
-#define ICOM_CALL4(xfn, p,a,b,c,d)               this_is_a_syntax_error
-#define ICOM_CALL5(xfn, p,a,b,c,d,e)             this_is_a_syntax_error
-#define ICOM_CALL6(xfn, p,a,b,c,d,e,f)           this_is_a_syntax_error
-#define ICOM_CALL7(xfn, p,a,b,c,d,e,f,g)         this_is_a_syntax_error
-
-
-#else
-/* C interface */
-
-
-#define ICOM_BEGIN(iface,ibase) \
-    typedef struct ICOM_VTABLE(iface) ICOM_VTABLE(iface); \
-    struct iface { \
-        const ICOM_VTABLE(iface)* lpvtbl; \
-    }; \
-    struct ICOM_VTABLE(iface) { \
-        ICOM_VTABLE(ibase) bvt;
-
-#define ICOM_METHOD(ret, xfn) \
-    ret (CALLBACK *fn##xfn)(ICOM_INTERFACE* me);
-
-#define ICOM_METHOD1(ret,xfn,ta,na) \
-    ret (CALLBACK *fn##xfn)(ICOM_INTERFACE* me,ta a);
-
-#define ICOM_METHOD2(ret,xfn,ta,na,tb,nb) \
-    ret (CALLBACK *fn##xfn)(ICOM_INTERFACE* me,ta a,tb b);
-
-#define ICOM_METHOD3(ret,xfn,ta,na,tb,nb,tc,nc) \
-    ret (CALLBACK *fn##xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c);
-
-#define ICOM_METHOD4(ret,xfn,ta,na,tb,nb,tc,nc,td,nd) \
-    ret (CALLBACK *fn##xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d);
-
-#define ICOM_METHOD5(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne) \
-    ret (CALLBACK *fn##xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e);
-
-#define ICOM_METHOD6(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf) \
-    ret (CALLBACK *fn##xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f);
-
-#define ICOM_METHOD7(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng) \
-    ret (CALLBACK *fn##xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f,tg g);
-
-
-#define ICOM_CMETHOD(ret, xfn) \
-        ret (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me);
-
-#define ICOM_CMETHOD1(ret,xfn,ta,na) \
-    ret (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me,ta a);
-
-#define ICOM_CMETHOD2(ret,xfn,ta,na,tb,nb) \
-    ret (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me,ta a,tb b);
-
-#define ICOM_CMETHOD3(ret,xfn,ta,na,tb,nb,tc,nc) \
-    ret (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me,ta a,tb b,tc c);
-
-#define ICOM_CMETHOD4(ret,xfn,ta,na,tb,nb,tc,nc,td,nd) \
-    ret (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me,ta a,tb b,tc c,td d);
-
-#define ICOM_CMETHOD5(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne) \
-    ret (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e);
-
-#define ICOM_CMETHOD6(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf) \
-    ret (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f);
-
-#define ICOM_CMETHOD7(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng) \
-    ret (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f,tg g);
-
-#define ICOM_END(iface) \
-    };
-
-#define ICOM_ICALL(ibase, xfn, p)  ((ICOM_VTABLE(ibase)*)(p)->lpvtbl)->fn##xfn((ibase*)p)
-#define ICOM_ICALL1(ibase, xfn, p,a) ((ICOM_VTABLE(ibase)*)(p)->lpvtbl)->fn##xfn((ibase*)p,a)
-#define ICOM_ICALL2(ibase, xfn, p,a,b) ((ICOM_VTABLE(ibase)*)(p)->lpvtbl)->fn##xfn((ibase*)p,a,b)
-#define ICOM_ICALL3(ibase, xfn, p,a,b,c) ((ICOM_VTABLE(ibase)*)(p)->lpvtbl)->fn##xfn((ibase*)p,a,b,c)
-#define ICOM_ICALL4(ibase, xfn, p,a,b,c,d) ((ICOM_VTABLE(ibase)*)(p)->lpvtbl)->fn##xfn((ibase*)p,a,b,c,d)
-#define ICOM_ICALL5(ibase, xfn, p,a,b,c,d,e) ((ICOM_VTABLE(ibase)*)(p)->lpvtbl)->fn##xfn((ibase*)p,a,b,c,d,e)
-#define ICOM_ICALL6(ibase, xfn, p,a,b,c,d,e,f) ((ICOM_VTABLE(ibase)*)(p)->lpvtbl)->fn##xfn((ibase*)p,a,b,c,d,e,f)
-#define ICOM_ICALL7(ibase, xfn, p,a,b,c,d,e,f,g) ((ICOM_VTABLE(ibase)*)(p)->lpvtbl)->fn##xfn((ibase*)p,a,b,c,d,e,f,g)
-
-#define ICOM_CALL(xfn, p)  (p)->lpvtbl->fn##xfn(p)
-#define ICOM_CALL1(xfn, p,a) (p)->lpvtbl->fn##xfn(p,a)
-#define ICOM_CALL2(xfn, p,a,b) (p)->lpvtbl->fn##xfn(p,a,b)
-#define ICOM_CALL3(xfn, p,a,b,c) (p)->lpvtbl->fn##xfn(p,a,b,c)
-#define ICOM_CALL4(xfn, p,a,b,c,d) (p)->lpvtbl->fn##xfn(p,a,b,c,d)
-#define ICOM_CALL5(xfn, p,a,b,c,d,e) (p)->lpvtbl->fn##xfn(p,a,b,c,d,e)
-#define ICOM_CALL6(xfn, p,a,b,c,d,e,f) (p)->lpvtbl->fn##xfn(p,a,b,c,d,e,f)
-#define ICOM_CALL7(xfn, p,a,b,c,d,e,f,g) (p)->lpvtbl->fn##xfn(p,a,b,c,d,e,f,g)
-
-
-#define ICOM_THIS(iface,me)          struct _##iface* this=(struct _##iface*)me
-#define ICOM_CTHIS(iface,me)         const _##iface* this=(const _##iface*)me
-
-#endif
-
-
-/* FIXME: compobj.h seems to be obsolete (replaced by objbase.h!) but it still contains REFIID */
-#include "compobj.h"
-
-typedef struct IUnknown      IUnknown ,*LPUNKNOWN;
+/*****************************************************************************
+ * IMalloc interface
+ */
+/* private prototypes for the constructors */
+LPMALLOC16	IMalloc16_Constructor(void);
+LPMALLOC32	IMalloc32_Constructor(void);
 
 
 /*****************************************************************************
  * IUnknown interface
  */
-#define ICOM_INTERFACE IUnknown
-#if defined(__cplusplus) && !defined(CINTERFACE)
-struct IUnknown {
-    union {
-        const void* lpvtbl;
-        HRESULT (CALLBACK *fnQueryInterface)(IUnknown* me, REFIID riid, LPVOID* ppvObj);
-    } t;
-    inline int QueryInterface(REFIID a, LPVOID* b) { return ((IUnknown*)t.lpvtbl)->t.fnQueryInterface(this,a,b); }
-#else
-typedef struct ICOM_VTABLE(IUnknown) ICOM_VTABLE(IUnknown);
-struct IUnknown {
+
+typedef struct _IUnknown {
+    /* IUnknown fields */
     ICOM_VTABLE(IUnknown)* lpvtbl;
-};
-struct ICOM_VTABLE(IUnknown) {
-    ICOM_METHOD2(HRESULT,QueryInterface,REFIID,riid, LPVOID*,ppvObj)
-#endif
+    DWORD                  ref;
+} _IUnknown;
 
-    ICOM_METHOD (ULONG,AddRef)
-    ICOM_METHOD (ULONG,Release)
-#ifdef __WRC__
-}; /* FIXME: WRC does not support function macros and it is ICOM_END that is supposed to close the class */
-#else
-ICOM_END(IUnknown)
-#endif
-#undef ICOM_INTERFACE
-
-#if !defined(__cplusplus) || defined(CINTERFACE)
-/*** IUnknown methods ***/
-#define IUnknown_QueryInterface(p,a,b) ICOM_CALL2(QueryInterface,p,a,b)
-#define IUnknown_AddRef(p)             ICOM_CALL (AddRef,p)
-#define IUnknown_Release(p)            ICOM_CALL (Release,p)
-#endif
-
+LPUNKNOWN	IUnknown_Constructor(void);
 
 #endif /* __WINE_OBJBASE_H */
diff --git a/include/objidl.h b/include/objidl.h
new file mode 100644
index 0000000..a923c1e
--- /dev/null
+++ b/include/objidl.h
@@ -0,0 +1,22 @@
+#ifndef __WINE_OBJIDL_H
+#define __WINE_OBJIDL_H
+
+
+#include "wine/obj_base.h"
+
+/* the following depend only on obj_base.h */
+#include "wine/obj_misc.h"
+#include "wine/obj_channel.h"
+#include "wine/obj_clientserver.h"
+#include "wine/obj_marshal.h"
+#include "wine/obj_storage.h"
+
+/* the following depend on obj_storage.h */
+#include "wine/obj_moniker.h"
+#include "wine/obj_propertystorage.h"
+
+/* the following depend on obj_moniker.h */
+#include "wine/obj_dataobject.h"
+
+
+#endif /* __WINE_OBJIDL_H */
diff --git a/include/ole.h b/include/ole.h
index 0a368ef..e5d4fab 100644
--- a/include/ole.h
+++ b/include/ole.h
@@ -7,37 +7,18 @@
 
 #include "wingdi.h"
 
-typedef CHAR		OLECHAR16;
-typedef OLECHAR16	*BSTR16;
-typedef BSTR16		*LPBSTR16;
-typedef LPSTR		LPOLESTR16;
-typedef LPCSTR		LPCOLESTR16;
-typedef WCHAR		OLECHAR32;
-typedef OLECHAR32	*BSTR32;
-typedef BSTR32		*LPBSTR32;
-typedef LPWSTR		LPOLESTR32;
-typedef LPCWSTR		LPCOLESTR32;
-DECL_WINELIB_TYPE(OLECHAR)
-DECL_WINELIB_TYPE(LPOLESTR)
-DECL_WINELIB_TYPE(LPCOLESTR)
-DECL_WINELIB_TYPE(BSTR)
-DECL_WINELIB_TYPE(LPBSTR)
+/* FIXME: we need to include wtypes.h mainly, it seems, because we need BSTR. 
+ * Normally none of the APIs in ole.h depend on it. It is most likey that they should 
+ * be moved to ole2.h (which includes objbase.h and thus wtypes.h) or some other 
+ * OLE include
+ */
+#include "wtypes.h"
+
 
 #define OLESTR16(x) x
 #define OLESTR32(x) L##x	/* probably wrong */
 #define OLESTR WINELIB_NAME(OLESTR)
 
-typedef enum tagCLSCTX
-{
-    CLSCTX_INPROC_SERVER   = 0x1,
-    CLSCTX_INPROC_HANDLER  = 0x2,
-    CLSCTX_LOCAL_SERVER    = 0x4,
-    CLSCTX_REMOTE_SERVER   = 0x10
-} CLSCTX;
-
-#define CLSCTX_SERVER (CLSCTX_INPROC_SERVER|CLSCTX_LOCAL_SERVER|CLSCTX_REMOTE_SERVER)
-#define CLSCTX_ALL    (CLSCTX_INPROC_HANDLER|CLSCTX_SERVER)
-
 typedef unsigned short VARTYPE;
 typedef LONG DISPID;
 
diff --git a/include/ole2.h b/include/ole2.h
index dc604c4..c91c9ae 100644
--- a/include/ole2.h
+++ b/include/ole2.h
@@ -6,18 +6,15 @@
 #define __WINE_OLE2_H
 
 /* to be implemented */
-typedef LPVOID LPMESSAGEFILTER;
+/* FIXME: this should be defined somewhere in oleidl.h instead, should it be repeated here ? */
 typedef LPVOID LPDROPTARGET;
-typedef struct tagMONIKER *LPMONIKER, IMoniker;
 
-#define S_OK	0
-#define S_FALSE	1
 
 /* OLE version */
 #define rmm             23
 #define rup            639
 
-/* FIXME should be in oleidl.h*/
+/* FIXME: should be in oleidl.h */
 typedef struct  tagOleMenuGroupWidths
 { LONG width[ 6 ];
 } OLEMENUGROUPWIDTHS32;
diff --git a/include/oleobj.h b/include/oleobj.h
index ab21084..d846d97 100644
--- a/include/oleobj.h
+++ b/include/oleobj.h
@@ -3,8 +3,10 @@
 
 #include "ole.h"
 #include "ole2.h"
-#include "compobj.h"
-/* #include "interfaces.h" */
+#include "wine/obj_base.h"
+#include "wine/obj_storage.h"
+#include "wine/obj_moniker.h"
+#include "wine/obj_dataobject.h"
 
 #define STDMETHOD(xfn) HRESULT (CALLBACK *fn##xfn)
 #define STDMETHOD_(type,xfn) type (CALLBACK *fn##xfn)
@@ -14,8 +16,6 @@
 
 /* forward declaration of the objects*/
 typedef struct tagOLEADVISEHOLDER	*LPOLEADVISEHOLDER,	IOleAdviseHolder;
-typedef struct tagADVISESINK		*LPADVISESINK,		IAdviseSink;
-typedef struct tagENUMSTATDATA		*LPENUMSTATDATA,	IEnumSTATDATA;
 
 
 /****************************************************************************
diff --git a/include/options.h b/include/options.h
index 9a09ecb..84150fc 100644
--- a/include/options.h
+++ b/include/options.h
@@ -92,6 +92,7 @@
 extern char* PROFILE_GetStringItem( char* );
 
 /* Version functions */
-extern void VERSION_ParseVersion( char *arg );
+extern void VERSION_ParseWinVersion( const char *arg );
+extern void VERSION_ParseDosVersion( const char *arg );
 
 #endif  /* __WINE_OPTIONS_H */
diff --git a/include/propsheet.h b/include/propsheet.h
new file mode 100644
index 0000000..0a42159
--- /dev/null
+++ b/include/propsheet.h
@@ -0,0 +1,21 @@
+/*
+ * Property sheet class extra info
+ *
+ * Copyright 1998 Anders Carlsson
+ */
+
+#ifndef __WINE_PROPSHEET_H  
+#define __WINE_PROPSHEET_H
+
+typedef struct tagPROPSHEET_INFO
+{
+    DWORD dwDummy;  /* just to keep the compiler happy ;-) */
+
+} PROPSHEET_INFO, *LPPROPSHEET_INFO;
+
+
+
+extern VOID PROPSHEET_Register (VOID);
+extern VOID PROPSHEET_UnRegister (VOID);
+
+#endif  /* __WINE_PROPSHEET_H */
diff --git a/include/servprov.h b/include/servprov.h
new file mode 100644
index 0000000..6df57b3
--- /dev/null
+++ b/include/servprov.h
@@ -0,0 +1,34 @@
+#ifndef __WINE_SERVPROV_H
+#define __WINE_SERVPROV_H
+
+
+#include "unknwn.h"
+
+
+/*****************************************************************************
+ * Predeclare the interfaces
+ */
+DEFINE_GUID   (IID_IServiceProvider,	0x6d5140c1L, 0x7436, 0x11ce, 0x80, 0x34, 0x00, 0xaa, 0x00, 0x60, 0x09, 0xfa);
+typedef struct IServiceProvider IServiceProvider,*LPSERVICEPROVIDER;
+
+
+/*****************************************************************************
+ * IServiceProvider interface
+ */
+#define ICOM_INTERFACE IServiceProvider
+ICOM_BEGIN(IServiceProvider,IUnknown)
+    ICOM_METHOD3(HRESULT,QueryService, REFGUID,guidService, REFIID,riid, void**,ppvObject);
+ICOM_END(IServiceProvider)
+#undef ICOM_INTERFACE
+
+#if !defined(__cplusplus) || defined(CINTERFACE)
+/*** IUnknown methods ***/
+#define IServiceProvider_QueryInterface(p,a,b) ICOM_ICALL2(IUnknown,QueryInterface,p,a,b)
+#define IServiceProvider_AddRef(p)             ICOM_ICALL (IUnknown,AddRef,p)
+#define IServiceProvider_Release(p)            ICOM_ICALL (IUnknown,Release,p)
+/*** IServiceProvider methods ***/
+#define IServiceProvider_QueryService(p,a,b,c) ICOM_CALL3(QueryService,p,a,b,c)
+#endif
+
+
+#endif /* __WINE_SERVPROV_H */
diff --git a/include/shell.h b/include/shell.h
index c19af49..2b5cdf6 100644
--- a/include/shell.h
+++ b/include/shell.h
@@ -4,13 +4,10 @@
 #ifndef __WINE_SHELL_H
 #define __WINE_SHELL_H
 
-#include "wintypes.h"
+#include "windows.h"
 #include "winreg.h"
 #include "imagelist.h"
 
-#ifndef MAX_PATH
-#define MAX_PATH 260
-#endif
 
 /****************************************************************************
 * shell 16
@@ -247,6 +244,11 @@
 /****************************************************************************
 *  string and path functions
 */
+BOOL32 WINAPI PathIsRoot32A(LPCSTR x);
+BOOL32 WINAPI PathIsRoot32W(LPCWSTR x);
+#define  PathIsRoot WINELIB_NAME_AW(PathIsRoot)
+BOOL32 WINAPI PathIsRoot32AW(LPCVOID x);
+
 LPSTR  WINAPI PathAddBackslash32A(LPSTR path);	
 LPWSTR WINAPI PathAddBackslash32W(LPWSTR path);	
 #define  PathAddBackslash WINELIB_NAME_AW(PathAddBackslash)
diff --git a/include/shlguid.h b/include/shlguid.h
new file mode 100644
index 0000000..3f6a853
--- /dev/null
+++ b/include/shlguid.h
@@ -0,0 +1,13 @@
+#ifndef __WINE_SHLGUID_H
+#define __WINE_SHLGUID_H
+
+
+/* This file defines the GUID of the shell objects. In WINE we define
+ * the GUIDs where the interface is declared so this file just 
+ * includes shlobj.h
+ */
+
+#include "shlobj.h"
+
+
+#endif /* __WINE_SHLGUID_H */
diff --git a/include/shlobj.h b/include/shlobj.h
index 8f82309..c741985 100644
--- a/include/shlobj.h
+++ b/include/shlobj.h
@@ -1,15 +1,13 @@
-#ifndef _WINE_SHLOBJ_H
-#define _WINE_SHLOBJ_H
+#ifndef __WINE_SHLOBJ_H
+#define __WINE_SHLOBJ_H
 
+#include "wine/obj_base.h"
 #include "shell.h"
 #include "ole.h"
 #include "ole2.h"
-#include "compobj.h"
 #include "oleobj.h"
-#include "storage.h"
 #include "commctrl.h"
 #include "wintypes.h"
-#include "interfaces.h"
 
 #define STDMETHOD(xfn) HRESULT (CALLBACK *fn##xfn)
 #define STDMETHOD_(type,xfn) type (CALLBACK *fn##xfn)
@@ -23,22 +21,19 @@
 DWORD WINAPI SHELL32_DllGetClassObject(LPCLSID,REFIID,LPVOID*);
 
 
-typedef LPVOID	LPBC; /* *IBindCtx really */
 
 /* foreward declaration of the objects*/
-typedef struct tagPERSISTFILE	*LPPERSISTFILE,	IPersistFile;
 typedef struct tagCONTEXTMENU	*LPCONTEXTMENU,	IContextMenu;
 typedef struct tagSHELLEXTINIT	*LPSHELLEXTINIT,IShellExtInit;
 typedef struct tagENUMIDLIST	*LPENUMIDLIST,	IEnumIDList;
 typedef struct tagSHELLFOLDER	*LPSHELLFOLDER,	IShellFolder;
 typedef struct tagSHELLVIEW	*LPSHELLVIEW,	IShellView;
 typedef struct tagSHELLBROWSER	*LPSHELLBROWSER,IShellBrowser;
-typedef struct tagDATAOBJECT	*LPDATAOBJECT,	IDataObject;
 typedef struct tagSHELLICON	*LPSHELLICON,	IShellIcon;
 typedef struct tagDOCKINGWINDOWFRAME	*LPDOCKINGWINDOWFRAME,	IDockingWindowFrame;
-typedef struct tagSERVICEPROVIDER	*LPSERVICEPROVIDER,	IServiceProvider;
 typedef struct tagCOMMDLGBROWSER	*LPCOMMDLGBROWSER,	ICommDlgBrowser;
-typedef struct tagENUMFORMATETC	*LPENUMFORMATETC,	IEnumFORMATETC;
+ 
+
  
 /****************************************************************************
 *  SHELL ID
@@ -47,24 +42,13 @@
 DEFINE_GUID (IID_MyComputer,		0x20D04FE0L, 0x3AEA, 0x1069, 0xA2, 0xD8, 0x08, 0x00, 0x2B, 0x30, 0x30, 0x9D);
 
 /* strange Objects */
-DEFINE_SHLGUID(IID_IEnumUnknown,	0x00000100L, 0, 0);
-DEFINE_SHLGUID(IID_IEnumString,		0x00000101L, 0, 0);
-DEFINE_SHLGUID(IID_IEnumMoniker,	0x00000102L, 0, 0);
-DEFINE_SHLGUID(IID_IEnumFORMATETC,	0x00000103L, 0, 0);
 DEFINE_SHLGUID(IID_IEnumOLEVERB,	0x00000104L, 0, 0);
-DEFINE_SHLGUID(IID_IEnumSTATDATA,	0x00000105L, 0, 0);
 
-DEFINE_SHLGUID(IID_IPersistStream,	0x00000109L, 0, 0);
-DEFINE_SHLGUID(IID_IPersistStorage,	0x0000010AL, 0, 0);
-DEFINE_SHLGUID(IID_IPersistFile,	0x0000010BL, 0, 0);
-DEFINE_SHLGUID(IID_IPersist,		0x0000010CL, 0, 0);
 DEFINE_SHLGUID(IID_IViewObject,		0x0000010DL, 0, 0);
-DEFINE_SHLGUID(IID_IDataObject,		0x0000010EL, 0, 0);
 
 DEFINE_SHLGUID(IID_IDropSource,		0x00000121L, 0, 0);
 DEFINE_SHLGUID(IID_IDropTarget,		0x00000122L, 0, 0);
 
-DEFINE_GUID (IID_IServiceProvider,	0x6D5140C1L, 0x7436, 0x11CE, 0x80, 0x34, 0x00, 0xAA, 0x00, 0x60, 0x09, 0xFA);
 DEFINE_GUID (IID_IDockingWindow,	0x012dd920L, 0x7B26, 0x11D0, 0x8C, 0xA9, 0x00, 0xA0, 0xC9, 0x2D, 0xBF, 0xE8);
 DEFINE_GUID (IID_IDockingWindowSite,	0x2A342FC2L, 0x7B26, 0x11D0, 0x8C, 0xA9, 0x00, 0xA0, 0xC9, 0x2D, 0xBF, 0xE8);
 DEFINE_GUID (IID_IDockingWindowFrame,	0x47D2657AL, 0x7B27, 0x11D0, 0x8C, 0xA9, 0x00, 0xA0, 0xC9, 0x2D, 0xBF, 0xE8);
@@ -127,31 +111,8 @@
     WCHAR	cStrW[MAX_PATH];
   }u;
 } STRRET,*LPSTRRET;
-/*****************************************************************************
- * IPersistFile interface
- */
-#define THIS LPPERSISTFILE this
-typedef struct IPersistFile_VTable
-{   /* *** IUnknown methods *** */
-    STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID * ppvObj) PURE;
-    STDMETHOD_(ULONG,AddRef) (THIS)  PURE;
-    STDMETHOD_(ULONG,Release) (THIS) PURE;
 
-    STDMETHOD(GetClassID )(THIS_ CLSID *pClassID) PURE;
-    STDMETHOD(IsDirty )(THIS) PURE;
-    STDMETHOD(Load )(THIS_ LPCOLESTR32 pszFileName, DWORD dwMode) PURE;
-    STDMETHOD(Save )(THIS_ LPCOLESTR32 pszFileName, BOOL32 fRemember) PURE;
-    STDMETHOD(SaveCompleted )(THIS_ LPCOLESTR32 pszFileName) PURE;
-    STDMETHOD(GetCurFile )(THIS_ LPOLESTR32 *ppszFileName) PURE;
 
-} IPersistFile_VTable,*LPPERSISTFILE_VTABLE;
-
-struct tagPERSISTFILE
-{ LPPERSISTFILE_VTABLE	lpvtbl;
-  DWORD			ref;
-};
-
-#undef THIS
 /*****************************************************************************
  * IContextMenu interface
  */
@@ -282,52 +243,6 @@
         DVASPECT_DOCPRINT	= 8
 } DVASPECT;
 
-typedef enum tagTYMED
-{	TYMED_HGLOBAL   = 1,
-	TYMED_FILE      = 2,
-	TYMED_ISTREAM   = 4,
-	TYMED_ISTORAGE  = 8,
-	TYMED_GDI       = 16,
-	TYMED_MFPICT    = 32,
-	TYMED_ENHMF     = 64,
-	TYMED_NULL      = 0
-} TYMED;
-  
-typedef struct
-{	DWORD tdSize;
-	WORD tdDriverNameOffset;
-	WORD tdDeviceNameOffset;
-	WORD tdPortNameOffset;
-	WORD tdExtDevmodeOffset;
-	BYTE tdData[ 1 ];
-} DVTARGETDEVICE32;
-
-typedef WORD CLIPFORMAT32, *LPCLIPFORMAT32;
-
-/* dataobject as answer to a request */
-typedef struct 
-{	DWORD tymed;
-	union 
-	{ HBITMAP32 hBitmap;
-	  /*HMETAFILEPICT32 hMetaFilePict;*/
-	  /*HENHMETAFILE32 hEnhMetaFile;*/
-	  HGLOBAL32 hGlobal;
-	  LPOLESTR32 lpszFileName;
-	  IStream32 *pstm;
-	  IStorage32 *pstg;
-        } u;
-	IUnknown *pUnkForRelease;
-} STGMEDIUM32;   
-
-/* wished data format */
-typedef struct 
-{	CLIPFORMAT32 cfFormat;
-	DVTARGETDEVICE32 *ptd;
-	DWORD dwAspect;
-	LONG lindex;
-	DWORD tymed;
-} FORMATETC32, *LPFORMATETC32;
-
 /* shell specific clipboard formats */
 
 /* DATAOBJECT_InitShellIDList*/
@@ -399,65 +314,6 @@
 extern LPIDLLIST IDLList_Constructor (UINT32 uStep);
 extern void IDLList_Destructor(LPIDLLIST this);
 #undef THIS
-/*****************************************************************************
- * IEnumFORMATETC interface
- */
-#define THIS LPENUMFORMATETC this
-
-typedef struct IEnumFORMATETC_VTable 
-{    /* IUnknown methods */
-	STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID * ppvObj) PURE;
-	STDMETHOD_(ULONG,AddRef) (THIS) PURE;
-	STDMETHOD_(ULONG,Release) (THIS) PURE;
-
-	/* IEnumFORMATETC methods */
-	STDMETHOD (Next)(THIS_ ULONG celt, FORMATETC32 *rgelt, ULONG *pceltFethed) PURE;
-	STDMETHOD (Skip)(THIS_ ULONG celt) PURE;
-	STDMETHOD (Reset)(THIS) PURE;
-	STDMETHOD (Clone)(THIS_ IEnumFORMATETC ** ppenum) PURE;
-} IEnumFORMATETC_VTable,*LPENUMFORMATETC_VTABLE;
-
-struct tagENUMFORMATETC
-{	LPENUMFORMATETC_VTABLE	lpvtbl;
-	DWORD			 ref;
-        UINT32	posFmt;
-        UINT32	countFmt;
-        LPFORMATETC32 pFmt;
-};
-
-#undef THIS
-
-/*****************************************************************************
- * IDataObject interface
- */
-#define THIS LPDATAOBJECT this
-
-typedef struct IDataObject_VTable 
-{	/*** IUnknown methods ***/
-	STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID * ppvObj) PURE;
-	STDMETHOD_(ULONG,AddRef) (THIS) PURE;
-	STDMETHOD_(ULONG,Release) (THIS) PURE;
-
-	STDMETHOD (GetData )(THIS_ LPFORMATETC32 pformatetcIn, STGMEDIUM32 *pmedium) PURE;
-	STDMETHOD (GetDataHere)(THIS_ LPFORMATETC32 pformatetc, STGMEDIUM32 *pmedium) PURE;
-        STDMETHOD (QueryGetData)(THIS_ LPFORMATETC32 pformatetc) PURE;
-        STDMETHOD (GetCanonicalFormatEtc)(THIS_ LPFORMATETC32 pformatectIn, LPFORMATETC32 pformatetcOut) PURE;
-        STDMETHOD (SetData)(THIS_ LPFORMATETC32 pformatetc, STGMEDIUM32 *pmedium, BOOL32 fRelease) PURE;
-        STDMETHOD (EnumFormatEtc)(THIS_ DWORD dwDirection, IEnumFORMATETC **ppenumFormatEtc) PURE;
-        STDMETHOD (DAdvise )(THIS_ LPFORMATETC32 *pformatetc, DWORD advf, IAdviseSink *pAdvSink, DWORD *pdwConnection) PURE;
-        STDMETHOD (DUnadvise)(THIS_ DWORD dwConnection) PURE;
-        STDMETHOD (EnumDAdvise)(THIS_ IEnumSTATDATA **ppenumAdvise) PURE;
-} IDataObject_VTable,*LPDATAOBJECT_VTABLE;
-
-struct tagDATAOBJECT
-{	LPDATAOBJECT_VTABLE	lpvtbl;
-	DWORD	ref;
-	LPSHELLFOLDER	psf;
-	LPIDLLIST  lpill;	/* the data of the dataobject */
-	LPITEMIDLIST  pidl;	
-};
-
-#undef THIS
 
 
 /*****************************************************************************
@@ -1108,24 +964,6 @@
 
 #undef THIS
 /****************************************************************************
- * IServiceProvider interface
- */
-#define THIS LPSERVICEPROVIDER this
-
-typedef struct IServiceProvider_VTable
-{	/*** IUnknown methods ***/
-	STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID * ppvObj) PURE;
-	STDMETHOD_(ULONG,AddRef) (THIS)  PURE;
-	STDMETHOD_(ULONG,Release) (THIS) PURE;
-
-	STDMETHOD(QueryService)(THIS_ REFGUID guidService, REFIID riid, void **ppvObject);
-} IServiceProvider_VTable, *LPSERVICEPROVIDER_VTABLE;
-
-struct tagSERVICEPROVIDER
-{	LPSERVICEPROVIDER_VTABLE lpvtbl;
-	DWORD ref;
-};           
-/****************************************************************************
  * Shell Execute API
  */
 #define SE_ERR_FNF              2       /* file not found */
@@ -1389,4 +1227,5 @@
 #undef THIS_
 #undef STDMETHOD
 #undef STDMETHOD_
-#endif /*_WINE_SHLOBJ_H*/
+
+#endif /* __WINE_SHLOBJ_H */
diff --git a/include/storage.h b/include/storage.h
index 678ea76..10fd693 100644
--- a/include/storage.h
+++ b/include/storage.h
@@ -1,254 +1,8 @@
 #ifndef __WINE_STORAGE_H
 #define __WINE_STORAGE_H
 
+/* "storage.h" is obsolete, you should include "objbase.h" instead */
+  
 #include "objbase.h"
-#include "windows.h"
-
-/* Does this look like a cellar to you? */
-
-struct storage_header {
-	BYTE	magic[8];	/* 00: magic */
-	BYTE	unknown1[36];	/* 08: unknown */
-	DWORD	num_of_bbd_blocks;/* 2C: length of big datablocks */
-	DWORD	root_startblock;/* 30: root storage first big block */
-	DWORD	unknown2[2];	/* 34: unknown */
-	DWORD	sbd_startblock;	/* 3C: small block depot first big block */
-	DWORD	unknown3[3];	/* 40: unknown */
-	DWORD	bbd_list[109];	/* 4C: big data block list (up to end of sector)*/
-};
-struct storage_pps_entry {
-	WCHAR	pps_rawname[32];/* 00: \0 terminated widechar name */
-	WORD	pps_sizeofname;	/* 40: namelength in bytes */
-	BYTE	pps_type;	/* 42: flags, 1 storage/dir, 2 stream, 5 root */
-	BYTE	pps_unknown0;	/* 43: unknown */
-	DWORD	pps_prev;	/* 44: previous pps */
-	DWORD	pps_next;	/* 48: next pps */
-	DWORD	pps_dir;	/* 4C: directory pps */
-	GUID	pps_guid;	/* 50: class ID */
-	DWORD	pps_unknown1;	/* 60: unknown */
-	FILETIME pps_ft1;	/* 64: filetime1 */
-	FILETIME pps_ft2;	/* 70: filetime2 */
-	DWORD	pps_sb;		/* 74: data startblock */
-	DWORD	pps_size;	/* 78: datalength. (<0x1000)?small:big blocks*/
-	DWORD	pps_unknown2;	/* 7C: unknown */
-};
-
-#define STORAGE_CHAINENTRY_FAT		0xfffffffd
-#define STORAGE_CHAINENTRY_ENDOFCHAIN	0xfffffffe
-#define STORAGE_CHAINENTRY_FREE		0xffffffff
-
-typedef LPOLESTR16 *SNB16;
-typedef LPOLESTR32 *SNB32;
-DECL_WINELIB_TYPE(SNB)
-
-typedef struct IStorage16 IStorage16,*LPSTORAGE16;
-typedef struct IStorage32 IStorage32,*LPSTORAGE32;
-typedef struct IStream16 IStream16,*LPSTREAM16;
-typedef struct IStream32 IStream32,*LPSTREAM32;
-
-typedef struct IEnumSTATSTG IEnumSTATSTG,*LPENUMSTATSTG;
-
-typedef struct {
-    LPOLESTR16	pwcsName;
-    DWORD	type;
-    ULARGE_INTEGER cbSize;
-    FILETIME	mtime;
-    FILETIME	ctime;
-    FILETIME	atime;
-    DWORD	grfMode;
-    DWORD	grfLocksSupported;
-    CLSID	clsid;
-    DWORD	grfStateBits;
-    DWORD	reserved;
-} STATSTG;
-
-#define STGM_DIRECT		0x00000000
-#define STGM_TRANSACTED		0x00010000
-#define STGM_SIMPLE		0x08000000
-#define STGM_READ		0x00000000
-#define STGM_WRITE		0x00000001
-#define STGM_READWRITE		0x00000002
-#define STGM_SHARE_DENY_NONE	0x00000040
-#define STGM_SHARE_DENY_READ	0x00000030
-#define STGM_SHARE_DENY_WRITE	0x00000020
-#define STGM_SHARE_EXCLUSIVE	0x00000010
-#define STGM_PRIORITY		0x00040000
-#define STGM_DELETEONRELEASE	0x04000000
-#define STGM_NOSCRATCH		0x00100000
-#define STGM_CREATE		0x00001000
-#define STGM_CONVERT		0x00020000
-#define STGM_FAILIFTHERE	0x00000000
-
-
-/*****************************************************************************
- * IStorage16 interface
- */
-#define ICOM_INTERFACE IStorage16
-ICOM_BEGIN(IStorage16,IUnknown)
-    ICOM_METHOD5(HRESULT,CreateStream,   LPCOLESTR16,pwcsName, DWORD,grfMode, DWORD,reserved1, DWORD,reserved2, IStream16**,ppstm)
-    ICOM_METHOD5(HRESULT,OpenStream,     LPCOLESTR16,pwcsName, void*,reserved1, DWORD,grfMode, DWORD,reserved2, IStream16**,ppstm)
-    ICOM_METHOD5(HRESULT,CreateStorage,  LPCOLESTR16,pwcsName, DWORD,grfMode, DWORD,dwStgFmt, DWORD,reserved2, IStorage16**,ppstg)
-    ICOM_METHOD6(HRESULT,OpenStorage,    LPCOLESTR16,pwcsName, IStorage16*,pstgPriority, DWORD,grfMode, SNB16,snb16Exclude, DWORD,reserved, IStorage16**,ppstg)
-    ICOM_METHOD4(HRESULT,CopyTo,         DWORD,ciidExclude, const IID*,rgiidExclude, SNB16,snb16Exclude, IStorage16*,pstgDest)
-    ICOM_METHOD4(HRESULT,MoveElementTo,  LPCOLESTR16,pwcsName, IStorage16*,pstgDest, LPCOLESTR16,pwcsNewName, DWORD,grfFlags)
-    ICOM_METHOD1(HRESULT,Commit,         DWORD,grfCommitFlags)
-    ICOM_METHOD (HRESULT,Revert)
-    ICOM_METHOD4(HRESULT,EnumElements,   DWORD,reserved1, void*,reserved2, DWORD,reserved3, IEnumSTATSTG**,ppenum)
-    ICOM_METHOD1(HRESULT,DestroyElement, LPCOLESTR16,pwcsName)
-    ICOM_METHOD2(HRESULT,RenameElement,  LPCOLESTR16,pwcsOldName, LPCOLESTR16,pwcsNewName)
-    ICOM_METHOD4(HRESULT,SetElementTimes,LPCOLESTR16,pwcsName, const FILETIME*,pctime, const FILETIME*,patime, const FILETIME*,pmtime)
-    ICOM_METHOD1(HRESULT,SetClass,       REFCLSID,clsid)
-    ICOM_METHOD2(HRESULT,SetStateBits,   DWORD,grfStateBits, DWORD,grfMask)
-    ICOM_METHOD2(HRESULT,Stat,           STATSTG*,pstatstg, DWORD,grfStatFlag)
-ICOM_END(IStorage16)
-#undef ICOM_INTERFACE
-
-#if !defined(__cplusplus) || defined(CINTERFACE)
-/*** IUnknown methods ***/
-#define IStorage16_QueryInterface(p,a,b) ICOM_ICALL2(QueryInterface,p,a,b)
-#define IStorage16_AddRef(p)             ICOM_ICALL (AddRef,p)
-#define IStorage16_Release(p)            ICOM_ICALL (Release,p)
-/*** IStorage16 methods ***/
-#define IStorage16_CreateStream(p,a,b,c,d,e)  ICOM_CALL5(CreateStream,p,a,b,c,d,e)
-#define IStorage16_OpenStream(p,a,b,c,d,e)    ICOM_CALL5(OpenStream,p,a,b,c,d,e)
-#define IStorage16_CreateStorage(p,a,b,c,d,e) ICOM_CALL5(CreateStorage,p,a,b,c,d,e)
-#define IStorage16_OpenStorage(p,a,b,c,d,e,f) ICOM_CALL6(OpenStorage,p,a,b,c,d,e,f)
-#define IStorage16_CopyTo(p,a,b,c,d)          ICOM_CALL4(CopyTo,p,a,b,c,d)
-#define IStorage16_MoveElementTo(p,a,b,c,d)   ICOM_CALL4(MoveElementTo,p,a,b,c,d)
-#define IStorage16_Commit(p,a)                ICOM_CALL1(Commit,p,a)
-#define IStorage16_Revert(p)                  ICOM_CALL (Revert,p)
-#define IStorage16_EnumElements(p,a,b,c,d)    ICOM_CALL4(EnumElements,p,a,b,c,d)
-#define IStorage16_DestroyElement(p,a)        ICOM_CALL1(DestroyElement,p,a)
-#define IStorage16_RenameElement(p,a,b)       ICOM_CALL2(RenameElement,p,a,b)
-#define IStorage16_SetElementTimes(p,a,b,c,d) ICOM_CALL4(SetElementTimes,p,a,b,c,d)
-#define IStorage16_SetClass(p,a)              ICOM_CALL1(SetClass,p,a)
-#define IStorage16_SetStateBits(p,a,b)        ICOM_CALL2(SetStateBits,p,a,b)
-#define IStorage16_Stat(p,a,b)                ICOM_CALL2(Stat,p,a,b)
-#endif
-
-
-/*****************************************************************************
- * IStorage32 interface
- */
-#define ICOM_INTERFACE IStorage32
-ICOM_BEGIN(IStorage32,IUnknown)
-    ICOM_METHOD5(HRESULT,CreateStream,   LPCOLESTR32,pwcsName, DWORD,grfMode, DWORD,reserved1, DWORD,reserved2, IStream32**,ppstm)
-    ICOM_METHOD5(HRESULT,OpenStream,     LPCOLESTR32,pwcsName, void*,reserved1, DWORD,grfMode, DWORD,reserved2, IStream32**,ppstm)
-    ICOM_METHOD5(HRESULT,CreateStorage,  LPCOLESTR32,pwcsName, DWORD,grfMode, DWORD,dwStgFmt, DWORD,reserved2, IStorage32**,ppstg)
-    ICOM_METHOD6(HRESULT,OpenStorage,    LPCOLESTR32,pwcsName, IStorage32*,pstgPriority, DWORD,grfMode, SNB32,snb16Exclude, DWORD,reserved, IStorage32**,ppstg)
-    ICOM_METHOD4(HRESULT,CopyTo,         DWORD,ciidExclude, const IID*,rgiidExclude, SNB32,snb16Exclude, IStorage32*,pstgDest)
-    ICOM_METHOD4(HRESULT,MoveElementTo,  LPCOLESTR32,pwcsName, IStorage32*,pstgDest, LPCOLESTR32,pwcsNewName, DWORD,grfFlags)
-    ICOM_METHOD1(HRESULT,Commit,         DWORD,grfCommitFlags)
-    ICOM_METHOD (HRESULT,Revert)
-    ICOM_METHOD4(HRESULT,EnumElements,   DWORD,reserved1, void*,reserved2, DWORD,reserved3, IEnumSTATSTG**,ppenum)
-    ICOM_METHOD1(HRESULT,DestroyElement, LPCOLESTR32,pwcsName)
-    ICOM_METHOD2(HRESULT,RenameElement,  LPCOLESTR32,pwcsOldName, LPCOLESTR32,pwcsNewName)
-    ICOM_METHOD4(HRESULT,SetElementTimes,LPCOLESTR32,pwcsName, const FILETIME*,pctime, const FILETIME*,patime, const FILETIME*,pmtime)
-    ICOM_METHOD1(HRESULT,SetClass,       REFCLSID,clsid)
-    ICOM_METHOD2(HRESULT,SetStateBits,   DWORD,grfStateBits, DWORD,grfMask)
-    ICOM_METHOD2(HRESULT,Stat,           STATSTG*,pstatstg, DWORD,grfStatFlag)
-ICOM_END(IStorage32)
-#undef ICOM_INTERFACE
-
-#if !defined(__cplusplus) || defined(CINTERFACE)
-/*** IUnknown methods ***/
-#define IStorage32_QueryInterface(p,a,b) ICOM_ICALL2(QueryInterface,p,a,b)
-#define IStorage32_AddRef(p)             ICOM_ICALL (AddRef,p)
-#define IStorage32_Release(p)            ICOM_ICALL (Release,p)
-/*** IStorage32 methods ***/
-#define IStorage32_CreateStream(p,a,b,c,d,e)  ICOM_CALL5(CreateStream,p,a,b,c,d,e)
-#define IStorage32_OpenStream(p,a,b,c,d,e)    ICOM_CALL5(OpenStream,p,a,b,c,d,e)
-#define IStorage32_CreateStorage(p,a,b,c,d,e) ICOM_CALL5(CreateStorage,p,a,b,c,d,e)
-#define IStorage32_OpenStorage(p,a,b,c,d,e,f) ICOM_CALL6(OpenStorage,p,a,b,c,d,e,f)
-#define IStorage32_CopyTo(p,a,b,c,d)          ICOM_CALL4(CopyTo,p,a,b,c,d)
-#define IStorage32_MoveElementTo(p,a,b,c,d)   ICOM_CALL4(MoveElementTo,p,a,b,c,d)
-#define IStorage32_Commit(p,a)                ICOM_CALL1(Commit,p,a)
-#define IStorage32_Revert(p)                  ICOM_CALL (Revert,p)
-#define IStorage32_EnumElements(p,a,b,c,d)    ICOM_CALL4(EnumElements,p,a,b,c,d)
-#define IStorage32_DestroyElement(p,a)        ICOM_CALL1(DestroyElement,p,a)
-#define IStorage32_RenameElement(p,a,b)       ICOM_CALL2(RenameElement,p,a,b)
-#define IStorage32_SetElementTimes(p,a,b,c,d) ICOM_CALL4(SetElementTimes,p,a,b,c,d)
-#define IStorage32_SetClass(p,a)              ICOM_CALL1(SetClass,p,a)
-#define IStorage32_SetStateBits(p,a,b)        ICOM_CALL2(SetStateBits,p,a,b)
-#define IStorage32_Stat(p,a,b)                ICOM_CALL2(Stat,p,a,b)
-#endif
-
-
-/*****************************************************************************
- * IStream16 interface
- */
-#define ICOM_INTERFACE IStream16
-ICOM_BEGIN(IStream16,IUnknown)
-    ICOM_METHOD3(HRESULT,Read,        void*,pv, ULONG,cb, ULONG*,pcbRead)
-    ICOM_METHOD3(HRESULT,Write,       const void*,pv, ULONG,cb, ULONG*,pcbWritten)
-    ICOM_METHOD3(HRESULT,Seek,        LARGE_INTEGER,dlibMove, DWORD,dwOrigin, ULARGE_INTEGER*,plibNewPosition)
-    ICOM_METHOD1(HRESULT,SetSize,     ULARGE_INTEGER,libNewSize)
-    ICOM_METHOD4(HRESULT,CopyTo,      IStream16*,pstm, ULARGE_INTEGER,cb, ULARGE_INTEGER*,pcbRead, ULARGE_INTEGER*,pcbWritten)
-    ICOM_METHOD1(HRESULT,Commit,      DWORD,grfCommitFlags)
-    ICOM_METHOD (HRESULT,Revert)
-    ICOM_METHOD3(HRESULT,LockRegion,  ULARGE_INTEGER,libOffset, ULARGE_INTEGER,cb, DWORD,dwLockType)
-    ICOM_METHOD3(HRESULT,UnlockRegion,ULARGE_INTEGER,libOffset, ULARGE_INTEGER,cb, DWORD,dwLockType)
-    ICOM_METHOD2(HRESULT,Stat,        STATSTG*,pstatstg, DWORD,grfStatFlag)
-    ICOM_METHOD1(HRESULT,Clone,       IStream16**,ppstm)
-ICOM_END(IStream16)
-#undef ICOM_INTERFACE
-
-#if !defined(__cplusplus) || defined(CINTERFACE)
-/*** IUnknown methods ***/
-#define IStream16_QueryInterface(p,a,b) ICOM_ICALL2(QueryInterface,p,a,b)
-#define IStream16_AddRef(p)             ICOM_ICALL (AddRef,p)
-#define IStream16_Release(p)            ICOM_ICALL (Release,p)
-/*** IStream16 methods ***/
-#define IStream16_Read(p,a,b,c)         ICOM_CALL3(Read,p,a,b,c)
-#define IStream16_Write(p,a,b,c)        ICOM_CALL3(Write,p,a,b,c)
-#define IStream16_Seek(p)               ICOM_CALL3(Seek,p)
-#define IStream16_SetSize(p,a,b)        ICOM_CALL1(SetSize,p,a,b)
-#define IStream16_CopyTo(pa,b,c,d)      ICOM_CALL4(CopyTo,pa,b,c,d)
-#define IStream16_Commit(p,a)           ICOM_CALL1(Commit,p,a)
-#define IStream16_Revert(p)             ICOM_CALL (Revert,p)
-#define IStream16_LockRegion(pa,b,c)    ICOM_CALL3(LockRegion,pa,b,c)
-#define IStream16_UnlockRegion(p,a,b,c) ICOM_CALL3(UnlockRegion,p,a,b,c)
-#define IStream16_Stat(p,a,b)           ICOM_CALL2(Stat,p,a,b)
-#define IStream16_Clone(p,a)            ICOM_CALL1(Clone,p,a)
-#endif
-
-
-/*****************************************************************************
- * IStream32 interface
- */
-#define ICOM_INTERFACE IStream32
-ICOM_BEGIN(IStream32,IUnknown)
-    ICOM_METHOD3(HRESULT,Read,        void*,pv, ULONG,cb, ULONG*,pcbRead)
-    ICOM_METHOD3(HRESULT,Write,       const void*,pv, ULONG,cb, ULONG*,pcbWritten)
-    ICOM_METHOD3(HRESULT,Seek,        LARGE_INTEGER,dlibMove, DWORD,dwOrigin, ULARGE_INTEGER*,plibNewPosition)
-    ICOM_METHOD1(HRESULT,SetSize,     ULARGE_INTEGER,libNewSize)
-    ICOM_METHOD4(HRESULT,CopyTo,      IStream32*,pstm, ULARGE_INTEGER,cb, ULARGE_INTEGER*,pcbRead, ULARGE_INTEGER*,pcbWritten)
-    ICOM_METHOD1(HRESULT,Commit,      DWORD,grfCommitFlags)
-    ICOM_METHOD (HRESULT,Revert)
-    ICOM_METHOD3(HRESULT,LockRegion,  ULARGE_INTEGER,libOffset, ULARGE_INTEGER,cb, DWORD,dwLockType)
-    ICOM_METHOD3(HRESULT,UnlockRegion,ULARGE_INTEGER,libOffset, ULARGE_INTEGER,cb, DWORD,dwLockType)
-    ICOM_METHOD2(HRESULT,Stat,        STATSTG*,pstatstg, DWORD,grfStatFlag)
-    ICOM_METHOD1(HRESULT,Clone,       IStream32**,ppstm)
-ICOM_END(IStream32)
-#undef ICOM_INTERFACE
-
-#if !defined(__cplusplus) || defined(CINTERFACE)
-/*** IUnknown methods ***/
-#define IStream32_QueryInterface(p,a,b) ICOM_ICALL2(QueryInterface,p,a,b)
-#define IStream32_AddRef(p)             ICOM_ICALL (AddRef,p)
-#define IStream32_Release(p)            ICOM_ICALL (Release,p)
-/*** IStream32 methods ***/
-#define IStream32_Read(p,a,b,c)         ICOM_CALL3(Read,p,a,b,c)
-#define IStream32_Write(p,a,b,c)        ICOM_CALL3(Write,p,a,b,c)
-#define IStream32_Seek(p)               ICOM_CALL3(Seek,p)
-#define IStream32_SetSize(p,a,b)        ICOM_CALL1(SetSize,p,a,b)
-#define IStream32_CopyTo(pa,b,c,d)      ICOM_CALL4(CopyTo,pa,b,c,d)
-#define IStream32_Commit(p,a)           ICOM_CALL1(Commit,p,a)
-#define IStream32_Revert(p)             ICOM_CALL (Revert,p)
-#define IStream32_LockRegion(pa,b,c)    ICOM_CALL3(LockRegion,pa,b,c)
-#define IStream32_UnlockRegion(p,a,b,c) ICOM_CALL3(UnlockRegion,p,a,b,c)
-#define IStream32_Stat(p,a,b)           ICOM_CALL2(Stat,p,a,b)
-#define IStream32_Clone(p,a)            ICOM_CALL1(Clone,p,a)
-#endif
 
 #endif
diff --git a/include/tab.h b/include/tab.h
index 81b7248..40f6e36 100644
--- a/include/tab.h
+++ b/include/tab.h
@@ -9,11 +9,10 @@
 
 typedef struct tagTAB_ITEM
 {
-    UINT32	mask;
-    UINT32	lpReserved1;
-    UINT32	lpReserved2;
+	UINT32  mask;
+	DWORD	dwState;
     LPSTR	pszText;
-    INT32	cchTextMax;
+	INT32   cchTextMax;
     INT32	iImage;
     LPARAM	lParam;
     RECT32   	rect;		/* bounding rectangle of the item */
@@ -21,13 +20,15 @@
 
 typedef struct tagTAB_INFO
 {
-    UINT32	uNumItem;	/* number of tab items */
-    INT32	nHeight;	/* height of the tab row */
-    HFONT32	hFont;		/* handle to the current font */
+    UINT32	    uNumItem;	/* number of tab items */
+    INT32	    nHeight;	/* height of the tab row */
+    HFONT32	    hFont;		/* handle to the current font */
     HCURSOR32	hcurArrow;	/* handle to the current cursor */
-    INT32	iSelected;	/* the currently selected item */
+	HIMAGELIST  himl;       /* handle to a image list (may be 0) */
+	UINT32		cchTextMax;
+    INT32	    iSelected;	/* the currently selected item */
     TAB_ITEM	*items;		/* pointer to an array of TAB_ITEM's */
-    RECT32	rect;
+    RECT32	    rect;
 } TAB_INFO;
 
 
diff --git a/include/unknwn.h b/include/unknwn.h
new file mode 100644
index 0000000..1803cb2
--- /dev/null
+++ b/include/unknwn.h
@@ -0,0 +1,8 @@
+#ifndef __WINE_UNKNWN_H
+#define __WINE_UNKNWN_H
+
+
+#include "wine/obj_base.h"
+
+
+#endif /* __WINE_UNKNWN_H */
diff --git a/include/version.h b/include/version.h
index 6d6aa5a..cf4f0e4 100644
--- a/include/version.h
+++ b/include/version.h
@@ -1 +1 @@
-#define WINE_RELEASE_INFO "Wine release 990103"
+#define WINE_RELEASE_INFO "Wine release 990110"
diff --git a/include/winbase.h b/include/winbase.h
index 8668da9..8df2d66 100644
--- a/include/winbase.h
+++ b/include/winbase.h
@@ -302,6 +302,7 @@
 void      WINAPI EnterCriticalSection(CRITICAL_SECTION *lpCrit);
 void      WINAPI InitializeCriticalSection(CRITICAL_SECTION *lpCrit);
 void      WINAPI LeaveCriticalSection(CRITICAL_SECTION *lpCrit);
+void      WINAPI MakeCriticalSectionGlobal(CRITICAL_SECTION *lpCrit);
 HANDLE32  WINAPI OpenProcess(DWORD access, BOOL32 inherit, DWORD id);
 BOOL32    WINAPI GetProcessWorkingSetSize(HANDLE32,LPDWORD,LPDWORD);
 BOOL32    WINAPI SetProcessWorkingSetSize(HANDLE32,DWORD,DWORD);
diff --git a/include/windows.h b/include/windows.h
index db13b18..3b602c4 100644
--- a/include/windows.h
+++ b/include/windows.h
@@ -12,8 +12,14 @@
 #include "wintypes.h"
 #include "winbase.h"  
 
-/* FIXME: Maybe we should try to get something from the Unix headers instead, this should be in windef.h by the way */
+/* FIXME: Maybe MAX_PATH and _MAX_PATH should be computed from the Unix headers instead
+ * and by the way, _MAX_PATH should be defined in stdlib.h and MAX_PATH in windef.h 
+ * and mapiwin.h
+ */
+#define _MAX_PATH 260
+#ifndef MAX_PATH
 #define MAX_PATH 260
+#endif
 
 #ifndef DONT_INCLUDE_WINGDI
 #include "winbase.h"
@@ -3836,6 +3842,8 @@
 VOID        WINAPI PostEvent(HTASK16);
 WORD        WINAPI PrestoChangoSelector(WORD,WORD);
 BOOL32      WINAPI RegisterShellHook(HWND16,UINT16);
+/* NOTE: This is SYSTEM.3, not USER.182, which is also named KillSystemTimer */
+WORD        WINAPI SYSTEM_KillSystemTimer( WORD );
 WORD        WINAPI SelectorAccessRights(WORD,WORD,WORD);
 VOID        WINAPI SetPriority(HTASK16,INT16);
 FARPROC16   WINAPI SetResourceHandler(HINSTANCE16,SEGPTR,FARPROC16);
@@ -3857,6 +3865,7 @@
 BOOL32      WINAPI Beep(DWORD,DWORD);
 BOOL32      WINAPI CloseHandle(HANDLE32);
 BOOL32      WINAPI CloseServiceHandle(HANDLE32);
+HANDLE32    WINAPI ConvertToGlobalHandle(HANDLE32 hSrc);
 BOOL32      WINAPI CopyFile32A(LPCSTR,LPCSTR,BOOL32);
 BOOL32      WINAPI CopyFile32W(LPCWSTR,LPCWSTR,BOOL32);
 #define     CopyFile WINELIB_NAME_AW(CopyFile)
@@ -4135,6 +4144,7 @@
 LONG        WINAPI RegUnLoadKey32A(HKEY,LPCSTR);
 LONG        WINAPI RegUnLoadKey32W(HKEY,LPCWSTR);
 #define     RegUnLoadKey WINELIB_NAME_AW(RegUnLoadKey)
+BOOL32      WINAPI ReleaseMutex(HANDLE32);
 BOOL32      WINAPI ReleaseSemaphore(HANDLE32,LONG,LPLONG);
 BOOL32      WINAPI ResetEvent(HANDLE32);
 DWORD       WINAPI ResumeThread(HANDLE32);
diff --git a/include/wine/obj_base.h b/include/wine/obj_base.h
new file mode 100644
index 0000000..d03d1e9
--- /dev/null
+++ b/include/wine/obj_base.h
@@ -0,0 +1,749 @@
+/*
+ * This file defines the macros and types necessary to define COM interfaces, 
+ * and the three most basic COM interfaces: IUnknown, IMalloc and IClassFactory.
+ */
+
+#ifndef __WINE_WINE_OBJ_BASE_H
+#define __WINE_WINE_OBJ_BASE_H
+
+
+/*****************************************************************************
+ * Defines the basic types
+ */
+#include "wtypes.h"
+
+
+/*****************************************************************************
+ * Macros to declare the GUIDs
+ */
+#ifdef INITGUID
+#define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
+        const GUID name = \
+	{ l, w1, w2, { b1, b2,  b3,  b4,  b5,  b6,  b7,  b8 } }
+#else
+#define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
+    extern const GUID name
+#endif
+
+#define DEFINE_OLEGUID(name, l, w1, w2) \
+	DEFINE_GUID(name, l, w1, w2, 0xC0,0,0,0,0,0,0,0x46)
+
+#define DEFINE_SHLGUID(name, l, w1, w2) DEFINE_OLEGUID(name,l,w1,w2)
+
+
+/*****************************************************************************
+ * GUID API
+ */
+HRESULT WINAPI StringFromCLSID16(const CLSID *id, LPOLESTR16*);
+HRESULT WINAPI StringFromCLSID32(const CLSID *id, LPOLESTR32*);
+#define StringFromCLSID WINELIB_NAME(StringFromCLSID)
+HRESULT WINAPI CLSIDFromString16(LPCOLESTR16, CLSID *);
+HRESULT WINAPI CLSIDFromString32(LPCOLESTR32, CLSID *);
+#define CLSIDFromString WINELIB_NAME(CLSIDFromString)
+HRESULT WINAPI CLSIDFromProgID16(LPCOLESTR16 progid, LPCLSID riid);
+HRESULT WINAPI CLSIDFromProgID32(LPCOLESTR32 progid, LPCLSID riid);
+#define CLSIDFromProgID WINELIB_NAME(CLSIDFromProgID)
+
+INT32 WINAPI StringFromGUID2(REFGUID id, LPOLESTR32 str, INT32 cmax);
+
+BOOL16 WINAPI IsEqualGUID16(GUID* g1,GUID* g2);
+BOOL32 WINAPI IsEqualGUID32(REFGUID rguid1,REFGUID rguid2);
+/*#define IsEqualGUID WINELIB_NAME(IsEqualGUID)*/
+#define IsEqualGUID(rguid1, rguid2) (!memcmp(rguid1, rguid2, sizeof(GUID)))
+#define IsEqualIID(riid1, riid2) IsEqualGUID(riid1, riid2)
+#define IsEqualCLSID(rclsid1, rclsid2) IsEqualGUID(rclsid1, rclsid2)
+
+
+/*****************************************************************************
+ * Macros to define a COM interface
+ */
+/*
+ * The goal of the following set of definitions is to provide a way to use the same 
+ * header file definitions to provide both a C interface and a C++ object oriented 
+ * interface to COM interfaces. The type of interface is selected automatically 
+ * depending on the language but it is always possible to get the C interface in C++ 
+ * by defining CINTERFACE.
+ *
+ * It is based on the following assumptions:
+ *  - all COM interfaces derive from IUnknown, this should not be a problem.
+ *  - the header file only defines the interface, the actual fields are defined 
+ *    separately in the C file implementing the interface.
+ *
+ * The natural approach to this problem would be to make sure we get a C++ class and 
+ * virtual methods in C++ and a structure with a table of pointer to functions in C.
+ * Unfortunately the layout of the virtual table is compiler specific, the layout of 
+ * g++ virtual tables is not the same as that of an egcs virtual table which is not the 
+ * same as that generated by Visual C+. There are workarounds to make the virtual tables 
+ * compatible via padding but unfortunately the one which is imposed to the WINE emulator
+ * by the Windows binaries, i.e. the Visual C++ one, is the most compact of all.
+ *
+ * So the solution I finally adopted does not use virtual tables. Instead I use inline 
+ * non virtual methods that dereference the method pointer themselves and perform the call.
+ *
+ * Let's take Direct3D as an example:
+ *
+ *    #define ICOM_INTERFACE IDirect3D
+ *    ICOM_BEGIN(IDirect3D,IUnknown)
+ *        ICOM_METHOD1(HRESULT,Initialize,    REFIID,);
+ *        ICOM_METHOD2(HRESULT,EnumDevices,   LPD3DENUMDEVICESCALLBACK,, LPVOID,);
+ *        ICOM_METHOD2(HRESULT,CreateLight,   LPDIRECT3DLIGHT*,, IUnknown*,);
+ *        ICOM_METHOD2(HRESULT,CreateMaterial,LPDIRECT3DMATERIAL*,, IUnknown*,);
+ *        ICOM_METHOD2(HRESULT,CreateViewport,LPDIRECT3DVIEWPORT*,, IUnknown*,);
+ *        ICOM_METHOD2(HRESULT,FindDevice,    LPD3DFINDDEVICESEARCH,, LPD3DFINDDEVICERESULT,);
+ *    ICOM_END(IDirect3D)
+ *    #undef ICOM_INTERFACE
+ *
+ *    #if !defined(__cplusplus) || defined(CINTERFACE)
+ *    // *** IUnknown methods *** //
+ *    #define IDirect3D_QueryInterface(p,a,b) ICOM_ICALL2(IUnknown,QueryInterface,p,a,b)
+ *    #define IDirect3D_AddRef(p)             ICOM_ICALL (IUnknown,AddRef,p)
+ *    #define IDirect3D_Release(p)            ICOM_ICALL (IUnknown,Release,p)
+ *    // *** IDirect3D methods *** //
+ *    #define IDirect3D_Initialize(p,a)       ICOM_CALL1(Initialize,p,a)
+ *    #define IDirect3D_EnumDevices(p,a,b)    ICOM_CALL2(EnumDevice,p,a,b)
+ *    #define IDirect3D_CreateLight(p,a,b)    ICOM_CALL2(CreateLight,p,a,b)
+ *    #define IDirect3D_CreateMaterial(p,a,b) ICOM_CALL2(CreateMaterial,p,a,b)
+ *    #define IDirect3D_CreateViewport(p,a,b) ICOM_CALL2(CreateViewport,p,a,b)
+ *    #define IDirect3D_FindDevice(p,a,b)     ICOM_CALL2(FindDevice,p,a,b)
+ *    #endif
+ *
+ * Comments:
+ *  - The ICOM_INTERFACE is used in the ICOM_METHOD macros for the 'this' pointer and to cast 
+ *    pointers. Defining this macro here saves us the trouble of having to repeat the interface 
+ *    name everywhere. Note haowever that because of the way macros work a macro like ICOM_METHOD1 
+ *    cannot use 'ICOM_INTERFACE##_VTABLE' because this would give 'ICOM_INTERFACE_VTABLE' and not 
+ *    'IDirect3D_VTABLE'.
+ *  - ICOM_BEGIN and ICOM_END are responsible for generating whatever structure is appropriate for 
+ *    representing the interface in the current language. In C this is a couple of structs in C++ 
+ *    it's a class. The first parameter is the interface name and the second one is the interface 
+ *    we inherit from. The reason why you have to repeat the interface name is because that's the 
+ *    only way these macro can successfully output "IDirect3D_VTABLE'. Trying to use ICOM_INTERFACE 
+ *    would, as in ICOM_METHOD, only yield 'ICOM_INTERFACE_VTABLE'.
+ *  - With the way ICOM_BEGIN works you don't have to repeat the definitions of the methods of the 
+ *    parent interface. They are automatically inherited both in C and in C++.
+ *  - In C++ the ICOM_METHOD macros generate a function prototype and a call to a function pointer 
+ *    method. This means using once 't1 p1, t2 p2, ...' and once 'p1, p2' without the types. The 
+ *    only way I found to handle this is to have one ICOM_METHOD macro per number of parameters and 
+ *    to have it take only the type information (with const if necessary) as parameters.
+ *    The 'undef ICOM_INTERFACE' is here to remind you that using ICOM_INTERFACE in the following 
+ *    macros will not work. This time it's because the ICOM_CALL macro expansion is done only once 
+ *    the 'IDirect3D_Xxx' macro is expanded. And by that time ICOM_INTERFACE will be long gone 
+ *    anyway.
+ *  - You may have noticed the double commas after each parameter type. This allows you to put the 
+ *    name of that parameter which I think is good for documentation. It is not required and since 
+ *    I did not know what to put there for this example (I could only find doc about IDirect3D2), 
+ *    I left them blank.
+ *  - Finally the set of 'IDirect3D_Xxx' macros is a standard set of macros defined to ease access 
+ *    to the interface methods in C. Unfortunately I don't see any way to avoid having to duplicate 
+ *    the inherited method definitions there. We must use ICOM_ICALL to invoke inherited methods, 
+ *    because in C we have to cast the virtual table pointer, and we should use the ICOM_CALL 
+ *    method in the other cases. This time I could have used a trick to use only one macro whatever 
+ *    the number of parameters but I prefered to have it work the same way as above.
+ *  - You probably have noticed that we don't define the fields we need to actually implement this 
+ *    interface: reference count, pointer to other resources and miscellaneous fields. That's 
+ *    because it's not needed, and the user will anyway only manipulate pointers to this structure
+ *    so he does not need to know its real size. Of course on the implementation side we have the 
+ *    real definition of the interface structure and they should match what the macros yield in 
+ *    each language (or conversely).
+ *
+ *
+ * In C this gives:
+ *    typedef struct IDirect3D_VTABLE IDirect3D_VTABLE;
+ *    struct IDirect3D {
+ *        IDirect3D_VTABLE* lpvtbl;
+ *    };
+ *    struct IDirect3D_VTABLE {
+ *        IUnknown_VTABLE bvt;
+ *        HRESULT (*fnInitialize)(IDirect3D* me, REFIID a);
+ *        HRESULT (*fnEnumDevices)(IDirect3D* me, LPD3DENUMDEVICESCALLBACK a, LPVOID b);
+ *        HRESULT (*fnCreateLight)(IDirect3D* me, LPDIRECT3DLIGHT* a, IUnknown* b);
+ *        HRESULT (*fnCreateMaterial)(IDirect3D* me, LPDIRECT3DMATERIAL* a, IUnknown* b);
+ *        HRESULT (*fnCreateViewport)(IDirect3D* me, LPDIRECT3DVIEWPORT* a, IUnknown* b);
+ *        HRESULT (*fnFindDevice)(IDirect3D* me, LPD3DFINDDEVICESEARCH a, LPD3DFINDDEVICERESULT b);
+ *    }; 
+ *
+ *    #if !defined(__cplusplus) || defined(CINTERFACE)
+ *    // *** IUnknown methods *** //
+ *    #define IDirect3D_QueryInterface(p,a,b) ((IUnknown_VTABLE*)(p)->lpvtbl)->fnQueryInterface((IUnknown*)p,a,b)
+ *    #define IDirect3D_AddRef(p)             ((IUnknown_VTABLE*)(p)->lpvtbl)->fnAddRef((IUnknown*)p)
+ *    #define IDirect3D_Release(p)            ((IUnknown_VTABLE*)(p)->lpvtbl)->fnRelease((IUnknown*)p)
+ *    // *** IDirect3D methods *** //
+ *    #define IDirect3D_Initialize(p,a)       (p)->lpvtbl->fnInitialize(p,a)
+ *    #define IDirect3D_EnumDevices(p,a,b)    (p)->lpvtbl->fnEnumDevice(p,a,b)
+ *    #define IDirect3D_CreateLight(p,a,b)    (p)->lpvtbl->fnCreateLight(p,a,b)
+ *    #define IDirect3D_CreateMaterial(p,a,b) (p)->lpvtbl->fnCreateMaterial(p,a,b)
+ *    #define IDirect3D_CreateViewport(p,a,b) (p)->lpvtbl->fnCreateViewport(p,a,b)
+ *    #define IDirect3D_FindDevice(p,a,b)     (p)->lpvtbl->fnFindDevice(p,a,b)
+ *    #endif
+ *
+ * Comments:
+ *  - IDirect3D only contains a pointer to the IDirect3D virtual/jump table. This is the only thing 
+ *    the user needs to know to use the interface. Of course the structure we will define to 
+ *    implement this interface will have more fields but the first one will match this pointer.
+ *  - The code generated by ICOM_BEGIN goes up to the bvt field in the IDirect3D virtual table. 
+ *    This bvt field is what saves us from having to duplicate the inherited method definitions.
+ *    It's a shame that C (gcc) will not allow unnamed structs. If this was possible we could 
+ *    seamlessly inherit and use the parent's interface function pointers.
+ *  - What follows is just a bunch of function pointer definitions generated by the ICOM_METHOD 
+ *    macros. The implementation will fill this jump table with appropriate values in a static 
+ *    variable and initialize the lpvtbl field to point to this variable.
+ *  - The IDirect3D_Xxx macros then just derefence the lpvtbl pointer and use the function pointer 
+ *    corresponding to the macro name. This emulates the behavior of a virtual table and should be 
+ *    about as fast. In the case of inherited methods we have some additional casting to do to 
+ *    because the inherited methods are defined in the bvt field or maybe further imbricated. Since 
+ *    the effect of the bvt field is that we inherit the parent virtual table fields this cast is 
+ *    relatively inocuous. A similar cast must be performed on the interface pointer before the 
+ *    invoked method will accept it. Despite all these casts there is little chance that you call a 
+ *    method on the wrong type of interface because the function names still have to match. But this 
+ *    is the only thing that will make the compilation fail.
+ *
+ *
+ * And in C++ (with gcc's g++):
+ *
+ *    typedef struct IDirect3D: public IUnknown {
+ *        private: HRESULT (*fnInitialize)(IDirect3D* me, REFIID a);
+ *        public: inline HRESULT Initialize(REFIID a) { return ((IDirect3D*)t.lpvtbl)->fnInitialize(this,a); };
+ *        private: HRESULT (*fnEnumDevices)(IDirect3D* me, LPD3DENUMDEVICESCALLBACK a, LPVOID b);
+ *        public: inline HRESULT EnumDevices(LPD3DENUMDEVICESCALLBACK a, LPVOID b)
+ *            { return ((IDirect3D*)t.lpvtbl)->fnEnumDevices(this,a,b); };
+ *        private: HRESULT (*fnCreateLight)(IDirect3D* me, LPDIRECT3DLIGHT* a, IUnknown* b);
+ *        public: inline HRESULT CreateLight(LPDIRECT3DLIGHT* a, IUnknown* b)
+ *            { return ((IDirect3D*)t.lpvtbl)->fnCreateLight(this,a,b); };
+ *        private: HRESULT (*fnCreateMaterial)(IDirect3D* me, LPDIRECT3DMATERIAL* a, IUnknown* b);
+ *        public: inline HRESULT CreateMaterial(LPDIRECT3DMATERIAL* a, IUnknown* b)
+ *            { return ((IDirect3D*)t.lpvtbl)->fnCreateMaterial(this,a,b); };
+ *        private: HRESULT (*fnCreateViewport)(IDirect3D* me, LPDIRECT3DVIEWPORT* a, IUnknown* b);
+ *        public: inline HRESULT CreateViewport(LPDIRECT3DVIEWPORT* a, IUnknown* b)
+ *            { return ((IDirect3D*)t.lpvtbl)->fnCreateViewport(this,a,b); };
+ *        private:  HRESULT (*fnFindDevice)(IDirect3D* me, LPD3DFINDDEVICESEARCH a, LPD3DFINDDEVICERESULT b);
+ *        public: inline HRESULT FindDevice(LPD3DFINDDEVICESEARCH a, LPD3DFINDDEVICERESULT b)
+ *            { return ((IDirect3D*)t.lpvtbl)->fnFindDevice(this,a,b); };
+ *    }; 
+ *
+ * Comments:
+ *  - In C++ IDirect3D does double duty as both the virtual/jump table and as the interface 
+ *    definition. The reason for this is to avoid having to duplicate the mehod definitions: once 
+ *    to have the function pointers in the jump table and once to have the methods in the interface 
+ *    class. Here one macro can generate both. This means though that the first pointer, t.lpvtbl 
+ *    defined in IUnknown,  must be interpreted as the jump table pointer if we interpret the 
+ *    structure as the the interface class, and as the function pointer to the QueryInterface 
+ *    method, t.fnQueryInterface, if we interpret the structure as the jump table. Fortunately this 
+ *    gymnastic is entirely taken care of in the header of IUnknown.
+ *  - Of course in C++ we use inheritance so that we don't have to duplicate the method definitions. 
+ *  - Since IDirect3D does double duty, each ICOM_METHOD macro defines both a function pointer and 
+ *    a non-vritual inline method which dereferences it and calls it. This way this method behaves 
+ *    just like a virtual method but does not create a true C++ virtual table which would break the 
+ *    structure layout. If you look at the implementation of these methods you'll notice that they 
+ *    would not work for void functions. We have to return something and fortunately this seems to 
+ *    be what all the COM methods do (otherwise we would need another set of macros).
+ *  - Note how the ICOM_METHOD generates both function prototypes mixing types and formal parameter 
+ *    names and the method invocation using only the formal parameter name. This is the reason why 
+ *    we need different macros to handle different numbers of parameters.
+ *  - Finally there is no IDirect3D_Xxx macro. These are not needed in C++ unless the CINTERFACE 
+ *    macro is defined in which case we would not be here.
+ *
+ *
+ * Implementing a COM interface.
+ *
+ * This continues the above example.I assume the implementation is in C but it would probably 
+ * be similar in C++.
+ *
+ *    typedef struct _IDirect3D {
+ *        void* lpvtbl;
+ *        // ...
+ *
+ *    } _IDirect3D;
+ *
+ *    static ICOM_VTABLE(IDirect3D) d3dvt;
+ *
+ *    // implement the IDirect3D methods here
+ *
+ *    int IDirect3D_fnQueryInterface(LPUNKNOWN me)
+ *    {
+ *        ICOM_THIS(IDirect3D,me);
+ *        // ...
+ *    }
+ *
+ *    // ...
+ *
+ *    static ICOM_VTABLE(IDirect3D) d3dvt = {
+ *        {
+ *            IDirect3D_fnQueryInterface,
+ *            IUnknown_fnAdd,
+ *            IUnknown_fnAdd2
+ *        },
+ *        IDirect3D_fnInitialize,
+ *        IDirect3D_fnSetWidth
+ *    };
+ *
+ * Comments:
+ *  - We first define what the interface really contains. This is th e_IDirect3D structure. The 
+ *    first field must of course be the virtual table pointer. Everything else is free.
+ *  - Then we predeclare our static virtual table variable, we will need its address in some 
+ *    methods to initialize the virtual table pointer of the returned interface objects.
+ *  - Then we implement the interface methods. To match what has been declared in the header file 
+ *    they must take a pointer to a IDirect3D structure so we must cast it to an _IDirect3D so that 
+ *    we can manipulate the fields. This is performed by the ICOM_THIS macro.
+ *  - Finally we initialize the virtual table. The inherited methods must be in curly brackets to 
+ *    match the parent interface's virtual table definition.
+ */
+
+
+#define ICOM_VTABLE(iface)       iface##_VTABLE
+
+
+#if defined(__cplusplus) && !defined(CINTERFACE)
+/* C++ interface */
+
+#define ICOM_BEGIN(iface,ibase) \
+    typedef struct iface: public ibase {
+
+
+#define ICOM_METHOD(ret,xfn) \
+    private: ret (CALLBACK *fn##xfn)(ICOM_INTERFACE* me); \
+    public: inline ret (CALLBACK xfn)(void) { return ((ICOM_INTERFACE*)t.lpvtbl)->fn##xfn(this); };
+
+#define ICOM_METHOD1(ret,xfn,ta,na) \
+    private: ret (CALLBACK *fn##xfn)(ICOM_INTERFACE* me,ta a); \
+    public: inline ret (CALLBACK xfn)(ta a) { return ((ICOM_INTERFACE*)t.lpvtbl)->fn##xfn(this,a); };
+
+#define ICOM_METHOD2(ret,xfn,ta,na,tb,nb) \
+    private: ret (CALLBACK *fn##xfn)(ICOM_INTERFACE* me,ta a,tb b); \
+    public: inline ret (CALLBACK xfn)(ta a,tb b) { return ((ICOM_INTERFACE*)t.lpvtbl)->fn##xfn(this,a,b); };
+
+#define ICOM_METHOD3(ret,xfn,ta,na,tb,nb,tc,nc) \
+    private: ret (CALLBACK *fn##xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c); \
+    public: inline ret (CALLBACK xfn)(ta a,tb b,tc c) { return ((ICOM_INTERFACE*)t.lpvtbl)->fn##xfn(this,a,b,c); };
+
+#define ICOM_METHOD4(ret,xfn,ta,na,tb,nb,tc,nc,td,nd) \
+    private: ret (CALLBACK *fn##xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d); \
+    public: inline ret (CALLBACK xfn)(ta a,tb b,tc c,td d) { return ((ICOM_INTERFACE*)t.lpvtbl)->fn##xfn(this,a,b,c,d); };
+
+#define ICOM_METHOD5(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne) \
+    private: ret (CALLBACK *fn##xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e); \
+    public: inline ret (CALLBACK xfn)(ta a,tb b,tc c,td d,te e) { return ((ICOM_INTERFACE*)t.lpvtbl)->fn##xfn(this,a,b,c,d,e); };
+
+#define ICOM_METHOD6(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf) \
+    private: ret (CALLBACK *fn##xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f); \
+    public: inline ret (CALLBACK xfn)(ta a,tb b,tc c,td d,te e,tf f) { return ((ICOM_INTERFACE*)t.lpvtbl)->fn##xfn(this,a,b,c,d,e,f); };
+
+#define ICOM_METHOD7(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng) \
+    private: ret (CALLBACK *fn##xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f,tg g); \
+    public: inline ret (CALLBACK xfn)(ta a,tb b,tc c,td d,te e,tf f,tg g) { return ((ICOM_INTERFACE*)t.lpvtbl)->fn##xfn(this,a,b,c,d,e,f,g); };
+
+
+#define ICOM_CMETHOD(ret,xfn) \
+    private: ret (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me); \
+    public: inline ret (CALLBACK xfn)(void) const { return ((ICOM_INTERFACE*)t.lpvtbl)->fn##xfn(this); };
+
+#define ICOM_CMETHOD1(ret,xfn,ta,na) \
+    private: ret (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me,ta a); \
+    public: inline ret (CALLBACK xfn)(ta a) const { return ((ICOM_INTERFACE*)t.lpvtbl)->fn##xfn(this,a); };
+
+#define ICOM_CMETHOD2(ret,xfn,ta,na,tb,nb) \
+    private: ret (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me,ta a,tb b); \
+    public: inline ret (CALLBACK xfn)(ta a,tb b) const { return ((ICOM_INTERFACE*)t.lpvtbl)->fn##xfn(this,a,b); };
+
+#define ICOM_CMETHOD3(ret,xfn,ta,na,tb,nb,tc,nc) \
+    private: ret (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me,ta a,tb b,tc c); \
+    public: inline ret (CALLBACK xfn)(ta a,tb b,tc c) const { return ((ICOM_INTERFACE*)t.lpvtbl)->fn##xfn(this,a,b,c); };
+
+#define ICOM_CMETHOD4(ret,xfn,ta,na,tb,nb,tc,nc,td,nd) \
+    private: ret (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me,ta a,tb b,tc c,td d); \
+    public: inline ret (CALLBACK xfn)(ta a,tb b,tc c,td d) const { return ((ICOM_INTERFACE*)t.lpvtbl)->fn##xfn(this,a,b,c,d); };
+
+#define ICOM_CMETHOD5(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne) \
+    private: ret (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e); \
+    public: inline ret (CALLBACK xfn)(ta a,tb b,tc c,td d,te e) const { return ((ICOM_INTERFACE*)t.lpvtbl)->fn##xfn(this,a,b,c,d,e); };
+
+#define ICOM_CMETHOD6(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf) \
+    private: ret (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f); \
+    public: inline ret (CALLBACK xfn)(ta a,tb b,tc c,td d,te e,tf f) const { return ((ICOM_INTERFACE*)t.lpvtbl)->fn##xfn(this,a,b,c,d,e,f); };
+
+#define ICOM_CMETHOD7(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng) \
+    private: ret (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f,tg g); \
+    public: inline ret (CALLBACK xfn)(ta a,tb b,tc c,td d,te e,tf f,tg g) const { return ((ICOM_INTERFACE*)t.lpvtbl)->fn##xfn(this,a,b,c,d,e,f,g); };
+
+
+#define ICOM_VMETHOD(xfn) \
+    private: void (CALLBACK *fn##xfn)(ICOM_INTERFACE* me); \
+    public: inline void (CALLBACK xfn)(void) { ((ICOM_INTERFACE*)t.lpvtbl)->fn##xfn(this); };
+
+#define ICOM_VMETHOD1(xfn,ta,na) \
+    private: void (CALLBACK *fn##xfn)(ICOM_INTERFACE* me,ta a); \
+    public: inline void (CALLBACK xfn)(ta a) { ((ICOM_INTERFACE*)t.lpvtbl)->fn##xfn(this,a); };
+
+#define ICOM_VMETHOD2(xfn,ta,na,tb,nb) \
+    private: void (CALLBACK *fn##xfn)(ICOM_INTERFACE* me,ta a,tb b); \
+    public: inline void (CALLBACK xfn)(ta a,tb b) { ((ICOM_INTERFACE*)t.lpvtbl)->fn##xfn(this,a,b); };
+
+#define ICOM_VMETHOD3(xfn,ta,na,tb,nb,tc,nc) \
+    private: void (CALLBACK *fn##xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c); \
+    public: inline void (CALLBACK xfn)(ta a,tb b,tc c) { ((ICOM_INTERFACE*)t.lpvtbl)->fn##xfn(this,a,b,c); };
+
+#define ICOM_VMETHOD4(xfn,ta,na,tb,nb,tc,nc,td,nd) \
+    private: void (CALLBACK *fn##xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d); \
+    public: inline void (CALLBACK xfn)(ta a,tb b,tc c,td d) { ((ICOM_INTERFACE*)t.lpvtbl)->fn##xfn(this,a,b,c,d); };
+
+#define ICOM_VMETHOD5(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne) \
+    private: void (CALLBACK *fn##xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e); \
+    public: inline void (CALLBACK xfn)(ta a,tb b,tc c,td d,te e) { ((ICOM_INTERFACE*)t.lpvtbl)->fn##xfn(this,a,b,c,d,e); };
+
+#define ICOM_VMETHOD6(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf) \
+    private: void (CALLBACK *fn##xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f); \
+    public: inline void (CALLBACK xfn)(ta a,tb b,tc c,td d,te e,tf f) { ((ICOM_INTERFACE*)t.lpvtbl)->fn##xfn(this,a,b,c,d,e,f); };
+
+#define ICOM_VMETHOD7(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng) \
+    private: void (CALLBACK *fn##xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f,tg g); \
+    public: inline void (CALLBACK xfn)(ta a,tb b,tc c,td d,te e,tf f,tg g) { ((ICOM_INTERFACE*)t.lpvtbl)->fn##xfn(this,a,b,c,d,e,f,g); };
+
+
+#define ICOM_CVMETHOD(xfn) \
+    private: void (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me); \
+    public: inline void (CALLBACK xfn)(void) const { ((ICOM_INTERFACE*)t.lpvtbl)->fn##xfn(this); };
+
+#define ICOM_CVMETHOD1(xfn,ta,na) \
+    private: void (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me,ta a); \
+    public: inline void (CALLBACK xfn)(ta a) const { ((ICOM_INTERFACE*)t.lpvtbl)->fn##xfn(this,a); };
+
+#define ICOM_CVMETHOD2(xfn,ta,na,tb,nb) \
+    private: void (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me,ta a,tb b); \
+    public: inline void (CALLBACK xfn)(ta a,tb b) const { ((ICOM_INTERFACE*)t.lpvtbl)->fn##xfn(this,a,b); };
+
+#define ICOM_CVMETHOD3(xfn,ta,na,tb,nb,tc,nc) \
+    private: void (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me,ta a,tb b,tc c); \
+    public: inline void (CALLBACK xfn)(ta a,tb b,tc c) const { ((ICOM_INTERFACE*)t.lpvtbl)->fn##xfn(this,a,b,c); };
+
+#define ICOM_CVMETHOD4(xfn,ta,na,tb,nb,tc,nc,td,nd) \
+    private: void (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me,ta a,tb b,tc c,td d); \
+    public: inline void (CALLBACK xfn)(ta a,tb b,tc c,td d) const { ((ICOM_INTERFACE*)t.lpvtbl)->fn##xfn(this,a,b,c,d); };
+
+#define ICOM_CVMETHOD5(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne) \
+    private: void (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e); \
+    public: inline void (CALLBACK xfn)(ta a,tb b,tc c,td d,te e) const { ((ICOM_INTERFACE*)t.lpvtbl)->fn##xfn(this,a,b,c,d,e); };
+
+#define ICOM_CVMETHOD6(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf) \
+    private: void (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f); \
+    public: inline void (CALLBACK xfn)(ta a,tb b,tc c,td d,te e,tf f) const { ((ICOM_INTERFACE*)t.lpvtbl)->fn##xfn(this,a,b,c,d,e,f); };
+
+#define ICOM_CVMETHOD7(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng) \
+    private: void (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f,tg g); \
+    public: inline void (CALLBACK xfn)(ta a,tb b,tc c,td d,te e,tf f,tg g) const { ((ICOM_INTERFACE*)t.lpvtbl)->fn##xfn(this,a,b,c,d,e,f,g); };
+
+
+#define ICOM_END(iface) \
+    };
+
+#define ICOM_ICALL(ibase, xfn, p)                this_is_a_syntax_error
+#define ICOM_ICALL1(ibase, xfn, p,a)             this_is_a_syntax_error
+#define ICOM_ICALL2(ibase, xfn, p,a,b)           this_is_a_syntax_error
+#define ICOM_ICALL3(ibase, xfn, p,a,b,c)         this_is_a_syntax_error
+#define ICOM_ICALL4(ibase, xfn, p,a,b,c,d)       this_is_a_syntax_error
+#define ICOM_ICALL5(ibase, xfn, p,a,b,c,d,e)     this_is_a_syntax_error
+#define ICOM_ICALL6(ibase, xfn, p,a,b,c,d,e,f)   this_is_a_syntax_error
+#define ICOM_ICALL7(ibase, xfn, p,a,b,c,d,e,f,g) this_is_a_syntax_error
+
+#define ICOM_CALL(xfn, p)                        this_is_a_syntax_error
+#define ICOM_CALL1(xfn, p,a)                     this_is_a_syntax_error
+#define ICOM_CALL2(xfn, p,a,b)                   this_is_a_syntax_error
+#define ICOM_CALL3(xfn, p,a,b,c)                 this_is_a_syntax_error
+#define ICOM_CALL4(xfn, p,a,b,c,d)               this_is_a_syntax_error
+#define ICOM_CALL5(xfn, p,a,b,c,d,e)             this_is_a_syntax_error
+#define ICOM_CALL6(xfn, p,a,b,c,d,e,f)           this_is_a_syntax_error
+#define ICOM_CALL7(xfn, p,a,b,c,d,e,f,g)         this_is_a_syntax_error
+
+
+#else
+/* C interface */
+
+
+#define ICOM_BEGIN(iface,ibase) \
+    typedef struct ICOM_VTABLE(iface) ICOM_VTABLE(iface); \
+    struct iface { \
+        const ICOM_VTABLE(iface)* lpvtbl; \
+    }; \
+    struct ICOM_VTABLE(iface) { \
+        ICOM_VTABLE(ibase) bvt;
+
+
+#define ICOM_METHOD(ret,xfn) \
+    ret (CALLBACK *fn##xfn)(ICOM_INTERFACE* me);
+
+#define ICOM_METHOD1(ret,xfn,ta,na) \
+    ret (CALLBACK *fn##xfn)(ICOM_INTERFACE* me,ta a);
+
+#define ICOM_METHOD2(ret,xfn,ta,na,tb,nb) \
+    ret (CALLBACK *fn##xfn)(ICOM_INTERFACE* me,ta a,tb b);
+
+#define ICOM_METHOD3(ret,xfn,ta,na,tb,nb,tc,nc) \
+    ret (CALLBACK *fn##xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c);
+
+#define ICOM_METHOD4(ret,xfn,ta,na,tb,nb,tc,nc,td,nd) \
+    ret (CALLBACK *fn##xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d);
+
+#define ICOM_METHOD5(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne) \
+    ret (CALLBACK *fn##xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e);
+
+#define ICOM_METHOD6(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf) \
+    ret (CALLBACK *fn##xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f);
+
+#define ICOM_METHOD7(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng) \
+    ret (CALLBACK *fn##xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f,tg g);
+
+
+#define ICOM_CMETHOD(ret,xfn) \
+        ret (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me);
+
+#define ICOM_CMETHOD1(ret,xfn,ta,na) \
+    ret (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me,ta a);
+
+#define ICOM_CMETHOD2(ret,xfn,ta,na,tb,nb) \
+    ret (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me,ta a,tb b);
+
+#define ICOM_CMETHOD3(ret,xfn,ta,na,tb,nb,tc,nc) \
+    ret (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me,ta a,tb b,tc c);
+
+#define ICOM_CMETHOD4(ret,xfn,ta,na,tb,nb,tc,nc,td,nd) \
+    ret (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me,ta a,tb b,tc c,td d);
+
+#define ICOM_CMETHOD5(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne) \
+    ret (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e);
+
+#define ICOM_CMETHOD6(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf) \
+    ret (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f);
+
+#define ICOM_CMETHOD7(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng) \
+    ret (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f,tg g);
+
+
+#define ICOM_VMETHOD(xfn) \
+    void (CALLBACK *fn##xfn)(ICOM_INTERFACE* me);
+
+#define ICOM_VMETHOD1(xfn,ta,na) \
+    void (CALLBACK *fn##xfn)(ICOM_INTERFACE* me,ta a);
+
+#define ICOM_VMETHOD2(xfn,ta,na,tb,nb) \
+    void (CALLBACK *fn##xfn)(ICOM_INTERFACE* me,ta a,tb b);
+
+#define ICOM_VMETHOD3(xfn,ta,na,tb,nb,tc,nc) \
+    void (CALLBACK *fn##xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c);
+
+#define ICOM_VMETHOD4(xfn,ta,na,tb,nb,tc,nc,td,nd) \
+    void (CALLBACK *fn##xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d);
+
+#define ICOM_VMETHOD5(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne) \
+    void (CALLBACK *fn##xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e);
+
+#define ICOM_VMETHOD6(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf) \
+    void (CALLBACK *fn##xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f);
+
+#define ICOM_VMETHOD7(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng) \
+    void (CALLBACK *fn##xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f,tg g);
+
+
+#define ICOM_CVMETHOD(xfn) \
+        void (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me);
+
+#define ICOM_CVMETHOD1(xfn,ta,na) \
+    void (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me,ta a);
+
+#define ICOM_CVMETHOD2(xfn,ta,na,tb,nb) \
+    void (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me,ta a,tb b);
+
+#define ICOM_CVMETHOD3(xfn,ta,na,tb,nb,tc,nc) \
+    void (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me,ta a,tb b,tc c);
+
+#define ICOM_CVMETHOD4(xfn,ta,na,tb,nb,tc,nc,td,nd) \
+    void (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me,ta a,tb b,tc c,td d);
+
+#define ICOM_CVMETHOD5(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne) \
+    void (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e);
+
+#define ICOM_CVMETHOD6(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf) \
+    void (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f);
+
+#define ICOM_CVMETHOD7(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng) \
+    void (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f,tg g);
+
+
+#define ICOM_END(iface) \
+    };
+
+#define ICOM_ICALL(ibase, xfn, p)  ((ICOM_VTABLE(ibase)*)(p)->lpvtbl)->fn##xfn((ibase*)p)
+#define ICOM_ICALL1(ibase, xfn, p,a) ((ICOM_VTABLE(ibase)*)(p)->lpvtbl)->fn##xfn((ibase*)p,a)
+#define ICOM_ICALL2(ibase, xfn, p,a,b) ((ICOM_VTABLE(ibase)*)(p)->lpvtbl)->fn##xfn((ibase*)p,a,b)
+#define ICOM_ICALL3(ibase, xfn, p,a,b,c) ((ICOM_VTABLE(ibase)*)(p)->lpvtbl)->fn##xfn((ibase*)p,a,b,c)
+#define ICOM_ICALL4(ibase, xfn, p,a,b,c,d) ((ICOM_VTABLE(ibase)*)(p)->lpvtbl)->fn##xfn((ibase*)p,a,b,c,d)
+#define ICOM_ICALL5(ibase, xfn, p,a,b,c,d,e) ((ICOM_VTABLE(ibase)*)(p)->lpvtbl)->fn##xfn((ibase*)p,a,b,c,d,e)
+#define ICOM_ICALL6(ibase, xfn, p,a,b,c,d,e,f) ((ICOM_VTABLE(ibase)*)(p)->lpvtbl)->fn##xfn((ibase*)p,a,b,c,d,e,f)
+#define ICOM_ICALL7(ibase, xfn, p,a,b,c,d,e,f,g) ((ICOM_VTABLE(ibase)*)(p)->lpvtbl)->fn##xfn((ibase*)p,a,b,c,d,e,f,g)
+
+#define ICOM_CALL(xfn, p)  (p)->lpvtbl->fn##xfn(p)
+#define ICOM_CALL1(xfn, p,a) (p)->lpvtbl->fn##xfn(p,a)
+#define ICOM_CALL2(xfn, p,a,b) (p)->lpvtbl->fn##xfn(p,a,b)
+#define ICOM_CALL3(xfn, p,a,b,c) (p)->lpvtbl->fn##xfn(p,a,b,c)
+#define ICOM_CALL4(xfn, p,a,b,c,d) (p)->lpvtbl->fn##xfn(p,a,b,c,d)
+#define ICOM_CALL5(xfn, p,a,b,c,d,e) (p)->lpvtbl->fn##xfn(p,a,b,c,d,e)
+#define ICOM_CALL6(xfn, p,a,b,c,d,e,f) (p)->lpvtbl->fn##xfn(p,a,b,c,d,e,f)
+#define ICOM_CALL7(xfn, p,a,b,c,d,e,f,g) (p)->lpvtbl->fn##xfn(p,a,b,c,d,e,f,g)
+
+
+#define ICOM_THIS(iface,me)          struct _##iface* this=(struct _##iface*)me
+#define ICOM_CTHIS(iface,me)         const _##iface* this=(const _##iface*)me
+
+#endif
+
+
+/*****************************************************************************
+ * Predeclare the interfaces
+ */
+DEFINE_OLEGUID(IID_IClassFactory,	0x00000001L, 0, 0);
+typedef struct IClassFactory IClassFactory, *LPCLASSFACTORY;
+
+DEFINE_OLEGUID(IID_IMalloc,		0x00000002L, 0, 0);
+typedef struct IMalloc16 IMalloc16,*LPMALLOC16;
+typedef struct IMalloc32 IMalloc32,*LPMALLOC32;
+DECL_WINELIB_TYPE(IMalloc)
+DECL_WINELIB_TYPE(LPMALLOC)
+
+DEFINE_OLEGUID(IID_IUnknown,		0x00000000L, 0, 0);
+typedef struct IUnknown IUnknown, *LPUNKNOWN;
+
+
+/*****************************************************************************
+ * IUnknown interface
+ */
+#define ICOM_INTERFACE IUnknown
+#if defined(__cplusplus) && !defined(CINTERFACE)
+struct IUnknown {
+    union {
+        const void* lpvtbl;
+        HRESULT (CALLBACK *fnQueryInterface)(IUnknown* me, REFIID riid, LPVOID* ppvObj);
+    } t;
+    inline int QueryInterface(REFIID a, LPVOID* b) { return ((IUnknown*)t.lpvtbl)->t.fnQueryInterface(this,a,b); }
+#else
+typedef struct ICOM_VTABLE(IUnknown) ICOM_VTABLE(IUnknown);
+struct IUnknown {
+    ICOM_VTABLE(IUnknown)* lpvtbl;
+};
+struct ICOM_VTABLE(IUnknown) {
+    ICOM_METHOD2(HRESULT,QueryInterface,REFIID,riid, LPVOID*,ppvObj)
+#endif
+
+    ICOM_METHOD (ULONG,AddRef)
+    ICOM_METHOD (ULONG,Release)
+#ifdef __WRC__
+}; /* FIXME: WRC does not support function macros and it is ICOM_END that is supposed to close the class */
+#else
+ICOM_END(IUnknown)
+#endif
+#undef ICOM_INTERFACE
+
+#if !defined(__cplusplus) || defined(CINTERFACE)
+/*** IUnknown methods ***/
+#define IUnknown_QueryInterface(p,a,b) ICOM_CALL2(QueryInterface,p,a,b)
+#define IUnknown_AddRef(p)             ICOM_CALL (AddRef,p)
+#define IUnknown_Release(p)            ICOM_CALL (Release,p)
+#endif
+
+
+/*****************************************************************************
+ * IClassFactory interface
+ */
+#define ICOM_INTERFACE IClassFactory
+ICOM_BEGIN(IClassFactory,IUnknown)
+    ICOM_METHOD3(HRESULT,CreateInstance, LPUNKNOWN,pUnkOuter, REFIID,riid, LPVOID*,ppvObject);
+    ICOM_METHOD1(HRESULT,LockServer,     BOOL32,fLock);
+ICOM_END(IClassFactory)
+#undef ICOM_INTERFACE
+
+#if !defined(__cplusplus) || defined(CINTERFACE)
+/*** IUnknown methods ***/
+#define IClassFactory_QueryInterface(p,a,b) ICOM_ICALL2(IUnknown,QueryInterface,p,a,b)
+#define IClassFactory_AddRef(p)             ICOM_ICALL (IUnknown,AddRef,p)
+#define IClassFactory_Release(p)            ICOM_ICALL (IUnknown,Release,p)
+/*** IClassFactory methods ***/
+#define IClassFactory_CreateInstance(p,a,b,c) ICOM_CALL3(CreateInstance,p,a,b,c)
+#define IClassFactory_LockServer(p,a)         ICOM_CALL1(LockServer,p,a)
+#endif
+
+
+/*****************************************************************************
+ * IMalloc interface
+ */
+#define ICOM_INTERFACE IMalloc16
+ICOM_BEGIN(IMalloc16,IUnknown)
+    ICOM_METHOD1 (LPVOID,Alloc,       DWORD,cb);
+    ICOM_METHOD2 (LPVOID,Realloc,     LPVOID,pv, DWORD,cb);
+    ICOM_VMETHOD1(       Free,        LPVOID,pv);
+    ICOM_CMETHOD1(DWORD, GetSize,     LPVOID,pv);
+    ICOM_CMETHOD1(INT16, DidAlloc,    LPVOID,pv);
+    ICOM_METHOD  (LPVOID,HeapMinimize);
+ICOM_END(IMalloc16)
+#undef ICOM_INTERFACE
+
+#if !defined(__cplusplus) || defined(CINTERFACE)
+/*** IUnknown methods ***/
+#define IMalloc16_QueryInterface(p,a,b) ICOM_ICALL2(IUnknown,QueryInterface,p,a,b)
+#define IMalloc16_AddRef(p)             ICOM_ICALL (IUnknown,AddRef,p)
+#define IMalloc16_Release(p)            ICOM_ICALL (IUnknown,Release,p)
+/*** IMalloc16 methods ***/
+#define IMalloc16_Alloc(p,a)      ICOM_CALL1(Alloc,p,a)
+#define IMalloc16_Realloc(p,a,b)  ICOM_CALL2(Realloc,p,a,b)
+#define IMalloc16_Free(p,a)       ICOM_CALL1(Free,p,a)
+#define IMalloc16_GetSize(p,a)    ICOM_CALL1(GetSize,p,a)
+#define IMalloc16_DidAlloc(p,a)   ICOM_CALL1(DidAlloc,p,a)
+#define IMalloc16_HeapMinimize(p) ICOM_CALL (HeapMinimize,p)
+#endif
+
+
+#define ICOM_INTERFACE IMalloc32
+ICOM_BEGIN(IMalloc32,IUnknown)
+    ICOM_METHOD1 (LPVOID,Alloc,       DWORD,cb);
+    ICOM_METHOD2 (LPVOID,Realloc,     LPVOID,pv, DWORD,cb);
+    ICOM_VMETHOD1(       Free,        LPVOID,pv);
+    ICOM_CMETHOD1(DWORD, GetSize,     LPVOID,pv);
+    ICOM_CMETHOD1(INT32, DidAlloc,    LPVOID,pv);
+    ICOM_METHOD  (LPVOID,HeapMinimize);
+ICOM_END(IMalloc32)
+#undef ICOM_INTERFACE
+
+#if !defined(__cplusplus) || defined(CINTERFACE)
+/*** IUnknown methods ***/
+#define IMalloc32_QueryInterface(p,a,b) ICOM_ICALL2(IUnknown,QueryInterface,p,a,b)
+#define IMalloc32_AddRef(p)             ICOM_ICALL (IUnknown,AddRef,p)
+#define IMalloc32_Release(p)            ICOM_ICALL (IUnknown,Release,p)
+/*** IMalloc32 methods ***/
+#define IMalloc32_Alloc(p,a)      ICOM_CALL1(Alloc,p,a)
+#define IMalloc32_Realloc(p,a,b)  ICOM_CALL2(Realloc,p,a,b)
+#define IMalloc32_Free(p,a)       ICOM_CALL1(Free,p,a)
+#define IMalloc32_GetSize(p,a)    ICOM_CALL1(GetSize,p,a)
+#define IMalloc32_DidAlloc(p,a)   ICOM_CALL1(DidAlloc,p,a)
+#define IMalloc32_HeapMinimize(p) ICOM_CALL (HeapMinimize,p)
+
+#ifndef __WINE__
+/* Duplicated for WINELIB */
+/*** IUnknown methods ***/
+#define IMalloc_QueryInterface(p,a,b) ICOM_ICALL2(IUnknown,QueryInterface,p,a,b)
+#define IMalloc_AddRef(p)             ICOM_ICALL (IUnknown,AddRef,p)
+#define IMalloc_Release(p)            ICOM_ICALL (IUnknown,Release,p)
+/*** IMalloc methods ***/
+#define IMalloc_Alloc(p,a)      ICOM_CALL1(Alloc,p,a)
+#define IMalloc_Realloc(p,a,b)  ICOM_CALL2(Realloc,p,a,b)
+#define IMalloc_Free(p,a)       ICOM_CALL1(Free,p,a)
+#define IMalloc_GetSize(p,a)    ICOM_CALL1(GetSize,p,a)
+#define IMalloc_DidAlloc(p,a)   ICOM_CALL1(DidAlloc,p,a)
+#define IMalloc_HeapMinimize(p) ICOM_CALL (HeapMinimize,p)
+#endif
+#endif
+
+
+HRESULT WINAPI CoCreateStandardMalloc16(DWORD dwMemContext, LPMALLOC16* lpMalloc);
+#define CoCreateStandardMalloc WINELIB_NAME(CoCreateStandardMalloc)
+
+HRESULT WINAPI CoGetMalloc16(DWORD dwMemContext,LPMALLOC16* lpMalloc);
+HRESULT WINAPI CoGetMalloc32(DWORD dwMemContext,LPMALLOC32* lpMalloc);
+#define CoGetMalloc WINELIB_NAME(CoGetMalloc)
+
+
+#endif /* __WINE_WINE_OBJ_BASE_H */
diff --git a/include/wine/obj_channel.h b/include/wine/obj_channel.h
new file mode 100644
index 0000000..e6372c4
--- /dev/null
+++ b/include/wine/obj_channel.h
@@ -0,0 +1,60 @@
+/*
+ * Defines undocumented Microsoft COM interfaces and APIs seemingly related to some 'channel' notion.
+ *
+ * Depends on 'obj_base.h'.
+ */
+
+#ifndef __WINE_WINE_OBJ_CHANNEL_H
+#define __WINE_WINE_OBJ_CHANNEL_H
+
+
+/*****************************************************************************
+ * Predeclare the interfaces
+ */
+DEFINE_GUID   (IID_IChannelHook,	0x1008c4a0L, 0x7613, 0x11cf, 0x9a, 0xf1, 0x00, 0x20, 0xaf, 0x6e, 0x72, 0xf4);
+typedef struct IChannelHook IChannelHook,*LPCHANNELHOOK;
+
+DEFINE_GUID   (IID_IPSFactoryBuffer,	0xd5f569d0L, 0x593b, 0x101a, 0xb5, 0x69, 0x08, 0x00, 0x2b, 0x2d, 0xbf, 0x7a);
+typedef struct IPSFactoryBuffer IPSFactoryBuffer,*LPPSFACTORYBUFFER;
+
+DEFINE_GUID   (IID_IRpcChannelBuffer,	0xd5f56b60L, 0x593b, 0x101a, 0xb5, 0x69, 0x08, 0x00, 0x2b, 0x2d, 0xbf, 0x7a);
+typedef struct IRpcChannelBuffer IRpcChannelBuffer,*LPRPCCHANNELBUFFER;
+
+DEFINE_GUID   (IID_IRpcProxyBuffer,	0xd5f56a34L, 0x593b, 0x101a, 0xb5, 0x69, 0x08, 0x00, 0x2b, 0x2d, 0xbf, 0x7a);
+typedef struct IRpcProxyBuffer IRpcProxyBuffer,*LPRPCPROXYBUFFER;
+
+DEFINE_GUID   (IID_IRpcStubBuffer,	0xd5f56afcL, 0x593b, 0x101a, 0xb5, 0x69, 0x08, 0x00, 0x2b, 0x2d, 0xbf, 0x7a);
+typedef struct IRpcStubBuffer IRpcStubBuffer,*LPRPCSTUBBUFFER;
+
+
+/*****************************************************************************
+ * IChannelHook interface
+ */
+/* FIXME: not implemented */
+
+
+/*****************************************************************************
+ * IPSFactoryBuffer interface
+ */
+/* FIXME: not implemented */
+
+
+/*****************************************************************************
+ * IRpcChannelBuffer interface
+ */
+/* FIXME: not implemented */
+
+
+/*****************************************************************************
+ * IRpcProxyBuffer interface
+ */
+/* FIXME: not implemented */
+
+
+/*****************************************************************************
+ * IRpcStubBuffer interface
+ */
+/* FIXME: not implemented */
+
+
+#endif /* __WINE_WINE_OBJ_CHANNEL_H */
diff --git a/include/wine/obj_clientserver.h b/include/wine/obj_clientserver.h
new file mode 100644
index 0000000..81aa7c9
--- /dev/null
+++ b/include/wine/obj_clientserver.h
@@ -0,0 +1,57 @@
+/*
+ * Defines the COM interfaces and APIs related to client/server aspects.
+ *
+ * Depends on 'obj_base.h'.
+ */
+
+#ifndef __WINE_WINE_OBJ_CLIENTSERVER_H
+#define __WINE_WINE_OBJ_CLIENTSERVER_H
+
+
+/*****************************************************************************
+ * Predeclare the interfaces
+ */
+DEFINE_OLEGUID(IID_IClientSecurity,	0x0000013dL, 0, 0);
+typedef struct IClientSecurity IClientSecurity,*LPCLIENTSECURITY;
+
+DEFINE_OLEGUID(IID_IExternalConnection,	0x00000019L, 0, 0);
+typedef struct IExternalConnection IExternalConnection,*LPEXTERNALCONNECTION;
+
+DEFINE_OLEGUID(IID_IMessageFilter,	0x00000016L, 0, 0);
+typedef struct IMessageFilter IMessageFilter,*LPMESSAGEFILTER;
+
+DEFINE_OLEGUID(IID_IServerSecurity,	0x0000013eL, 0, 0);
+typedef struct IServerSecurity IServerSecurity,*LPSERVERSECURITY;
+
+
+/*****************************************************************************
+ * IClientSecurity interface
+ */
+/* FIXME: not implemented */
+
+
+/*****************************************************************************
+ * IExternalConnection interface
+ */
+/* FIXME: not implemented */
+
+HRESULT WINAPI CoDisconnectObject(LPUNKNOWN lpUnk, DWORD reserved);
+
+
+/*****************************************************************************
+ * IMessageFilter interface
+ */
+/* FIXME: not implemented */
+
+HRESULT WINAPI CoRegisterMessageFilter16(LPMESSAGEFILTER lpMessageFilter,LPMESSAGEFILTER *lplpMessageFilter);
+HRESULT WINAPI CoRegisterMessageFilter32(LPMESSAGEFILTER lpMessageFilter,LPMESSAGEFILTER *lplpMessageFilter);
+#define CoRegisterMessageFilter WINELIB_NAME(CoRegisterMessageFilter)
+
+
+/*****************************************************************************
+ * IServerSecurity interface
+ */
+/* FIXME: not implemented */
+
+
+#endif /* __WINE_WINE_OBJ_CLIENTSERVER_H */
diff --git a/include/wine/obj_dataobject.h b/include/wine/obj_dataobject.h
new file mode 100644
index 0000000..4bc3bac
--- /dev/null
+++ b/include/wine/obj_dataobject.h
@@ -0,0 +1,192 @@
+/*
+ * Defines the COM interfaces and APIs related to IDataObject.
+ *
+ * Depends on 'obj_moniker.h', 'obj_storage.h' and 'obj_base.h'.
+ */
+
+#ifndef __WINE_WINE_OBJ_DATAOBJECT_H
+#define __WINE_WINE_OBJ_DATAOBJECT_H
+
+
+/*****************************************************************************
+ * Predeclare the structures
+ */
+typedef struct DVTARGETDEVICE32 DVTARGETDEVICE32, *LPDVTARGETDEVICE32;
+DECL_WINELIB_TYPE(DVTARGETDEVICE)
+DECL_WINELIB_TYPE(LPDVTARGETDEVICE)
+
+typedef struct FORMATETC32 FORMATETC32, *LPFORMATETC32;
+DECL_WINELIB_TYPE(FORMATETC)
+DECL_WINELIB_TYPE(LPFORMATETC)
+
+typedef struct STGMEDIUM32 STGMEDIUM32, *LPSTGMEDIUM32;
+DECL_WINELIB_TYPE(STGMEDIUM)
+DECL_WINELIB_TYPE(LPSTGMEDIUM)
+
+
+/*****************************************************************************
+ * Predeclare the interfaces
+ */
+DEFINE_OLEGUID(IID_IAdviseSink,		0x0000010fL, 0, 0);
+typedef struct IAdviseSink IAdviseSink,*LPADVISESINK;
+
+DEFINE_OLEGUID(IID_IAdviseSink2,	0x00000125L, 0, 0);
+typedef struct IAdviseSink2 IAdviseSink2,*LPADVISESINK2;
+
+DEFINE_OLEGUID(IID_IDataAdviseHolder,	0x00000110L, 0, 0);
+typedef struct IDataAdviseHolder IDataAdviseHolder,*LPDATAADVISEHOLDER;
+
+DEFINE_OLEGUID(IID_IDataObject,		0x0000010EL, 0, 0);
+typedef struct IDataObject IDataObject,*LPDATAOBJECT;
+
+DEFINE_OLEGUID(IID_IEnumFORMATETC,	0x00000103L, 0, 0);
+typedef struct IEnumFORMATETC IEnumFORMATETC,*LPENUMFORMATETC;
+
+DEFINE_OLEGUID(IID_IEnumSTATDATA,	0x00000105L, 0, 0);
+typedef struct IEnumSTATDATA IEnumSTATDATA,*LPENUMSTATDATA;
+
+
+/*****************************************************************************
+ * DVTARGETDEVICE structure
+ */
+struct DVTARGETDEVICE32
+{
+    DWORD tdSize;
+    WORD tdDriverNameOffset;
+    WORD tdDeviceNameOffset;
+    WORD tdPortNameOffset;
+    WORD tdExtDevmodeOffset;
+    BYTE tdData[1];
+};
+
+
+/*****************************************************************************
+ * FORMATETC structure
+ */
+/* wished data format */
+struct FORMATETC32
+{
+    CLIPFORMAT32 cfFormat;
+    DVTARGETDEVICE32* ptd;
+    DWORD dwAspect;
+    LONG lindex;
+    DWORD tymed;
+};
+
+
+/*****************************************************************************
+ * STGMEDIUM structure
+ */
+typedef enum tagTYMED
+{	TYMED_HGLOBAL   = 1,
+	TYMED_FILE      = 2,
+	TYMED_ISTREAM   = 4,
+	TYMED_ISTORAGE  = 8,
+	TYMED_GDI       = 16,
+	TYMED_MFPICT    = 32,
+	TYMED_ENHMF     = 64,
+	TYMED_NULL      = 0
+} TYMED;
+  
+/* dataobject as answer to a request */
+struct STGMEDIUM32
+{
+    DWORD tymed;
+    union {
+        HBITMAP32 hBitmap;
+        HMETAFILEPICT32 hMetaFilePict;
+        HENHMETAFILE32 hEnhMetaFile;
+        HGLOBAL32 hGlobal;
+        LPOLESTR32 lpszFileName;
+        IStream32 *pstm;
+        IStorage32 *pstg;
+    } u;
+    IUnknown *pUnkForRelease;
+};   
+
+
+/*****************************************************************************
+ * IAdviseSink interface
+ */
+/* FIXME: not implemented */
+
+
+/*****************************************************************************
+ * IAdviseSink2 interface
+ */
+/* FIXME: not implemented */
+
+
+/*****************************************************************************
+ * IDataAdviseHolder interface
+ */
+/* FIXME: not implemented */
+
+
+/*****************************************************************************
+ * IDataObject interface
+ */
+#define ICOM_INTERFACE IDataObject
+ICOM_BEGIN(IDataObject,IUnknown)
+    ICOM_METHOD2(HRESULT,GetData,               LPFORMATETC32,pformatetcIn, STGMEDIUM32*,pmedium);
+    ICOM_METHOD2(HRESULT,GetDataHere,           LPFORMATETC32,pformatetc, STGMEDIUM32*,pmedium);
+    ICOM_METHOD1(HRESULT,QueryGetData,          LPFORMATETC32,pformatetc);
+    ICOM_METHOD2(HRESULT,GetCanonicalFormatEtc, LPFORMATETC32,pformatectIn, LPFORMATETC32,pformatetcOut);
+    ICOM_METHOD3(HRESULT,SetData,               LPFORMATETC32,pformatetc, STGMEDIUM32*,pmedium, BOOL32,fRelease);
+    ICOM_METHOD2(HRESULT,EnumFormatEtc,         DWORD,dwDirection, IEnumFORMATETC**,ppenumFormatEtc);
+    ICOM_METHOD4(HRESULT,DAdvise,               LPFORMATETC32*,pformatetc, DWORD,advf, IAdviseSink*,pAdvSink, DWORD*,pdwConnection);
+    ICOM_METHOD1(HRESULT,DUnadvise,             DWORD,dwConnection);
+    ICOM_METHOD1(HRESULT,EnumDAdvise,           IEnumSTATDATA**,ppenumAdvise);
+ICOM_END(IDataObject)
+#undef ICOM_INTERFACE
+
+#if !defined(__cplusplus) || defined(CINTERFACE)
+/*** IUnknown methods ***/
+#define IDataObject_QueryInterface(p,a,b) ICOM_ICALL2(IUnknown,QueryInterface,p,a,b)
+#define IDataObject_AddRef(p)             ICOM_ICALL (IUnknown,AddRef,p)
+#define IDataObject_Release(p)            ICOM_ICALL (IUnknown,Release,p)
+/*** IDataObject methods ***/
+#define IDataObject_GetData(p,a,b)               ICOM_CALL2(GetData,p,a,b)
+#define IDataObject_GetDataHere(p,a,b)           ICOM_CALL2(GetDataHere,p,a,b)
+#define IDataObject_QueryGetData(p,a)            ICOM_CALL1(QueryGetData,p,a)
+#define IDataObject_GetCanonicalFormatEtc(p,a,b) ICOM_CALL2(GetCanonicalFormatEtc,p,a,b)
+#define IDataObject_SetData(p,a,b,c)             ICOM_CALL3(SetData,p,a,b,c)
+#define IDataObject_EnumFormatEtc(p,a,b)         ICOM_CALL2(EnumFormatEtc,p,a,b)
+#define IDataObject_DAdvise(p,a,b,c,d)           ICOM_CALL4(DAdvise,p,a,b,c,d)
+#define IDataObject_DUnadvise(p,a)               ICOM_CALL1(DUnadvise,p,a)
+#define IDataObject_EnumDAdvise(p,a)             ICOM_CALL1(EnumDAdvise,p,a)
+#endif
+
+
+/*****************************************************************************
+ * IEnumFORMATETC interface
+ */
+#define ICOM_INTERFACE IEnumFORMATETC
+ICOM_BEGIN(IEnumFORMATETC,IUnknown)
+    ICOM_METHOD3(HRESULT,Next,  ULONG,celt, FORMATETC32*,rgelt, ULONG*,pceltFethed);
+    ICOM_METHOD1(HRESULT,Skip,  ULONG,celt);
+    ICOM_METHOD (HRESULT,Reset);
+    ICOM_METHOD1(HRESULT,Clone, IEnumFORMATETC**,ppenum);
+ICOM_END(IEnumFORMATETC)
+#undef ICOM_INTERFACE
+
+#if !defined(__cplusplus) || defined(CINTERFACE)
+/*** IUnknown methods ***/
+#define IEnumFORMATETC_QueryInterface(p,a,b) ICOM_ICALL2(IUnknown,QueryInterface,p,a,b)
+#define IEnumFORMATETC_AddRef(p)             ICOM_ICALL (IUnknown,AddRef,p)
+#define IEnumFORMATETC_Release(p)            ICOM_ICALL (IUnknown,Release,p)
+/*** IEnumFORMATETC methods ***/
+#define IEnumFORMATETC_Next(p,a,b,c) ICOM_CALL3(Next,p,a,b,c)
+#define IEnumFORMATETC_Skip(p,a)     ICOM_CALL1(Skip,p,a)
+#define IEnumFORMATETC_Reset(p)      ICOM_CALL (Reset,p)
+#define IEnumFORMATETC_Clone(p,a)    ICOM_CALL1(Clone,p,a)
+#endif
+
+
+/*****************************************************************************
+ * IEnumSTATDATA interface
+ */
+/* FIXME: not implemented */
+
+
+#endif /* __WINE_WINE_OBJ_DATAOBJECT_H */
diff --git a/include/wine/obj_marshal.h b/include/wine/obj_marshal.h
new file mode 100644
index 0000000..92fc243
--- /dev/null
+++ b/include/wine/obj_marshal.h
@@ -0,0 +1,34 @@
+/*
+ * Defines the COM interfaces and APIs that allow an interface to 
+ * specify a custom marshaling for its objects.
+ *
+ * Depends on 'obj_storage.h' and 'obj_base.h'.
+ */
+
+#ifndef __WINE_WINE_OBJ_MARSHAL_H
+#define __WINE_WINE_OBJ_MARSHAL_H
+
+
+/*****************************************************************************
+ * Predeclare the interfaces
+ */
+DEFINE_OLEGUID(IID_IMarshal,		0x00000003L, 0, 0);
+typedef struct IMarshal IMarshal,*LPMARSHAL;
+
+DEFINE_OLEGUID(IID_IStdMarshalInfo,	0x00000018L, 0, 0);
+typedef struct IStdMarshalInfo IStdMarshalInfo,*LPSTDMARSHALINFO;
+
+
+/*****************************************************************************
+ * IMarshal interface
+ */
+/* FIXME: not implemented */
+
+
+/*****************************************************************************
+ * IStdMarshalInfo interface
+ */
+/* FIXME: not implemented */
+
+
+#endif /* __WINE_WINE_OBJ_MARSHAL_H */
diff --git a/include/wine/obj_misc.h b/include/wine/obj_misc.h
new file mode 100644
index 0000000..98dc1e4
--- /dev/null
+++ b/include/wine/obj_misc.h
@@ -0,0 +1,54 @@
+/*
+ * Defines miscellaneous COM interfaces and APIs defined in objidl.h.
+ * These did not really fit into the other categories, whould have 
+ * required their own specific category or are too rarely used to be 
+ * put in 'obj_base.h'.
+ *
+ * Depends on 'obj_base.h'.
+ */
+
+#ifndef __WINE_WINE_OBJ_MISC_H
+#define __WINE_WINE_OBJ_MISC_H
+
+
+/*****************************************************************************
+ * Predeclare the interfaces
+ */
+DEFINE_OLEGUID(IID_IEnumString,		0x00000101L, 0, 0);
+typedef struct IEnumString IEnumString,*LPENUMSTRING;
+
+DEFINE_OLEGUID(IID_IEnumUnknown,	0x00000100L, 0, 0);
+typedef struct IEnumUnknown IEnumUnknown,*LPENUMUNKNOWN;
+
+DEFINE_OLEGUID(IID_IMallocSpy,		0x0000001dL, 0, 0);
+typedef struct IMallocSpy IMallocSpy,*LPMALLOCSPY;
+
+DEFINE_OLEGUID(IID_IMultiQI,		0x00000020L, 0, 0);
+typedef struct IMultiQI IMultiQI,*LPMULTIQI;
+
+
+/*****************************************************************************
+ * IEnumString interface
+ */
+/* FIXME: not implemented */
+
+
+/*****************************************************************************
+ * IEnumUnknown interface
+ */
+/* FIXME: not implemented */
+
+
+/*****************************************************************************
+ * IMallocSpy interface
+ */
+/* FIXME: not implemented */
+
+
+/*****************************************************************************
+ * IMultiQI interface
+ */
+/* FIXME: not implemented */
+
+
+#endif /* __WINE_WINE_OBJ_MISC_H */
diff --git a/include/wine/obj_moniker.h b/include/wine/obj_moniker.h
new file mode 100644
index 0000000..194ddd0
--- /dev/null
+++ b/include/wine/obj_moniker.h
@@ -0,0 +1,87 @@
+/*
+ * Defines the COM interfaces and APIs related to the moniker functionality.
+ *
+ * This file depends on 'obj_storage.h' and 'obj_base.h'.
+ */
+
+
+#ifndef __WINE_WINE_OBJ_MONIKER_H
+#define __WINE_WINE_OBJ_MONIKER_H
+
+
+/*****************************************************************************
+ * Predeclare the interfaces
+ */
+DEFINE_OLEGUID(IID_IBindCtx,0xe,0,0);
+typedef struct IBindCtx IBindCtx,*LPBINDCTX;
+typedef LPBINDCTX LPBC;
+
+DEFINE_OLEGUID(IID_IClassActivator,	0x00000140L, 0, 0);
+typedef struct IClassActivator IClassActivator,*LPCLASSACTIVATOR;
+
+DEFINE_OLEGUID(IID_IEnumMoniker,	0x00000102L, 0, 0);
+typedef struct IEnumMoniker IEnumMoniker,*LPENUMMONIKER;
+
+DEFINE_OLEGUID(IID_IMoniker,		0x0000000fL, 0, 0);
+typedef struct IMoniker IMoniker,*LPMONIKER;
+
+DEFINE_GUID   (IID_IROTData,		0xf29f6bc0L, 0x5021, 0x11ce, 0xaa, 0x15, 0x00, 0x00, 0x69, 0x01, 0x29, 0x3f);
+typedef struct IROTData IROTData,*LPROTDATA;
+
+DEFINE_OLEGUID(IID_IRunnableObject,	0x00000126L, 0, 0);
+typedef struct IRunnableObject IRunnableObject,*LPRUNNABLEOBJECT;
+
+DEFINE_OLEGUID(IID_IRunningObjectTable,	0x00000010L, 0, 0);
+typedef struct IRunningObjectTable IRunningObjectTable,*LPRUNNINGOBJECTTABLE;
+
+
+/*****************************************************************************
+ * IBindCtx interface
+ */
+/* FIXME: not implemented */
+
+
+/*****************************************************************************
+ * IClassActivator interface
+ */
+/* FIXME: not implemented */
+
+
+/*****************************************************************************
+ * IEnumMoniker interface
+ */
+/* FIXME: not implemented */
+
+
+/*****************************************************************************
+ * IMoniker interface
+ */
+/* FIXME: not implemented */
+
+HRESULT WINAPI CreateFileMoniker16(LPCOLESTR16 lpszPathName,LPMONIKER* ppmk);
+HRESULT WINAPI CreateFileMoniker32(LPCOLESTR32 lpszPathName,LPMONIKER* ppmk);
+#define CreateFileMoniker WINELIB_NAME(CreateFileMoniker)
+
+HRESULT WINAPI CreateItemMoniker32(LPCOLESTR32 lpszDelim,LPCOLESTR32 lpszItem,LPMONIKER* ppmk);
+#define CreateItemMoniker WINELIB_NAME(CreateItemMoniker)
+
+
+/*****************************************************************************
+ * IROTData interface
+ */
+/* FIXME: not implemented */
+
+
+/*****************************************************************************
+ * IRunnableObject interface
+ */
+/* FIXME: not implemented */
+
+
+/*****************************************************************************
+ * IRunningObjectTable interface
+ */
+/* FIXME: not implemented */
+
+
+#endif /* __WINE_WINE_OBJ_MONIKER_H */
diff --git a/include/wine/obj_propertystorage.h b/include/wine/obj_propertystorage.h
new file mode 100644
index 0000000..837daa1
--- /dev/null
+++ b/include/wine/obj_propertystorage.h
@@ -0,0 +1,52 @@
+/*
+ * Defines the COM interfaces and APIs related to saving properties to file.
+ *
+ * Depends on 'obj_storage.h' and 'obj_base.h'.
+ */
+
+#ifndef __WINE_WINE_OBJ_PROPERTYSTORAGE_H
+#define __WINE_WINE_OBJ_PROPERTYSTORAGE_H
+
+
+/*****************************************************************************
+ * Predeclare the interfaces
+ */
+DEFINE_OLEGUID(IID_IEnumSTATPROPSETSTG,	0x0000013bL, 0, 0);
+typedef struct IEnumSTATPROPSETSTG IEnumSTATPROPSETSTG,*LPENUMSTATPROPSETSTG;
+
+DEFINE_OLEGUID(IID_IEnumSTATPROPSTG,	0x00000139L, 0, 0);
+typedef struct IEnumSTATPROPSTG IEnumSTATPROPSTG,*LPENUMSTATPROPSTG;
+
+DEFINE_OLEGUID(IID_IPropertySetStorage,	0x0000013aL, 0, 0);
+typedef struct IPropertySetStorage IPropertySetStorage,*LPPROPERTYSETSTORAGE;
+
+DEFINE_OLEGUID(IID_IPropertyStorage,	0x00000138L, 0, 0);
+typedef struct IPropertyStorage IPropertyStorage,*LPPROPERTYSTORAGE;
+
+
+/*****************************************************************************
+ * IEnumSTATPROPSETSTG interface
+ */
+/* FIXME: not implemented */
+
+
+/*****************************************************************************
+ * IEnumSTATPROPSTG interface
+ */
+/* FIXME: not implemented */
+
+
+/*****************************************************************************
+ * IPropertySetStorage interface
+ */
+/* FIXME: not implemented */
+
+
+/*****************************************************************************
+ * IPropertyStorage interface
+ */
+/* FIXME: not implemented */
+
+
+
+#endif /* __WINE_WINE_OBJ_PROPERTYSTORAGE_H */
diff --git a/include/wine/obj_storage.h b/include/wine/obj_storage.h
new file mode 100644
index 0000000..88797d6
--- /dev/null
+++ b/include/wine/obj_storage.h
@@ -0,0 +1,459 @@
+/*
+ * Defines the COM interfaces and APIs related to structured data storage.
+ *
+ * Depends on 'obj_base.h'.
+ */
+
+#ifndef __WINE_WINE_OBJ_STORAGE_H
+#define __WINE_WINE_OBJ_STORAGE_H
+
+
+#include "winnt.h"
+
+
+/*****************************************************************************
+ * Predeclare the structures
+ */
+typedef LPOLESTR16 *SNB16;
+typedef LPOLESTR32 *SNB32;
+DECL_WINELIB_TYPE(SNB)
+
+typedef struct STATSTG STATSTG;
+
+
+/*****************************************************************************
+ * Predeclare the interfaces
+ */
+DEFINE_OLEGUID(IID_IEnumSTATSTG,	0x0000000dL, 0, 0);
+typedef struct IEnumSTATSTG IEnumSTATSTG,*LPENUMSTATSTG;
+
+DEFINE_GUID   (IID_IFillLockBytes,	0x99caf010L, 0x415e, 0x11cf, 0x88, 0x14, 0x00, 0xaa, 0x00, 0xb5, 0x69, 0xf5);
+typedef struct IFillLockBytes IFillLockBytes,*LPFILLLOCKBYTES;
+
+DEFINE_GUID   (IID_ILayoutStorage,	0x0e6d4d90L, 0x6738, 0x11cf, 0x96, 0x08, 0x00, 0xaa, 0x00, 0x68, 0x0d, 0xb4);
+typedef struct ILayoutStorage ILayoutStorage,*LPLAYOUTSTORAGE;
+
+DEFINE_OLEGUID(IID_ILockBytes,		0x0000000aL, 0, 0);
+typedef struct ILockBytes ILockBytes,*LPLOCKBYTES;
+
+DEFINE_OLEGUID(IID_IPersist,		0x0000010cL, 0, 0);
+typedef struct IPersist IPersist,*LPPERSIST;
+
+DEFINE_OLEGUID(IID_IPersistFile,	0x0000010bL, 0, 0);
+typedef struct IPersistFile IPersistFile,*LPPERSISTFILE;
+
+DEFINE_OLEGUID(IID_IPersistStorage,	0x0000010aL, 0, 0);
+typedef struct IPersistStorage IPersistStorage,*LPPERSISTSTORAGE;
+
+DEFINE_OLEGUID(IID_IPersistStream,	0x00000109L, 0, 0);
+typedef struct IPersistStream IPersistStream,*LPPERSISTSTREAM;
+
+DEFINE_GUID   (IID_IProgressNotify,	0xa9d758a0L, 0x4617, 0x11cf, 0x95, 0xfc, 0x00, 0xaa, 0x00, 0x68, 0x0d, 0xb4);
+typedef struct IProgressNotify IProgressNotify,*LPPROGRESSNOTIFY;
+
+DEFINE_OLEGUID(IID_IRootStorage,	0x00000012L, 0, 0);
+typedef struct IRootStorage IRootStorage,*LPROOTSTORAGE;
+
+DEFINE_GUID   (IID_ISequentialStream,	0x0c733a30L, 0x2a1c, 0x11ce, 0xad, 0xe5, 0x00, 0xaa, 0x00, 0x44, 0x77, 0x3d);
+typedef struct ISequentialStream ISequentialStream,*LPSEQUENTIALSTREAM;
+
+DEFINE_OLEGUID(IID_IStorage,		0x0000000bL, 0, 0);
+typedef struct IStorage16 IStorage16,*LPSTORAGE16;
+typedef struct IStorage32 IStorage32,*LPSTORAGE32;
+DECL_WINELIB_TYPE(IStorage)
+DECL_WINELIB_TYPE(LPSTORAGE)
+
+DEFINE_OLEGUID(IID_IStream,		0x0000000cL, 0, 0);
+typedef struct IStream16 IStream16,*LPSTREAM16;
+typedef struct IStream32 IStream32,*LPSTREAM32;
+DECL_WINELIB_TYPE(IStream)
+DECL_WINELIB_TYPE(LPSTREAM)
+
+
+/*****************************************************************************
+ * STGM enumeration
+ *
+ * See IStorage and IStream
+ */
+#define STGM_DIRECT		0x00000000
+#define STGM_TRANSACTED		0x00010000
+#define STGM_SIMPLE		0x08000000
+#define STGM_READ		0x00000000
+#define STGM_WRITE		0x00000001
+#define STGM_READWRITE		0x00000002
+#define STGM_SHARE_DENY_NONE	0x00000040
+#define STGM_SHARE_DENY_READ	0x00000030
+#define STGM_SHARE_DENY_WRITE	0x00000020
+#define STGM_SHARE_EXCLUSIVE	0x00000010
+#define STGM_PRIORITY		0x00040000
+#define STGM_DELETEONRELEASE	0x04000000
+#define STGM_CREATE		0x00001000
+#define STGM_CONVERT		0x00020000
+#define STGM_FAILIFTHERE	0x00000000
+#define STGM_NOSCRATCH		0x00100000
+#define STGM_NOSNAPSHOT		0x00200000
+
+
+/*****************************************************************************
+ * STATSTG structure
+ */
+struct STATSTG {
+    LPOLESTR16	pwcsName;
+    DWORD	type;
+    ULARGE_INTEGER cbSize;
+    FILETIME	mtime;
+    FILETIME	ctime;
+    FILETIME	atime;
+    DWORD	grfMode;
+    DWORD	grfLocksSupported;
+    CLSID	clsid;
+    DWORD	grfStateBits;
+    DWORD	reserved;
+};
+
+
+/*****************************************************************************
+ * IEnumSTATSTG interface
+ */
+/* FIXME: not implemented */
+
+
+/*****************************************************************************
+ * IFillLockBytes interface
+ */
+/* FIXME: not implemented */
+
+
+/*****************************************************************************
+ * ILayoutStorage interface
+ */
+/* FIXME: not implemented */
+
+
+/*****************************************************************************
+ * ILockBytes interface
+ */
+/* FIXME: not implemented */
+
+
+/*****************************************************************************
+ * IPersist interface
+ */
+#define ICOM_INTERFACE IPersist
+ICOM_BEGIN(IPersist,IUnknown)
+    ICOM_CMETHOD1(HRESULT,GetClassID, CLSID*,pClassID);
+ICOM_END(IPersist)
+#undef ICOM_INTERFACE
+
+#if !defined(__cplusplus) || defined(CINTERFACE)
+/*** IUnknown methods ***/
+#define IPersist_QueryInterface(p,a,b) ICOM_ICALL2(IUnknown,QueryInterface,p,a,b)
+#define IPersist_AddRef(p)             ICOM_ICALL (IUnknown,AddRef,p)
+#define IPersist_Release(p)            ICOM_ICALL (IUnknown,Release,p)
+/*** IPersist methods ***/
+#define IPersist_GetClassID(p,a) ICOM_CALL1(GetClassID,p,a)
+#endif
+
+
+/*****************************************************************************
+ * IPersistFile interface
+ */
+#define ICOM_INTERFACE IPersistFile
+ICOM_BEGIN(IPersistFile,IPersist)
+    ICOM_CMETHOD (HRESULT,IsDirty);
+    ICOM_METHOD2 (HRESULT,Load,          LPCOLESTR32,pszFileName, DWORD,dwMode);
+    ICOM_METHOD2 (HRESULT,Save,          LPCOLESTR32,pszFileName, BOOL32,fRemember);
+    ICOM_METHOD1 (HRESULT,SaveCompleted, LPCOLESTR32,pszFileName);
+    ICOM_CMETHOD1(HRESULT,GetCurFile,    LPOLESTR32*,ppszFileName);
+ICOM_END(IPersistFile)
+#undef ICOM_INTERFACE
+
+#if !defined(__cplusplus) || defined(CINTERFACE)
+/*** IUnknown methods ***/
+#define IPersistFile_QueryInterface(p,a,b) ICOM_ICALL2(IUnknown,QueryInterface,p,a,b)
+#define IPersistFile_AddRef(p)             ICOM_ICALL (IUnknown,AddRef,p)
+#define IPersistFile_Release(p)            ICOM_ICALL (IUnknown,Release,p)
+/*** IPersist methods ***/
+#define IPersistFile_GetClassID(p,a) ICOM_ICALL1(IPersist,GetClassID,p,a)
+/*** IPersistFile methods ***/
+#define IPersistFile_IsDirty(p)         ICOM_CALL(IsDirty,p)
+#define IPersistFile_Load(p,a,b)        ICOM_CALL(Load,p,a,b)
+#define IPersistFile_Save(p,a,b)        ICOM_CALL(Save,p,a,b)
+#define IPersistFile_SaveCompleted(p,a) ICOM_CALL(SaveCompleted,p,a)
+#define IPersistFile_GetCurFile(p,a)    ICOM_CALL(GetCurFile,p,a)
+#endif
+
+
+/*****************************************************************************
+ * IPersistStorage interface
+ */
+/* FIXME: not implemented */
+
+
+/*****************************************************************************
+ * IPersistStream interface
+ */
+/* FIXME: not implemented */
+
+
+/*****************************************************************************
+ * IProgressNotify interface
+ */
+/* FIXME: not implemented */
+
+
+/*****************************************************************************
+ * IRootStorage interface
+ */
+/* FIXME: not implemented */
+
+
+/*****************************************************************************
+ * ISequentialStream interface
+ */
+#define ICOM_INTERFACE ISequentialStream
+ICOM_BEGIN(ISequentialStream,IUnknown)
+    ICOM_METHOD3(HRESULT,Read,        void*,pv, ULONG,cb, ULONG*,pcbRead);
+    ICOM_METHOD3(HRESULT,Write,       const void*,pv, ULONG,cb, ULONG*,pcbWritten);
+ICOM_END(ISequentialStream)
+#undef ICOM_INTERFACE
+
+#if !defined(__cplusplus) || defined(CINTERFACE)
+/*** IUnknown methods ***/
+#define ISequentialStream_QueryInterface(p,a,b) ICOM_ICALL2(IUnknown,QueryInterface,p,a,b)
+#define ISequentialStream_AddRef(p)             ICOM_ICALL (IUnknown,AddRef,p)
+#define ISequentialStream_Release(p)            ICOM_ICALL (IUnknown,Release,p)
+/*** ISequentialStream methods ***/
+#define ISequentialStream_Read(p,a,b,c)  ICOM_CALL3(Read,p,a,b,c)
+#define ISequentialStream_Write(p,a,b,c) ICOM_CALL3(Write,p,a,b,c)
+#endif
+
+
+/*****************************************************************************
+ * IStorage interface
+ */
+#define ICOM_INTERFACE IStorage16
+ICOM_BEGIN(IStorage16,IUnknown)
+    ICOM_METHOD5(HRESULT,CreateStream,   LPCOLESTR16,pwcsName, DWORD,grfMode, DWORD,reserved1, DWORD,reserved2, IStream16**,ppstm)
+    ICOM_METHOD5(HRESULT,OpenStream,     LPCOLESTR16,pwcsName, void*,reserved1, DWORD,grfMode, DWORD,reserved2, IStream16**,ppstm)
+    ICOM_METHOD5(HRESULT,CreateStorage,  LPCOLESTR16,pwcsName, DWORD,grfMode, DWORD,dwStgFmt, DWORD,reserved2, IStorage16**,ppstg)
+    ICOM_METHOD6(HRESULT,OpenStorage,    LPCOLESTR16,pwcsName, IStorage16*,pstgPriority, DWORD,grfMode, SNB16,snb16Exclude, DWORD,reserved, IStorage16**,ppstg)
+    ICOM_METHOD4(HRESULT,CopyTo,         DWORD,ciidExclude, const IID*,rgiidExclude, SNB16,snb16Exclude, IStorage16*,pstgDest)
+    ICOM_METHOD4(HRESULT,MoveElementTo,  LPCOLESTR16,pwcsName, IStorage16*,pstgDest, LPCOLESTR16,pwcsNewName, DWORD,grfFlags)
+    ICOM_METHOD1(HRESULT,Commit,         DWORD,grfCommitFlags)
+    ICOM_METHOD (HRESULT,Revert)
+    ICOM_METHOD4(HRESULT,EnumElements,   DWORD,reserved1, void*,reserved2, DWORD,reserved3, IEnumSTATSTG**,ppenum)
+    ICOM_METHOD1(HRESULT,DestroyElement, LPCOLESTR16,pwcsName)
+    ICOM_METHOD2(HRESULT,RenameElement,  LPCOLESTR16,pwcsOldName, LPCOLESTR16,pwcsNewName)
+    ICOM_METHOD4(HRESULT,SetElementTimes,LPCOLESTR16,pwcsName, const FILETIME*,pctime, const FILETIME*,patime, const FILETIME*,pmtime)
+    ICOM_METHOD1(HRESULT,SetClass,       REFCLSID,clsid)
+    ICOM_METHOD2(HRESULT,SetStateBits,   DWORD,grfStateBits, DWORD,grfMask)
+    ICOM_METHOD2(HRESULT,Stat,           STATSTG*,pstatstg, DWORD,grfStatFlag)
+ICOM_END(IStorage16)
+#undef ICOM_INTERFACE
+
+#if !defined(__cplusplus) || defined(CINTERFACE)
+/*** IUnknown methods ***/
+#define IStorage16_QueryInterface(p,a,b) ICOM_ICALL2(IUnknown,QueryInterface,p,a,b)
+#define IStorage16_AddRef(p)             ICOM_ICALL (IUnknown,AddRef,p)
+#define IStorage16_Release(p)            ICOM_ICALL (IUnknown,Release,p)
+/*** IStorage16 methods ***/
+#define IStorage16_CreateStream(p,a,b,c,d,e)  ICOM_CALL5(CreateStream,p,a,b,c,d,e)
+#define IStorage16_OpenStream(p,a,b,c,d,e)    ICOM_CALL5(OpenStream,p,a,b,c,d,e)
+#define IStorage16_CreateStorage(p,a,b,c,d,e) ICOM_CALL5(CreateStorage,p,a,b,c,d,e)
+#define IStorage16_OpenStorage(p,a,b,c,d,e,f) ICOM_CALL6(OpenStorage,p,a,b,c,d,e,f)
+#define IStorage16_CopyTo(p,a,b,c,d)          ICOM_CALL4(CopyTo,p,a,b,c,d)
+#define IStorage16_MoveElementTo(p,a,b,c,d)   ICOM_CALL4(MoveElementTo,p,a,b,c,d)
+#define IStorage16_Commit(p,a)                ICOM_CALL1(Commit,p,a)
+#define IStorage16_Revert(p)                  ICOM_CALL (Revert,p)
+#define IStorage16_EnumElements(p,a,b,c,d)    ICOM_CALL4(EnumElements,p,a,b,c,d)
+#define IStorage16_DestroyElement(p,a)        ICOM_CALL1(DestroyElement,p,a)
+#define IStorage16_RenameElement(p,a,b)       ICOM_CALL2(RenameElement,p,a,b)
+#define IStorage16_SetElementTimes(p,a,b,c,d) ICOM_CALL4(SetElementTimes,p,a,b,c,d)
+#define IStorage16_SetClass(p,a)              ICOM_CALL1(SetClass,p,a)
+#define IStorage16_SetStateBits(p,a,b)        ICOM_CALL2(SetStateBits,p,a,b)
+#define IStorage16_Stat(p,a,b)                ICOM_CALL2(Stat,p,a,b)
+#endif
+
+
+#define ICOM_INTERFACE IStorage32
+ICOM_BEGIN(IStorage32,IUnknown)
+    ICOM_METHOD5(HRESULT,CreateStream,   LPCOLESTR32,pwcsName, DWORD,grfMode, DWORD,reserved1, DWORD,reserved2, IStream32**,ppstm);
+    ICOM_METHOD5(HRESULT,OpenStream,     LPCOLESTR32,pwcsName, void*,reserved1, DWORD,grfMode, DWORD,reserved2, IStream32**,ppstm);
+    ICOM_METHOD5(HRESULT,CreateStorage,  LPCOLESTR32,pwcsName, DWORD,grfMode, DWORD,dwStgFmt, DWORD,reserved2, IStorage32**,ppstg);
+    ICOM_METHOD6(HRESULT,OpenStorage,    LPCOLESTR32,pwcsName, IStorage32*,pstgPriority, DWORD,grfMode, SNB32,snb16Exclude, DWORD,reserved, IStorage32**,ppstg);
+    ICOM_METHOD4(HRESULT,CopyTo,         DWORD,ciidExclude, const IID*,rgiidExclude, SNB32,snb16Exclude, IStorage32*,pstgDest);
+    ICOM_METHOD4(HRESULT,MoveElementTo,  LPCOLESTR32,pwcsName, IStorage32*,pstgDest, LPCOLESTR32,pwcsNewName, DWORD,grfFlags);
+    ICOM_METHOD1(HRESULT,Commit,         DWORD,grfCommitFlags);
+    ICOM_METHOD (HRESULT,Revert);
+    ICOM_METHOD4(HRESULT,EnumElements,   DWORD,reserved1, void*,reserved2, DWORD,reserved3, IEnumSTATSTG**,ppenum);
+    ICOM_METHOD1(HRESULT,DestroyElement, LPCOLESTR32,pwcsName);
+    ICOM_METHOD2(HRESULT,RenameElement,  LPCOLESTR32,pwcsOldName, LPCOLESTR32,pwcsNewName);
+    ICOM_METHOD4(HRESULT,SetElementTimes,LPCOLESTR32,pwcsName, const FILETIME*,pctime, const FILETIME*,patime, const FILETIME*,pmtime);
+    ICOM_METHOD1(HRESULT,SetClass,       REFCLSID,clsid);
+    ICOM_METHOD2(HRESULT,SetStateBits,   DWORD,grfStateBits, DWORD,grfMask);
+    ICOM_METHOD2(HRESULT,Stat,           STATSTG*,pstatstg, DWORD,grfStatFlag);
+ICOM_END(IStorage32)
+#undef ICOM_INTERFACE
+
+#if !defined(__cplusplus) || defined(CINTERFACE)
+/*** IUnknown methods ***/
+#define IStorage32_QueryInterface(p,a,b) ICOM_ICALL2(IUnknown,QueryInterface,p,a,b)
+#define IStorage32_AddRef(p)             ICOM_ICALL (IUnknown,AddRef,p)
+#define IStorage32_Release(p)            ICOM_ICALL (IUnknown,Release,p)
+/*** IStorage32 methods ***/
+#define IStorage32_CreateStream(p,a,b,c,d,e)  ICOM_CALL5(CreateStream,p,a,b,c,d,e)
+#define IStorage32_OpenStream(p,a,b,c,d,e)    ICOM_CALL5(OpenStream,p,a,b,c,d,e)
+#define IStorage32_CreateStorage(p,a,b,c,d,e) ICOM_CALL5(CreateStorage,p,a,b,c,d,e)
+#define IStorage32_OpenStorage(p,a,b,c,d,e,f) ICOM_CALL6(OpenStorage,p,a,b,c,d,e,f)
+#define IStorage32_CopyTo(p,a,b,c,d)          ICOM_CALL4(CopyTo,p,a,b,c,d)
+#define IStorage32_MoveElementTo(p,a,b,c,d)   ICOM_CALL4(MoveElementTo,p,a,b,c,d)
+#define IStorage32_Commit(p,a)                ICOM_CALL1(Commit,p,a)
+#define IStorage32_Revert(p)                  ICOM_CALL (Revert,p)
+#define IStorage32_EnumElements(p,a,b,c,d)    ICOM_CALL4(EnumElements,p,a,b,c,d)
+#define IStorage32_DestroyElement(p,a)        ICOM_CALL1(DestroyElement,p,a)
+#define IStorage32_RenameElement(p,a,b)       ICOM_CALL2(RenameElement,p,a,b)
+#define IStorage32_SetElementTimes(p,a,b,c,d) ICOM_CALL4(SetElementTimes,p,a,b,c,d)
+#define IStorage32_SetClass(p,a)              ICOM_CALL1(SetClass,p,a)
+#define IStorage32_SetStateBits(p,a,b)        ICOM_CALL2(SetStateBits,p,a,b)
+#define IStorage32_Stat(p,a,b)                ICOM_CALL2(Stat,p,a,b)
+
+#ifndef __WINE__
+/* Duplicated for WINELIB */
+/*** IUnknown methods ***/
+#define IStorage_QueryInterface(p,a,b) ICOM_ICALL2(IUnknown,QueryInterface,p,a,b)
+#define IStorage_AddRef(p)             ICOM_ICALL (IUnknown,AddRef,p)
+#define IStorage_Release(p)            ICOM_ICALL (IUnknown,Release,p)
+/*** IStorage methods ***/
+#define IStorage_CreateStream(p,a,b,c,d,e)  ICOM_CALL5(CreateStream,p,a,b,c,d,e)
+#define IStorage_OpenStream(p,a,b,c,d,e)    ICOM_CALL5(OpenStream,p,a,b,c,d,e)
+#define IStorage_CreateStorage(p,a,b,c,d,e) ICOM_CALL5(CreateStorage,p,a,b,c,d,e)
+#define IStorage_OpenStorage(p,a,b,c,d,e,f) ICOM_CALL6(OpenStorage,p,a,b,c,d,e,f)
+#define IStorage_CopyTo(p,a,b,c,d)          ICOM_CALL4(CopyTo,p,a,b,c,d)
+#define IStorage_MoveElementTo(p,a,b,c,d)   ICOM_CALL4(MoveElementTo,p,a,b,c,d)
+#define IStorage_Commit(p,a)                ICOM_CALL1(Commit,p,a)
+#define IStorage_Revert(p)                  ICOM_CALL (Revert,p)
+#define IStorage_EnumElements(p,a,b,c,d)    ICOM_CALL4(EnumElements,p,a,b,c,d)
+#define IStorage_DestroyElement(p,a)        ICOM_CALL1(DestroyElement,p,a)
+#define IStorage_RenameElement(p,a,b)       ICOM_CALL2(RenameElement,p,a,b)
+#define IStorage_SetElementTimes(p,a,b,c,d) ICOM_CALL4(SetElementTimes,p,a,b,c,d)
+#define IStorage_SetClass(p,a)              ICOM_CALL1(SetClass,p,a)
+#define IStorage_SetStateBits(p,a,b)        ICOM_CALL2(SetStateBits,p,a,b)
+#define IStorage_Stat(p,a,b)                ICOM_CALL2(Stat,p,a,b)
+#endif
+#endif
+
+
+/*****************************************************************************
+ * IStream interface
+ */
+#define ICOM_INTERFACE IStream16
+ICOM_BEGIN(IStream16,ISequentialStream)
+    ICOM_METHOD3(HRESULT,Seek,        LARGE_INTEGER,dlibMove, DWORD,dwOrigin, ULARGE_INTEGER*,plibNewPosition); 
+    ICOM_METHOD1(HRESULT,SetSize,     ULARGE_INTEGER,libNewSize);
+    ICOM_METHOD4(HRESULT,CopyTo,      IStream16*,pstm, ULARGE_INTEGER,cb, ULARGE_INTEGER*,pcbRead, ULARGE_INTEGER*,pcbWritten);
+    ICOM_METHOD1(HRESULT,Commit,      DWORD,grfCommitFlags);
+    ICOM_METHOD (HRESULT,Revert);
+    ICOM_METHOD3(HRESULT,LockRegion,  ULARGE_INTEGER,libOffset, ULARGE_INTEGER,cb, DWORD,dwLockType);
+    ICOM_METHOD3(HRESULT,UnlockRegion,ULARGE_INTEGER,libOffset, ULARGE_INTEGER,cb, DWORD,dwLockType);
+    ICOM_METHOD2(HRESULT,Stat,        STATSTG*,pstatstg, DWORD,grfStatFlag);
+    ICOM_METHOD1(HRESULT,Clone,       IStream16**,ppstm);
+ICOM_END(IStream16)
+#undef ICOM_INTERFACE
+
+#if !defined(__cplusplus) || defined(CINTERFACE)
+/*** IUnknown methods ***/
+#define IStream16_QueryInterface(p,a,b) ICOM_ICALL2(IUnknown,QueryInterface,p,a,b)
+#define IStream16_AddRef(p)             ICOM_ICALL (IUnknown,AddRef,p)
+#define IStream16_Release(p)            ICOM_ICALL (IUnknown,Release,p)
+/*** ISequentialStream methods ***/
+#define IStream16_Read(p,a,b,c)  ICOM_ICALL3(ISequentialStream,Read,p,a,b,c)
+#define IStream16_Write(p,a,b,c) ICOM_ICALL3(ISequentialStream,Write,p,a,b,c)
+/*** IStream16 methods ***/
+#define IStream16_Seek(p)               ICOM_CALL3(Seek,p)
+#define IStream16_SetSize(p,a,b)        ICOM_CALL1(SetSize,p,a,b)
+#define IStream16_CopyTo(pa,b,c,d)      ICOM_CALL4(CopyTo,pa,b,c,d)
+#define IStream16_Commit(p,a)           ICOM_CALL1(Commit,p,a)
+#define IStream16_Revert(p)             ICOM_CALL (Revert,p)
+#define IStream16_LockRegion(pa,b,c)    ICOM_CALL3(LockRegion,pa,b,c)
+#define IStream16_UnlockRegion(p,a,b,c) ICOM_CALL3(UnlockRegion,p,a,b,c)
+#define IStream16_Stat(p,a,b)           ICOM_CALL2(Stat,p,a,b)
+#define IStream16_Clone(p,a)            ICOM_CALL1(Clone,p,a)
+#endif
+
+
+#define ICOM_INTERFACE IStream32
+ICOM_BEGIN(IStream32,ISequentialStream)
+    ICOM_METHOD3(HRESULT,Seek,        LARGE_INTEGER,dlibMove, DWORD,dwOrigin, ULARGE_INTEGER*,plibNewPosition); 
+    ICOM_METHOD1(HRESULT,SetSize,     ULARGE_INTEGER,libNewSize);
+    ICOM_METHOD4(HRESULT,CopyTo,      IStream32*,pstm, ULARGE_INTEGER,cb, ULARGE_INTEGER*,pcbRead, ULARGE_INTEGER*,pcbWritten);
+    ICOM_METHOD1(HRESULT,Commit,      DWORD,grfCommitFlags);
+    ICOM_METHOD (HRESULT,Revert);
+    ICOM_METHOD3(HRESULT,LockRegion,  ULARGE_INTEGER,libOffset, ULARGE_INTEGER,cb, DWORD,dwLockType);
+    ICOM_METHOD3(HRESULT,UnlockRegion,ULARGE_INTEGER,libOffset, ULARGE_INTEGER,cb, DWORD,dwLockType);
+    ICOM_METHOD2(HRESULT,Stat,        STATSTG*,pstatstg, DWORD,grfStatFlag);
+    ICOM_METHOD1(HRESULT,Clone,       IStream32**,ppstm);
+ICOM_END(IStream32)
+#undef ICOM_INTERFACE
+
+#if !defined(__cplusplus) || defined(CINTERFACE)
+/*** IUnknown methods ***/
+#define IStream32_QueryInterface(p,a,b) ICOM_ICALL2(IUnknown,QueryInterface,p,a,b)
+#define IStream32_AddRef(p)             ICOM_ICALL (IUnknown,AddRef,p)
+#define IStream32_Release(p)            ICOM_ICALL (IUnknown,Release,p)
+/*** ISequentialStream methods ***/
+#define IStream32_Read(p,a,b,c)  ICOM_ICALL3(ISequentialStream,Read,p,a,b,c)
+#define IStream32_Write(p,a,b,c) ICOM_ICALL3(ISequentialStream,Write,p,a,b,c)
+/*** IStream32 methods ***/
+#define IStream32_Seek(p)               ICOM_CALL3(Seek,p)
+#define IStream32_SetSize(p,a,b)        ICOM_CALL1(SetSize,p,a,b)
+#define IStream32_CopyTo(pa,b,c,d)      ICOM_CALL4(CopyTo,pa,b,c,d)
+#define IStream32_Commit(p,a)           ICOM_CALL1(Commit,p,a)
+#define IStream32_Revert(p)             ICOM_CALL (Revert,p)
+#define IStream32_LockRegion(pa,b,c)    ICOM_CALL3(LockRegion,pa,b,c)
+#define IStream32_UnlockRegion(p,a,b,c) ICOM_CALL3(UnlockRegion,p,a,b,c)
+#define IStream32_Stat(p,a,b)           ICOM_CALL2(Stat,p,a,b)
+#define IStream32_Clone(p,a)            ICOM_CALL1(Clone,p,a)
+
+#ifndef __WINE__
+/* Duplicated for WINELIB */
+/*** IUnknown methods ***/
+#define IStream_QueryInterface(p,a,b) ICOM_ICALL2(IUnknown,QueryInterface,p,a,b)
+#define IStream_AddRef(p)             ICOM_ICALL (IUnknown,AddRef,p)
+#define IStream_Release(p)            ICOM_ICALL (IUnknown,Release,p)
+/*** ISequentialStream methods ***/
+#define IStream_Read(p,a,b,c)  ICOM_ICALL3(ISequentialStream,Read,p,a,b,c)
+#define IStream_Write(p,a,b,c) ICOM_ICALL3(ISequentialStream,Write,p,a,b,c)
+/*** IStream methods ***/
+#define IStream_Seek(p)               ICOM_CALL3(Seek,p)
+#define IStream_SetSize(p,a,b)        ICOM_CALL1(SetSize,p,a,b)
+#define IStream_CopyTo(pa,b,c,d)      ICOM_CALL4(CopyTo,pa,b,c,d)
+#define IStream_Commit(p,a)           ICOM_CALL1(Commit,p,a)
+#define IStream_Revert(p)             ICOM_CALL (Revert,p)
+#define IStream_LockRegion(pa,b,c)    ICOM_CALL3(LockRegion,pa,b,c)
+#define IStream_UnlockRegion(p,a,b,c) ICOM_CALL3(UnlockRegion,p,a,b,c)
+#define IStream_Stat(p,a,b)           ICOM_CALL2(Stat,p,a,b)
+#define IStream_Clone(p,a)            ICOM_CALL1(Clone,p,a)
+#endif
+#endif
+
+
+/*****************************************************************************
+ * StgXXX API
+ */
+/* FIXME: many functions are missing */
+HRESULT WINAPI StgCreateDocFile16(LPCOLESTR16 pwcsName,DWORD grfMode,DWORD reserved,IStorage16 **ppstgOpen);
+HRESULT WINAPI StgCreateDocfile32(LPCOLESTR32 pwcsName,DWORD grfMode,DWORD reserved,IStorage32 **ppstgOpen);
+#define StgCreateDocfile WINELIB_NAME(StgCreateDocfile)
+
+HRESULT WINAPI StgIsStorageFile16(LPCOLESTR16 fn);
+HRESULT WINAPI StgIsStorageFile32(LPCOLESTR32 fn);
+#define StgIsStorageFile WINELIB_NAME(StgIsStorageFile)
+
+HRESULT WINAPI StgOpenStorage16(const OLECHAR16* pwcsName,IStorage16* pstgPriority,DWORD grfMode,SNB16 snbExclude,DWORD reserved,IStorage16**ppstgOpen);
+HRESULT WINAPI StgOpenStorage32(const OLECHAR32* pwcsName,IStorage32* pstgPriority,DWORD grfMode,SNB32 snbExclude,DWORD reserved,IStorage32**ppstgOpen);
+#define StgOpenStorage WINELIB_NAME(StgOpenStorage)
+
+
+
+#endif /* __WINE_WINE_OBJ_STORAGE_H */
diff --git a/include/winerror.h b/include/winerror.h
index da07d75..b7fdcbb 100644
--- a/include/winerror.h
+++ b/include/winerror.h
@@ -145,8 +145,9 @@
 
 /* HRESULT values for OLE, SHELL and other Interface stuff */
 /* the codes 4000-40ff are reserved for OLE */
-#define	NOERROR				0
-#define	S_OK				0
+#define NOERROR                                0L
+#define S_OK                                   ((HRESULT)0L)
+#define S_FALSE                                ((HRESULT)1L)
 
 #define DISP_E_BADVARTYPE   0x80020008L
 #define DISP_E_OVERFLOW     0x8002000AL
diff --git a/include/wtypes.h b/include/wtypes.h
new file mode 100644
index 0000000..8d21349
--- /dev/null
+++ b/include/wtypes.h
@@ -0,0 +1,68 @@
+/*
+ * Defines the basic types used by COM interfaces.
+ */
+
+#ifndef __WINE_WTYPES_H
+#define __WINE_WTYPES_H
+
+
+#include "wintypes.h"
+
+
+typedef WORD CLIPFORMAT32, *LPCLIPFORMAT32;
+DECL_WINELIB_TYPE(CLIPFORMAT)
+
+typedef CHAR		OLECHAR16;
+typedef WCHAR		OLECHAR32;
+DECL_WINELIB_TYPE(OLECHAR)
+
+typedef LPSTR		LPOLESTR16;
+typedef LPWSTR		LPOLESTR32;
+DECL_WINELIB_TYPE(LPOLESTR)
+
+typedef LPCSTR		LPCOLESTR16;
+typedef LPCWSTR		LPCOLESTR32;
+DECL_WINELIB_TYPE(LPCOLESTR)
+
+typedef OLECHAR16	*BSTR16;
+typedef OLECHAR32	*BSTR32;
+DECL_WINELIB_TYPE(BSTR)
+
+typedef BSTR16		*LPBSTR16;
+typedef BSTR32		*LPBSTR32;
+DECL_WINELIB_TYPE(LPBSTR)
+
+struct _GUID
+{
+    DWORD Data1;
+    WORD  Data2;
+    WORD  Data3;
+    BYTE  Data4[8];
+};
+
+typedef struct _GUID	GUID,*LPGUID,*REFGUID;
+typedef struct _GUID	CLSID,*LPCLSID,*REFCLSID;
+typedef struct _GUID	IID,*REFIID,*LPIID;
+
+#define DECLARE_HANDLE(a)  typedef HANDLE16 a##16; typedef HANDLE32 a##32
+DECLARE_HANDLE(HMETAFILEPICT);
+#undef DECLARE_HANDLE
+
+typedef enum tagCLSCTX
+{
+    CLSCTX_INPROC_SERVER     = 0x1,
+    CLSCTX_INPROC_HANDLER    = 0x2,
+    CLSCTX_LOCAL_SERVER      = 0x4,
+    CLSCTX_INPROC_SERVER16   = 0x8,
+    CLSCTX_REMOTE_SERVER     = 0x10,
+    CLSCTX_INPROC_HANDLER16  = 0x20,
+    CLSCTX_INPROC_SERVERX86  = 0x40,
+    CLSCTX_INPROC_HANDLERX86 = 0x80
+} CLSCTX;
+
+#define CLSCTX_INPROC           (CLSCTX_INPROC_SERVER | CLSCTX_INPROC_HANDLER)
+#define CLSCTX_ALL              (CLSCTX_INPROC_SERVER | CLSCTX_INPROC_HANDLER | CLSCTX_LOCAL_SERVER | CLSCTX_REMOTE_SERVER)
+#define CLSCTX_SERVER           (CLSCTX_INPROC_SERVER | CLSCTX_LOCAL_SERVER | CLSCTX_REMOTE_SERVER)
+
+
+#endif /* __WINE_WTYPES_H */
diff --git a/include/x11drv.h b/include/x11drv.h
index 01dfb7a..1e89604 100644
--- a/include/x11drv.h
+++ b/include/x11drv.h
@@ -272,6 +272,8 @@
 extern UINT16 X11DRV_KEYBOARD_MapVirtualKey(UINT16 wCode, UINT16 wMapType);
 extern INT16 X11DRV_KEYBOARD_GetKeyNameText(LONG lParam, LPSTR lpBuffer, INT16 nSize);
 extern INT16 X11DRV_KEYBOARD_ToAscii(UINT16 virtKey, UINT16 scanCode, LPBYTE lpKeyState, LPVOID lpChar, UINT16 flags);
+extern void KEYBOARD_HandleEvent( WND *pWnd, XKeyEvent *event );
+extern void KEYBOARD_UpdateState ( void );
 
 /* X11 mouse driver */
 
diff --git a/libtest/.cvsignore b/libtest/.cvsignore
index 19e3247..eff5fce 100644
--- a/libtest/.cvsignore
+++ b/libtest/.cvsignore
@@ -9,3 +9,5 @@
 hello5
 new
 rolex
+vartest
+volinfo
diff --git a/libtest/Makefile.in b/libtest/Makefile.in
index 084a2a6..f93f344 100644
--- a/libtest/Makefile.in
+++ b/libtest/Makefile.in
@@ -4,7 +4,7 @@
 VPATH     = @srcdir@
 MODULE    = none
 RCFLAGS   = -w32 -h
-PROGRAMS  = expand hello hello2 hello3 hello4 hello5 new rolex volinfo
+PROGRAMS  = expand hello hello2 hello3 hello4 hello5 new rolex vartest volinfo
 ALL_LIBS  = $(WINELIB) $(X_LIBS) $(XLIB) $(LIBS)
 
 C_SRCS = \
@@ -16,6 +16,7 @@
 	hello5.c \
 	new.c \
 	rolex.c \
+	vartest.c \
 	volinfo.c
 
 RC_SRCS = \
@@ -54,6 +55,9 @@
 rolex: rolex.o
 	$(CC) -o rolex rolex.o $(LDOPTIONS) $(ALL_LIBS)
 
+vartest: vartest.o
+	$(CC) -o vartest vartest.o $(LDOPTIONS) $(ALL_LIBS)
+
 volinfo: volinfo.o
 	$(CC) -o volinfo volinfo.o $(LDOPTIONS) $(ALL_LIBS)
 
diff --git a/libtest/vartest-Win32.log b/libtest/vartest-Win32.log
new file mode 100644
index 0000000..3377dcc
--- /dev/null
+++ b/libtest/vartest-Win32.log
@@ -0,0 +1,1800 @@
+
+
+======== Testing VarUI1FromXXX ========
+VarUI1FromI2: passing in NULL as return val makes it crash, 0
+VarUI1FromStr: passing in NULL as param: 80020005
+VarUI1FromI2: 0, 0, 0
+VarUI1FromI2: 69, 45, 0
+VarUI1FromI2: 70, 46, 0
+VarUI1FromI2: 128, 80, 0
+VarUI1FromI2: 255, FF, 0
+VarUI1FromI2: 256, FF, 8002000A
+VarUI1FromI2: 257, FF, 8002000A
+VarUI1FromR8: 0.0, 0, 0
+VarUI1FromR8: 69.33, 45, 0
+VarUI1FromR8: 69.66, 46, 0
+VarUI1FromR8: -69.33, 46, 8002000A
+VarUI1FromR8: -69.66, 46, 8002000A
+VarUI1FromR8: -0.5, 0, 0
+VarUI1FromR8: -0.51, 0, 8002000A
+VarUI1FromR8: -0.49, 0, 0
+VarUI1FromR8: 0.5, 0, 0
+VarUI1FromR8: 0.51, 1, 0
+VarUI1FromR8: 0.49, 0, 0
+VarUI1FromDate: 0.0, 0, 0
+VarUI1FromDate: 69.33, 45, 0
+VarUI1FromDate: 69.66, 46, 0
+VarUI1FromDate: -69.33, 46, 8002000A
+VarUI1FromDate: -69.66, 46, 8002000A
+VarUI1FromBool: VARIANT_TRUE, FF, 0
+VarUI1FromBool: VARIANT_FALSE, 0, 0
+VarUI1FromStr: "-2", 0, 8002000A
+VarUI1FromStr: "-1", 0, 8002000A
+VarUI1FromStr: "-0.51", 0, 8002000A
+VarUI1FromStr: "-0.5", 0, 0
+VarUI1FromStr: "-0.49", 0, 0
+VarUI1FromStr: "-0.0", 0, 0
+VarUI1FromStr: "0.0", 0, 0
+VarUI1FromStr: "0.49", 0, 0
+VarUI1FromStr: "0.5", 0, 0
+VarUI1FromStr: "0.51", 1, 0
+VarUI1FromStr: "1", 1, 0
+VarUI1FromStr: "127", 7F, 0
+VarUI1FromStr: "128", 80, 0
+VarUI1FromStr: "129", 81, 0
+VarUI1FromStr: "255", FF, 0
+VarUI1FromStr: "256", FF, 8002000A
+VarUI1FromStr: "257", FF, 8002000A
+VarUI1FromStr: "32767", FF, 8002000A
+VarUI1FromStr: "32768", FF, 8002000A
+VarUI1FromStr: "-32768", FF, 8002000A
+VarUI1FromStr: "-32769", FF, 8002000A
+VarUI1FromStr: "16777216", FF, 8002000A
+VarUI1FromStr: "16777217", FF, 8002000A
+VarUI1FromStr: "-16777216", FF, 8002000A
+VarUI1FromStr: "16777217", FF, 8002000A
+VarUI1FromStr: "2147483647", FF, 8002000A
+VarUI1FromStr: "2147483648", FF, 8002000A
+VarUI1FromStr: "-2147483647", FF, 8002000A
+VarUI1FromStr: "-2147483648", FF, 8002000A
+VarUI1FromStr: "", FF, 80020005
+VarUI1FromStr: " ", FF, 80020005
+VarUI1FromStr: "1F", FF, 80020005
+VarUI1FromStr: "1G", FF, 80020005
+VarUI1FromStr: " 1 ", 1, 0
+VarUI1FromStr: " 1 2 ", 1, 80020005
+VarUI1FromStr: "1,2,3", 7B, 0
+VarUI1FromStr: "1 2 3", 7B, 80020005
+VarUI1FromStr: "1,2, 3", 7B, 80020005
+VarUI1FromStr: "1;2;3", 7B, 80020005
+VarUI1FromStr: "1.2.3", 7B, 80020005
+VarUI1FromStr: "0.", 0, 0
+VarUI1FromStr: ".0", 0, 0
+VarUI1FromStr: "0.1E12", 0, 8002000A
+VarUI1FromStr: "2.4,E1", 18, 0
+VarUI1FromStr: "  +3.2,E1", 20, 0
+VarUI1FromStr: "4E2.5", 20, 80020005
+VarUI1FromStr: "	2E+2", C8, 0
+VarUI1FromStr: "1 E+2", C8, 80020005
+VarUI1FromStr: ".", C8, 80020005
+VarUI1FromStr: ".E2", C8, 80020005
+VarUI1FromStr: "1000000000000000000000000000000000000000000000000000000000000000", C8, 8002000A
+VarUI1FromStr: "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001", 1, 0
+VarUI1FromStr: "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001", 1, 0
+VarUI1FromStr: "100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001", 1, 8002000A
+VarUI1FromStr: "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001", 1, 0
+VarUI1FromStr: "65535", 1, 8002000A
+VarUI1FromStr: "65535.5", 1, 8002000A
+VarUI1FromStr: "65536", 1, 8002000A
+VarUI1FromStr: "4294967295", 1, 8002000A
+VarUI1FromStr: "4294967296", 1, 8002000A
+VarUI1FromStr: "1 January 99", 1, 80020005
+VarUI1FromStr: "December 31, 2078", 1, 80020005
+VarUI1FromStr: "January 1, 1900", 1, 80020005
+VarUI1FromStr: "January 2 1900", 1, 80020005
+VarUI1FromStr: "11.11.1999", 1, 80020005
+VarUI1FromStr: "11/11/1999", 1, 80020005
+VarUI1FromStr: " 11 / 11 / 1999", 1, 80020005
+VarUI1FromStr: "11/11/1999:11:11:1134", 1, 80020005
+VarUI1FromStr: "11/11/1999 11:11:11:1", 1, 80020005
+VarUI1FromStr: "	1999/	11/21 11 :11:11am", 1, 80020005
+VarUI1FromStr: "11/11/1999 11:11:11Am", 1, 80020005
+VarUI1FromStr: "11/11/1999 11:11:11PM", 1, 80020005
+VarUI1FromStr: "11/11/199911:11:11PM", 1, 80020005
+VarUI1FromStr: "11/11/1999 0:0:11am", 1, 80020005
+VarUI1FromStr: "11/11/1999 11,11:11am", 1, 80020005
+VarUI1FromStr: "11/11/1999 11:11:11am", 1, 80020005
+VarUI1FromStr: "11/11/1999 11/11:11am", 1, 80020005
+VarUI1FromStr: "11/11/1999 11:11AM", 1, 80020005
+VarUI1FromStr: "11/11/1999 1AM", 1, 80020005
+VarUI1FromStr: "11/11/1999 0AM", 1, 80020005
+VarUI1FromStr: "11/11/1999 11:11:11", 1, 80020005
+VarUI1FromStr: "11/13/1999 0AM", 1, 80020005
+VarUI1FromStr: "13/13/1999 0AM", 1, 80020005
+VarUI1FromStr: "13/11/1999 0AM", 1, 80020005
+VarUI1FromStr: "11/33/1999 0AM", 1, 80020005
+VarUI1FromStr: "11/11/1999 AM", 1, 80020005
+VarUI1FromStr: "1/1/0 0AM", 1, 80020005
+VarUI1FromStr: "1/1/-1 0AM", 1, 80020005
+VarUI1FromStr: "1999 January 3 9AM", 1, 80020005
+VarUI1FromStr: "1 January 1999 11AM", 1, 80020005
+VarUI1FromStr: "4AM 11/11/1999", 1, 80020005
+VarUI1FromStr: "4:22 11/11/1999 AM", 1, 80020005
+VarUI1FromStr: " 1 1 /11/1999", 1, 80020005
+VarUI1FromStr: "11-11/1999 11:11:11.12AM", 1, 80020005
+VarUI1FromStr: "1999 January 3, 9AM", 1, 80020005
+VarUI1FromStr: "December, 31, 2078", 1, 80020005
+VarUI1FromStr: "December, 31, 2078,", 1, 80020005
+VarUI1FromStr: "December, 31 2078", 1, 80020005
+VarUI1FromStr: "11/99", 1, 80020005
+VarUI1FromStr: "11-1999", 1, 80020005
+VarUI1FromStr: "true", 1, 80020005
+VarUI1FromStr: "True", 1, 80020005
+VarUI1FromStr: "TRue", 1, 80020005
+VarUI1FromStr: "TRUE", 1, 80020005
+VarUI1FromStr: " TRUE", 1, 80020005
+VarUI1FromStr: "FALSE ", 1, 80020005
+VarUI1FromStr: "False", 1, 80020005
+VarUI1FromStr: "JustSomeText", 1, 80020005
+VarUI1FromStr: "Just Some Text", 1, 80020005
+VarUI1FromStr: "", 1, 80020005
+VarUI1FromStr: "1.5", 2, 0
+VarUI1FromStr: "2.5", 2, 0
+VarUI1FromStr: "3.5", 4, 0
+VarUI1FromStr: "4.5", 4, 0
+VarUI1FromStr: "", 4, 80020005
+VarUI1FromStr: "", 4, 80020005
+VarUI1FromStr: "", 4, 80020005
+VarUI1FromStr: "", 4, 80020005
+VarUI1FromStr: "", 4, 80020005
+VarUI1FromStr: "", 4, 80020005
+
+
+======== Testing VarUI2FromXXX ========
+VarUI2FromI2: -1, 0, 8002000A
+VarUI2FromI2: passing in NULL as return val makes it crash, 8002000A
+VarUI2FromStr: passing in NULL as param: 80020005
+VarUI2FromI2: 0, 0, 0
+VarUI2FromI2: 69, 69, 0
+VarUI2FromI2: 70, 70, 0
+VarUI2FromI2: 128, 128, 0
+VarUI2FromI4: 65535, 65535, 0
+VarUI2FromI4: 65536, 65535, 8002000A
+VarUI2FromI4: 65537, 65535, 8002000A
+VarUI2FromR8: 0.0, 0, 0
+VarUI2FromR8: 69.33, 69, 0
+VarUI2FromR8: 69.66, 70, 0
+VarUI2FromR8: -69.33, 70, 8002000A
+VarUI2FromR8: -69.66, 70, 8002000A
+VarUI2FromR8: -0.5, 0, 0
+VarUI2FromR8: -0.51, 0, 8002000A
+VarUI2FromR8: -0.49, 0, 0
+VarUI2FromR8: 0.5, 0, 0
+VarUI2FromR8: 0.51, 1, 0
+VarUI2FromR8: 0.49, 0, 0
+VarUI2FromDate: 0.0, 0, 0
+VarUI2FromDate: 69.33, 69, 0
+VarUI2FromDate: 69.66, 70, 0
+VarUI2FromDate: -69.33, 70, 8002000A
+VarUI2FromDate: -69.66, 70, 8002000A
+VarUI2FromBool: VARIANT_TRUE, 65535, 0
+VarUI2FromBool: VARIANT_FALSE, 0, 0
+VarUI2FromStr: "-2", 0, 8002000A
+VarUI2FromStr: "-1", 0, 8002000A
+VarUI2FromStr: "-0.51", 0, 8002000A
+VarUI2FromStr: "-0.5", 0, 0
+VarUI2FromStr: "-0.49", 0, 0
+VarUI2FromStr: "-0.0", 0, 0
+VarUI2FromStr: "0.0", 0, 0
+VarUI2FromStr: "0.49", 0, 0
+VarUI2FromStr: "0.5", 0, 0
+VarUI2FromStr: "0.51", 1, 0
+VarUI2FromStr: "1", 1, 0
+VarUI2FromStr: "127", 127, 0
+VarUI2FromStr: "128", 128, 0
+VarUI2FromStr: "129", 129, 0
+VarUI2FromStr: "255", 255, 0
+VarUI2FromStr: "256", 256, 0
+VarUI2FromStr: "257", 257, 0
+VarUI2FromStr: "32767", 32767, 0
+VarUI2FromStr: "32768", 32768, 0
+VarUI2FromStr: "-32768", 32768, 8002000A
+VarUI2FromStr: "-32769", 32768, 8002000A
+VarUI2FromStr: "16777216", 32768, 8002000A
+VarUI2FromStr: "16777217", 32768, 8002000A
+VarUI2FromStr: "-16777216", 32768, 8002000A
+VarUI2FromStr: "16777217", 32768, 8002000A
+VarUI2FromStr: "2147483647", 32768, 8002000A
+VarUI2FromStr: "2147483648", 32768, 8002000A
+VarUI2FromStr: "-2147483647", 32768, 8002000A
+VarUI2FromStr: "-2147483648", 32768, 8002000A
+VarUI2FromStr: "", 32768, 80020005
+VarUI2FromStr: " ", 32768, 80020005
+VarUI2FromStr: "1F", 32768, 80020005
+VarUI2FromStr: "1G", 32768, 80020005
+VarUI2FromStr: " 1 ", 1, 0
+VarUI2FromStr: " 1 2 ", 1, 80020005
+VarUI2FromStr: "1,2,3", 123, 0
+VarUI2FromStr: "1 2 3", 123, 80020005
+VarUI2FromStr: "1,2, 3", 123, 80020005
+VarUI2FromStr: "1;2;3", 123, 80020005
+VarUI2FromStr: "1.2.3", 123, 80020005
+VarUI2FromStr: "0.", 0, 0
+VarUI2FromStr: ".0", 0, 0
+VarUI2FromStr: "0.1E12", 0, 8002000A
+VarUI2FromStr: "2.4,E1", 24, 0
+VarUI2FromStr: "  +3.2,E1", 32, 0
+VarUI2FromStr: "4E2.5", 32, 80020005
+VarUI2FromStr: "	2E+2", 200, 0
+VarUI2FromStr: "1 E+2", 200, 80020005
+VarUI2FromStr: ".", 200, 80020005
+VarUI2FromStr: ".E2", 200, 80020005
+VarUI2FromStr: "1000000000000000000000000000000000000000000000000000000000000000", 200, 8002000A
+VarUI2FromStr: "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001", 1, 0
+VarUI2FromStr: "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001", 1, 0
+VarUI2FromStr: "100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001", 1, 8002000A
+VarUI2FromStr: "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001", 1, 0
+VarUI2FromStr: "65535", 65535, 0
+VarUI2FromStr: "65535.5", 65535, 8002000A
+VarUI2FromStr: "65536", 65535, 8002000A
+VarUI2FromStr: "4294967295", 65535, 8002000A
+VarUI2FromStr: "4294967296", 65535, 8002000A
+VarUI2FromStr: "1 January 99", 65535, 80020005
+VarUI2FromStr: "December 31, 2078", 65535, 80020005
+VarUI2FromStr: "January 1, 1900", 65535, 80020005
+VarUI2FromStr: "January 2 1900", 65535, 80020005
+VarUI2FromStr: "11.11.1999", 65535, 80020005
+VarUI2FromStr: "11/11/1999", 65535, 80020005
+VarUI2FromStr: " 11 / 11 / 1999", 65535, 80020005
+VarUI2FromStr: "11/11/1999:11:11:1134", 65535, 80020005
+VarUI2FromStr: "11/11/1999 11:11:11:1", 65535, 80020005
+VarUI2FromStr: "	1999/	11/21 11 :11:11am", 65535, 80020005
+VarUI2FromStr: "11/11/1999 11:11:11Am", 65535, 80020005
+VarUI2FromStr: "11/11/1999 11:11:11PM", 65535, 80020005
+VarUI2FromStr: "11/11/199911:11:11PM", 65535, 80020005
+VarUI2FromStr: "11/11/1999 0:0:11am", 65535, 80020005
+VarUI2FromStr: "11/11/1999 11,11:11am", 65535, 80020005
+VarUI2FromStr: "11/11/1999 11:11:11am", 65535, 80020005
+VarUI2FromStr: "11/11/1999 11/11:11am", 65535, 80020005
+VarUI2FromStr: "11/11/1999 11:11AM", 65535, 80020005
+VarUI2FromStr: "11/11/1999 1AM", 65535, 80020005
+VarUI2FromStr: "11/11/1999 0AM", 65535, 80020005
+VarUI2FromStr: "11/11/1999 11:11:11", 65535, 80020005
+VarUI2FromStr: "11/13/1999 0AM", 65535, 80020005
+VarUI2FromStr: "13/13/1999 0AM", 65535, 80020005
+VarUI2FromStr: "13/11/1999 0AM", 65535, 80020005
+VarUI2FromStr: "11/33/1999 0AM", 65535, 80020005
+VarUI2FromStr: "11/11/1999 AM", 65535, 80020005
+VarUI2FromStr: "1/1/0 0AM", 65535, 80020005
+VarUI2FromStr: "1/1/-1 0AM", 65535, 80020005
+VarUI2FromStr: "1999 January 3 9AM", 65535, 80020005
+VarUI2FromStr: "1 January 1999 11AM", 65535, 80020005
+VarUI2FromStr: "4AM 11/11/1999", 65535, 80020005
+VarUI2FromStr: "4:22 11/11/1999 AM", 65535, 80020005
+VarUI2FromStr: " 1 1 /11/1999", 65535, 80020005
+VarUI2FromStr: "11-11/1999 11:11:11.12AM", 65535, 80020005
+VarUI2FromStr: "1999 January 3, 9AM", 65535, 80020005
+VarUI2FromStr: "December, 31, 2078", 65535, 80020005
+VarUI2FromStr: "December, 31, 2078,", 65535, 80020005
+VarUI2FromStr: "December, 31 2078", 65535, 80020005
+VarUI2FromStr: "11/99", 65535, 80020005
+VarUI2FromStr: "11-1999", 65535, 80020005
+VarUI2FromStr: "true", 65535, 80020005
+VarUI2FromStr: "True", 65535, 80020005
+VarUI2FromStr: "TRue", 65535, 80020005
+VarUI2FromStr: "TRUE", 65535, 80020005
+VarUI2FromStr: " TRUE", 65535, 80020005
+VarUI2FromStr: "FALSE ", 65535, 80020005
+VarUI2FromStr: "False", 65535, 80020005
+VarUI2FromStr: "JustSomeText", 65535, 80020005
+VarUI2FromStr: "Just Some Text", 65535, 80020005
+VarUI2FromStr: "", 65535, 80020005
+VarUI2FromStr: "1.5", 2, 0
+VarUI2FromStr: "2.5", 2, 0
+VarUI2FromStr: "3.5", 4, 0
+VarUI2FromStr: "4.5", 4, 0
+VarUI2FromStr: "", 4, 80020005
+VarUI2FromStr: "", 4, 80020005
+VarUI2FromStr: "", 4, 80020005
+VarUI2FromStr: "", 4, 80020005
+VarUI2FromStr: "", 4, 80020005
+VarUI2FromStr: "", 4, 80020005
+
+
+======== Testing VarUI4FromXXX ========
+VarUI4FromI2: passing in NULL as return val makes it crash, 80020005
+VarUI4FromStr: passing in NULL as param: 80020005
+VarUI4FromI2: 0, 0, 0
+VarUI4FromI2: 69, 69, 0
+VarUI4FromI2: 70, 70, 0
+VarUI4FromI2: 128, 128, 0
+VarUI4FromI2: 255, 255, 0
+VarUI4FromR8: 4294967295, 4294967295, 0
+VarUI4FromR8: 4294967296, 4294967295, 8002000A
+VarUI4FromR8: 0.0, 0, 0
+VarUI4FromR8: 69.33, 69, 0
+VarUI4FromR8: 69.66, 70, 0
+VarUI4FromR8: -69.33, 70, 8002000A
+VarUI4FromR8: -69.66, 70, 8002000A
+VarUI4FromR8: -0.5, 0, 0
+VarUI4FromR8: -0.51, 0, 8002000A
+VarUI4FromR8: -0.49, 0, 0
+VarUI4FromR8: 0.5, 0, 0
+VarUI4FromR8: 0.51, 1, 0
+VarUI4FromR8: 0.49, 0, 0
+VarUI4FromDate: 0.0, 0, 0
+VarUI4FromDate: 69.33, 69, 0
+VarUI4FromDate: 69.66, 70, 0
+VarUI4FromDate: -69.33, 70, 8002000A
+VarUI4FromDate: -69.66, 70, 8002000A
+VarUI4FromBool: VARIANT_TRUE, 4294967295, 0
+VarUI4FromBool: VARIANT_FALSE, 0, 0
+VarUI4FromStr: "-2", 0, 8002000A
+VarUI4FromStr: "-1", 0, 8002000A
+VarUI4FromStr: "-0.51", 0, 8002000A
+VarUI4FromStr: "-0.5", 0, 0
+VarUI4FromStr: "-0.49", 0, 0
+VarUI4FromStr: "-0.0", 0, 0
+VarUI4FromStr: "0.0", 0, 0
+VarUI4FromStr: "0.49", 0, 0
+VarUI4FromStr: "0.5", 0, 0
+VarUI4FromStr: "0.51", 1, 0
+VarUI4FromStr: "1", 1, 0
+VarUI4FromStr: "127", 127, 0
+VarUI4FromStr: "128", 128, 0
+VarUI4FromStr: "129", 129, 0
+VarUI4FromStr: "255", 255, 0
+VarUI4FromStr: "256", 256, 0
+VarUI4FromStr: "257", 257, 0
+VarUI4FromStr: "32767", 32767, 0
+VarUI4FromStr: "32768", 32768, 0
+VarUI4FromStr: "-32768", 32768, 8002000A
+VarUI4FromStr: "-32769", 32768, 8002000A
+VarUI4FromStr: "16777216", 16777216, 0
+VarUI4FromStr: "16777217", 16777217, 0
+VarUI4FromStr: "-16777216", 16777217, 8002000A
+VarUI4FromStr: "16777217", 16777217, 0
+VarUI4FromStr: "2147483647", 2147483647, 0
+VarUI4FromStr: "2147483648", 2147483648, 0
+VarUI4FromStr: "-2147483647", 2147483648, 8002000A
+VarUI4FromStr: "-2147483648", 2147483648, 8002000A
+VarUI4FromStr: "", 2147483648, 80020005
+VarUI4FromStr: " ", 2147483648, 80020005
+VarUI4FromStr: "1F", 2147483648, 80020005
+VarUI4FromStr: "1G", 2147483648, 80020005
+VarUI4FromStr: " 1 ", 1, 0
+VarUI4FromStr: " 1 2 ", 1, 80020005
+VarUI4FromStr: "1,2,3", 123, 0
+VarUI4FromStr: "1 2 3", 123, 80020005
+VarUI4FromStr: "1,2, 3", 123, 80020005
+VarUI4FromStr: "1;2;3", 123, 80020005
+VarUI4FromStr: "1.2.3", 123, 80020005
+VarUI4FromStr: "0.", 0, 0
+VarUI4FromStr: ".0", 0, 0
+VarUI4FromStr: "0.1E12", 0, 8002000A
+VarUI4FromStr: "2.4,E1", 24, 0
+VarUI4FromStr: "  +3.2,E1", 32, 0
+VarUI4FromStr: "4E2.5", 32, 80020005
+VarUI4FromStr: "	2E+2", 200, 0
+VarUI4FromStr: "1 E+2", 200, 80020005
+VarUI4FromStr: ".", 200, 80020005
+VarUI4FromStr: ".E2", 200, 80020005
+VarUI4FromStr: "1000000000000000000000000000000000000000000000000000000000000000", 200, 8002000A
+VarUI4FromStr: "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001", 1, 0
+VarUI4FromStr: "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001", 1, 0
+VarUI4FromStr: "100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001", 1, 8002000A
+VarUI4FromStr: "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001", 1, 0
+VarUI4FromStr: "65535", 65535, 0
+VarUI4FromStr: "65535.5", 65536, 0
+VarUI4FromStr: "65536", 65536, 0
+VarUI4FromStr: "4294967295", 4294967295, 0
+VarUI4FromStr: "4294967296", 4294967295, 8002000A
+VarUI4FromStr: "1 January 99", 4294967295, 80020005
+VarUI4FromStr: "December 31, 2078", 4294967295, 80020005
+VarUI4FromStr: "January 1, 1900", 4294967295, 80020005
+VarUI4FromStr: "January 2 1900", 4294967295, 80020005
+VarUI4FromStr: "11.11.1999", 4294967295, 80020005
+VarUI4FromStr: "11/11/1999", 4294967295, 80020005
+VarUI4FromStr: " 11 / 11 / 1999", 4294967295, 80020005
+VarUI4FromStr: "11/11/1999:11:11:1134", 4294967295, 80020005
+VarUI4FromStr: "11/11/1999 11:11:11:1", 4294967295, 80020005
+VarUI4FromStr: "	1999/	11/21 11 :11:11am", 4294967295, 80020005
+VarUI4FromStr: "11/11/1999 11:11:11Am", 4294967295, 80020005
+VarUI4FromStr: "11/11/1999 11:11:11PM", 4294967295, 80020005
+VarUI4FromStr: "11/11/199911:11:11PM", 4294967295, 80020005
+VarUI4FromStr: "11/11/1999 0:0:11am", 4294967295, 80020005
+VarUI4FromStr: "11/11/1999 11,11:11am", 4294967295, 80020005
+VarUI4FromStr: "11/11/1999 11:11:11am", 4294967295, 80020005
+VarUI4FromStr: "11/11/1999 11/11:11am", 4294967295, 80020005
+VarUI4FromStr: "11/11/1999 11:11AM", 4294967295, 80020005
+VarUI4FromStr: "11/11/1999 1AM", 4294967295, 80020005
+VarUI4FromStr: "11/11/1999 0AM", 4294967295, 80020005
+VarUI4FromStr: "11/11/1999 11:11:11", 4294967295, 80020005
+VarUI4FromStr: "11/13/1999 0AM", 4294967295, 80020005
+VarUI4FromStr: "13/13/1999 0AM", 4294967295, 80020005
+VarUI4FromStr: "13/11/1999 0AM", 4294967295, 80020005
+VarUI4FromStr: "11/33/1999 0AM", 4294967295, 80020005
+VarUI4FromStr: "11/11/1999 AM", 4294967295, 80020005
+VarUI4FromStr: "1/1/0 0AM", 4294967295, 80020005
+VarUI4FromStr: "1/1/-1 0AM", 4294967295, 80020005
+VarUI4FromStr: "1999 January 3 9AM", 4294967295, 80020005
+VarUI4FromStr: "1 January 1999 11AM", 4294967295, 80020005
+VarUI4FromStr: "4AM 11/11/1999", 4294967295, 80020005
+VarUI4FromStr: "4:22 11/11/1999 AM", 4294967295, 80020005
+VarUI4FromStr: " 1 1 /11/1999", 4294967295, 80020005
+VarUI4FromStr: "11-11/1999 11:11:11.12AM", 4294967295, 80020005
+VarUI4FromStr: "1999 January 3, 9AM", 4294967295, 80020005
+VarUI4FromStr: "December, 31, 2078", 4294967295, 80020005
+VarUI4FromStr: "December, 31, 2078,", 4294967295, 80020005
+VarUI4FromStr: "December, 31 2078", 4294967295, 80020005
+VarUI4FromStr: "11/99", 4294967295, 80020005
+VarUI4FromStr: "11-1999", 4294967295, 80020005
+VarUI4FromStr: "true", 4294967295, 80020005
+VarUI4FromStr: "True", 4294967295, 80020005
+VarUI4FromStr: "TRue", 4294967295, 80020005
+VarUI4FromStr: "TRUE", 4294967295, 80020005
+VarUI4FromStr: " TRUE", 4294967295, 80020005
+VarUI4FromStr: "FALSE ", 4294967295, 80020005
+VarUI4FromStr: "False", 4294967295, 80020005
+VarUI4FromStr: "JustSomeText", 4294967295, 80020005
+VarUI4FromStr: "Just Some Text", 4294967295, 80020005
+VarUI4FromStr: "", 4294967295, 80020005
+VarUI4FromStr: "1.5", 2, 0
+VarUI4FromStr: "2.5", 2, 0
+VarUI4FromStr: "3.5", 4, 0
+VarUI4FromStr: "4.5", 4, 0
+VarUI4FromStr: "", 4, 80020005
+VarUI4FromStr: "", 4, 80020005
+VarUI4FromStr: "", 4, 80020005
+VarUI4FromStr: "", 4, 80020005
+VarUI4FromStr: "", 4, 80020005
+VarUI4FromStr: "", 4, 80020005
+
+
+======== Testing VarI1FromXXX ========
+VarI1FromBool: VARIANT_TRUE, 255, 0
+VarI1FromBool: VARIANT_TRUE, -1, 0
+VarI1FromBool: VARIANT_FALSE, 0, 0
+VarI1FromUI1: 32767, 0, 8002000A
+VarI1FromUI1: 65535, 0, 8002000A
+VarI1FromI4: 32767, 0, 8002000A
+VarI1FromI4: 32768, 0, 8002000A
+VarI1FromI4: -32768, 0, 8002000A
+VarI1FromI4: -32769, 0, 8002000A
+VarI1FromR8: 69.33, 69, 0
+VarI1FromR8: 69.66, 70, 0
+VarI1FromR8: -69.33, -69, 0
+VarI1FromR8: -69.66, -70, 0
+VarI1FromDate: -69.66, -70, 0
+VarI1FromStr: "-2", -2, 0
+VarI1FromStr: "-1", -1, 0
+VarI1FromStr: "-0.51", -1, 0
+VarI1FromStr: "-0.5", 0, 0
+VarI1FromStr: "-0.49", 0, 0
+VarI1FromStr: "-0.0", 0, 0
+VarI1FromStr: "0.0", 0, 0
+VarI1FromStr: "0.49", 0, 0
+VarI1FromStr: "0.5", 0, 0
+VarI1FromStr: "0.51", 1, 0
+VarI1FromStr: "1", 1, 0
+VarI1FromStr: "127", 127, 0
+VarI1FromStr: "128", 127, 8002000A
+VarI1FromStr: "129", 127, 8002000A
+VarI1FromStr: "255", 127, 8002000A
+VarI1FromStr: "256", 127, 8002000A
+VarI1FromStr: "257", 127, 8002000A
+VarI1FromStr: "32767", 127, 8002000A
+VarI1FromStr: "32768", 127, 8002000A
+VarI1FromStr: "-32768", 127, 8002000A
+VarI1FromStr: "-32769", 127, 8002000A
+VarI1FromStr: "16777216", 127, 8002000A
+VarI1FromStr: "16777217", 127, 8002000A
+VarI1FromStr: "-16777216", 127, 8002000A
+VarI1FromStr: "16777217", 127, 8002000A
+VarI1FromStr: "2147483647", 127, 8002000A
+VarI1FromStr: "2147483648", 127, 8002000A
+VarI1FromStr: "-2147483647", 127, 8002000A
+VarI1FromStr: "-2147483648", 127, 8002000A
+VarI1FromStr: "", 127, 80020005
+VarI1FromStr: " ", 127, 80020005
+VarI1FromStr: "1F", 127, 80020005
+VarI1FromStr: "1G", 127, 80020005
+VarI1FromStr: " 1 ", 1, 0
+VarI1FromStr: " 1 2 ", 1, 80020005
+VarI1FromStr: "1,2,3", 123, 0
+VarI1FromStr: "1 2 3", 123, 80020005
+VarI1FromStr: "1,2, 3", 123, 80020005
+VarI1FromStr: "1;2;3", 123, 80020005
+VarI1FromStr: "1.2.3", 123, 80020005
+VarI1FromStr: "0.", 0, 0
+VarI1FromStr: ".0", 0, 0
+VarI1FromStr: "0.1E12", 0, 8002000A
+VarI1FromStr: "2.4,E1", 24, 0
+VarI1FromStr: "  +3.2,E1", 32, 0
+VarI1FromStr: "4E2.5", 32, 80020005
+VarI1FromStr: "	2E+2", 32, 8002000A
+VarI1FromStr: "1 E+2", 32, 80020005
+VarI1FromStr: ".", 32, 80020005
+VarI1FromStr: ".E2", 32, 80020005
+VarI1FromStr: "1000000000000000000000000000000000000000000000000000000000000000", 32, 8002000A
+VarI1FromStr: "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001", 1, 0
+VarI1FromStr: "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001", 1, 0
+VarI1FromStr: "100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001", 1, 8002000A
+VarI1FromStr: "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001", 1, 0
+VarI1FromStr: "65535", 1, 8002000A
+VarI1FromStr: "65535.5", 1, 8002000A
+VarI1FromStr: "65536", 1, 8002000A
+VarI1FromStr: "4294967295", 1, 8002000A
+VarI1FromStr: "4294967296", 1, 8002000A
+VarI1FromStr: "1 January 99", 1, 80020005
+VarI1FromStr: "December 31, 2078", 1, 80020005
+VarI1FromStr: "January 1, 1900", 1, 80020005
+VarI1FromStr: "January 2 1900", 1, 80020005
+VarI1FromStr: "11.11.1999", 1, 80020005
+VarI1FromStr: "11/11/1999", 1, 80020005
+VarI1FromStr: " 11 / 11 / 1999", 1, 80020005
+VarI1FromStr: "11/11/1999:11:11:1134", 1, 80020005
+VarI1FromStr: "11/11/1999 11:11:11:1", 1, 80020005
+VarI1FromStr: "	1999/	11/21 11 :11:11am", 1, 80020005
+VarI1FromStr: "11/11/1999 11:11:11Am", 1, 80020005
+VarI1FromStr: "11/11/1999 11:11:11PM", 1, 80020005
+VarI1FromStr: "11/11/199911:11:11PM", 1, 80020005
+VarI1FromStr: "11/11/1999 0:0:11am", 1, 80020005
+VarI1FromStr: "11/11/1999 11,11:11am", 1, 80020005
+VarI1FromStr: "11/11/1999 11:11:11am", 1, 80020005
+VarI1FromStr: "11/11/1999 11/11:11am", 1, 80020005
+VarI1FromStr: "11/11/1999 11:11AM", 1, 80020005
+VarI1FromStr: "11/11/1999 1AM", 1, 80020005
+VarI1FromStr: "11/11/1999 0AM", 1, 80020005
+VarI1FromStr: "11/11/1999 11:11:11", 1, 80020005
+VarI1FromStr: "11/13/1999 0AM", 1, 80020005
+VarI1FromStr: "13/13/1999 0AM", 1, 80020005
+VarI1FromStr: "13/11/1999 0AM", 1, 80020005
+VarI1FromStr: "11/33/1999 0AM", 1, 80020005
+VarI1FromStr: "11/11/1999 AM", 1, 80020005
+VarI1FromStr: "1/1/0 0AM", 1, 80020005
+VarI1FromStr: "1/1/-1 0AM", 1, 80020005
+VarI1FromStr: "1999 January 3 9AM", 1, 80020005
+VarI1FromStr: "1 January 1999 11AM", 1, 80020005
+VarI1FromStr: "4AM 11/11/1999", 1, 80020005
+VarI1FromStr: "4:22 11/11/1999 AM", 1, 80020005
+VarI1FromStr: " 1 1 /11/1999", 1, 80020005
+VarI1FromStr: "11-11/1999 11:11:11.12AM", 1, 80020005
+VarI1FromStr: "1999 January 3, 9AM", 1, 80020005
+VarI1FromStr: "December, 31, 2078", 1, 80020005
+VarI1FromStr: "December, 31, 2078,", 1, 80020005
+VarI1FromStr: "December, 31 2078", 1, 80020005
+VarI1FromStr: "11/99", 1, 80020005
+VarI1FromStr: "11-1999", 1, 80020005
+VarI1FromStr: "true", 1, 80020005
+VarI1FromStr: "True", 1, 80020005
+VarI1FromStr: "TRue", 1, 80020005
+VarI1FromStr: "TRUE", 1, 80020005
+VarI1FromStr: " TRUE", 1, 80020005
+VarI1FromStr: "FALSE ", 1, 80020005
+VarI1FromStr: "False", 1, 80020005
+VarI1FromStr: "JustSomeText", 1, 80020005
+VarI1FromStr: "Just Some Text", 1, 80020005
+VarI1FromStr: "", 1, 80020005
+VarI1FromStr: "1.5", 2, 0
+VarI1FromStr: "2.5", 2, 0
+VarI1FromStr: "3.5", 4, 0
+VarI1FromStr: "4.5", 4, 0
+VarI1FromStr: "", 4, 80020005
+VarI1FromStr: "", 4, 80020005
+VarI1FromStr: "", 4, 80020005
+VarI1FromStr: "", 4, 80020005
+VarI1FromStr: "", 4, 80020005
+VarI1FromStr: "", 4, 80020005
+
+
+======== Testing VarI2FromXXX ========
+VarI2FromUI2: 32767, 32767, 0
+VarI2FromUI2: 65535, 32767, 8002000A
+VarI2FromI4: 32767, 32767, 0
+VarI2FromI4: 32768, 32767, 8002000A
+VarI2FromI4: -32768, -32768, 0
+VarI2FromI4: -32769, -32768, 8002000A
+VarI2FromR8: 69.33, 69, 0
+VarI2FromR8: 69.66, 70, 0
+VarI2FromR8: -69.33, -69, 0
+VarI2FromR8: -69.66, -70, 0
+VarI2FromDate: -69.66, -70, 0
+VarI2FromStr: "-2", -2, 0
+VarI2FromStr: "-1", -1, 0
+VarI2FromStr: "-0.51", -1, 0
+VarI2FromStr: "-0.5", 0, 0
+VarI2FromStr: "-0.49", 0, 0
+VarI2FromStr: "-0.0", 0, 0
+VarI2FromStr: "0.0", 0, 0
+VarI2FromStr: "0.49", 0, 0
+VarI2FromStr: "0.5", 0, 0
+VarI2FromStr: "0.51", 1, 0
+VarI2FromStr: "1", 1, 0
+VarI2FromStr: "127", 127, 0
+VarI2FromStr: "128", 128, 0
+VarI2FromStr: "129", 129, 0
+VarI2FromStr: "255", 255, 0
+VarI2FromStr: "256", 256, 0
+VarI2FromStr: "257", 257, 0
+VarI2FromStr: "32767", 32767, 0
+VarI2FromStr: "32768", 32767, 8002000A
+VarI2FromStr: "-32768", -32768, 0
+VarI2FromStr: "-32769", -32768, 8002000A
+VarI2FromStr: "16777216", -32768, 8002000A
+VarI2FromStr: "16777217", -32768, 8002000A
+VarI2FromStr: "-16777216", -32768, 8002000A
+VarI2FromStr: "16777217", -32768, 8002000A
+VarI2FromStr: "2147483647", -32768, 8002000A
+VarI2FromStr: "2147483648", -32768, 8002000A
+VarI2FromStr: "-2147483647", -32768, 8002000A
+VarI2FromStr: "-2147483648", -32768, 8002000A
+VarI2FromStr: "", -32768, 80020005
+VarI2FromStr: " ", -32768, 80020005
+VarI2FromStr: "1F", -32768, 80020005
+VarI2FromStr: "1G", -32768, 80020005
+VarI2FromStr: " 1 ", 1, 0
+VarI2FromStr: " 1 2 ", 1, 80020005
+VarI2FromStr: "1,2,3", 123, 0
+VarI2FromStr: "1 2 3", 123, 80020005
+VarI2FromStr: "1,2, 3", 123, 80020005
+VarI2FromStr: "1;2;3", 123, 80020005
+VarI2FromStr: "1.2.3", 123, 80020005
+VarI2FromStr: "0.", 0, 0
+VarI2FromStr: ".0", 0, 0
+VarI2FromStr: "0.1E12", 0, 8002000A
+VarI2FromStr: "2.4,E1", 24, 0
+VarI2FromStr: "  +3.2,E1", 32, 0
+VarI2FromStr: "4E2.5", 32, 80020005
+VarI2FromStr: "	2E+2", 200, 0
+VarI2FromStr: "1 E+2", 200, 80020005
+VarI2FromStr: ".", 200, 80020005
+VarI2FromStr: ".E2", 200, 80020005
+VarI2FromStr: "1000000000000000000000000000000000000000000000000000000000000000", 200, 8002000A
+VarI2FromStr: "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001", 1, 0
+VarI2FromStr: "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001", 1, 0
+VarI2FromStr: "100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001", 1, 8002000A
+VarI2FromStr: "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001", 1, 0
+VarI2FromStr: "65535", 1, 8002000A
+VarI2FromStr: "65535.5", 1, 8002000A
+VarI2FromStr: "65536", 1, 8002000A
+VarI2FromStr: "4294967295", 1, 8002000A
+VarI2FromStr: "4294967296", 1, 8002000A
+VarI2FromStr: "1 January 99", 1, 80020005
+VarI2FromStr: "December 31, 2078", 1, 80020005
+VarI2FromStr: "January 1, 1900", 1, 80020005
+VarI2FromStr: "January 2 1900", 1, 80020005
+VarI2FromStr: "11.11.1999", 1, 80020005
+VarI2FromStr: "11/11/1999", 1, 80020005
+VarI2FromStr: " 11 / 11 / 1999", 1, 80020005
+VarI2FromStr: "11/11/1999:11:11:1134", 1, 80020005
+VarI2FromStr: "11/11/1999 11:11:11:1", 1, 80020005
+VarI2FromStr: "	1999/	11/21 11 :11:11am", 1, 80020005
+VarI2FromStr: "11/11/1999 11:11:11Am", 1, 80020005
+VarI2FromStr: "11/11/1999 11:11:11PM", 1, 80020005
+VarI2FromStr: "11/11/199911:11:11PM", 1, 80020005
+VarI2FromStr: "11/11/1999 0:0:11am", 1, 80020005
+VarI2FromStr: "11/11/1999 11,11:11am", 1, 80020005
+VarI2FromStr: "11/11/1999 11:11:11am", 1, 80020005
+VarI2FromStr: "11/11/1999 11/11:11am", 1, 80020005
+VarI2FromStr: "11/11/1999 11:11AM", 1, 80020005
+VarI2FromStr: "11/11/1999 1AM", 1, 80020005
+VarI2FromStr: "11/11/1999 0AM", 1, 80020005
+VarI2FromStr: "11/11/1999 11:11:11", 1, 80020005
+VarI2FromStr: "11/13/1999 0AM", 1, 80020005
+VarI2FromStr: "13/13/1999 0AM", 1, 80020005
+VarI2FromStr: "13/11/1999 0AM", 1, 80020005
+VarI2FromStr: "11/33/1999 0AM", 1, 80020005
+VarI2FromStr: "11/11/1999 AM", 1, 80020005
+VarI2FromStr: "1/1/0 0AM", 1, 80020005
+VarI2FromStr: "1/1/-1 0AM", 1, 80020005
+VarI2FromStr: "1999 January 3 9AM", 1, 80020005
+VarI2FromStr: "1 January 1999 11AM", 1, 80020005
+VarI2FromStr: "4AM 11/11/1999", 1, 80020005
+VarI2FromStr: "4:22 11/11/1999 AM", 1, 80020005
+VarI2FromStr: " 1 1 /11/1999", 1, 80020005
+VarI2FromStr: "11-11/1999 11:11:11.12AM", 1, 80020005
+VarI2FromStr: "1999 January 3, 9AM", 1, 80020005
+VarI2FromStr: "December, 31, 2078", 1, 80020005
+VarI2FromStr: "December, 31, 2078,", 1, 80020005
+VarI2FromStr: "December, 31 2078", 1, 80020005
+VarI2FromStr: "11/99", 1, 80020005
+VarI2FromStr: "11-1999", 1, 80020005
+VarI2FromStr: "true", 1, 80020005
+VarI2FromStr: "True", 1, 80020005
+VarI2FromStr: "TRue", 1, 80020005
+VarI2FromStr: "TRUE", 1, 80020005
+VarI2FromStr: " TRUE", 1, 80020005
+VarI2FromStr: "FALSE ", 1, 80020005
+VarI2FromStr: "False", 1, 80020005
+VarI2FromStr: "JustSomeText", 1, 80020005
+VarI2FromStr: "Just Some Text", 1, 80020005
+VarI2FromStr: "", 1, 80020005
+VarI2FromStr: "1.5", 2, 0
+VarI2FromStr: "2.5", 2, 0
+VarI2FromStr: "3.5", 4, 0
+VarI2FromStr: "4.5", 4, 0
+VarI2FromStr: "", 4, 80020005
+VarI2FromStr: "", 4, 80020005
+VarI2FromStr: "", 4, 80020005
+VarI2FromStr: "", 4, 80020005
+VarI2FromStr: "", 4, 80020005
+VarI2FromStr: "", 4, 80020005
+
+
+======== Testing VarI4FromXXX ========
+VarIntFromI2: 3, 3, 0
+VarI4FromR8: 69.33, 69, 0
+VarI4FromR8: 69.66, 70, 0
+VarI4FromR8: -69.33, -69, 0
+VarI4FromR8: -69.66, -70, 0
+VarI4FromR8: 2147483647.0, 2147483647, 0
+VarI4FromR8: 2147483648.0, 2147483647, 8002000A
+VarI4FromR8: -2147483647.0, -2147483647, 0
+VarI4FromR8: -2147483648.0, -2147483648, 0
+VarI4FromR8: -2147483649.0, -2147483648, 8002000A
+VarI4FromDate: -2147483649.0, -2147483648, 8002000A
+VarI4FromStr: "-2", -2, 0
+VarI4FromStr: "-1", -1, 0
+VarI4FromStr: "-0.51", -1, 0
+VarI4FromStr: "-0.5", 0, 0
+VarI4FromStr: "-0.49", 0, 0
+VarI4FromStr: "-0.0", 0, 0
+VarI4FromStr: "0.0", 0, 0
+VarI4FromStr: "0.49", 0, 0
+VarI4FromStr: "0.5", 0, 0
+VarI4FromStr: "0.51", 1, 0
+VarI4FromStr: "1", 1, 0
+VarI4FromStr: "127", 127, 0
+VarI4FromStr: "128", 128, 0
+VarI4FromStr: "129", 129, 0
+VarI4FromStr: "255", 255, 0
+VarI4FromStr: "256", 256, 0
+VarI4FromStr: "257", 257, 0
+VarI4FromStr: "32767", 32767, 0
+VarI4FromStr: "32768", 32768, 0
+VarI4FromStr: "-32768", -32768, 0
+VarI4FromStr: "-32769", -32769, 0
+VarI4FromStr: "16777216", 16777216, 0
+VarI4FromStr: "16777217", 16777217, 0
+VarI4FromStr: "-16777216", -16777216, 0
+VarI4FromStr: "16777217", 16777217, 0
+VarI4FromStr: "2147483647", 2147483647, 0
+VarI4FromStr: "2147483648", 2147483647, 8002000A
+VarI4FromStr: "-2147483647", -2147483647, 0
+VarI4FromStr: "-2147483648", -2147483648, 0
+VarI4FromStr: "", -2147483648, 80020005
+VarI4FromStr: " ", -2147483648, 80020005
+VarI4FromStr: "1F", -2147483648, 80020005
+VarI4FromStr: "1G", -2147483648, 80020005
+VarI4FromStr: " 1 ", 1, 0
+VarI4FromStr: " 1 2 ", 1, 80020005
+VarI4FromStr: "1,2,3", 123, 0
+VarI4FromStr: "1 2 3", 123, 80020005
+VarI4FromStr: "1,2, 3", 123, 80020005
+VarI4FromStr: "1;2;3", 123, 80020005
+VarI4FromStr: "1.2.3", 123, 80020005
+VarI4FromStr: "0.", 0, 0
+VarI4FromStr: ".0", 0, 0
+VarI4FromStr: "0.1E12", 0, 8002000A
+VarI4FromStr: "2.4,E1", 24, 0
+VarI4FromStr: "  +3.2,E1", 32, 0
+VarI4FromStr: "4E2.5", 32, 80020005
+VarI4FromStr: "	2E+2", 200, 0
+VarI4FromStr: "1 E+2", 200, 80020005
+VarI4FromStr: ".", 200, 80020005
+VarI4FromStr: ".E2", 200, 80020005
+VarI4FromStr: "1000000000000000000000000000000000000000000000000000000000000000", 200, 8002000A
+VarI4FromStr: "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001", 1, 0
+VarI4FromStr: "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001", 1, 0
+VarI4FromStr: "100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001", 1, 8002000A
+VarI4FromStr: "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001", 1, 0
+VarI4FromStr: "65535", 65535, 0
+VarI4FromStr: "65535.5", 65536, 0
+VarI4FromStr: "65536", 65536, 0
+VarI4FromStr: "4294967295", 65536, 8002000A
+VarI4FromStr: "4294967296", 65536, 8002000A
+VarI4FromStr: "1 January 99", 65536, 80020005
+VarI4FromStr: "December 31, 2078", 65536, 80020005
+VarI4FromStr: "January 1, 1900", 65536, 80020005
+VarI4FromStr: "January 2 1900", 65536, 80020005
+VarI4FromStr: "11.11.1999", 65536, 80020005
+VarI4FromStr: "11/11/1999", 65536, 80020005
+VarI4FromStr: " 11 / 11 / 1999", 65536, 80020005
+VarI4FromStr: "11/11/1999:11:11:1134", 65536, 80020005
+VarI4FromStr: "11/11/1999 11:11:11:1", 65536, 80020005
+VarI4FromStr: "	1999/	11/21 11 :11:11am", 65536, 80020005
+VarI4FromStr: "11/11/1999 11:11:11Am", 65536, 80020005
+VarI4FromStr: "11/11/1999 11:11:11PM", 65536, 80020005
+VarI4FromStr: "11/11/199911:11:11PM", 65536, 80020005
+VarI4FromStr: "11/11/1999 0:0:11am", 65536, 80020005
+VarI4FromStr: "11/11/1999 11,11:11am", 65536, 80020005
+VarI4FromStr: "11/11/1999 11:11:11am", 65536, 80020005
+VarI4FromStr: "11/11/1999 11/11:11am", 65536, 80020005
+VarI4FromStr: "11/11/1999 11:11AM", 65536, 80020005
+VarI4FromStr: "11/11/1999 1AM", 65536, 80020005
+VarI4FromStr: "11/11/1999 0AM", 65536, 80020005
+VarI4FromStr: "11/11/1999 11:11:11", 65536, 80020005
+VarI4FromStr: "11/13/1999 0AM", 65536, 80020005
+VarI4FromStr: "13/13/1999 0AM", 65536, 80020005
+VarI4FromStr: "13/11/1999 0AM", 65536, 80020005
+VarI4FromStr: "11/33/1999 0AM", 65536, 80020005
+VarI4FromStr: "11/11/1999 AM", 65536, 80020005
+VarI4FromStr: "1/1/0 0AM", 65536, 80020005
+VarI4FromStr: "1/1/-1 0AM", 65536, 80020005
+VarI4FromStr: "1999 January 3 9AM", 65536, 80020005
+VarI4FromStr: "1 January 1999 11AM", 65536, 80020005
+VarI4FromStr: "4AM 11/11/1999", 65536, 80020005
+VarI4FromStr: "4:22 11/11/1999 AM", 65536, 80020005
+VarI4FromStr: " 1 1 /11/1999", 65536, 80020005
+VarI4FromStr: "11-11/1999 11:11:11.12AM", 65536, 80020005
+VarI4FromStr: "1999 January 3, 9AM", 65536, 80020005
+VarI4FromStr: "December, 31, 2078", 65536, 80020005
+VarI4FromStr: "December, 31, 2078,", 65536, 80020005
+VarI4FromStr: "December, 31 2078", 65536, 80020005
+VarI4FromStr: "11/99", 65536, 80020005
+VarI4FromStr: "11-1999", 65536, 80020005
+VarI4FromStr: "true", 65536, 80020005
+VarI4FromStr: "True", 65536, 80020005
+VarI4FromStr: "TRue", 65536, 80020005
+VarI4FromStr: "TRUE", 65536, 80020005
+VarI4FromStr: " TRUE", 65536, 80020005
+VarI4FromStr: "FALSE ", 65536, 80020005
+VarI4FromStr: "False", 65536, 80020005
+VarI4FromStr: "JustSomeText", 65536, 80020005
+VarI4FromStr: "Just Some Text", 65536, 80020005
+VarI4FromStr: "", 65536, 80020005
+VarI4FromStr: "1.5", 2, 0
+VarI4FromStr: "2.5", 2, 0
+VarI4FromStr: "3.5", 4, 0
+VarI4FromStr: "4.5", 4, 0
+VarI4FromStr: "", 4, 80020005
+VarI4FromStr: "", 4, 80020005
+VarI4FromStr: "", 4, 80020005
+VarI4FromStr: "", 4, 80020005
+VarI4FromStr: "", 4, 80020005
+VarI4FromStr: "", 4, 80020005
+
+
+======== Testing VarR4FromXXX ========
+VarR4FromI4: 16777216, 16777216.000000, 0
+VarR4FromI4: 16777217, 16777216.000000, 0
+VarR4FromI4: -16777216, -16777216.000000, 0
+VarR4FromI4: -16777217, -16777216.000000, 0
+VarR4FromR8: 16777216.0, 16777216.000000, 0
+VarR4FromR8: 16777217.0, 16777216.000000, 0
+VarR4FromR8: -16777216.0, -16777216.000000, 0
+VarR4FromR8: -16777217.0, -16777216.000000, 0
+VarR4FromR8: 16777218e31, 167772177736353110000000000000000000000.000000, 0
+VarR4FromR8: 16777218e32, 167772177736353110000000000000000000000.000000, 8002000A
+VarR4FromDate: 16777218e31, 167772177736353110000000000000000000000.000000, 0
+VarR4FromStr: "-2", -2.000000, 0
+VarR4FromStr: "-1", -1.000000, 0
+VarR4FromStr: "-0.51", -0.510000, 0
+VarR4FromStr: "-0.5", -0.500000, 0
+VarR4FromStr: "-0.49", -0.490000, 0
+VarR4FromStr: "-0.0", 0.000000, 0
+VarR4FromStr: "0.0", 0.000000, 0
+VarR4FromStr: "0.49", 0.490000, 0
+VarR4FromStr: "0.5", 0.500000, 0
+VarR4FromStr: "0.51", 0.510000, 0
+VarR4FromStr: "1", 1.000000, 0
+VarR4FromStr: "127", 127.000000, 0
+VarR4FromStr: "128", 128.000000, 0
+VarR4FromStr: "129", 129.000000, 0
+VarR4FromStr: "255", 255.000000, 0
+VarR4FromStr: "256", 256.000000, 0
+VarR4FromStr: "257", 257.000000, 0
+VarR4FromStr: "32767", 32767.000000, 0
+VarR4FromStr: "32768", 32768.000000, 0
+VarR4FromStr: "-32768", -32768.000000, 0
+VarR4FromStr: "-32769", -32769.000000, 0
+VarR4FromStr: "16777216", 16777216.000000, 0
+VarR4FromStr: "16777217", 16777216.000000, 0
+VarR4FromStr: "-16777216", -16777216.000000, 0
+VarR4FromStr: "16777217", 16777216.000000, 0
+VarR4FromStr: "2147483647", 2147483648.000000, 0
+VarR4FromStr: "2147483648", 2147483648.000000, 0
+VarR4FromStr: "-2147483647", -2147483648.000000, 0
+VarR4FromStr: "-2147483648", -2147483648.000000, 0
+VarR4FromStr: "", -2147483648.000000, 80020005
+VarR4FromStr: " ", -2147483648.000000, 80020005
+VarR4FromStr: "1F", -2147483648.000000, 80020005
+VarR4FromStr: "1G", -2147483648.000000, 80020005
+VarR4FromStr: " 1 ", 1.000000, 0
+VarR4FromStr: " 1 2 ", 1.000000, 80020005
+VarR4FromStr: "1,2,3", 123.000000, 0
+VarR4FromStr: "1 2 3", 123.000000, 80020005
+VarR4FromStr: "1,2, 3", 123.000000, 80020005
+VarR4FromStr: "1;2;3", 123.000000, 80020005
+VarR4FromStr: "1.2.3", 123.000000, 80020005
+VarR4FromStr: "0.", 0.000000, 0
+VarR4FromStr: ".0", 0.000000, 0
+VarR4FromStr: "0.1E12", 99999997952.000000, 0
+VarR4FromStr: "2.4,E1", 24.000000, 0
+VarR4FromStr: "  +3.2,E1", 32.000000, 0
+VarR4FromStr: "4E2.5", 32.000000, 80020005
+VarR4FromStr: "	2E+2", 200.000000, 0
+VarR4FromStr: "1 E+2", 200.000000, 80020005
+VarR4FromStr: ".", 200.000000, 80020005
+VarR4FromStr: ".E2", 200.000000, 80020005
+VarR4FromStr: "1000000000000000000000000000000000000000000000000000000000000000", 200.000000, 8002000A
+VarR4FromStr: "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001", 1.000000, 0
+VarR4FromStr: "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001", 1.000000, 0
+VarR4FromStr: "100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001", 1.000000, 8002000A
+VarR4FromStr: "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001", 1.000000, 0
+VarR4FromStr: "65535", 65535.000000, 0
+VarR4FromStr: "65535.5", 65535.500000, 0
+VarR4FromStr: "65536", 65536.000000, 0
+VarR4FromStr: "4294967295", 4294967296.000000, 0
+VarR4FromStr: "4294967296", 4294967296.000000, 0
+VarR4FromStr: "1 January 99", 4294967296.000000, 80020005
+VarR4FromStr: "December 31, 2078", 4294967296.000000, 80020005
+VarR4FromStr: "January 1, 1900", 4294967296.000000, 80020005
+VarR4FromStr: "January 2 1900", 4294967296.000000, 80020005
+VarR4FromStr: "11.11.1999", 4294967296.000000, 80020005
+VarR4FromStr: "11/11/1999", 4294967296.000000, 80020005
+VarR4FromStr: " 11 / 11 / 1999", 4294967296.000000, 80020005
+VarR4FromStr: "11/11/1999:11:11:1134", 4294967296.000000, 80020005
+VarR4FromStr: "11/11/1999 11:11:11:1", 4294967296.000000, 80020005
+VarR4FromStr: "	1999/	11/21 11 :11:11am", 4294967296.000000, 80020005
+VarR4FromStr: "11/11/1999 11:11:11Am", 4294967296.000000, 80020005
+VarR4FromStr: "11/11/1999 11:11:11PM", 4294967296.000000, 80020005
+VarR4FromStr: "11/11/199911:11:11PM", 4294967296.000000, 80020005
+VarR4FromStr: "11/11/1999 0:0:11am", 4294967296.000000, 80020005
+VarR4FromStr: "11/11/1999 11,11:11am", 4294967296.000000, 80020005
+VarR4FromStr: "11/11/1999 11:11:11am", 4294967296.000000, 80020005
+VarR4FromStr: "11/11/1999 11/11:11am", 4294967296.000000, 80020005
+VarR4FromStr: "11/11/1999 11:11AM", 4294967296.000000, 80020005
+VarR4FromStr: "11/11/1999 1AM", 4294967296.000000, 80020005
+VarR4FromStr: "11/11/1999 0AM", 4294967296.000000, 80020005
+VarR4FromStr: "11/11/1999 11:11:11", 4294967296.000000, 80020005
+VarR4FromStr: "11/13/1999 0AM", 4294967296.000000, 80020005
+VarR4FromStr: "13/13/1999 0AM", 4294967296.000000, 80020005
+VarR4FromStr: "13/11/1999 0AM", 4294967296.000000, 80020005
+VarR4FromStr: "11/33/1999 0AM", 4294967296.000000, 80020005
+VarR4FromStr: "11/11/1999 AM", 4294967296.000000, 80020005
+VarR4FromStr: "1/1/0 0AM", 4294967296.000000, 80020005
+VarR4FromStr: "1/1/-1 0AM", 4294967296.000000, 80020005
+VarR4FromStr: "1999 January 3 9AM", 4294967296.000000, 80020005
+VarR4FromStr: "1 January 1999 11AM", 4294967296.000000, 80020005
+VarR4FromStr: "4AM 11/11/1999", 4294967296.000000, 80020005
+VarR4FromStr: "4:22 11/11/1999 AM", 4294967296.000000, 80020005
+VarR4FromStr: " 1 1 /11/1999", 4294967296.000000, 80020005
+VarR4FromStr: "11-11/1999 11:11:11.12AM", 4294967296.000000, 80020005
+VarR4FromStr: "1999 January 3, 9AM", 4294967296.000000, 80020005
+VarR4FromStr: "December, 31, 2078", 4294967296.000000, 80020005
+VarR4FromStr: "December, 31, 2078,", 4294967296.000000, 80020005
+VarR4FromStr: "December, 31 2078", 4294967296.000000, 80020005
+VarR4FromStr: "11/99", 4294967296.000000, 80020005
+VarR4FromStr: "11-1999", 4294967296.000000, 80020005
+VarR4FromStr: "true", 4294967296.000000, 80020005
+VarR4FromStr: "True", 4294967296.000000, 80020005
+VarR4FromStr: "TRue", 4294967296.000000, 80020005
+VarR4FromStr: "TRUE", 4294967296.000000, 80020005
+VarR4FromStr: " TRUE", 4294967296.000000, 80020005
+VarR4FromStr: "FALSE ", 4294967296.000000, 80020005
+VarR4FromStr: "False", 4294967296.000000, 80020005
+VarR4FromStr: "JustSomeText", 4294967296.000000, 80020005
+VarR4FromStr: "Just Some Text", 4294967296.000000, 80020005
+VarR4FromStr: "", 4294967296.000000, 80020005
+VarR4FromStr: "1.5", 1.500000, 0
+VarR4FromStr: "2.5", 2.500000, 0
+VarR4FromStr: "3.5", 3.500000, 0
+VarR4FromStr: "4.5", 4.500000, 0
+VarR4FromStr: "", 4.500000, 80020005
+VarR4FromStr: "", 4.500000, 80020005
+VarR4FromStr: "", 4.500000, 80020005
+VarR4FromStr: "", 4.500000, 80020005
+VarR4FromStr: "", 4.500000, 80020005
+VarR4FromStr: "", 4.500000, 80020005
+
+
+======== Testing VarR8FromXXX ========
+VarR8FromDate: 900719925474099.0, 900719925474099.000000, 0
+VarR8FromStr: "-2", -2.000000, 0
+VarR8FromStr: "-1", -1.000000, 0
+VarR8FromStr: "-0.51", -0.510000, 0
+VarR8FromStr: "-0.5", -0.500000, 0
+VarR8FromStr: "-0.49", -0.490000, 0
+VarR8FromStr: "-0.0", 0.000000, 0
+VarR8FromStr: "0.0", 0.000000, 0
+VarR8FromStr: "0.49", 0.490000, 0
+VarR8FromStr: "0.5", 0.500000, 0
+VarR8FromStr: "0.51", 0.510000, 0
+VarR8FromStr: "1", 1.000000, 0
+VarR8FromStr: "127", 127.000000, 0
+VarR8FromStr: "128", 128.000000, 0
+VarR8FromStr: "129", 129.000000, 0
+VarR8FromStr: "255", 255.000000, 0
+VarR8FromStr: "256", 256.000000, 0
+VarR8FromStr: "257", 257.000000, 0
+VarR8FromStr: "32767", 32767.000000, 0
+VarR8FromStr: "32768", 32768.000000, 0
+VarR8FromStr: "-32768", -32768.000000, 0
+VarR8FromStr: "-32769", -32769.000000, 0
+VarR8FromStr: "16777216", 16777216.000000, 0
+VarR8FromStr: "16777217", 16777217.000000, 0
+VarR8FromStr: "-16777216", -16777216.000000, 0
+VarR8FromStr: "16777217", 16777217.000000, 0
+VarR8FromStr: "2147483647", 2147483647.000000, 0
+VarR8FromStr: "2147483648", 2147483648.000000, 0
+VarR8FromStr: "-2147483647", -2147483647.000000, 0
+VarR8FromStr: "-2147483648", -2147483648.000000, 0
+VarR8FromStr: "", -2147483648.000000, 80020005
+VarR8FromStr: " ", -2147483648.000000, 80020005
+VarR8FromStr: "1F", -2147483648.000000, 80020005
+VarR8FromStr: "1G", -2147483648.000000, 80020005
+VarR8FromStr: " 1 ", 1.000000, 0
+VarR8FromStr: " 1 2 ", 1.000000, 80020005
+VarR8FromStr: "1,2,3", 123.000000, 0
+VarR8FromStr: "1 2 3", 123.000000, 80020005
+VarR8FromStr: "1,2, 3", 123.000000, 80020005
+VarR8FromStr: "1;2;3", 123.000000, 80020005
+VarR8FromStr: "1.2.3", 123.000000, 80020005
+VarR8FromStr: "0.", 0.000000, 0
+VarR8FromStr: ".0", 0.000000, 0
+VarR8FromStr: "0.1E12", 100000000000.000000, 0
+VarR8FromStr: "2.4,E1", 24.000000, 0
+VarR8FromStr: "  +3.2,E1", 32.000000, 0
+VarR8FromStr: "4E2.5", 32.000000, 80020005
+VarR8FromStr: "	2E+2", 200.000000, 0
+VarR8FromStr: "1 E+2", 200.000000, 80020005
+VarR8FromStr: ".", 200.000000, 80020005
+VarR8FromStr: ".E2", 200.000000, 80020005
+VarR8FromStr: "1000000000000000000000000000000000000000000000000000000000000000", 1000000000000000100000000000000000000000000000000000000000000000.000000, 0
+VarR8FromStr: "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001", 1.000000, 0
+VarR8FromStr: "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001", 1.000000, 0
+VarR8FromStr: "100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001", 99999999999999997000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.000000, 0
+VarR8FromStr: "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001", 1.000000, 0
+VarR8FromStr: "65535", 65535.000000, 0
+VarR8FromStr: "65535.5", 65535.500000, 0
+VarR8FromStr: "65536", 65536.000000, 0
+VarR8FromStr: "4294967295", 4294967295.000000, 0
+VarR8FromStr: "4294967296", 4294967296.000000, 0
+VarR8FromStr: "1 January 99", 4294967296.000000, 80020005
+VarR8FromStr: "December 31, 2078", 4294967296.000000, 80020005
+VarR8FromStr: "January 1, 1900", 4294967296.000000, 80020005
+VarR8FromStr: "January 2 1900", 4294967296.000000, 80020005
+VarR8FromStr: "11.11.1999", 4294967296.000000, 80020005
+VarR8FromStr: "11/11/1999", 4294967296.000000, 80020005
+VarR8FromStr: " 11 / 11 / 1999", 4294967296.000000, 80020005
+VarR8FromStr: "11/11/1999:11:11:1134", 4294967296.000000, 80020005
+VarR8FromStr: "11/11/1999 11:11:11:1", 4294967296.000000, 80020005
+VarR8FromStr: "	1999/	11/21 11 :11:11am", 4294967296.000000, 80020005
+VarR8FromStr: "11/11/1999 11:11:11Am", 4294967296.000000, 80020005
+VarR8FromStr: "11/11/1999 11:11:11PM", 4294967296.000000, 80020005
+VarR8FromStr: "11/11/199911:11:11PM", 4294967296.000000, 80020005
+VarR8FromStr: "11/11/1999 0:0:11am", 4294967296.000000, 80020005
+VarR8FromStr: "11/11/1999 11,11:11am", 4294967296.000000, 80020005
+VarR8FromStr: "11/11/1999 11:11:11am", 4294967296.000000, 80020005
+VarR8FromStr: "11/11/1999 11/11:11am", 4294967296.000000, 80020005
+VarR8FromStr: "11/11/1999 11:11AM", 4294967296.000000, 80020005
+VarR8FromStr: "11/11/1999 1AM", 4294967296.000000, 80020005
+VarR8FromStr: "11/11/1999 0AM", 4294967296.000000, 80020005
+VarR8FromStr: "11/11/1999 11:11:11", 4294967296.000000, 80020005
+VarR8FromStr: "11/13/1999 0AM", 4294967296.000000, 80020005
+VarR8FromStr: "13/13/1999 0AM", 4294967296.000000, 80020005
+VarR8FromStr: "13/11/1999 0AM", 4294967296.000000, 80020005
+VarR8FromStr: "11/33/1999 0AM", 4294967296.000000, 80020005
+VarR8FromStr: "11/11/1999 AM", 4294967296.000000, 80020005
+VarR8FromStr: "1/1/0 0AM", 4294967296.000000, 80020005
+VarR8FromStr: "1/1/-1 0AM", 4294967296.000000, 80020005
+VarR8FromStr: "1999 January 3 9AM", 4294967296.000000, 80020005
+VarR8FromStr: "1 January 1999 11AM", 4294967296.000000, 80020005
+VarR8FromStr: "4AM 11/11/1999", 4294967296.000000, 80020005
+VarR8FromStr: "4:22 11/11/1999 AM", 4294967296.000000, 80020005
+VarR8FromStr: " 1 1 /11/1999", 4294967296.000000, 80020005
+VarR8FromStr: "11-11/1999 11:11:11.12AM", 4294967296.000000, 80020005
+VarR8FromStr: "1999 January 3, 9AM", 4294967296.000000, 80020005
+VarR8FromStr: "December, 31, 2078", 4294967296.000000, 80020005
+VarR8FromStr: "December, 31, 2078,", 4294967296.000000, 80020005
+VarR8FromStr: "December, 31 2078", 4294967296.000000, 80020005
+VarR8FromStr: "11/99", 4294967296.000000, 80020005
+VarR8FromStr: "11-1999", 4294967296.000000, 80020005
+VarR8FromStr: "true", 4294967296.000000, 80020005
+VarR8FromStr: "True", 4294967296.000000, 80020005
+VarR8FromStr: "TRue", 4294967296.000000, 80020005
+VarR8FromStr: "TRUE", 4294967296.000000, 80020005
+VarR8FromStr: " TRUE", 4294967296.000000, 80020005
+VarR8FromStr: "FALSE ", 4294967296.000000, 80020005
+VarR8FromStr: "False", 4294967296.000000, 80020005
+VarR8FromStr: "JustSomeText", 4294967296.000000, 80020005
+VarR8FromStr: "Just Some Text", 4294967296.000000, 80020005
+VarR8FromStr: "", 4294967296.000000, 80020005
+VarR8FromStr: "1.5", 1.500000, 0
+VarR8FromStr: "2.5", 2.500000, 0
+VarR8FromStr: "3.5", 3.500000, 0
+VarR8FromStr: "4.5", 4.500000, 0
+VarR8FromStr: "", 4.500000, 80020005
+VarR8FromStr: "", 4.500000, 80020005
+VarR8FromStr: "", 4.500000, 80020005
+VarR8FromStr: "", 4.500000, 80020005
+VarR8FromStr: "", 4.500000, 80020005
+VarR8FromStr: "", 4.500000, 80020005
+
+
+======== Testing VarDateFromXXX ========
+VarDateFromI4: 2958465, 2958465.000000, 0
+VarDateFromI4: 2958466, 2958465.000000, 8002000A
+VarDateFromI4: -657434, -657434.000000, 0
+VarDateFromI4: -657435, -657434.000000, 8002000A
+VarDateFromR8: 2958465.9999, 2958465.999900, 0
+VarDateFromR8: 2958466, 2958465.999900, 8002000A
+VarDateFromR8: -657434.9999, -657434.999900, 0
+VarDateFromR8: -657435, -657434.999900, 8002000A
+VarDateFromR8: 0.0, 0.000000, 0
+VarDateFromR8: 1.0, 1.000000, 0
+VarDateFromR8: 2.25, 2.250000, 0
+VarDateFromR8: -2.0, -2.000000, 0
+VarDateFromStr: "-2", -2.000000, 80020005
+VarDateFromStr: "-1", -2.000000, 80020005
+VarDateFromStr: "-0.51", -2.000000, 80020005
+VarDateFromStr: "-0.5", -2.000000, 80020005
+VarDateFromStr: "-0.49", -2.000000, 80020005
+VarDateFromStr: "-0.0", -2.000000, 80020005
+VarDateFromStr: "0.0", 0.000000, 0
+VarDateFromStr: "0.49", 0.034028, 0
+VarDateFromStr: "0.5", 0.003472, 0
+VarDateFromStr: "0.51", 0.035417, 0
+VarDateFromStr: "1", 0.035417, 80020005
+VarDateFromStr: "127", 0.035417, 80020005
+VarDateFromStr: "128", 0.035417, 80020005
+VarDateFromStr: "129", 0.035417, 80020005
+VarDateFromStr: "255", 0.035417, 80020005
+VarDateFromStr: "256", 0.035417, 80020005
+VarDateFromStr: "257", 0.035417, 80020005
+VarDateFromStr: "32767", 0.035417, 80020005
+VarDateFromStr: "32768", 0.035417, 80020005
+VarDateFromStr: "-32768", 0.035417, 80020005
+VarDateFromStr: "-32769", 0.035417, 80020005
+VarDateFromStr: "16777216", 0.035417, 80020005
+VarDateFromStr: "16777217", 0.035417, 80020005
+VarDateFromStr: "-16777216", 0.035417, 80020005
+VarDateFromStr: "16777217", 0.035417, 80020005
+VarDateFromStr: "2147483647", 0.035417, 80020005
+VarDateFromStr: "2147483648", 0.035417, 80020005
+VarDateFromStr: "-2147483647", 0.035417, 80020005
+VarDateFromStr: "-2147483648", 0.035417, 80020005
+VarDateFromStr: "", 0.035417, 80020005
+VarDateFromStr: " ", 0.035417, 80020005
+VarDateFromStr: "1F", 0.035417, 80020005
+VarDateFromStr: "1G", 0.035417, 80020005
+VarDateFromStr: " 1 ", 0.035417, 80020005
+VarDateFromStr: " 1 2 ", 35797.000000, 0
+VarDateFromStr: "1,2,3", 37623.000000, 0
+VarDateFromStr: "1 2 3", 37623.000000, 0
+VarDateFromStr: "1,2, 3", 37623.000000, 0
+VarDateFromStr: "1;2;3", 37623.000000, 80020005
+VarDateFromStr: "1.2.3", 0.043090, 0
+VarDateFromStr: "0.", 0.043090, 80020005
+VarDateFromStr: ".0", 0.043090, 80020005
+VarDateFromStr: "0.1E12", 0.043090, 80020005
+VarDateFromStr: "2.4,E1", 0.043090, 80020005
+VarDateFromStr: "  +3.2,E1", 0.043090, 80020005
+VarDateFromStr: "4E2.5", 0.043090, 80020005
+VarDateFromStr: "	2E+2", 0.043090, 80020005
+VarDateFromStr: "1 E+2", 0.043090, 80020005
+VarDateFromStr: ".", 0.043090, 80020005
+VarDateFromStr: ".E2", 0.043090, 80020005
+VarDateFromStr: "1000000000000000000000000000000000000000000000000000000000000000", 0.043090, 80020005
+VarDateFromStr: "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001", 0.043090, 80020005
+VarDateFromStr: "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001", 0.043090, 80020005
+VarDateFromStr: "100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001", 0.043090, 80020005
+VarDateFromStr: "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001", 0.043090, 80020005
+VarDateFromStr: "65535", 0.043090, 80020005
+VarDateFromStr: "65535.5", 0.043090, 80020005
+VarDateFromStr: "65536", 0.043090, 80020005
+VarDateFromStr: "4294967295", 0.043090, 80020005
+VarDateFromStr: "4294967296", 0.043090, 80020005
+VarDateFromStr: "1 January 99", 36161.000000, 0
+VarDateFromStr: "December 31, 2078", 65380.000000, 0
+VarDateFromStr: "January 1, 1900", 2.000000, 0
+VarDateFromStr: "January 2 1900", 3.000000, 0
+VarDateFromStr: "11.11.1999", 3.000000, 80020005
+VarDateFromStr: "11/11/1999", 36475.000000, 0
+VarDateFromStr: " 11 / 11 / 1999", 36475.000000, 0
+VarDateFromStr: "11/11/1999:11:11:1134", 36475.000000, 80020005
+VarDateFromStr: "11/11/1999 11:11:11:1", 36475.000000, 80020005
+VarDateFromStr: "	1999/	11/21 11 :11:11am", 36485.466100, 0
+VarDateFromStr: "11/11/1999 11:11:11Am", 36475.466100, 0
+VarDateFromStr: "11/11/1999 11:11:11PM", 36475.966100, 0
+VarDateFromStr: "11/11/199911:11:11PM", 36475.966100, 80020005
+VarDateFromStr: "11/11/1999 0:0:11am", 36475.000127, 0
+VarDateFromStr: "11/11/1999 11,11:11am", 36475.000127, 80020005
+VarDateFromStr: "11/11/1999 11:11:11am", 36475.466100, 0
+VarDateFromStr: "11/11/1999 11/11:11am", 36475.466100, 80020005
+VarDateFromStr: "11/11/1999 11:11AM", 36475.465972, 0
+VarDateFromStr: "11/11/1999 1AM", 36475.041667, 0
+VarDateFromStr: "11/11/1999 0AM", 36475.000000, 0
+VarDateFromStr: "11/11/1999 11:11:11", 36475.466100, 0
+VarDateFromStr: "11/13/1999 0AM", 36477.000000, 0
+VarDateFromStr: "13/13/1999 0AM", 36477.000000, 80020005
+VarDateFromStr: "13/11/1999 0AM", 36477.000000, 0
+VarDateFromStr: "11/33/1999 0AM", 36477.000000, 80020005
+VarDateFromStr: "11/11/1999 AM", 36477.000000, 80020005
+VarDateFromStr: "1/1/0 0AM", 36526.000000, 0
+VarDateFromStr: "1/1/-1 0AM", 36526.000000, 80020005
+VarDateFromStr: "1999 January 3 9AM", 36163.375000, 0
+VarDateFromStr: "1 January 1999 11AM", 36161.458333, 0
+VarDateFromStr: "4AM 11/11/1999", 36475.166667, 0
+VarDateFromStr: "4:22 11/11/1999 AM", 36475.166667, 80020005
+VarDateFromStr: " 1 1 /11/1999", 36475.166667, 80020005
+VarDateFromStr: "11-11/1999 11:11:11.12AM", 36475.166667, 80020005
+VarDateFromStr: "1999 January 3, 9AM", 36475.166667, 80020005
+VarDateFromStr: "December, 31, 2078", 65380.000000, 0
+VarDateFromStr: "December, 31, 2078,", 65380.000000, 80020005
+VarDateFromStr: "December, 31 2078", 65380.000000, 0
+VarDateFromStr: "11/99", 36465.000000, 0
+VarDateFromStr: "11-1999", 36465.000000, 0
+VarDateFromStr: "true", 36465.000000, 80020005
+VarDateFromStr: "True", 36465.000000, 80020005
+VarDateFromStr: "TRue", 36465.000000, 80020005
+VarDateFromStr: "TRUE", 36465.000000, 80020005
+VarDateFromStr: " TRUE", 36465.000000, 80020005
+VarDateFromStr: "FALSE ", 36465.000000, 80020005
+VarDateFromStr: "False", 36465.000000, 80020005
+VarDateFromStr: "JustSomeText", 36465.000000, 80020005
+VarDateFromStr: "Just Some Text", 36465.000000, 80020005
+VarDateFromStr: "", 36465.000000, 80020005
+VarDateFromStr: "1.5", 0.045139, 0
+VarDateFromStr: "2.5", 0.086806, 0
+VarDateFromStr: "3.5", 0.128472, 0
+VarDateFromStr: "4.5", 0.170139, 0
+VarDateFromStr: "", 0.170139, 80020005
+VarDateFromStr: "", 0.170139, 80020005
+VarDateFromStr: "", 0.170139, 80020005
+VarDateFromStr: "", 0.170139, 80020005
+VarDateFromStr: "", 0.170139, 80020005
+VarDateFromStr: "", 0.170139, 80020005
+
+
+======== Testing VarBoolFromXXX ========
+VarBoolFromI4: 0, 0, 0
+VarBoolFromI4: 1, -1, 0
+VarBoolFromI4: -1, -1, 0
+VarBoolFromI4: 2, -1, 0
+VarBoolFromUI1: ' ', -1, 0
+VarBoolFromUI1: '\0', 0, 0
+VarBoolFromUI1: 0x0000, 0, 0
+VarBoolFromUI1: 0xFFF, -1, 0
+VarBoolFromUI1: 0xFFFF, -1, 0
+VarBoolFromR8: 0.0, 0, 0
+VarBoolFromR8: 1.1, -1, 0
+VarBoolFromR8: 0.5, -1, 0
+VarBoolFromR8: 0.49, -1, 0
+VarBoolFromR8: 0.51, -1, 0
+VarBoolFromR8: -0.5, -1, 0
+VarBoolFromR8: -0.49, -1, 0
+VarBoolFromR8: -0.51, -1, 0
+VarBoolFromStr: "-2", -1, 0
+VarBoolFromStr: "-1", -1, 0
+VarBoolFromStr: "-0.51", -1, 0
+VarBoolFromStr: "-0.5", -1, 0
+VarBoolFromStr: "-0.49", -1, 0
+VarBoolFromStr: "-0.0", 0, 0
+VarBoolFromStr: "0.0", 0, 0
+VarBoolFromStr: "0.49", -1, 0
+VarBoolFromStr: "0.5", -1, 0
+VarBoolFromStr: "0.51", -1, 0
+VarBoolFromStr: "1", -1, 0
+VarBoolFromStr: "127", -1, 0
+VarBoolFromStr: "128", -1, 0
+VarBoolFromStr: "129", -1, 0
+VarBoolFromStr: "255", -1, 0
+VarBoolFromStr: "256", -1, 0
+VarBoolFromStr: "257", -1, 0
+VarBoolFromStr: "32767", -1, 0
+VarBoolFromStr: "32768", -1, 0
+VarBoolFromStr: "-32768", -1, 0
+VarBoolFromStr: "-32769", -1, 0
+VarBoolFromStr: "16777216", -1, 0
+VarBoolFromStr: "16777217", -1, 0
+VarBoolFromStr: "-16777216", -1, 0
+VarBoolFromStr: "16777217", -1, 0
+VarBoolFromStr: "2147483647", -1, 0
+VarBoolFromStr: "2147483648", -1, 0
+VarBoolFromStr: "-2147483647", -1, 0
+VarBoolFromStr: "-2147483648", -1, 0
+VarBoolFromStr: "", -1, 80020005
+VarBoolFromStr: " ", -1, 80020005
+VarBoolFromStr: "1F", -1, 80020005
+VarBoolFromStr: "1G", -1, 80020005
+VarBoolFromStr: " 1 ", -1, 0
+VarBoolFromStr: " 1 2 ", -1, 80020005
+VarBoolFromStr: "1,2,3", -1, 0
+VarBoolFromStr: "1 2 3", -1, 80020005
+VarBoolFromStr: "1,2, 3", -1, 80020005
+VarBoolFromStr: "1;2;3", -1, 80020005
+VarBoolFromStr: "1.2.3", -1, 80020005
+VarBoolFromStr: "0.", 0, 0
+VarBoolFromStr: ".0", 0, 0
+VarBoolFromStr: "0.1E12", -1, 0
+VarBoolFromStr: "2.4,E1", -1, 0
+VarBoolFromStr: "  +3.2,E1", -1, 0
+VarBoolFromStr: "4E2.5", -1, 80020005
+VarBoolFromStr: "	2E+2", -1, 0
+VarBoolFromStr: "1 E+2", -1, 80020005
+VarBoolFromStr: ".", -1, 80020005
+VarBoolFromStr: ".E2", -1, 80020005
+VarBoolFromStr: "1000000000000000000000000000000000000000000000000000000000000000", -1, 0
+VarBoolFromStr: "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001", -1, 0
+VarBoolFromStr: "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001", -1, 0
+VarBoolFromStr: "100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001", -1, 0
+VarBoolFromStr: "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001", -1, 0
+VarBoolFromStr: "65535", -1, 0
+VarBoolFromStr: "65535.5", -1, 0
+VarBoolFromStr: "65536", -1, 0
+VarBoolFromStr: "4294967295", -1, 0
+VarBoolFromStr: "4294967296", -1, 0
+VarBoolFromStr: "1 January 99", -1, 80020005
+VarBoolFromStr: "December 31, 2078", -1, 80020005
+VarBoolFromStr: "January 1, 1900", -1, 80020005
+VarBoolFromStr: "January 2 1900", -1, 80020005
+VarBoolFromStr: "11.11.1999", -1, 80020005
+VarBoolFromStr: "11/11/1999", -1, 80020005
+VarBoolFromStr: " 11 / 11 / 1999", -1, 80020005
+VarBoolFromStr: "11/11/1999:11:11:1134", -1, 80020005
+VarBoolFromStr: "11/11/1999 11:11:11:1", -1, 80020005
+VarBoolFromStr: "	1999/	11/21 11 :11:11am", -1, 80020005
+VarBoolFromStr: "11/11/1999 11:11:11Am", -1, 80020005
+VarBoolFromStr: "11/11/1999 11:11:11PM", -1, 80020005
+VarBoolFromStr: "11/11/199911:11:11PM", -1, 80020005
+VarBoolFromStr: "11/11/1999 0:0:11am", -1, 80020005
+VarBoolFromStr: "11/11/1999 11,11:11am", -1, 80020005
+VarBoolFromStr: "11/11/1999 11:11:11am", -1, 80020005
+VarBoolFromStr: "11/11/1999 11/11:11am", -1, 80020005
+VarBoolFromStr: "11/11/1999 11:11AM", -1, 80020005
+VarBoolFromStr: "11/11/1999 1AM", -1, 80020005
+VarBoolFromStr: "11/11/1999 0AM", -1, 80020005
+VarBoolFromStr: "11/11/1999 11:11:11", -1, 80020005
+VarBoolFromStr: "11/13/1999 0AM", -1, 80020005
+VarBoolFromStr: "13/13/1999 0AM", -1, 80020005
+VarBoolFromStr: "13/11/1999 0AM", -1, 80020005
+VarBoolFromStr: "11/33/1999 0AM", -1, 80020005
+VarBoolFromStr: "11/11/1999 AM", -1, 80020005
+VarBoolFromStr: "1/1/0 0AM", -1, 80020005
+VarBoolFromStr: "1/1/-1 0AM", -1, 80020005
+VarBoolFromStr: "1999 January 3 9AM", -1, 80020005
+VarBoolFromStr: "1 January 1999 11AM", -1, 80020005
+VarBoolFromStr: "4AM 11/11/1999", -1, 80020005
+VarBoolFromStr: "4:22 11/11/1999 AM", -1, 80020005
+VarBoolFromStr: " 1 1 /11/1999", -1, 80020005
+VarBoolFromStr: "11-11/1999 11:11:11.12AM", -1, 80020005
+VarBoolFromStr: "1999 January 3, 9AM", -1, 80020005
+VarBoolFromStr: "December, 31, 2078", -1, 80020005
+VarBoolFromStr: "December, 31, 2078,", -1, 80020005
+VarBoolFromStr: "December, 31 2078", -1, 80020005
+VarBoolFromStr: "11/99", -1, 80020005
+VarBoolFromStr: "11-1999", -1, 80020005
+VarBoolFromStr: "true", -1, 0
+VarBoolFromStr: "True", -1, 0
+VarBoolFromStr: "TRue", -1, 0
+VarBoolFromStr: "TRUE", -1, 0
+VarBoolFromStr: " TRUE", -1, 80020005
+VarBoolFromStr: "FALSE ", -1, 80020005
+VarBoolFromStr: "False", 0, 0
+VarBoolFromStr: "JustSomeText", 0, 80020005
+VarBoolFromStr: "Just Some Text", 0, 80020005
+VarBoolFromStr: "", 0, 80020005
+VarBoolFromStr: "1.5", -1, 0
+VarBoolFromStr: "2.5", -1, 0
+VarBoolFromStr: "3.5", -1, 0
+VarBoolFromStr: "4.5", -1, 0
+VarBoolFromStr: "", -1, 80020005
+VarBoolFromStr: "", -1, 80020005
+VarBoolFromStr: "", -1, 80020005
+VarBoolFromStr: "", -1, 80020005
+VarBoolFromStr: "", -1, 80020005
+VarBoolFromStr: "", -1, 80020005
+VarI1FromBool: VARIANT_TRUE, 255, 0
+VarUI2FromI2: -1, 0, 8002000A
+
+
+======== Testing VarBSTRFromXXX ========
+VarBstrFromI1: -100, "-100", 0
+VarBstrFromUI1: 0x5A, "90", 0
+VarBstrFromI4: 2958465, "2958465", 0
+VarBstrFromR8: 1.000000, "1", 0
+VarBstrFromR8: -1.000000, "-1", 0
+VarBstrFromR8: 21.000000, "21", 0
+VarBstrFromR8: -21.000000, "-21", 0
+VarBstrFromR8: 321.000000, "321", 0
+VarBstrFromR8: -321.000000, "-321", 0
+VarBstrFromR8: 4321.000000, "4321", 0
+VarBstrFromR8: -4321.000000, "-4321", 0
+VarBstrFromR8: 54321.000000, "54321", 0
+VarBstrFromR8: -54321.000000, "-54321", 0
+VarBstrFromR8: 654321.000000, "654321", 0
+VarBstrFromR8: -654321.000000, "-654321", 0
+VarBstrFromR8: 7654321.000000, "7654321", 0
+VarBstrFromR8: -7654321.000000, "-7654321", 0
+VarBstrFromR8: 87654321.000000, "87654321", 0
+VarBstrFromR8: -87654321.000000, "-87654321", 0
+VarBstrFromR8: 987654321.000000, "987654321", 0
+VarBstrFromR8: -987654321.000000, "-987654321", 0
+VarBstrFromR8: 1987654321.000000, "1987654321", 0
+VarBstrFromR8: -1987654321.000000, "-1987654321", 0
+VarBstrFromR8: 21987654321.000000, "21987654321", 0
+VarBstrFromR8: -21987654321.000000, "-21987654321", 0
+VarBstrFromR8: 321987654321.000000, "321987654321", 0
+VarBstrFromR8: -321987654321.000000, "-321987654321", 0
+VarBstrFromR8: 4321987654321.000000, "4321987654321", 0
+VarBstrFromR8: -4321987654321.000000, "-4321987654321", 0
+VarBstrFromR8: 54321987654321.000000, "54321987654321", 0
+VarBstrFromR8: -54321987654321.000000, "-54321987654321", 0
+VarBstrFromR8: 654321987654321.000000, "654321987654321", 0
+VarBstrFromR8: -654321987654321.000000, "-654321987654321", 0
+VarBstrFromR8: 7654321987654321.000000, "7.65432198765432e+15", 0
+VarBstrFromR8: -7654321987654321.000000, "-7.65432198765432e+15", 0
+VarBstrFromR8: 87654321987654320.000000, "8.76543219876543e+16", 0
+VarBstrFromR8: -87654321987654320.000000, "-8.76543219876543e+16", 0
+VarBstrFromR8: 987654321987654270.000000, "9.87654321987654e+17", 0
+VarBstrFromR8: -987654321987654270.000000, "-9.87654321987654e+17", 0
+VarBstrFromR8: 1987654321987654100.000000, "1.98765432198765e+18", 0
+VarBstrFromR8: -1987654321987654100.000000, "-1.98765432198765e+18", 0
+VarBstrFromR8: 21987654321987654000.000000, "2.19876543219877e+19", 0
+VarBstrFromR8: -21987654321987654000.000000, "-2.19876543219877e+19", 0
+VarBstrFromR8: 1.000000, "1", 0
+VarBstrFromR8: 0.000000, "0", 0
+VarBstrFromR8: -1.000000, "-1", 0
+VarBstrFromR8: 1.200000, "1.2", 0
+VarBstrFromR8: 0.200000, "0.2", 0
+VarBstrFromR8: -1.200000, "-1.2", 0
+VarBstrFromR8: 1.230000, "1.23", 0
+VarBstrFromR8: 0.230000, "0.23", 0
+VarBstrFromR8: -1.230000, "-1.23", 0
+VarBstrFromR8: 1.234000, "1.234", 0
+VarBstrFromR8: 0.234000, "0.234", 0
+VarBstrFromR8: -1.234000, "-1.234", 0
+VarBstrFromR8: 1.234500, "1.2345", 0
+VarBstrFromR8: 0.234500, "0.2345", 0
+VarBstrFromR8: -1.234500, "-1.2345", 0
+VarBstrFromR8: 1.234560, "1.23456", 0
+VarBstrFromR8: 0.234560, "0.23456", 0
+VarBstrFromR8: -1.234560, "-1.23456", 0
+VarBstrFromR8: 1.234567, "1.234567", 0
+VarBstrFromR8: 0.234567, "0.234567", 0
+VarBstrFromR8: -1.234567, "-1.234567", 0
+VarBstrFromR8: 1.234568, "1.2345678", 0
+VarBstrFromR8: 0.234568, "0.2345678", 0
+VarBstrFromR8: -1.234568, "-1.2345678", 0
+VarBstrFromR8: 1.234568, "1.23456789", 0
+VarBstrFromR8: 0.234568, "0.23456789", 0
+VarBstrFromR8: -1.234568, "-1.23456789", 0
+VarBstrFromR8: 1.234568, "1.234567891", 0
+VarBstrFromR8: 0.234568, "0.234567891", 0
+VarBstrFromR8: -1.234568, "-1.234567891", 0
+VarBstrFromR8: 1.234568, "1.2345678912", 0
+VarBstrFromR8: 0.234568, "0.2345678912", 0
+VarBstrFromR8: -1.234568, "-1.2345678912", 0
+VarBstrFromR8: 1.234568, "1.23456789123", 0
+VarBstrFromR8: 0.234568, "0.23456789123", 0
+VarBstrFromR8: -1.234568, "-1.23456789123", 0
+VarBstrFromR8: 1.234568, "1.234567891234", 0
+VarBstrFromR8: 0.234568, "0.234567891234", 0
+VarBstrFromR8: -1.234568, "-1.234567891234", 0
+VarBstrFromR8: 1.234568, "1.2345678912345", 0
+VarBstrFromR8: 0.234568, "0.2345678912345", 0
+VarBstrFromR8: -1.234568, "-1.2345678912345", 0
+VarBstrFromR8: 1.234568, "1.23456789123456", 0
+VarBstrFromR8: 0.234568, "0.23456789123456", 0
+VarBstrFromR8: -1.234568, "-1.23456789123456", 0
+VarBstrFromR8: 1.234568, "1.23456789123457", 0
+VarBstrFromR8: 0.234568, "0.234567891234567", 0
+VarBstrFromR8: -1.234568, "-1.23456789123457", 0
+VarBstrFromR8: 1.234568, "1.23456789123457", 0
+VarBstrFromR8: 0.234568, "0.234567891234568", 0
+VarBstrFromR8: -1.234568, "-1.23456789123457", 0
+VarBstrFromR8: 1.234568, "1.23456789123457", 0
+VarBstrFromR8: 0.234568, "0.234567891234568", 0
+VarBstrFromR8: -1.234568, "-1.23456789123457", 0
+VarBstrFromR8: 1.234568, "1.23456789123457", 0
+VarBstrFromR8: 0.234568, "0.234567891234568", 0
+VarBstrFromR8: -1.234568, "-1.23456789123457", 0
+VarBstrFromR8: 1.234568, "1.23456789123457", 0
+VarBstrFromR8: 0.234568, "0.234567891234568", 0
+VarBstrFromR8: -1.234568, "-1.23456789123457", 0
+VarBstrFromR8: 2.000000, "2", 0
+VarBstrFromR8: -2.000000, "-2", 0
+VarBstrFromR8: 22.200000, "22.2", 0
+VarBstrFromR8: -22.200000, "-22.2", 0
+VarBstrFromR8: 322.230000, "322.23", 0
+VarBstrFromR8: -322.230000, "-322.23", 0
+VarBstrFromR8: 4322.234000, "4322.234", 0
+VarBstrFromR8: -4322.234000, "-4322.234", 0
+VarBstrFromR8: 54322.234500, "54322.2345", 0
+VarBstrFromR8: -54322.234500, "-54322.2345", 0
+VarBstrFromR8: 654322.234560, "654322.23456", 0
+VarBstrFromR8: -654322.234560, "-654322.23456", 0
+VarBstrFromR8: 7654322.234567, "7654322.234567", 0
+VarBstrFromR8: -7654322.234567, "-7654322.234567", 0
+VarBstrFromR8: 87654322.234568, "87654322.2345678", 0
+VarBstrFromR8: -87654322.234568, "-87654322.2345678", 0
+VarBstrFromR8: 987654322.234568, "987654322.234568", 0
+VarBstrFromR8: -987654322.234568, "-987654322.234568", 0
+VarBstrFromR8: 1987654322.234568, "1987654322.23457", 0
+VarBstrFromR8: -1987654322.234568, "-1987654322.23457", 0
+VarBstrFromR8: 21987654322.234570, "21987654322.2346", 0
+VarBstrFromR8: -21987654322.234570, "-21987654322.2346", 0
+VarBstrFromR8: 321987654322.234560, "321987654322.235", 0
+VarBstrFromR8: -321987654322.234560, "-321987654322.235", 0
+VarBstrFromR8: 4321987654322.234400, "4321987654322.23", 0
+VarBstrFromR8: -4321987654322.234400, "-4321987654322.23", 0
+VarBstrFromR8: 54321987654322.234000, "54321987654322.2", 0
+VarBstrFromR8: -54321987654322.234000, "-54321987654322.2", 0
+VarBstrFromR8: 654321987654322.250000, "654321987654322", 0
+VarBstrFromR8: -654321987654322.250000, "-654321987654322", 0
+VarBstrFromR8: 7654321987654322.000000, "7.65432198765432e+15", 0
+VarBstrFromR8: -7654321987654322.000000, "-7.65432198765432e+15", 0
+VarBstrFromR8: 87654321987654320.000000, "8.76543219876543e+16", 0
+VarBstrFromR8: -87654321987654320.000000, "-8.76543219876543e+16", 0
+VarBstrFromR8: 987654321987654270.000000, "9.87654321987654e+17", 0
+VarBstrFromR8: -987654321987654270.000000, "-9.87654321987654e+17", 0
+VarBstrFromR8: 1987654321987654100.000000, "1.98765432198765e+18", 0
+VarBstrFromR8: -1987654321987654100.000000, "-1.98765432198765e+18", 0
+VarBstrFromR8: 21987654321987654000.000000, "2.19876543219877e+19", 0
+VarBstrFromR8: -21987654321987654000.000000, "-2.19876543219877e+19", 0
+VarBstrFromR4: 1.000000, "1", 0
+VarBstrFromR4: -1.000000, "-1", 0
+VarBstrFromR4: 21.000000, "21", 0
+VarBstrFromR4: -21.000000, "-21", 0
+VarBstrFromR4: 321.000000, "321", 0
+VarBstrFromR4: -321.000000, "-321", 0
+VarBstrFromR4: 4321.000000, "4321", 0
+VarBstrFromR4: -4321.000000, "-4321", 0
+VarBstrFromR4: 54321.000000, "54321", 0
+VarBstrFromR4: -54321.000000, "-54321", 0
+VarBstrFromR4: 654321.000000, "654321", 0
+VarBstrFromR4: -654321.000000, "-654321", 0
+VarBstrFromR4: 7654321.000000, "7654321", 0
+VarBstrFromR4: -7654321.000000, "-7654321", 0
+VarBstrFromR4: 87654321.000000, "8.765432e+07", 0
+VarBstrFromR4: -87654321.000000, "-8.765432e+07", 0
+VarBstrFromR4: 987654321.000000, "9.876543e+08", 0
+VarBstrFromR4: -987654321.000000, "-9.876543e+08", 0
+VarBstrFromR4: 1987654321.000000, "1.987654e+09", 0
+VarBstrFromR4: -1987654321.000000, "-1.987654e+09", 0
+VarBstrFromR4: 1.000000, "1", 0
+VarBstrFromR4: 0.000000, "0", 0
+VarBstrFromR4: -1.000000, "-1", 0
+VarBstrFromR4: 1.200000, "1.2", 0
+VarBstrFromR4: 0.200000, "0.2", 0
+VarBstrFromR4: -1.200000, "-1.2", 0
+VarBstrFromR4: 1.230000, "1.23", 0
+VarBstrFromR4: 0.230000, "0.23", 0
+VarBstrFromR4: -1.230000, "-1.23", 0
+VarBstrFromR4: 1.234000, "1.234", 0
+VarBstrFromR4: 0.234000, "0.234", 0
+VarBstrFromR4: -1.234000, "-1.234", 0
+VarBstrFromR4: 1.234500, "1.2345", 0
+VarBstrFromR4: 0.234500, "0.2345", 0
+VarBstrFromR4: -1.234500, "-1.2345", 0
+VarBstrFromR4: 1.234560, "1.23456", 0
+VarBstrFromR4: 0.234560, "0.23456", 0
+VarBstrFromR4: -1.234560, "-1.23456", 0
+VarBstrFromR4: 1.234567, "1.234567", 0
+VarBstrFromR4: 0.234567, "0.234567", 0
+VarBstrFromR4: -1.234567, "-1.234567", 0
+VarBstrFromR4: 1.234568, "1.234568", 0
+VarBstrFromR4: 0.234568, "0.2345678", 0
+VarBstrFromR4: -1.234568, "-1.234568", 0
+VarBstrFromR4: 1.234568, "1.234568", 0
+VarBstrFromR4: 0.234568, "0.2345679", 0
+VarBstrFromR4: -1.234568, "-1.234568", 0
+VarBstrFromR4: 1.234568, "1.234568", 0
+VarBstrFromR4: 0.234568, "0.2345679", 0
+VarBstrFromR4: -1.234568, "-1.234568", 0
+VarBstrFromR4: 2.000000, "2", 0
+VarBstrFromR4: -2.000000, "-2", 0
+VarBstrFromR4: 22.200000, "22.2", 0
+VarBstrFromR4: -22.200000, "-22.2", 0
+VarBstrFromR4: 322.230000, "322.23", 0
+VarBstrFromR4: -322.230000, "-322.23", 0
+VarBstrFromR4: 4322.234000, "4322.234", 0
+VarBstrFromR4: -4322.234000, "-4322.234", 0
+VarBstrFromR4: 54322.234500, "54322.23", 0
+VarBstrFromR4: -54322.234500, "-54322.23", 0
+VarBstrFromR4: 654322.234560, "654322.3", 0
+VarBstrFromR4: -654322.234560, "-654322.3", 0
+VarBstrFromR4: 7654322.234567, "7654322", 0
+VarBstrFromR4: -7654322.234567, "-7654322", 0
+VarBstrFromR4: 87654322.234568, "8.765432e+07", 0
+VarBstrFromR4: -87654322.234568, "-8.765432e+07", 0
+VarBstrFromR4: 987654322.234568, "9.876543e+08", 0
+VarBstrFromR4: -987654322.234568, "-9.876543e+08", 0
+VarBstrFromR4: 1987654322.234568, "1.987654e+09", 0
+VarBstrFromR4: -1987654322.234568, "-1.987654e+09", 0
+VarBstrFromBool: 0x00, "False", 0
+VarBstrFromBool: 0xFF, "True", 0
+VarBstrFromDate: 0.0, "12:00:00 AM", 0
+VarBstrFromDate: 3.34, "1/2/1900 8:09:36 AM", 0
+VarBstrFromDate: 3339.34, "2/20/1909 8:09:36 AM", 0
+VarBstrFromDate: 365.00, "12/30/1900", 0
+VarBstrFromDate: 365.25, "12/30/1900 6:00:00 AM", 0
+VarBstrFromDate: 1461.00, "12/31/1903", 0
+VarBstrFromDate: 1461.5, "12/31/1903 12:00:00 PM", 0
+VarBstrFromBool: 0x00, "False", 0
+VarBstrFromBool: 0xFF, "True", 0
+VarBstrFromDate: 0.0, "12:00:00 AM", 0
+VarBstrFromDate: 3.34, "1/2/1900 8:09:36 AM", 0
+
+
+======== Testing Hi-Level Variant API ========
+Result is: 80020008
+VariantClear: 0
+VariantClear: 0
+VariantCopy: 0
+VariantClear: 0
+VariantClear: 0
+VariantCopy 4.123000 -> 4.123000: 0
+VariantCopyInd 31.123000: 0
+VariantCopy 1.123000 -> 1.123000: 0
+VariantCopy 123.123000 -> 123.123000: 0
+VariantCopyInd 111.200000 -> 111.200000: 0
+VariantChangeTypeEx 1211: 0
+VariantChangeTypeEx 4 -> "4": 0
+VariantChangeTypeEx 34465.332431 -> "5/11/94 7:58:42 AM": 0
+VariantChangeTypeEx "-0.49" -> -0.490000: 0
+VariantCopyInd: 80070057
+-------------- Testing different VARTYPES ----------------
+VariantCopyInd: 0 -> 0
+VariantCopyInd: 0 -> 80070057
+VariantChangeTypeEx: 0 -> 0
+VariantChangeTypeEx: VT_BYREF 0 -> 80020008
+VariantClear: 0 -> 80020008
+VariantCopyInd: 1 -> 0
+VariantCopyInd: 1 -> 80070057
+VariantChangeTypeEx: 1 -> 0
+VariantChangeTypeEx: VT_BYREF 1 -> 80020008
+VariantClear: 1 -> 80020008
+VariantCopyInd: 2 -> 0
+VariantCopyInd: 2 -> 0
+VariantChangeTypeEx: 2 -> 0
+VariantChangeTypeEx: VT_BYREF 2 -> 80020005
+VariantClear: 2 -> 80020008
+VariantCopyInd: 3 -> 0
+VariantCopyInd: 3 -> 0
+VariantChangeTypeEx: 3 -> 0
+VariantChangeTypeEx: VT_BYREF 3 -> 80020005
+VariantClear: 3 -> 80020008
+VariantCopyInd: 4 -> 0
+VariantCopyInd: 4 -> 0
+VariantChangeTypeEx: 4 -> 0
+VariantChangeTypeEx: VT_BYREF 4 -> 80020005
+VariantClear: 4 -> 80020008
+VariantCopyInd: 5 -> 0
+VariantCopyInd: 5 -> 0
+VariantChangeTypeEx: 5 -> 0
+VariantChangeTypeEx: VT_BYREF 5 -> 80020005
+VariantClear: 5 -> 80020008
+VariantCopyInd: 6 -> 0
+VariantCopyInd: 6 -> 0
+VariantChangeTypeEx: 6 -> 0
+VariantChangeTypeEx: VT_BYREF 6 -> 80020005
+VariantClear: 6 -> 80020008
+VariantCopyInd: 7 -> 0
+VariantCopyInd: 7 -> 0
+VariantChangeTypeEx: 7 -> 0
+VariantChangeTypeEx: VT_BYREF 7 -> 80020005
+VariantClear: 7 -> 80020008
+VariantCopyInd: 77 -> 80020008
+VariantCopyInd: 77 -> 80070057
+VariantChangeTypeEx: 77 -> 80020008
+VariantChangeTypeEx: VT_BYREF 77 -> 80020008
+VariantClear: 77 -> 80020008
+VariantCopyInd: 78 -> 80020008
+VariantCopyInd: 78 -> 80070057
+VariantChangeTypeEx: 78 -> 80020008
+VariantChangeTypeEx: VT_BYREF 78 -> 80020008
+VariantClear: 78 -> 80020008
+VariantCopyInd: 79 -> 80020008
+VariantCopyInd: 79 -> 80070057
+VariantChangeTypeEx: 79 -> 80020008
+VariantChangeTypeEx: VT_BYREF 79 -> 80020008
+VariantClear: 79 -> 80020008
+VariantCopyInd: 80 -> 80020008
+VariantCopyInd: 80 -> 80070057
+VariantChangeTypeEx: 80 -> 80020008
+VariantChangeTypeEx: VT_BYREF 80 -> 80020008
+VariantClear: 80 -> 80020008
+VariantCopyInd: 81 -> 80020008
+VariantCopyInd: 81 -> 80070057
+VariantChangeTypeEx: 81 -> 80020008
+VariantChangeTypeEx: VT_BYREF 81 -> 80020008
+VariantClear: 81 -> 80020008
+VariantCopyInd: 82 -> 80020008
+VariantCopyInd: 82 -> 80070057
+VariantChangeTypeEx: 82 -> 80020008
+VariantChangeTypeEx: VT_BYREF 82 -> 80020008
+VariantClear: 82 -> 80020008
+VariantCopyInd: 83 -> 80020008
+VariantCopyInd: 83 -> 80070057
+VariantChangeTypeEx: 83 -> 80020008
+VariantChangeTypeEx: VT_BYREF 83 -> 80020008
+VariantClear: 83 -> 80020008
+VariantCopyInd: 84 -> 80020008
+VariantCopyInd: 84 -> 80070057
+VariantChangeTypeEx: 84 -> 80020008
+VariantChangeTypeEx: VT_BYREF 84 -> 80020008
+VariantClear: 84 -> 80020008
+VariantCopyInd: 85 -> 80020008
+VariantCopyInd: 85 -> 80070057
+VariantChangeTypeEx: 85 -> 80020008
+VariantChangeTypeEx: VT_BYREF 85 -> 80020008
+VariantClear: 85 -> 80020008
+VariantCopyInd: 86 -> 80020008
+VariantCopyInd: 86 -> 80070057
+VariantChangeTypeEx: 86 -> 80020008
+VariantChangeTypeEx: VT_BYREF 86 -> 80020008
+VariantClear: 86 -> 80020008
+VariantCopyInd: 87 -> 80020008
+VariantCopyInd: 87 -> 80070057
+VariantChangeTypeEx: 87 -> 80020008
+VariantChangeTypeEx: VT_BYREF 87 -> 80020008
+VariantClear: 87 -> 80020008
+VariantCopyInd: 88 -> 80020008
+VariantCopyInd: 88 -> 80070057
+VariantChangeTypeEx: 88 -> 80020008
+VariantChangeTypeEx: VT_BYREF 88 -> 80020008
+VariantClear: 88 -> 80020008
+VariantCopyInd: 89 -> 80020008
+VariantCopyInd: 89 -> 80070057
+VariantChangeTypeEx: 89 -> 80020008
+VariantChangeTypeEx: VT_BYREF 89 -> 80020008
+VariantClear: 89 -> 80020008
+VariantCopyInd: 90 -> 80020008
+VariantCopyInd: 90 -> 80070057
+VariantChangeTypeEx: 90 -> 80020008
+VariantChangeTypeEx: VT_BYREF 90 -> 80020008
+VariantClear: 90 -> 80020008
+VariantCopyInd: 91 -> 80020008
+VariantCopyInd: 91 -> 80070057
+VariantChangeTypeEx: 91 -> 80020008
+VariantChangeTypeEx: VT_BYREF 91 -> 80020008
+VariantClear: 91 -> 80020008
+VariantCopyInd: 92 -> 80020008
+VariantCopyInd: 92 -> 80070057
+VariantChangeTypeEx: 92 -> 80020008
+VariantChangeTypeEx: VT_BYREF 92 -> 80020008
+VariantClear: 92 -> 80020008
+VariantCopyInd: 93 -> 80020008
+VariantCopyInd: 93 -> 80070057
+VariantChangeTypeEx: 93 -> 80020008
+VariantChangeTypeEx: VT_BYREF 93 -> 80020008
+VariantClear: 93 -> 80020008
+VariantCopyInd: 94 -> 80020008
+VariantCopyInd: 94 -> 80070057
+VariantChangeTypeEx: 94 -> 80020008
+VariantChangeTypeEx: VT_BYREF 94 -> 80020008
+VariantClear: 94 -> 80020008
+VariantCopyInd: 95 -> 80020008
+VariantCopyInd: 95 -> 80070057
+VariantChangeTypeEx: 95 -> 80020008
+VariantChangeTypeEx: VT_BYREF 95 -> 80020008
+VariantClear: 95 -> 80020008
+VariantCopyInd: 96 -> 80020008
+VariantCopyInd: 96 -> 80070057
+VariantChangeTypeEx: 96 -> 80020008
+VariantChangeTypeEx: VT_BYREF 96 -> 80020008
+VariantClear: 96 -> 80020008
+VariantCopyInd: 97 -> 80020008
+VariantCopyInd: 97 -> 80070057
+VariantChangeTypeEx: 97 -> 80020008
+VariantChangeTypeEx: VT_BYREF 97 -> 80020008
+VariantClear: 97 -> 80020008
+VariantCopyInd: 98 -> 80020008
+VariantCopyInd: 98 -> 80070057
+VariantChangeTypeEx: 98 -> 80020008
+VariantChangeTypeEx: VT_BYREF 98 -> 80020008
+VariantClear: 98 -> 80020008
+VariantCopyInd: 99 -> 80020008
+VariantCopyInd: 99 -> 80070057
+VariantChangeTypeEx: 99 -> 80020008
+VariantChangeTypeEx: VT_BYREF 99 -> 80020008
+VariantClear: 99 -> 80020008
+VariantClear: 80020008
+VariantClear: 0
+VariantClear: 0
+VariantClear: 0
+VariantClear: 0
diff --git a/libtest/vartest.c b/libtest/vartest.c
new file mode 100644
index 0000000..8506cf2
--- /dev/null
+++ b/libtest/vartest.c
@@ -0,0 +1,1051 @@
+/*
+ * VARIANT test program
+ *
+ * Copyright 1998 Jean-Claude Cote
+ *
+ * The purpose of this program is validate the implementation
+ * of the APIs related to VARIANTs. The validation is done
+ * by comparing the results given by the Windows implementation
+ * versus the Wine implementation.
+ *
+ * This program tests the creation/coercion/destruction of VARIANTs.
+ *
+ * The program does not currently test any API that takes
+ * arguments of type: IDispatch, IUnknown, DECIMAL, CURRENCY.
+ *
+ * Since the purpose of this program is to compare the results
+ * from Windows and Wine it is written so that with a simple
+ * define it can be compiled either in Windows or Linux.
+ *
+ *
+ * NOTES
+ *	 - The Variant structure in Windows has a non-named union. This means
+ *	 the member of the union are accessible simply by doing pVariant->pfltVal.
+ *	 With gcc it is not possible to have non-named union so it has been named
+ *	 'u'.  So it's members are accessible using this name like so
+ *	 pVariant->u.pfltVal.  So if this program is compiled in Windows
+ *	 the references to 'u' will need to be take out of this file.
+ *
+ *	 - Also the printf is a little different so the format specifiers may
+ *	 need to be tweaked if this file is compile in Windows.
+ *	 Printf is also different in that it continues printing numbers
+ *	 even after there is no more significative digits left to print.  These
+ *	 number are garbage and in windows they are set to zero but not
+ *	 on Linux.
+ *
+ *	 - The VarDateFromStr is not implemented yet.
+ *
+ *	 - The date and floating point format may not be the exact same format has the one in
+ *	 windows depending on what the Internatinal setting are in windows.
+ *
+ */
+
+
+
+#include <stdio.h>
+#include <malloc.h>
+#include <windows.h>
+#include <winerror.h>
+#include <winnt.h>
+
+#include <oleauto.h>
+
+#include <math.h>
+#include <float.h>
+#include <time.h>
+
+#if WINDOWS
+#include <wtypes.h>
+#else
+#include <wintypes.h>
+#endif
+
+
+#ifdef WINDOWS
+#else
+#include <debugstr.h>
+extern LPWSTR HEAP_strdupAtoW( HANDLE32 heap, DWORD flags, LPCSTR str );
+#endif
+
+
+static const int MAX_BUFFER = 1024;
+
+
+#ifdef WINDOWS
+char* WtoA( OLECHAR* p )
+{
+	int i = 0;
+	char* pc = (char *)malloc( MAX_BUFFER*sizeof(char) );
+	pc[0] = '\"';
+	pc++;
+	i = wcstombs( pc, p, MAX_BUFFER );
+	if( i < MAX_BUFFER-1 )
+	{
+		pc[i] = '\"';
+		pc[i+1] = '\0';
+	}
+	pc--;
+	return pc;
+}
+
+OLECHAR* AtoW( char* p )
+{
+	int i = 0;
+	OLECHAR* pwc = (OLECHAR *)malloc( MAX_BUFFER*sizeof(OLECHAR) );
+	i = mbstowcs( pwc, p, MAX_BUFFER );
+	return pwc;
+}
+#else 
+char* WtoA( OLECHAR* p )
+{
+	return debugstr_wn( p, MAX_BUFFER );
+}
+OLECHAR* AtoW( char* p )
+{
+	return HEAP_strdupAtoW( GetProcessHeap(), 0, p );
+}
+#endif
+
+
+int PASCAL WinMain (HANDLE inst, HANDLE prev, LPSTR cmdline, int show)
+{
+	VARIANTARG va;
+	VARIANTARG vb;
+	VARIANTARG vc;
+	VARIANTARG vd;
+	VARIANTARG ve;
+
+	int theInt = 0;
+	int* pInt = &theInt;
+	VARIANT_BOOL b = 0;
+	VARIANT_BOOL* pBool = &b;
+	unsigned short uShort = 0;
+	unsigned short* pUShort = &uShort;
+	unsigned long uLong = 0;
+	unsigned long* pULong = &uLong;
+	CHAR theChar;
+	CHAR* pChar = &theChar;
+	BYTE byte;
+	BYTE* pByte = &byte;
+	short s = 0;
+	short* pShort = &s;
+	long Long = 0;
+	long* pLong = &Long;
+	float f = 0;
+	float* pFloat = &f;
+	double d = 0;
+	double* pDouble = &d;
+	
+	unsigned short i = 0;
+	HRESULT res = 0;
+	BSTR bstr = NULL;
+	int olePtrIndex = 0;
+	int nOlePtrs = 120;
+	OLECHAR* pOleChar[120];
+
+	pOleChar[0] = AtoW( "-2" );
+	pOleChar[1] = AtoW( "-1" );
+	pOleChar[2] = AtoW( "-0.51" );
+	pOleChar[3] = AtoW( "-0.5" );
+	pOleChar[4] = AtoW( "-0.49" );
+	pOleChar[5] = AtoW( "-0.0" );
+	pOleChar[6] = AtoW( "0.0" );
+	pOleChar[7] = AtoW( "0.49" );
+	pOleChar[8] = AtoW( "0.5" );
+	pOleChar[9] = AtoW( "0.51" );
+	pOleChar[10] = AtoW( "1" );
+	pOleChar[11] = AtoW( "127" );
+	pOleChar[12] = AtoW( "128" );
+	pOleChar[13] = AtoW( "129" );
+	pOleChar[14] = AtoW( "255" );
+	pOleChar[15] = AtoW( "256" );
+	pOleChar[16] = AtoW( "257" );
+	pOleChar[17] = AtoW( "32767" );
+	pOleChar[18] = AtoW( "32768" );
+	pOleChar[19] = AtoW( "-32768" );
+	pOleChar[20] = AtoW( "-32769" );
+	pOleChar[21] = AtoW( "16777216" );
+	pOleChar[22] = AtoW( "16777217" );
+	pOleChar[23] = AtoW( "-16777216" );
+	pOleChar[24] = AtoW( "16777217" );
+	pOleChar[25] = AtoW( "2147483647" );
+	pOleChar[26] = AtoW( "2147483648" );
+	pOleChar[27] = AtoW( "-2147483647" );
+	pOleChar[28] = AtoW( "-2147483648" );
+
+	pOleChar[29] = AtoW( "" );
+	pOleChar[30] = AtoW( " " );
+	pOleChar[31] = AtoW( "1F" );
+	pOleChar[32] = AtoW( "1G" );
+	pOleChar[33] = AtoW( " 1 " );
+	pOleChar[34] = AtoW( " 1 2 " );
+	pOleChar[35] = AtoW( "1,2,3" );
+	pOleChar[36] = AtoW( "1 2 3" );
+	pOleChar[37] = AtoW( "1,2, 3" );
+	pOleChar[38] = AtoW( "1;2;3" );
+	pOleChar[39] = AtoW( "1.2.3" );
+
+	pOleChar[40] = AtoW( "0." );
+	pOleChar[41] = AtoW( ".0" );
+	pOleChar[42] = AtoW( "0.1E12" );
+	pOleChar[43] = AtoW( "2.4,E1" );
+	pOleChar[44] = AtoW( "	+3.2,E1" );
+	pOleChar[45] = AtoW( "4E2.5" );
+	pOleChar[46] = AtoW( "	2E+2" );
+	pOleChar[47] = AtoW( "1 E+2" );
+	pOleChar[48] = AtoW( "." );
+	pOleChar[49] = AtoW( ".E2" );
+	pOleChar[50] = AtoW( "1000000000000000000000000000000000000000000000000000000000000000" );
+	pOleChar[51] = AtoW( "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001" );
+	pOleChar[52] = AtoW( "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001" );
+	pOleChar[53] = AtoW( "100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001" );
+	pOleChar[54] = AtoW( "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001" );
+	pOleChar[55] = AtoW( "65535" );
+	pOleChar[56] = AtoW( "65535.5" );
+	pOleChar[57] = AtoW( "65536" );
+	pOleChar[58] = AtoW( "4294967295" );
+	pOleChar[59] = AtoW( "4294967296" );
+	
+	pOleChar[60] = AtoW( "1 January 99" );
+	pOleChar[61] = AtoW( "December 31, 2078" );
+	pOleChar[62] = AtoW( "January 1, 1900" );
+	pOleChar[63] = AtoW( "January 2 1900" );
+	pOleChar[64] = AtoW( "11.11.1999" );
+	pOleChar[65] = AtoW( "11/11/1999" );
+	pOleChar[66] = AtoW( " 11 / 11 / 1999" );
+	pOleChar[67] = AtoW( "11/11/1999:11:11:1134" );
+	pOleChar[68] = AtoW( "11/11/1999 11:11:11:1" );
+	pOleChar[69] = AtoW( "\t1999/\t11/21 11 :11:11am" );
+
+	pOleChar[70] = AtoW( "11/11/1999 11:11:11Am" );
+	pOleChar[71] = AtoW( "11/11/1999 11:11:11PM" );
+	pOleChar[72] = AtoW( "11/11/199911:11:11PM" );
+	pOleChar[73] = AtoW( "11/11/1999 0:0:11am" );
+	pOleChar[74] = AtoW( "11/11/1999 11,11:11am" );
+	pOleChar[75] = AtoW( "11/11/1999 11:11:11am" );
+	pOleChar[76] = AtoW( "11/11/1999 11/11:11am" );
+	pOleChar[77] = AtoW( "11/11/1999 11:11AM" );
+	pOleChar[78] = AtoW( "11/11/1999 1AM" );
+	pOleChar[79] = AtoW( "11/11/1999 0AM" );
+
+	pOleChar[80] = AtoW( "11/11/1999 11:11:11" );
+	pOleChar[81] = AtoW( "11/13/1999 0AM" );
+	pOleChar[82] = AtoW( "13/13/1999 0AM" );
+	pOleChar[83] = AtoW( "13/11/1999 0AM" );
+	pOleChar[84] = AtoW( "11/33/1999 0AM" );
+	pOleChar[85] = AtoW( "11/11/1999 AM" );
+	pOleChar[86] = AtoW( "1/1/0 0AM" );
+	pOleChar[87] = AtoW( "1/1/-1 0AM" );
+	pOleChar[88] = AtoW( "1999 January 3 9AM" );
+	pOleChar[89] = AtoW( "1 January 1999 11AM" );
+
+	pOleChar[90] = AtoW( "4AM 11/11/1999" );
+	pOleChar[91] = AtoW( "4:22 11/11/1999 AM" );
+	pOleChar[92] = AtoW( " 1 1 /11/1999" );
+	pOleChar[93] = AtoW( "11-11/1999 11:11:11.12AM" );
+	pOleChar[94] = AtoW( "1999 January 3, 9AM" );
+	pOleChar[95] = AtoW( "December, 31, 2078" );
+	pOleChar[96] = AtoW( "December, 31, 2078," );
+	pOleChar[97] = AtoW( "December, 31 2078" );
+	pOleChar[98] = AtoW( "11/99" );
+	pOleChar[99] = AtoW( "11-1999" );
+
+	pOleChar[100] = AtoW( "true" );
+	pOleChar[101] = AtoW( "True" );
+	pOleChar[102] = AtoW( "TRue" );
+	pOleChar[103] = AtoW( "TRUE" );
+	pOleChar[104] = AtoW( " TRUE" );
+	pOleChar[105] = AtoW( "FALSE " );
+	pOleChar[106] = AtoW( "False" );
+	pOleChar[107] = AtoW( "JustSomeText" );
+	pOleChar[108] = AtoW( "Just Some Text" );
+	pOleChar[109] = AtoW( "" );
+
+	pOleChar[110] = AtoW( "1.5" );
+	pOleChar[111] = AtoW( "2.5" );
+	pOleChar[112] = AtoW( "3.5" );
+	pOleChar[113] = AtoW( "4.5" );
+	pOleChar[114] = AtoW( "" );
+	pOleChar[115] = AtoW( "" );
+	pOleChar[116] = AtoW( "" );
+	pOleChar[117] = AtoW( "" );
+	pOleChar[118] = AtoW( "" );
+	pOleChar[119] = AtoW( "" );
+
+
+	/* Start testing the Low-Level API ( the coercions )
+	 */
+
+
+	/* unsigned char from...
+	 */
+	printf( "\n\n======== Testing VarUI1FromXXX ========\n");
+	
+	/* res = VarUI1FromI2( 0, NULL );
+	 */
+	printf( "VarUI1FromI2: passing in NULL as return val makes it crash, %X\n", (unsigned int) res );
+
+	res = VarUI1FromStr( NULL, 0, 0, pByte );
+	printf( "VarUI1FromStr: passing in NULL as param: %X\n", (unsigned int) res );
+
+	res = VarUI1FromI2( 0, pByte );
+	printf( "VarUI1FromI2: 0, %X, %X\n", *pByte, (unsigned int) res );
+	res = VarUI1FromI2( 69, pByte );
+	printf( "VarUI1FromI2: 69, %X, %X\n", *pByte, (unsigned int) res );
+	res = VarUI1FromI2( 70, pByte );
+	printf( "VarUI1FromI2: 70, %X, %X\n", *pByte, (unsigned int) res );
+	res = VarUI1FromI2( 128, pByte );
+	printf( "VarUI1FromI2: 128, %X, %X\n", *pByte, (unsigned int) res );
+	res = VarUI1FromI2( 255, pByte );
+	printf( "VarUI1FromI2: 255, %X, %X\n", *pByte, (unsigned int) res );
+	res = VarUI1FromI2( 256, pByte );
+	printf( "VarUI1FromI2: 256, %X, %X\n", *pByte, (unsigned int) res );
+	res = VarUI1FromI2( 257, pByte );
+	printf( "VarUI1FromI2: 257, %X, %X\n", *pByte, (unsigned int) res );
+
+	res = VarUI1FromR8( 0.0, pByte );
+	printf( "VarUI1FromR8: 0.0, %X, %X\n", *pByte, (unsigned int) res );
+	res = VarUI1FromR8( 69.33, pByte );
+	printf( "VarUI1FromR8: 69.33, %X, %X\n", *pByte, (unsigned int) res );
+	res = VarUI1FromR8( 69.66, pByte );
+	printf( "VarUI1FromR8: 69.66, %X, %X\n", *pByte, (unsigned int) res );
+	res = VarUI1FromR8( -69.33, pByte );
+	printf( "VarUI1FromR8: -69.33, %X, %X\n", *pByte, (unsigned int) res );
+	res = VarUI1FromR8( -69.66, pByte );
+	printf( "VarUI1FromR8: -69.66, %X, %X\n", *pByte, (unsigned int) res );
+
+	res = VarUI1FromR8( -0.5, pByte );
+	printf( "VarUI1FromR8: -0.5, %X, %X\n", *pByte, (unsigned int) res );
+	res = VarUI1FromR8( -0.51, pByte );
+	printf( "VarUI1FromR8: -0.51, %X, %X\n", *pByte, (unsigned int) res );
+	res = VarUI1FromR8( -0.49, pByte );
+	printf( "VarUI1FromR8: -0.49, %X, %X\n", *pByte, (unsigned int) res );
+
+	res = VarUI1FromR8( 0.5, pByte );
+	printf( "VarUI1FromR8: 0.5, %X, %X\n", *pByte, (unsigned int) res );
+	res = VarUI1FromR8( 0.51, pByte );
+	printf( "VarUI1FromR8: 0.51, %X, %X\n", *pByte, (unsigned int) res );
+	res = VarUI1FromR8( 0.49, pByte );
+	printf( "VarUI1FromR8: 0.49, %X, %X\n", *pByte, (unsigned int) res );
+
+	res = VarUI1FromDate( 0.0, pByte );
+	printf( "VarUI1FromDate: 0.0, %X, %X\n", *pByte, (unsigned int) res );
+	res = VarUI1FromDate( 69.33, pByte );
+	printf( "VarUI1FromDate: 69.33, %X, %X\n", *pByte, (unsigned int) res );
+	res = VarUI1FromDate( 69.66, pByte );
+	printf( "VarUI1FromDate: 69.66, %X, %X\n", *pByte, (unsigned int) res );
+	res = VarUI1FromDate( -69.33, pByte );
+	printf( "VarUI1FromDate: -69.33, %X, %X\n", *pByte, (unsigned int) res );
+	res = VarUI1FromDate( -69.66, pByte );
+	printf( "VarUI1FromDate: -69.66, %X, %X\n", *pByte, (unsigned int) res );
+
+	res = VarUI1FromBool( VARIANT_TRUE, pByte );
+	printf( "VarUI1FromBool: VARIANT_TRUE, %X, %X\n", *pByte, (unsigned int) res );
+	res = VarUI1FromBool( VARIANT_FALSE, pByte );
+	printf( "VarUI1FromBool: VARIANT_FALSE, %X, %X\n", *pByte, (unsigned int) res );
+
+	for( olePtrIndex = 0; olePtrIndex < nOlePtrs; olePtrIndex ++ )
+	{
+		res = VarUI1FromStr( pOleChar[olePtrIndex], 0, 0, pByte );
+		printf( "VarUI1FromStr: %s, %X, %X\n", WtoA(pOleChar[olePtrIndex]), *pByte, (unsigned int) res );
+	}
+
+
+	/* unsigned short from ...
+	 */
+	printf( "\n\n======== Testing VarUI2FromXXX ========\n");
+	
+	res = VarUI2FromI2( -1, &i );
+	printf( "VarUI2FromI2: -1, %d, %X\n", i, (unsigned int) res );
+
+	/* res = VarUI2FromI2( 0, NULL );
+	 */
+	printf( "VarUI2FromI2: passing in NULL as return val makes it crash, %X\n", (unsigned int) res );
+
+	res = VarUI2FromStr( NULL, 0, 0, pUShort );
+	printf( "VarUI2FromStr: passing in NULL as param: %X\n", (unsigned int) res );
+
+	res = VarUI2FromI2( 0, pUShort );
+	printf( "VarUI2FromI2: 0, %u, %X\n", *pUShort, (unsigned int) res );
+	res = VarUI2FromI2( 69, pUShort );
+	printf( "VarUI2FromI2: 69, %u, %X\n", *pUShort, (unsigned int) res );
+	res = VarUI2FromI2( 70, pUShort );
+	printf( "VarUI2FromI2: 70, %u, %X\n", *pUShort, (unsigned int) res );
+	res = VarUI2FromI2( 128, pUShort );
+	printf( "VarUI2FromI2: 128, %u, %X\n", *pUShort, (unsigned int) res );
+	res = VarUI2FromI4( 65535, pUShort );
+	printf( "VarUI2FromI4: 65535, %u, %X\n", *pUShort, (unsigned int) res );
+	res = VarUI2FromI4( 65536, pUShort );
+	printf( "VarUI2FromI4: 65536, %u, %X\n", *pUShort, (unsigned int) res );
+	res = VarUI2FromI4( 65537, pUShort );
+	printf( "VarUI2FromI4: 65537, %u, %X\n", *pUShort, (unsigned int) res );
+
+	res = VarUI2FromR8( 0.0, pUShort );
+	printf( "VarUI2FromR8: 0.0, %u, %X\n", *pUShort, (unsigned int) res );
+	res = VarUI2FromR8( 69.33, pUShort );
+	printf( "VarUI2FromR8: 69.33, %u, %X\n", *pUShort, (unsigned int) res );
+	res = VarUI2FromR8( 69.66, pUShort );
+	printf( "VarUI2FromR8: 69.66, %u, %X\n", *pUShort, (unsigned int) res );
+	res = VarUI2FromR8( -69.33, pUShort );
+	printf( "VarUI2FromR8: -69.33, %u, %X\n", *pUShort, (unsigned int) res );
+	res = VarUI2FromR8( -69.66, pUShort );
+	printf( "VarUI2FromR8: -69.66, %u, %X\n", *pUShort, (unsigned int) res );
+
+	res = VarUI2FromR8( -0.5, pUShort );
+	printf( "VarUI2FromR8: -0.5, %u, %X\n", *pUShort, (unsigned int) res );
+	res = VarUI2FromR8( -0.51, pUShort );
+	printf( "VarUI2FromR8: -0.51, %u, %X\n", *pUShort, (unsigned int) res );
+	res = VarUI2FromR8( -0.49, pUShort );
+	printf( "VarUI2FromR8: -0.49, %u, %X\n", *pUShort, (unsigned int) res );
+
+	res = VarUI2FromR8( 0.5, pUShort );
+	printf( "VarUI2FromR8: 0.5, %u, %X\n", *pUShort, (unsigned int) res );
+	res = VarUI2FromR8( 0.51, pUShort );
+	printf( "VarUI2FromR8: 0.51, %u, %X\n", *pUShort, (unsigned int) res );
+	res = VarUI2FromR8( 0.49, pUShort );
+	printf( "VarUI2FromR8: 0.49, %u, %X\n", *pUShort, (unsigned int) res );
+
+	res = VarUI2FromDate( 0.0, pUShort );
+	printf( "VarUI2FromDate: 0.0, %u, %X\n", *pUShort, (unsigned int) res );
+	res = VarUI2FromDate( 69.33, pUShort );
+	printf( "VarUI2FromDate: 69.33, %u, %X\n", *pUShort, (unsigned int) res );
+	res = VarUI2FromDate( 69.66, pUShort );
+	printf( "VarUI2FromDate: 69.66, %u, %X\n", *pUShort, (unsigned int) res );
+	res = VarUI2FromDate( -69.33, pUShort );
+	printf( "VarUI2FromDate: -69.33, %u, %X\n", *pUShort, (unsigned int) res );
+	res = VarUI2FromDate( -69.66, pUShort );
+	printf( "VarUI2FromDate: -69.66, %u, %X\n", *pUShort, (unsigned int) res );
+
+	res = VarUI2FromBool( VARIANT_TRUE, pUShort );
+	printf( "VarUI2FromBool: VARIANT_TRUE, %u, %X\n", *pUShort, (unsigned int) res );
+	res = VarUI2FromBool( VARIANT_FALSE, pUShort );
+	printf( "VarUI2FromBool: VARIANT_FALSE, %u, %X\n", *pUShort, (unsigned int) res );
+
+	for( olePtrIndex = 0; olePtrIndex < nOlePtrs; olePtrIndex ++ )
+	{
+		res = VarUI2FromStr( pOleChar[olePtrIndex], 0, 0, pUShort );
+		printf( "VarUI2FromStr: %s, %u, %X\n", WtoA(pOleChar[olePtrIndex]), (int)*pUShort, (unsigned int) res );
+	}
+
+	/* unsigned long from ...
+	 */
+	printf( "\n\n======== Testing VarUI4FromXXX ========\n");
+	
+	/*res = VarUI4FromI2( 0, NULL );
+	 */
+	printf( "VarUI4FromI2: passing in NULL as return val makes it crash, %X\n", (unsigned int) res );
+
+	res = VarUI4FromStr( NULL, 0, 0, pULong );
+	printf( "VarUI4FromStr: passing in NULL as param: %X\n", (unsigned int) res );
+
+	res = VarUI4FromI2( 0, pULong );
+	printf( "VarUI4FromI2: 0, %lu, %X\n", *pULong, (unsigned int) res );
+	res = VarUI4FromI2( 69, pULong );
+	printf( "VarUI4FromI2: 69, %lu, %X\n", *pULong, (unsigned int) res );
+	res = VarUI4FromI2( 70, pULong );
+	printf( "VarUI4FromI2: 70, %lu, %X\n", *pULong, (unsigned int) res );
+	res = VarUI4FromI2( 128, pULong );
+	printf( "VarUI4FromI2: 128, %lu, %X\n", *pULong, (unsigned int) res );
+	res = VarUI4FromI2( 255, pULong );
+	printf( "VarUI4FromI2: 255, %lu, %X\n", *pULong, (unsigned int) res );
+	res = VarUI4FromR8( 4294967295.0, pULong );
+	printf( "VarUI4FromR8: 4294967295, %lu, %X\n", *pULong, (unsigned int) res );
+	res = VarUI4FromR8( 4294967296.0, pULong );
+	printf( "VarUI4FromR8: 4294967296, %lu, %X\n", *pULong, (unsigned int) res );
+
+	res = VarUI4FromR8( 0.0, pULong );
+	printf( "VarUI4FromR8: 0.0, %lu, %X\n", *pULong, (unsigned int) res );
+	res = VarUI4FromR8( 69.33, pULong );
+	printf( "VarUI4FromR8: 69.33, %lu, %X\n", *pULong, (unsigned int) res );
+	res = VarUI4FromR8( 69.66, pULong );
+	printf( "VarUI4FromR8: 69.66, %lu, %X\n", *pULong, (unsigned int) res );
+	res = VarUI4FromR8( -69.33, pULong );
+	printf( "VarUI4FromR8: -69.33, %lu, %X\n", *pULong, (unsigned int) res );
+	res = VarUI4FromR8( -69.66, pULong );
+	printf( "VarUI4FromR8: -69.66, %lu, %X\n", *pULong, (unsigned int) res );
+
+	res = VarUI4FromR8( -0.5, pULong );
+	printf( "VarUI4FromR8: -0.5, %lu, %X\n", *pULong, (unsigned int) res );
+	res = VarUI4FromR8( -0.51, pULong );
+	printf( "VarUI4FromR8: -0.51, %lu, %X\n", *pULong, (unsigned int) res );
+	res = VarUI4FromR8( -0.49, pULong );
+	printf( "VarUI4FromR8: -0.49, %lu, %X\n", *pULong, (unsigned int) res );
+
+	res = VarUI4FromR8( 0.5, pULong );
+	printf( "VarUI4FromR8: 0.5, %lu, %X\n", *pULong, (unsigned int) res );
+	res = VarUI4FromR8( 0.51, pULong );
+	printf( "VarUI4FromR8: 0.51, %lu, %X\n", *pULong, (unsigned int) res );
+	res = VarUI4FromR8( 0.49, pULong );
+	printf( "VarUI4FromR8: 0.49, %lu, %X\n", *pULong, (unsigned int) res );
+
+	res = VarUI4FromDate( 0.0, pULong );
+	printf( "VarUI4FromDate: 0.0, %lu, %X\n", *pULong, (unsigned int) res );
+	res = VarUI4FromDate( 69.33, pULong );
+	printf( "VarUI4FromDate: 69.33, %lu, %X\n", *pULong, (unsigned int) res );
+	res = VarUI4FromDate( 69.66, pULong );
+	printf( "VarUI4FromDate: 69.66, %lu, %X\n", *pULong, (unsigned int) res );
+	res = VarUI4FromDate( -69.33, pULong );
+	printf( "VarUI4FromDate: -69.33, %lu, %X\n", *pULong, (unsigned int) res );
+	res = VarUI4FromDate( -69.66, pULong );
+	printf( "VarUI4FromDate: -69.66, %lu, %X\n", *pULong, (unsigned int) res );
+
+	res = VarUI4FromBool( VARIANT_TRUE, pULong );
+	printf( "VarUI4FromBool: VARIANT_TRUE, %lu, %X\n", *pULong, (unsigned int) res );
+	res = VarUI4FromBool( VARIANT_FALSE, pULong );
+	printf( "VarUI4FromBool: VARIANT_FALSE, %lu, %X\n", *pULong, (unsigned int) res );
+
+	for( olePtrIndex = 0; olePtrIndex < nOlePtrs; olePtrIndex ++ )
+	{
+		res = VarUI4FromStr( pOleChar[olePtrIndex], 0, 0, pULong );
+		printf( "VarUI4FromStr: %s, %lu, %X\n", WtoA(pOleChar[olePtrIndex]), *pULong, (unsigned int) res );
+	}
+
+	/* CHAR from ...
+	 */
+	printf( "\n\n======== Testing VarI1FromXXX ========\n");
+
+	res = VarI1FromBool( VARIANT_TRUE, pByte );
+	printf( "VarI1FromBool: VARIANT_TRUE, %d, %X\n", *pByte, (unsigned int) res );
+
+	res = VarI1FromBool( VARIANT_TRUE, pChar );
+	printf( "VarI1FromBool: VARIANT_TRUE, %d, %X\n", *pChar, (unsigned int) res );
+
+	res = VarI1FromBool( VARIANT_FALSE, pChar );
+	printf( "VarI1FromBool: VARIANT_FALSE, %d, %X\n", *pChar, (unsigned int) res );
+
+	res = VarI1FromUI1( (unsigned char)32767, pChar );
+	printf( "VarI1FromUI1: 32767, %d, %X\n", *pChar, (unsigned int) res );
+	res = VarI1FromUI1( (unsigned char)65535, pChar );
+	printf( "VarI1FromUI1: 65535, %d, %X\n", *pChar, (unsigned int) res );
+
+	res = VarI1FromI4( 32767, pChar );
+	printf( "VarI1FromI4: 32767, %d, %X\n", *pChar, (unsigned int) res );
+	res = VarI1FromI4( 32768, pChar );
+	printf( "VarI1FromI4: 32768, %d, %X\n", *pChar, (unsigned int) res );
+	res = VarI1FromI4( -32768, pChar );
+	printf( "VarI1FromI4: -32768, %d, %X\n", *pChar, (unsigned int) res );
+	res = VarI1FromI4( -32769, pChar );
+	printf( "VarI1FromI4: -32769, %d, %X\n", *pChar, (unsigned int) res );
+
+	res = VarI1FromR8( 69.33, pChar );
+	printf( "VarI1FromR8: 69.33, %d, %X\n", *pChar, (unsigned int) res );
+	res = VarI1FromR8( 69.66, pChar );
+	printf( "VarI1FromR8: 69.66, %d, %X\n", *pChar, (unsigned int) res );
+	res = VarI1FromR8( -69.33, pChar );
+	printf( "VarI1FromR8: -69.33, %d, %X\n", *pChar, (unsigned int) res );
+	res = VarI1FromR8( -69.66, pChar );
+	printf( "VarI1FromR8: -69.66, %d, %X\n", *pChar, (unsigned int) res );
+
+	res = VarI1FromDate( -69.66, pChar );
+	printf( "VarI1FromDate: -69.66, %d, %X\n", *pChar, (unsigned int) res );
+
+	for( olePtrIndex = 0; olePtrIndex < nOlePtrs; olePtrIndex ++ )
+	{
+		res = VarI1FromStr( pOleChar[olePtrIndex], 0, 0, pChar );
+		printf( "VarI1FromStr: %s, %d, %X\n", WtoA(pOleChar[olePtrIndex]), *pChar, (unsigned int) res );
+	}
+
+	/* short from ...
+	 */
+	printf( "\n\n======== Testing VarI2FromXXX ========\n");
+
+	res = VarI2FromUI2( 32767, pShort );
+	printf( "VarI2FromUI2: 32767, %d, %X\n", *pShort, (unsigned int) res );
+	res = VarI2FromUI2( 65535, pShort );
+	printf( "VarI2FromUI2: 65535, %d, %X\n", *pShort, (unsigned int) res );
+
+	res = VarI2FromI4( 32767, pShort );
+	printf( "VarI2FromI4: 32767, %d, %X\n", *pShort, (unsigned int) res );
+	res = VarI2FromI4( 32768, pShort );
+	printf( "VarI2FromI4: 32768, %d, %X\n", *pShort, (unsigned int) res );
+	res = VarI2FromI4( -32768, pShort );
+	printf( "VarI2FromI4: -32768, %d, %X\n", *pShort, (unsigned int) res );
+	res = VarI2FromI4( -32769, pShort );
+	printf( "VarI2FromI4: -32769, %d, %X\n", *pShort, (unsigned int) res );
+
+	res = VarI2FromR8( 69.33, pShort );
+	printf( "VarI2FromR8: 69.33, %d, %X\n", *pShort, (unsigned int) res );
+	res = VarI2FromR8( 69.66, pShort );
+	printf( "VarI2FromR8: 69.66, %d, %X\n", *pShort, (unsigned int) res );
+	res = VarI2FromR8( -69.33, pShort );
+	printf( "VarI2FromR8: -69.33, %d, %X\n", *pShort, (unsigned int) res );
+	res = VarI2FromR8( -69.66, pShort );
+	printf( "VarI2FromR8: -69.66, %d, %X\n", *pShort, (unsigned int) res );
+
+	res = VarI2FromDate( -69.66, pShort );
+	printf( "VarI2FromDate: -69.66, %d, %X\n", *pShort, (unsigned int) res );
+
+	for( olePtrIndex = 0; olePtrIndex < nOlePtrs; olePtrIndex ++ )
+	{
+		res = VarI2FromStr( pOleChar[olePtrIndex], 0, 0, pShort );
+		printf( "VarI2FromStr: %s, %d, %X\n", WtoA(pOleChar[olePtrIndex]), *pShort, (unsigned int) res );
+	}
+	
+	/* long from ...
+	 */
+	printf( "\n\n======== Testing VarI4FromXXX ========\n");
+
+	res = VarI4FromI2( 3, (long*)pInt );
+	printf( "VarIntFromI2: 3, %d, %X\n", *pInt, (unsigned int) res );
+
+	res = VarI4FromR8( 69.33, pLong );
+	printf( "VarI4FromR8: 69.33, %ld, %X\n", *pLong, (unsigned int) res );
+	res = VarI4FromR8( 69.66, pLong );
+	printf( "VarI4FromR8: 69.66, %ld, %X\n", *pLong, (unsigned int) res );
+	res = VarI4FromR8( -69.33, pLong );
+	printf( "VarI4FromR8: -69.33, %ld, %X\n", *pLong, (unsigned int) res );
+	res = VarI4FromR8( -69.66, pLong );
+	printf( "VarI4FromR8: -69.66, %ld, %X\n", *pLong, (unsigned int) res );
+
+	res = VarI4FromR8( 2147483647.0, pLong );
+	printf( "VarI4FromR8: 2147483647.0, %ld, %X\n", *pLong, (unsigned int) res );
+	res = VarI4FromR8( 2147483648.0, pLong );
+	printf( "VarI4FromR8: 2147483648.0, %ld, %X\n", *pLong, (unsigned int) res );
+	res = VarI4FromR8( -2147483647.0, pLong );
+	printf( "VarI4FromR8: -2147483647.0, %ld, %X\n", *pLong, (unsigned int) res );
+	res = VarI4FromR8( -2147483648.0, pLong );
+	printf( "VarI4FromR8: -2147483648.0, %ld, %X\n", *pLong, (unsigned int) res );
+	res = VarI4FromR8( -2147483649.0, pLong );
+	printf( "VarI4FromR8: -2147483649.0, %ld, %X\n", *pLong, (unsigned int) res );
+
+	res = VarI4FromDate( -2147483649.0, pLong );
+	printf( "VarI4FromDate: -2147483649.0, %ld, %X\n", *pLong, (unsigned int) res );
+
+	for( olePtrIndex = 0; olePtrIndex < nOlePtrs; olePtrIndex ++ )
+	{
+		res = VarI4FromStr( pOleChar[olePtrIndex], 0, 0, pLong );
+		printf( "VarI4FromStr: %s, %ld, %X\n", WtoA(pOleChar[olePtrIndex]), *pLong, (unsigned int) res );
+	}
+
+	/* float from ...
+	 */
+	printf( "\n\n======== Testing VarR4FromXXX ========\n");
+
+	res = VarR4FromI4( 16777216, pFloat );
+	printf( "VarR4FromI4: 16777216, %f, %X\n", *pFloat, (unsigned int) res );
+	res = VarR4FromI4( 16777217, pFloat );
+	printf( "VarR4FromI4: 16777217, %f, %X\n", *pFloat, (unsigned int) res );
+	res = VarR4FromI4( -16777216, pFloat );
+	printf( "VarR4FromI4: -16777216, %f, %X\n", *pFloat, (unsigned int) res );
+	res = VarR4FromI4( -16777217, pFloat );
+	printf( "VarR4FromI4: -16777217, %f, %X\n", *pFloat, (unsigned int) res );
+
+	res = VarR4FromR8( 16777216.0, pFloat );
+	printf( "VarR4FromR8: 16777216.0, %f, %X\n", *pFloat, (unsigned int) res );
+	res = VarR4FromR8( 16777217.0, pFloat );
+	printf( "VarR4FromR8: 16777217.0, %f, %X\n", *pFloat, (unsigned int) res );
+	res = VarR4FromR8( -16777216.0, pFloat );
+	printf( "VarR4FromR8: -16777216.0, %f, %X\n", *pFloat, (unsigned int) res );
+	res = VarR4FromR8( -16777217.0, pFloat );
+	printf( "VarR4FromR8: -16777217.0, %f, %X\n", *pFloat, (unsigned int) res );
+	
+	res = VarR4FromR8( 16777218e31, pFloat );
+	printf( "VarR4FromR8: 16777218e31, %f, %X\n", *pFloat, (unsigned int) res );
+	res = VarR4FromR8( 16777218e32, pFloat );
+	printf( "VarR4FromR8: 16777218e32, %f, %X\n", *pFloat, (unsigned int) res );
+	
+	res = VarR4FromDate( 16777218e31, pFloat );
+	printf( "VarR4FromDate: 16777218e31, %f, %X\n", *pFloat, (unsigned int) res );
+
+	for( olePtrIndex = 0; olePtrIndex < nOlePtrs; olePtrIndex ++ )
+	{
+		res = VarR4FromStr( pOleChar[olePtrIndex], 0, 0, pFloat );
+		printf( "VarR4FromStr: %s, %f, %X\n", WtoA(pOleChar[olePtrIndex]), *pFloat, (unsigned int) res );
+	}
+
+	/* double from ...
+	 */
+	printf( "\n\n======== Testing VarR8FromXXX ========\n");
+
+	res = VarR8FromDate( 900719925474099.0, pDouble );
+	printf( "VarR8FromDate: 900719925474099.0, %f, %X\n", *pDouble, (unsigned int) res );
+
+	for( olePtrIndex = 0; olePtrIndex < nOlePtrs; olePtrIndex ++ )
+	{
+		res = VarR8FromStr( pOleChar[olePtrIndex], 0, 0, pDouble );
+		printf( "VarR8FromStr: %s, %f, %X\n", WtoA(pOleChar[olePtrIndex]), *pDouble, (unsigned int) res );
+	}
+
+	/* date from ...
+	 */
+	printf( "\n\n======== Testing VarDateFromXXX ========\n");
+
+	res = VarDateFromI4( 2958465, pDouble );
+	printf( "VarDateFromI4: 2958465, %f, %X\n", *pDouble, (unsigned int) res );
+	res = VarDateFromI4( 2958466, pDouble );
+	printf( "VarDateFromI4: 2958466, %f, %X\n", *pDouble, (unsigned int) res );
+	res = VarDateFromI4( -657434, pDouble );
+	printf( "VarDateFromI4: -657434, %f, %X\n", *pDouble, (unsigned int) res );
+	res = VarDateFromI4( -657435, pDouble );
+	printf( "VarDateFromI4: -657435, %f, %X\n", *pDouble, (unsigned int) res );
+
+	res = VarDateFromR8( 2958465.9999, pDouble );
+	printf( "VarDateFromR8: 2958465.9999, %f, %X\n", *pDouble, (unsigned int) res );
+	res = VarDateFromR8( 2958466, pDouble );
+	printf( "VarDateFromR8: 2958466, %f, %X\n", *pDouble, (unsigned int) res );
+	res = VarDateFromR8( -657434.9999, pDouble );
+	printf( "VarDateFromR8: -657434.9999, %f, %X\n", *pDouble, (unsigned int) res );
+	res = VarDateFromR8( -657435, pDouble );
+	printf( "VarDateFromR8: -657435, %f, %X\n", *pDouble, (unsigned int) res );
+
+
+	res = VarDateFromR8( 0.0, pDouble );
+	printf( "VarDateFromR8: 0.0, %f, %X\n", *pDouble, (unsigned int) res );
+	res = VarDateFromR8( 1.0, pDouble );
+	printf( "VarDateFromR8: 1.0, %f, %X\n", *pDouble, (unsigned int) res );
+	res = VarDateFromR8( 2.25, pDouble );
+	printf( "VarDateFromR8: 2.25, %f, %X\n", *pDouble, (unsigned int) res );
+	res = VarDateFromR8( -2.0, pDouble );
+	printf( "VarDateFromR8: -2.0, %f, %X\n", *pDouble, (unsigned int) res );
+
+	/* Need some parsing function in Linux to emulate this...
+	 * Still in progess.
+	 */
+	for( olePtrIndex = 0; olePtrIndex < nOlePtrs; olePtrIndex ++ )
+	{
+		res = VarDateFromStr( pOleChar[olePtrIndex], 0, 0, pDouble );
+		printf( "VarDateFromStr: %s, %f, %X\n", WtoA(pOleChar[olePtrIndex]), *pDouble, (unsigned int) res );
+	}
+	
+	/* bool from ...
+	 */
+	printf( "\n\n======== Testing VarBoolFromXXX ========\n");
+
+	res = VarBoolFromI4( 0, pBool );
+	printf( "VarBoolFromI4: 0, %d, %X\n", *pBool, (unsigned int) res );
+	res = VarBoolFromI4( 1, pBool );
+	printf( "VarBoolFromI4: 1, %d, %X\n", *pBool, (unsigned int) res );
+	res = VarBoolFromI4( -1, pBool );
+	printf( "VarBoolFromI4: -1, %d, %X\n", *pBool, (unsigned int) res );
+	res = VarBoolFromI4( 2, pBool );
+	printf( "VarBoolFromI4: 2, %d, %X\n", *pBool, (unsigned int) res );
+
+	res = VarBoolFromUI1( ' ', pBool );
+	printf( "VarBoolFromUI1: ' ', %d, %X\n", *pBool, (unsigned int) res );
+	res = VarBoolFromUI1( '\0', pBool );
+	printf( "VarBoolFromUI1: '\\0', %d, %X\n", *pBool, (unsigned int) res );
+	res = VarBoolFromUI1( 0x0000, pBool );
+	printf( "VarBoolFromUI1: 0x0000, %d, %X\n", *pBool, (unsigned int) res );
+	res = VarBoolFromUI1( (unsigned char)0xFFF, pBool );
+	printf( "VarBoolFromUI1: 0xFFF, %d, %X\n", *pBool, (unsigned int) res );
+	res = VarBoolFromUI1( (unsigned char)0xFFFF, pBool );
+	printf( "VarBoolFromUI1: 0xFFFF, %d, %X\n", *pBool, (unsigned int) res );
+	
+	res = VarBoolFromR8( 0.0, pBool );
+	printf( "VarBoolFromR8: 0.0, %d, %X\n", *pBool, (unsigned int) res );
+	res = VarBoolFromR8( 1.1, pBool );
+	printf( "VarBoolFromR8: 1.1, %d, %X\n", *pBool, (unsigned int) res );
+	res = VarBoolFromR8( 0.5, pBool );
+	printf( "VarBoolFromR8: 0.5, %d, %X\n", *pBool, (unsigned int) res );
+	res = VarBoolFromR8( 0.49, pBool );
+	printf( "VarBoolFromR8: 0.49, %d, %X\n", *pBool, (unsigned int) res );
+	res = VarBoolFromR8( 0.51, pBool );
+	printf( "VarBoolFromR8: 0.51, %d, %X\n", *pBool, (unsigned int) res );
+	res = VarBoolFromR8( -0.5, pBool );
+	printf( "VarBoolFromR8: -0.5, %d, %X\n", *pBool, (unsigned int) res );
+	res = VarBoolFromR8( -0.49, pBool );
+	printf( "VarBoolFromR8: -0.49, %d, %X\n", *pBool, (unsigned int) res );
+	res = VarBoolFromR8( -0.51, pBool );
+	printf( "VarBoolFromR8: -0.51, %d, %X\n", *pBool, (unsigned int) res );
+
+	
+	for( olePtrIndex = 0; olePtrIndex < nOlePtrs; olePtrIndex ++ )
+	{
+		res = VarBoolFromStr( pOleChar[olePtrIndex], 0, 0, pBool );
+		printf( "VarBoolFromStr: %s, %d, %X\n", WtoA(pOleChar[olePtrIndex]), *pBool, (unsigned int) res );
+	}
+
+	res = VarI1FromBool( VARIANT_TRUE, pByte );
+	printf( "VarI1FromBool: VARIANT_TRUE, %d, %X\n", *pByte, (unsigned int) res );
+
+	res = VarUI2FromI2( -1, &i );
+	printf( "VarUI2FromI2: -1, %d, %X\n", i, (unsigned int) res );
+
+
+	/* BSTR from ...
+	 */
+	printf( "\n\n======== Testing VarBSTRFromXXX ========\n");
+
+	/* integers...
+	 */
+	res = VarBstrFromI1( -100, 0, 0, &bstr );
+	printf( "VarBstrFromI1: -100, %s, %X\n", WtoA( bstr ), (unsigned int) res );
+
+	res = VarBstrFromUI1( 0x5A, 0, 0, &bstr );
+	printf( "VarBstrFromUI1: 0x5A, %s, %X\n", WtoA( bstr ), (unsigned int) res );
+
+	res = VarBstrFromI4( 2958465, 0, 0, &bstr );
+	printf( "VarBstrFromI4: 2958465, %s, %X\n", WtoA( bstr ), (unsigned int) res );
+
+	/* reals...
+	 */
+	d=0;
+	for( i=0; i<20; i++ )
+	{
+		/* add an integer to the real number
+		 */
+		d += ((i%9)+1) * pow( 10, i );
+		res = VarBstrFromR8( d, 0, 0, &bstr );
+		printf( "VarBstrFromR8: %f, %s, %X\n", d, WtoA( bstr ), (unsigned int) res );
+		res = VarBstrFromR8( -d, 0, 0, &bstr );
+		printf( "VarBstrFromR8: %f, %s, %X\n", -d, WtoA( bstr ), (unsigned int) res );
+	}
+	d=0;
+	for( i=0; i<20; i++ )
+	{
+		/* add a decimal to the real number
+		 */
+		d += ((i%9)+1) * pow( 10, (i*-1) );
+		res = VarBstrFromR8( d, 0, 0, &bstr );
+		printf( "VarBstrFromR8: %f, %s, %X\n", d, WtoA( bstr ), (unsigned int) res );
+		res = VarBstrFromR8( d-1, 0, 0, &bstr );
+		printf( "VarBstrFromR8: %f, %s, %X\n", d-1, WtoA( bstr ), (unsigned int) res );
+		res = VarBstrFromR8( -d, 0, 0, &bstr );
+		printf( "VarBstrFromR8: %f, %s, %X\n", -d, WtoA( bstr ), (unsigned int) res );
+	}
+
+	d=0;
+	for( i=0; i<20; i++ )
+	{
+		/* add an integer to the real number
+		 */
+		d += ((i%9)+1) * pow( 10, i );
+		/* add a decimal to the real number
+		 */
+		d += ((i%9)+1) * pow( 10, (i*-1) );
+		res = VarBstrFromR8( d, 0, 0, &bstr );
+		printf( "VarBstrFromR8: %f, %s, %X\n", d, WtoA( bstr ), (unsigned int)res );
+		res = VarBstrFromR8( -d, 0, 0, &bstr );
+		printf( "VarBstrFromR8: %f, %s, %X\n", -d, WtoA( bstr ), (unsigned int) res );
+	}
+
+
+
+	d=0;
+	for( i=0; i<10; i++ )
+	{
+		/* add an integer to the real number
+		 */
+		d += ((i%9)+1) * pow( 10, i );
+		res = VarBstrFromR4( (float)d, 0, 0, &bstr );
+		printf( "VarBstrFromR4: %f, %s, %X\n", d, WtoA( bstr ), (unsigned int) res );
+		res = VarBstrFromR4( (float)-d, 0, 0, &bstr );
+		printf( "VarBstrFromR4: %f, %s, %X\n", -d, WtoA( bstr ), (unsigned int) res );
+	}
+	d=0;
+	for( i=0; i<10; i++ )
+	{
+		/* add a decimal to the real number
+		 */
+		d += ((i%9)+1) * pow( 10, (i*-1) );
+		res = VarBstrFromR4( (float)d, 0, 0, &bstr );
+		printf( "VarBstrFromR4: %f, %s, %X\n", d, WtoA( bstr ), (unsigned int) res );
+		res = VarBstrFromR4( (float)d-1, 0, 0, &bstr );
+		printf( "VarBstrFromR4: %f, %s, %X\n", d-1, WtoA( bstr ), (unsigned int) res );
+		res = VarBstrFromR4( (float)-d, 0, 0, &bstr );
+		printf( "VarBstrFromR4: %f, %s, %X\n", -d, WtoA( bstr ), (unsigned int) res );
+	}
+
+	d=0;
+	for( i=0; i<10; i++ )
+	{
+		/* add an integer to the real number
+		 */
+		d += ((i%9)+1) * pow( 10, i );
+		/* add a decimal to the real number
+		 */
+		d += ((i%9)+1) * pow( 10, (i*-1) );
+		res = VarBstrFromR4( (float)d, 0, 0, &bstr );
+		printf( "VarBstrFromR4: %f, %s, %X\n", d, WtoA( bstr ), (unsigned int) res );
+		res = VarBstrFromR4( (float)-d, 0, 0, &bstr );
+		printf( "VarBstrFromR4: %f, %s, %X\n", -d, WtoA( bstr ), (unsigned int) res );
+	}
+
+	res = VarBstrFromBool( 0x00, 0, 0, &bstr );
+	printf( "VarBstrFromBool: 0x00, %s, %X\n", WtoA( bstr ), (unsigned int) res );
+	res = VarBstrFromBool( 0xFF, 0, 0, &bstr );
+	printf( "VarBstrFromBool: 0xFF, %s, %X\n", WtoA( bstr ), (unsigned int) res );
+
+	res = VarBstrFromDate( 0.0, 0, 0, &bstr );
+	printf( "VarBstrFromDate: 0.0, %s, %X\n", WtoA( bstr ), (unsigned int) res );
+	res = VarBstrFromDate( 3.34, 0, 0, &bstr );
+	printf( "VarBstrFromDate: 3.34, %s, %X\n", WtoA( bstr ), (unsigned int) res );
+	res = VarBstrFromDate( 3339.34, 0, 0, &bstr );
+	printf( "VarBstrFromDate: 3339.34, %s, %X\n", WtoA( bstr ), (unsigned int) res );
+	res = VarBstrFromDate( 365.00, 0, 0, &bstr );
+	printf( "VarBstrFromDate: 365.00, %s, %X\n", WtoA( bstr ), (unsigned int) res );
+	res = VarBstrFromDate( 365.25, 0, 0, &bstr );
+	printf( "VarBstrFromDate: 365.25, %s, %X\n", WtoA( bstr ), (unsigned int) res );
+	res = VarBstrFromDate( 1461.0, 0, 0, &bstr );
+	printf( "VarBstrFromDate: 1461.00, %s, %X\n", WtoA( bstr ), (unsigned int) res );
+	res = VarBstrFromDate( 1461.5, 0, 0, &bstr );
+	printf( "VarBstrFromDate: 1461.5, %s, %X\n", WtoA( bstr ), (unsigned int) res );
+	
+
+	res = VarBstrFromBool( 0x00, 0, 0, &bstr );
+	printf( "VarBstrFromBool: 0x00, %s, %X\n", WtoA(bstr), (unsigned int) res );
+	res = VarBstrFromBool( 0xFF, 0, 0, &bstr );
+	printf( "VarBstrFromBool: 0xFF, %s, %X\n", WtoA(bstr), (unsigned int) res );
+
+	res = VarBstrFromDate( 0.0, 0, 0, &bstr );
+	printf( "VarBstrFromDate: 0.0, %s, %X\n", WtoA(bstr), (unsigned int) res );
+	res = VarBstrFromDate( 3.34, 0, 0, &bstr );
+	printf( "VarBstrFromDate: 3.34, %s, %X\n", WtoA(bstr), (unsigned int) res );
+
+	/* Test variant API...
+	 */
+	printf( "\n\n======== Testing Hi-Level Variant API ========\n");
+
+	bstr = SysAllocString( pOleChar[4] );
+
+	res = VariantClear( &va );
+	printf( "Result is: %x\n", (unsigned int)res );
+
+	VariantInit( &va );
+	VariantInit( &vb );
+	VariantInit( &vc );
+	VariantInit( &vd );
+	VariantInit( &ve );
+
+	va.vt = VT_BSTR;
+	va.u.bstrVal = bstr;
+	res = VariantClear( &va );
+	printf( "VariantClear: %x\n", (unsigned int)res );
+	printf( "VariantClear: %x\n", (unsigned int)res );
+	SysFreeString( bstr );
+	SysFreeString( bstr );
+
+	res = VariantCopy( &vb, &va );
+	printf( "VariantCopy: %x\n", (unsigned int)res );
+	res = VariantClear( &vb );
+	printf( "VariantClear: %x\n", (unsigned int)res );
+	res = VariantClear( &va );
+	printf( "VariantClear: %x\n", (unsigned int)res );
+
+
+	va.vt = VT_R8;
+	d = 4.123;
+	va.u.dblVal = d;
+	res = VariantCopy( &va, &va );
+	printf( "VariantCopy %f -> %f: %x\n", V_R8(&va), V_R8(&va), (unsigned int)res );
+
+	va.vt = VT_R8 | VT_BYREF;
+	d = 31.123;
+	va.u.pdblVal = &d;
+	res = VariantCopyInd( &va, &va );
+	printf( "VariantCopyInd %f: %x\n", V_R8(&va), (unsigned int)res );
+
+	va.vt = VT_R8;
+	d = 1.123;
+	va.u.dblVal = d;
+	res = VariantCopy( &vb, &va );
+	printf( "VariantCopy %f -> %f: %x\n", V_R8(&va), V_R8(&vb), (unsigned int)res );
+
+	va.vt = VT_R8 | VT_BYREF;
+	d = 123.123;
+	va.u.pdblVal = &d;
+	res = VariantCopy( &vb, &va );
+	printf( "VariantCopy %f -> %f: %x\n", *(V_R8REF(&va)), *(V_R8REF(&vb)), (unsigned int)res );
+
+	va.vt = VT_R8 | VT_BYREF;
+	d = 111.2;
+	va.u.pdblVal = &d;
+	res = VariantCopyInd( &vb, &va );
+	printf( "VariantCopyInd %f -> %f: %x\n", *(V_R8REF(&va)), V_R8(&vb), (unsigned int)res );
+
+	va.vt = VT_R8 | VT_BYREF;
+	d = 1211.123453;
+	va.u.pdblVal = &d;
+	res = VariantChangeTypeEx( &va, &va, 0, 0, VT_I2 );
+	printf( "VariantChangeTypeEx %d: %x\n", V_I2(&va), (unsigned int) res );
+
+	va.vt = VT_INT;
+	va.u.intVal = 4;
+	res = VariantChangeTypeEx(&vb, &va, 0, 0, VT_BSTR );
+	printf( "VariantChangeTypeEx %d -> %s: %x\n", V_INT(&va), WtoA(V_BSTR(&vb)), (unsigned int)res );
+
+	va.vt = VT_DATE;
+	va.u.date = 34465.332431;
+	res = VariantChangeTypeEx(&vb, &va, 0, 0, VT_BSTR );
+	printf( "VariantChangeTypeEx %f -> %s: %x\n", V_DATE(&va), WtoA(V_BSTR(&vb)), (unsigned int)res );
+
+	bstr = pOleChar[4];
+	va.vt = VT_BSTR;
+	va.u.bstrVal = bstr;
+	res = VariantChangeTypeEx(&vb, &va, 0, 0, VT_R8 );
+	printf( "VariantChangeTypeEx %s -> %f: %x\n", WtoA(V_BSTR(&va)), V_R8(&vb), (unsigned int)res );
+
+
+	vc.vt = VT_BSTR | VT_BYREF;
+	vc.u.pbstrVal = &bstr;
+	vb.vt = VT_VARIANT | VT_BYREF;
+	vb.u.pvarVal = &vc;
+	va.vt = VT_VARIANT | VT_BYREF;
+	va.u.pvarVal = &vb;
+	res = VariantCopyInd( &vd, &va );
+	printf( "VariantCopyInd: %x\n", (unsigned int)res );
+
+	/* test what happens when bad vartypes are passed in
+	 */
+	printf( "-------------- Testing different VARTYPES ----------------\n" );
+
+	for( i=0; i<100; i++ )
+	{
+		/* Trying to use variants that are set to be BSTR but
+		 * do not contain a valid pointer makes the program crash
+		 * in Windows so we will skip those.  We do not need them
+		 * anyways to illustrate the behavior.
+		 */
+		if( i ==  VT_BSTR )
+			i = 77;
+
+		va.vt = i;
+		d = 4.123;
+		va.u.dblVal = d;
+		res = VariantCopyInd( &vb, &va );
+		printf( "VariantCopyInd: %d -> %x\n", i, (unsigned int)res );
+
+		va.vt = i | VT_BYREF;
+		d = 4.123;
+		va.u.pdblVal = &d;
+		res = VariantCopyInd( &vb, &va );
+		printf( "VariantCopyInd: %d -> %x\n", i, (unsigned int)res );
+
+		va.vt = VT_R8;
+		d = 4.123;
+		va.u.dblVal = d;
+		res = VariantChangeTypeEx( &vb, &va, 0, 0, i );
+		printf( "VariantChangeTypeEx: %d -> %x\n", i, (unsigned int)res );
+
+		va.vt = VT_R8;
+		d = 4.123;
+		va.u.dblVal = d;
+		res = VariantChangeTypeEx( &vb, &va, 0, 0, i | VT_BYREF );
+		printf( "VariantChangeTypeEx: VT_BYREF %d -> %x\n", i, (unsigned int)res );
+
+		va.vt = 99;
+		d = 4.123;
+		va.u.dblVal = d;
+		res = VariantClear( &va );
+		printf( "VariantClear: %d -> %x\n", i, (unsigned int)res );
+
+	}
+	
+	res = VariantClear( &va );
+	printf( "VariantClear: %x\n", (unsigned int)res );
+	res = VariantClear( &vb );
+	printf( "VariantClear: %x\n", (unsigned int)res );
+	res = VariantClear( &vc );
+	printf( "VariantClear: %x\n", (unsigned int)res );
+	res = VariantClear( &vd );
+	printf( "VariantClear: %x\n", (unsigned int)res );
+	res = VariantClear( &ve );
+	printf( "VariantClear: %x\n", (unsigned int)res );
+
+
+	/* There is alot of memory leaks but this is simply a test program.
+	 */
+
+	return 0;
+}
+
diff --git a/libtest/vartest.readme b/libtest/vartest.readme
new file mode 100644
index 0000000..5d1c495
--- /dev/null
+++ b/libtest/vartest.readme
@@ -0,0 +1,21 @@
+The purpose of this program is validate the implementation 
+of the APIs related to VARIANTs. The validation is done
+by comparing the results given by the Windows implementation
+versus the Wine implementation.
+
+This program tests the creation/coercion/destruction of VARIANTs.
+
+This program was built in both Windows and Wine and the purpose
+of this program is to compare the output produced in both 
+environments. To facilitate that, the log of the output created 
+by the windows version of this program was added to CVS.
+
+If you modify this program, it might be wise to rebuild it in
+Windows, regenerate that output file and resubmit it to CVS.
+
+The output of the programs differ slightly from the one generated
+in Windows but most of the differences are caused by differences 
+in the way that printf interprets some escape sequences and the way
+floating point numbers are printed. See the notes in vartest.c for
+more information.
+
diff --git a/loader/dos/dosmod.c b/loader/dos/dosmod.c
index 75ac48f..b53c8fa 100644
--- a/loader/dos/dosmod.c
+++ b/loader/dos/dosmod.c
@@ -56,6 +56,41 @@
     return -1;
 }
 
+int XREAD(int fd,void*buf,int size) {
+ int res;
+
+ while (1) {
+  res = read(fd, buf, size);
+  if (res==size)
+   return res;
+  if (res==-1) {
+   if (errno==EINTR)
+    continue;
+   perror("dosmod read");
+   return -1;
+  }
+  fprintf(stderr,"dosmod read only %d of %d bytes.\n",res,size);
+  return res;
+ }
+}
+int XWRITE(int fd,void*buf,int size) {
+ int res;
+
+ while (1) {
+  res = write(fd, buf, size);
+  if (res==size)
+   return res;
+  if (res==-1) {
+   if (errno==EINTR)
+    continue;
+   perror("dosmod write");
+   return -1;
+  }
+  fprintf(stderr,"dosmod write only %d of %d bytes.\n",res,size);
+  return res;
+ }
+}
+
 void set_timer(struct timeval*tim)
 {
  struct itimerval cur;
@@ -65,7 +100,15 @@
  setitimer(ITIMER_REAL,&cur,NULL);
 }
 
-volatile int sig_pend,sig_fatal=0;
+void get_timer(struct timeval*tim)
+{
+ struct itimerval cur;
+
+ getitimer(ITIMER_REAL,&cur);
+ *tim=cur.it_value;
+}
+
+volatile int sig_pend,sig_fatal=0,sig_alrm=0;
 void*img;
 struct vm86plus_struct VM86;
 
@@ -84,6 +127,12 @@
  signal(sig,bad_handler);
 }
 
+void alarm_handler(int sig)
+{
+ sig_alrm++;
+ signal(sig,alarm_handler);
+}
+
 int main(int argc,char**argv)
 {
  int mfd=open(argv[0],O_RDWR);
@@ -121,7 +170,7 @@
  signal(SIGINT,sig_handler);
  signal(SIGUSR1,sig_handler);
  signal(SIGUSR2,sig_handler);
- signal(SIGALRM,sig_handler);
+ signal(SIGALRM,alarm_handler);
 
  signal(SIGQUIT,bad_handler);
  signal(SIGILL,bad_handler);
@@ -135,28 +184,33 @@
 #endif
 /* report back to the main program that we're ready */
  ret=1; /* dosmod protocol revision 1 */
- write(1,&ret,sizeof(ret));
+ XWRITE(1,&ret,sizeof(ret));
 /* context exchange loop */
  do {
-  if (read(0,&func,sizeof(func))!=sizeof(func)) return 1;
+  if (XREAD(0,&func,sizeof(func))!=sizeof(func)) return 1;
   if (func<0) break;
   switch (func) {
    case DOSMOD_SET_TIMER:
-    if (read(0,&tim,sizeof(tim))!=sizeof(tim)) return 1;
+    if (XREAD(0,&tim,sizeof(tim))!=sizeof(tim)) return 1;
     set_timer(&tim);
     /* no response */
     break;
+   case DOSMOD_GET_TIMER:
+    get_timer(&tim);
+    if (XWRITE(1,&tim,sizeof(tim))!=sizeof(tim)) return 1;
+    break;
    case DOSMOD_ENTER:
    default:
-    if (read(0,&VM86,sizeof(VM86))!=sizeof(VM86)) return 1;
-    if (sig_pend) ret=DOSMOD_SIGNAL; else
+    if (XREAD(0,&VM86,sizeof(VM86))!=sizeof(VM86)) return 1;
+    if (sig_pend||sig_alrm) ret=DOSMOD_SIGNAL; else
      ret=vm86plus(func,&VM86);
-    if (write(1,&ret,sizeof(ret))!=sizeof(ret)) return 1;
-    if (write(1,&VM86,sizeof(VM86))!=sizeof(VM86)) return 1;
+    if (XWRITE(1,&ret,sizeof(ret))!=sizeof(ret)) return 1;
+    if (XWRITE(1,&VM86,sizeof(VM86))!=sizeof(VM86)) return 1;
     switch (ret&0xff) {
      case DOSMOD_SIGNAL:
       ret=sig_pend; sig_pend=0;
-      if (write(1,&ret,sizeof(ret))!=sizeof(ret)) return 1;
+      if (!ret) { ret=SIGALRM; sig_alrm--; }
+      if (XWRITE(1,&ret,sizeof(ret))!=sizeof(ret)) return 1;
       if (sig_fatal) return 1;
       break;
     }
diff --git a/loader/dos/dosmod.h b/loader/dos/dosmod.h
index 6545620..ee9d9f3 100644
--- a/loader/dos/dosmod.h
+++ b/loader/dos/dosmod.h
@@ -3,6 +3,7 @@
 
 #define DOSMOD_ENTER     0x01 /* VM86_ENTER */
 #define DOSMOD_SET_TIMER 0x10
+#define DOSMOD_GET_TIMER 0x11
 
 #define DOSMOD_SIGNAL 0x00 /* VM86_SIGNAL */
 
diff --git a/loader/dos/dosvm.c b/loader/dos/dosvm.c
index 989b6a9..c493363 100644
--- a/loader/dos/dosvm.c
+++ b/loader/dos/dosvm.c
@@ -295,6 +295,56 @@
  return 0;
 }
 
+void DOSVM_SetTimer( unsigned ticks )
+{
+ TDB *pTask = (TDB *)GlobalLock16( GetCurrentTask() );
+ NE_MODULE *pModule = NE_GetPtr( pTask->hModule );
+ int stat=DOSMOD_SET_TIMER;
+ struct timeval tim;
+
+ GlobalUnlock16( GetCurrentTask() );
+ if (pModule&&pModule->lpDosTask) {
+  /* the PC clocks ticks at 1193180 Hz */
+  tim.tv_sec=0;
+  tim.tv_usec=((unsigned long long)ticks*1000000)/1193180;
+  /* sanity check */
+  if (!tim.tv_usec) tim.tv_usec=1;
+
+  if (write(pModule->lpDosTask->write_pipe,&stat,sizeof(stat))!=sizeof(stat)) {
+   ERR(module,"dosmod sync lost, errno=%d\n",errno);
+   return;
+  }
+  if (write(pModule->lpDosTask->write_pipe,&tim,sizeof(tim))!=sizeof(tim)) {
+   ERR(module,"dosmod sync lost, errno=%d\n",errno);
+   return;
+  }
+  /* there's no return */
+ }
+}
+
+unsigned DOSVM_GetTimer( void )
+{
+ TDB *pTask = (TDB *)GlobalLock16( GetCurrentTask() );
+ NE_MODULE *pModule = NE_GetPtr( pTask->hModule );
+ int stat=DOSMOD_GET_TIMER;
+ struct timeval tim;
+
+ GlobalUnlock16( GetCurrentTask() );
+ if (pModule&&pModule->lpDosTask) {
+  if (write(pModule->lpDosTask->write_pipe,&stat,sizeof(stat))!=sizeof(stat)) {
+   ERR(module,"dosmod sync lost, errno=%d\n",errno);
+   return 0;
+  }
+  /* read response */
+  if (read(pModule->lpDosTask->read_pipe,&tim,sizeof(tim))!=sizeof(tim)) {
+   ERR(module,"dosmod sync lost, errno=%d\n",errno);
+   return 0;
+  }
+  return ((unsigned long long)tim.tv_usec*1193180)/1000000;
+ }
+ return 0;
+}
+
 void MZ_Tick( WORD handle )
 {
  /* find the DOS task that has the right system_timer handle... */
@@ -319,5 +369,7 @@
 }
 
 void MZ_Tick( WORD handle ) {}
+void DOSVM_SetTimer( unsigned ticks ) {}
+unsigned DOSVM_GetTimer( void ) { return 0; }
 
 #endif
diff --git a/loader/dos/module.c b/loader/dos/module.c
index 64feff4..dc01307 100644
--- a/loader/dos/module.c
+++ b/loader/dos/module.c
@@ -45,8 +45,6 @@
 #define SEG16(ptr,seg) ((LPVOID)((BYTE*)ptr+((DWORD)(seg)<<4)))
 #define SEGPTR16(ptr,segptr) ((LPVOID)((BYTE*)ptr+((DWORD)SELECTOROF(segptr)<<4)+OFFSETOF(segptr)))
 
-extern WORD WINAPI SYSTEM_KillSystemTimer( WORD timer );
-
 static void MZ_InitPSP( LPVOID lpPSP, LPCSTR cmdline, WORD env )
 {
  PDB*psp=lpPSP;
@@ -494,7 +492,7 @@
 
 #else /* !MZ_SUPPORTED */
 
-HINSTANCE16 MZ_CreateProcess( LPCSTR name, LPCSTR cmdline, LPCSTR env, 
+HINSTANCE16 MZ_CreateProcess( LPCSTR name, LPCSTR cmdline, LPCSTR env, BOOL32 inherit,
                               LPSTARTUPINFO32A startup, LPPROCESS_INFORMATION info )
 {
  WARN(module,"DOS executables not supported on this architecture\n");
diff --git a/loader/main.c b/loader/main.c
index 0f48ae3..bbbadac37 100644
--- a/loader/main.c
+++ b/loader/main.c
@@ -43,6 +43,7 @@
 #include "debug.h"
 #include "psdrv.h"
 #include "server.h"
+#include "console.h"
 
 int __winelib = 1;  /* Winelib run-time flag */
 
@@ -88,6 +89,9 @@
     /* Set up text-mode stuff */
     CONSOLE_ResizeScreen(80, 25);
 
+    /* Read DOS config.sys */
+    if (!DOSCONF_ReadConfig()) return FALSE;
+
     return TRUE;
 }
 
diff --git a/loader/ne/convert.c b/loader/ne/convert.c
index ec6975c..0d201e6 100644
--- a/loader/ne/convert.c
+++ b/loader/ne/convert.c
@@ -376,6 +376,28 @@
 }
 
 /**********************************************************************
+ *	    ConvertAccelerator32To16
+ */
+VOID ConvertAccelerator32To16( LPVOID acc32, DWORD size, LPVOID acc16 )
+{
+    int type;
+
+    do
+    {
+        /* Copy type */
+        type = *((BYTE *)acc16)++ = *((BYTE *)acc32)++;
+        /* Skip padding */
+        ((BYTE *)acc32)++;
+        /* Copy event and IDval */
+        *((WORD *)acc16)++ = *((WORD *)acc32)++;
+        *((WORD *)acc16)++ = *((WORD *)acc32)++;
+        /* Skip padding */
+        ((WORD *)acc32)++;
+
+    } while ( !( type & 0x80 ) );
+}
+
+/**********************************************************************
  *	    NE_LoadPEResource
  */
 HGLOBAL16 NE_LoadPEResource( NE_MODULE *pModule, WORD type, LPVOID bits, DWORD size )
@@ -397,6 +419,10 @@
         ConvertDialog32To16( bits, size, GlobalLock16( handle ) );
         break;
 
+    case RT_ACCELERATOR16:
+        ConvertAccelerator32To16( bits, size, GlobalLock16( handle ) );
+        break;
+
     case RT_STRING16:
         FIXME( resource, "not yet implemented!\n" );
         /* fall through */
diff --git a/loader/ne/segment.c b/loader/ne/segment.c
index 854cbf3..a40ee19 100644
--- a/loader/ne/segment.c
+++ b/loader/ne/segment.c
@@ -148,7 +148,7 @@
       */
       char* buff = xmalloc(size);
       char* curr = buff;
-      ReadFile(hf, mem, size, &res, NULL);
+      ReadFile(hf, buff, size, &res, NULL);
       while(curr < buff + size) {
 	unsigned int rept = *((short*) curr)++;
 	unsigned int len = *((short*) curr)++;
@@ -800,6 +800,17 @@
 {
     WORD size = wSize << wElem;
     HANDLE16 hMem = GlobalAlloc16( NE_Ne2MemFlags(wFlags), size);
+
+    /* not data == code */
+    if (	(wFlags & NE_SEGFLAGS_EXECUTEONLY) ||
+    		!(wFlags & NE_SEGFLAGS_DATA)
+    ) {
+        WORD hSel = GlobalHandleToSel(hMem);
+        WORD access = SelectorAccessRights(hSel,0,0);
+
+	access |= 2<<2; /* SEGMENT_CODE */
+	SelectorAccessRights(hSel,1,access);
+    }
     return MAKELONG( hMem, GlobalHandleToSel(hMem) );
 }
 
diff --git a/loader/task.c b/loader/task.c
index b0aba02..3f742d2 100644
--- a/loader/task.c
+++ b/loader/task.c
@@ -251,7 +251,6 @@
         if (pModule->heap_size)
             LocalInit( pTask->hInstance, 0, pModule->heap_size );
 
-        InitApp( pTask->hModule );
         MODULE_InitializeDLLs( PROCESS_Current(), 0, DLL_PROCESS_ATTACH, (LPVOID)-1 );
         TRACE(relay, "(entryproc=%p)\n", entry );
 
diff --git a/memory/virtual.c b/memory/virtual.c
index 0950942..a387b9b 100644
--- a/memory/virtual.c
+++ b/memory/virtual.c
@@ -1094,9 +1094,16 @@
     {
         if (obj->type == K32OBJ_MEM_MAPPED_FILE)
         {
-            SetLastError( ERROR_ALREADY_EXISTS );
+            req.handle = -1;
+            CLIENT_SendRequest( REQ_CREATE_MAPPING, -1, 2,
+                                &req, sizeof(req),
+                                name, name ? strlen(name) + 1 : 0 );
+            CLIENT_WaitSimpleReply( &reply, sizeof(reply), NULL );
+            if (reply.handle == -1) return 0;
+            if (GetLastError() != ERROR_ALREADY_EXISTS)
+                return 0;  /* not supposed to happen */
             handle = HANDLE_Alloc( PROCESS_Current(), obj,
-                                   FILE_MAP_ALL_ACCESS /*FIXME*/, inherit, -1 );
+                                   FILE_MAP_ALL_ACCESS /*FIXME*/, inherit, reply.handle );
         }
         else
         {
diff --git a/misc/main.c b/misc/main.c
index f148a5b..86a1307 100644
--- a/misc/main.c
+++ b/misc/main.c
@@ -122,7 +122,8 @@
     { "-winver",        ".winver",          XrmoptionSepArg, (caddr_t)NULL },
     { "-config",        ".config",          XrmoptionSepArg, (caddr_t)NULL },
     { "-nodga",         ".nodga",           XrmoptionNoArg,  (caddr_t)"off"},
-    { "-console",       ".console",         XrmoptionSepArg, (caddr_t)NULL }
+    { "-console",       ".console",         XrmoptionSepArg, (caddr_t)NULL },
+    { "-dosver",        ".dosver",          XrmoptionSepArg, (caddr_t)NULL }
 };
 
 #define NB_OPTIONS  (sizeof(optionsTable) / sizeof(optionsTable[0]))
@@ -154,7 +155,8 @@
   "    -privatemap     Use a private color map\n" \
   "    -synchronous    Turn on synchronous display mode\n" \
   "    -version        Display the Wine version\n" \
-  "    -winver         Version to imitate (one of win31,win95,nt351,nt40)\n"
+  "    -winver         Windows version to imitate (one of win31,win95,nt351,nt40)\n" \
+  "    -dosver         DOS version to imitate (x.xx, e.g. 6.22). Only valid with -winver win31\n"
 
 
 
@@ -866,7 +868,20 @@
       {
           /* Hack: store option value in Options to be retrieved */
           /* later on inside the emulator code. */
-          if (!__winelib) Options.dllFlags = xstrdup((char *)value.addr);
+          if (!__winelib)
+                        {
+                                if (Options.dllFlags)
+                                {
+                                        /* don't overwrite previous value. Should we
+                                         * automatically add the ',' between multiple DLLs ?
+                                         */
+                                        MSG("Only one -dll flag is allowed. Use ',' between multiple DLLs\n");
+                                }
+                                else
+                                {
+                                        Options.dllFlags = xstrdup((char *)value.addr);
+                                }
+                        }
           else
           {
               MSG("-dll not supported in Winelib\n" );
@@ -875,7 +890,9 @@
       }
 
       if (MAIN_GetResource( db, ".winver", &value))
-          VERSION_ParseVersion( (char*)value.addr );
+          VERSION_ParseWinVersion( (char*)value.addr );
+      if (MAIN_GetResource( db, ".dosver", &value))
+          VERSION_ParseDosVersion( (char*)value.addr );
       if (MAIN_GetResource( db, ".config", &value))
          Options.configFileName = xstrdup((char *)value.addr);
       if (MAIN_GetResource( db, ".nodga", &value))
@@ -1041,6 +1058,7 @@
 
     /* We need this before calling any Xlib function */
     InitializeCriticalSection( &X11DRV_CritSection );
+    MakeCriticalSectionGlobal( &X11DRV_CritSection );
 
     TSXrmInitialize();
 
diff --git a/misc/printdrv.c b/misc/printdrv.c
index d53a5f6..5cfade5 100644
--- a/misc/printdrv.c
+++ b/misc/printdrv.c
@@ -742,6 +742,25 @@
           Level,pDriverInfo,cbBuf, pcbNeeded);
     return FALSE;
 }
+/*****************************************************************************
+ *          AddPrinterDriver32A  [WINSPOOL.120]
+ */
+BOOL32 WINAPI AddPrinterDriver32A(LPSTR printerName,DWORD level, 
+				   LPBYTE pDriverInfo)
+{
+    FIXME(print, "(%s,%ld,%p): stub\n",printerName,level,pDriverInfo);
+    return FALSE;
+}
+/*****************************************************************************
+ *          AddPrinterDriver32W  [WINSPOOL.121]
+ */
+BOOL32 WINAPI AddPrinterDriver32W(LPWSTR printerName,DWORD level, 
+				   LPBYTE pDriverInfo)
+{
+    FIXME(print, "(%s,%ld,%p): stub\n",debugstr_w(printerName),
+	  level,pDriverInfo);
+    return FALSE;
+}
 
 
 
diff --git a/misc/registry.c b/misc/registry.c
index 2f53228..e8f22e2 100644
--- a/misc/registry.c
+++ b/misc/registry.c
@@ -831,6 +831,12 @@
 			*ws++=*((unsigned char*)s++);
 		else {
 			s++;
+			if (!*s) {
+				/* Dangling \ ... may only happen if a registry
+				 * write was short. FIXME: What do to?
+				 */
+				 break;
+			}
 			if (*s=='\\') {
 				*ws++='\\';
 				s++;
diff --git a/misc/shell.c b/misc/shell.c
index 530a9b4..4947eeb 100644
--- a/misc/shell.c
+++ b/misc/shell.c
@@ -19,7 +19,6 @@
 #include "dlgs.h"
 #include "win.h"
 #include "cursoricon.h"
-#include "interfaces.h"
 #include "sysmetrics.h"
 #include "shlobj.h"
 #include "debug.h"
diff --git a/misc/version.c b/misc/version.c
index a865e4c..92d1f15 100644
--- a/misc/version.c
+++ b/misc/version.c
@@ -1,12 +1,14 @@
 /*
- * Windows version functions
+ * Windows and DOS version functions
  *
  * Copyright 1997 Alexandre Julliard
  * Copyright 1997 Marcus Meissner
  * Copyright 1998 Patrik Stridvall
+ * Copyright 1998 Andreas Mohr
  */
 
 #include <string.h>
+#include <stdlib.h>
 #include "windows.h"
 #include "winbase.h"
 #include "process.h"
@@ -24,7 +26,7 @@
 
 
 /* FIXME: compare values below with original and fix */
-static const VERSION_DATA VersionData[NB_WINDOWS_VERSIONS] =
+static VERSION_DATA VersionData[NB_WINDOWS_VERSIONS] =
 {
     /* WIN31 */
     {
@@ -64,7 +66,7 @@
     }
 };
 
-static const char *VersionNames[NB_WINDOWS_VERSIONS] =
+static const char *WinVersionNames[NB_WINDOWS_VERSIONS] =
 {
     "win31",
     "win95",
@@ -74,20 +76,20 @@
 
 /* the current version has not been autodetected but forced via cmdline */
 static BOOL32 versionForced = FALSE;
-static WINDOWS_VERSION defaultVersion = WIN31;
+static WINDOWS_VERSION defaultWinVersion = WIN31;
 
 
 /**********************************************************************
- *         VERSION_ParseVersion
+ *         VERSION_ParseWinVersion
  */
-void VERSION_ParseVersion( char *arg )
+void VERSION_ParseWinVersion( const char *arg )
 {
     int i;
     for (i = 0; i < NB_WINDOWS_VERSIONS; i++)
     {
-        if (!strcmp( VersionNames[i], arg ))
+        if (!strcmp( WinVersionNames[i], arg ))
         {
-            defaultVersion = (WINDOWS_VERSION)i;
+            defaultWinVersion = (WINDOWS_VERSION)i;
             versionForced = TRUE;
             return;
         }
@@ -95,12 +97,29 @@
     MSG("Invalid winver value '%s' specified.\n", arg );
     MSG("Valid versions are:" );
     for (i = 0; i < NB_WINDOWS_VERSIONS; i++)
-        MSG(" '%s'%c", VersionNames[i],
+        MSG(" '%s'%c", WinVersionNames[i],
 	    (i == NB_WINDOWS_VERSIONS - 1) ? '\n' : ',' );
 }
 
 
 /**********************************************************************
+ *         VERSION_ParseDosVersion
+ */
+void VERSION_ParseDosVersion( const char *arg )
+{
+    int hi, lo;
+    if (sscanf( arg, "%d.%d", &hi, &lo ) == 2)
+    {
+        VersionData[WIN31].getVersion16 =
+            MAKELONG(LOWORD(VersionData[WIN31].getVersion16),
+                     (hi<<8) + lo);
+    }
+    else
+        fprintf( stderr, "-dosver: Wrong version format. Use \"-dosver x.xx\"\n");
+}
+
+
+/**********************************************************************
  *         VERSION_GetVersion
  */
 WINDOWS_VERSION VERSION_GetVersion(void)
@@ -108,7 +127,7 @@
     PIMAGE_NT_HEADERS peheader;	
 
     if (versionForced) /* user has overridden any sensible checks */
-        return defaultVersion;
+        return defaultWinVersion;
     if (!PROCESS_Current()->exe_modref)
     {
         /* HACK: if we have loaded a PE image into this address space,
@@ -135,7 +154,7 @@
     ERR(ver,"unknown subsystem version: %04x.%04x, please report.\n",
 	peheader->OptionalHeader.MajorSubsystemVersion,
 	peheader->OptionalHeader.MinorSubsystemVersion );
-    return defaultVersion;
+    return defaultWinVersion;
 }
 
 
@@ -348,14 +367,16 @@
 {
     WINDOWS_VERSION ver = VERSION_GetVersion();
 
+    FIXME(ver, "Please report to a.mohr@mailto.de if you get version error messages !\n");
     switch(VersionData[ver].getVersion32)
     {
         case 0x80000a03: /* Win 3.1 */
 		return 0x140fd1; /* from Win32s 1.1e */
         case 0xc0000004: /* Win 95 */
-		return 0x0a0bd3;
+		return 0x1e10a9; /* some older version: 0x0a0bd3 */
         case 0x04213303: /* NT 3.51 */
-		return 0x0; /* FIXME */
+		FIXME(ver, "NT 3.51 version value unknown !\n");
+		return 0x1e10a9; /* value borrowed from Win95 */
         case 0x05650004: /* NT 4.0 */
 		return 0x141016;
 	default:
diff --git a/misc/winsock_dns.c b/misc/winsock_dns.c
index 5408c95..801e77c 100644
--- a/misc/winsock_dns.c
+++ b/misc/winsock_dns.c
@@ -30,7 +30,7 @@
 #ifdef HAVE_SYS_FILIO_H
 # include <sys/filio.h>
 #endif
-#ifdef __svr4__
+#ifdef HAVE_SYS_FILE_H
 # include <sys/file.h>
 #endif
 
diff --git a/msdos/Makefile.in b/msdos/Makefile.in
index 06d1288..db4c25a 100644
--- a/msdos/Makefile.in
+++ b/msdos/Makefile.in
@@ -7,6 +7,7 @@
 
 C_SRCS = \
 	cdrom.c \
+	dosconf.c \
 	dosmem.c \
 	dpmi.c \
 	xms.c \
diff --git a/msdos/cdrom.c b/msdos/cdrom.c
index 1881c77..817d430 100644
--- a/msdos/cdrom.c
+++ b/msdos/cdrom.c
@@ -24,7 +24,6 @@
 #include "msdos.h"
 #include "miscemu.h"
 #include "module.h"
-/* #define DEBUG_INT */
 #include "debug.h"
 
 
@@ -159,14 +158,18 @@
 	 io_stru[3]=io_stru[4]=0;
 	 io_stru[2]=1; /* supports audio channels (?? FIXME ??) */
 	 io_stru[1]=16; /* data read and plays audio racks */
+#if defined(CDROM_DRIVE_STATUS) && defined(CDS_TRAY_OPEN)
 	 io_stru[1]|=(ioctl(fdcd,CDROM_DRIVE_STATUS,0)==CDS_TRAY_OPEN);
+#endif
          TRACE(int," ----> DEVICE STATUS <0x%08lx>\n\n",(DWORD)io_stru[1]); 
 	 break;
 
 	case 9: /* media changed ? */
+#ifdef CDROM_MEDIA_CHANGED
 	 if (ioctl(fdcd,CDROM_MEDIA_CHANGED,0))
           io_stru[1]=0xff;
          else
+#endif
 	  io_stru[0]=0; /* FIXME? 1? */
 	 break;
 
diff --git a/msdos/dosconf.c b/msdos/dosconf.c
new file mode 100644
index 0000000..dd447ac
--- /dev/null
+++ b/msdos/dosconf.c
@@ -0,0 +1,440 @@
+/*
+ * DOS CONFIG.SYS parser
+ *
+ * Copyright 1998 Andreas Mohr 
+ *
+ */
+
+#include <stdio.h>
+#include <unistd.h>
+#include <string.h>
+#include <stdlib.h>
+#include <ctype.h>
+#include "windows.h"
+#include "msdos.h"
+#include "debug.h"
+#include "options.h"
+#include "file.h"
+
+
+static int DOSCONF_Device(char **confline);
+static int DOSCONF_Dos(char **confline);
+static int DOSCONF_Fcbs(char **confline);
+static int DOSCONF_Break(char **confline);
+static int DOSCONF_Files(char **confline);
+static int DOSCONF_Install(char **confline);
+static int DOSCONF_Lastdrive(char **confline);
+static int DOSCONF_Menu(char **confline);
+static int DOSCONF_Include(char **confline);
+static int DOSCONF_Country(char **confline);
+static int DOSCONF_Numlock(char **confline);
+static int DOSCONF_Switches(char **confline);
+static int DOSCONF_Shell(char **confline);
+static int DOSCONF_Stacks(char **confline);
+static int DOSCONF_Buffers(char **confline);
+static void DOSCONF_Parse(char *menuname);
+
+DOSCONF DOSCONF_config = 
+{
+    'E',  /* lastdrive */
+    0,    /* brk_flag */
+    8,    /* files */
+    9,    /* stacks_nr */
+    256,  /* stacks_sz */
+    15,   /* buf */
+    1,    /* buf2 */
+    4,    /* fcbs */
+    0,    /* flags */
+    NULL, /* shell */
+    NULL  /* country */
+};
+
+typedef struct {
+    const char *tag_name;
+    int (*tag_handler)(char **p);
+    void *data;
+} TAG_ENTRY;
+
+
+/*
+ * see
+ * http://egeria.cm.cf.ac.uk/User/P.L.Poulain/project/internal/allinter.htm
+ * or
+ * http://www.csulb.edu/~murdock/dosindex.html
+ */
+
+static const TAG_ENTRY tag_entries[] =
+{
+    { ";", NULL },
+    { "REM ", NULL },
+    { "DEVICE", DOSCONF_Device },
+    { "[", DOSCONF_Menu },
+    { "SUBMENU", NULL },
+    { "MENUDEFAULT", DOSCONF_Menu },
+    { "INCLUDE", DOSCONF_Include },
+
+    { "INSTALL", DOSCONF_Install },
+    { "DOS", DOSCONF_Dos },
+    { "FCBS", DOSCONF_Fcbs },
+    { "BREAK", DOSCONF_Break },
+    { "FILES", DOSCONF_Files },
+    { "SHELL", DOSCONF_Shell },    
+    { "STACKS", DOSCONF_Stacks },
+    { "BUFFERS", DOSCONF_Buffers },
+    { "COUNTRY", DOSCONF_Country },
+    { "NUMLOCK", DOSCONF_Numlock },
+    { "SWITCHES", DOSCONF_Switches },
+    { "LASTDRIVE", DOSCONF_Lastdrive }
+};
+
+static FILE *cfg_fd;
+
+static char *menu_default = NULL;
+static int menu_in_listing = 0;		/* we are in the [menu] section */
+static int menu_skip = 0;				/* the current menu gets skipped */
+
+
+static void DOSCONF_skip(char **pconfline)
+{
+    char *p;
+    
+    p = *pconfline;
+    while ( (*p == ' ') || (*p == '\t') ) p++;
+    *pconfline = p;
+}
+		
+static int DOSCONF_JumpToEntry(char **pconfline, char separator)
+{
+    char *p;
+    
+    p = *pconfline;
+    while ( (*p != separator) && (*p != '\0') ) p++;
+
+    if (*p != separator)
+	return 0;
+    else p++;
+
+    while ( (*p == ' ') || (*p == '\t') ) p++;
+    *pconfline = p;
+    return 1;
+}
+
+static int DOSCONF_Device(char **confline)
+{
+    int loadhigh = 0;
+
+    *confline += 6; /* strlen("DEVICE") */
+    if (!(strncasecmp(*confline, "HIGH", 4)))
+    {
+	loadhigh = 1;
+	*confline += 4;
+	/* FIXME: get DEVICEHIGH parameters if avail ? */
+    }
+    if (!(DOSCONF_JumpToEntry(confline, '='))) return 0;
+    TRACE(profile, "Loading device '%s'\n", *confline);
+#if 0
+    DOSMOD_LoadDevice(*confline, loadhigh);
+#endif
+    return 1;
+}
+
+static int DOSCONF_Dos(char **confline)
+{
+    *confline += 3; /* strlen("DOS") */
+    if (!(DOSCONF_JumpToEntry(confline, '='))) return 0;
+    while (**confline != '\0')
+    {
+	if (!(strncasecmp(*confline, "HIGH", 4)))
+	{
+	    DOSCONF_config.flags |= DOSCONF_MEM_HIGH;
+	    *confline += 4;
+	}
+	else
+	if (!(strncasecmp(*confline, "UMB", 3)))
+	{
+	    DOSCONF_config.flags |= DOSCONF_MEM_UMB;
+	    *confline += 3;
+	}
+        else (*confline)++;
+	DOSCONF_JumpToEntry(confline, ',');
+    }
+    TRACE(profile, "DOSCONF_Dos: HIGH is %d, UMB is %d\n",
+    	(DOSCONF_config.flags & DOSCONF_MEM_HIGH) != 0, (DOSCONF_config.flags & DOSCONF_MEM_UMB) != 0);
+    return 1;
+}
+
+static int DOSCONF_Fcbs(char **confline)
+{
+    *confline += 4; /* strlen("FCBS") */
+    if (!(DOSCONF_JumpToEntry(confline, '='))) return 0;
+    DOSCONF_config.fcbs = atoi(*confline);
+    if (DOSCONF_config.fcbs > 255)
+    {
+		MSG("The FCBS value in the config.sys file is too high ! Setting to 255.\n");
+		DOSCONF_config.fcbs = 255;
+    }
+    TRACE(profile, "DOSCONF_Fcbs returning %d\n", DOSCONF_config.fcbs);
+    return 1;
+}
+
+static int DOSCONF_Break(char **confline)
+{
+    *confline += 5; /* strlen("BREAK") */
+    if (!(DOSCONF_JumpToEntry(confline, '='))) return 0;
+    if (!(strcasecmp(*confline, "ON")))
+        DOSCONF_config.brk_flag = 1;
+    TRACE(profile, "BREAK is %d\n", DOSCONF_config.brk_flag);
+    return 1;
+}
+
+static int DOSCONF_Files(char **confline)
+{
+    *confline += 5; /* strlen("FILES") */
+    if (!(DOSCONF_JumpToEntry(confline, '='))) return 0;
+    DOSCONF_config.files = atoi(*confline);
+    if (DOSCONF_config.files > 255)
+    {
+    	MSG("The FILES value in the config.sys file is too high ! Setting to 255.\n");
+        DOSCONF_config.files = 255;
+    }
+    if (DOSCONF_config.files < 8)
+    {
+    	MSG("The FILES value in the config.sys file is too low ! Setting to 8.\n");
+        DOSCONF_config.files = 8;
+    }
+    TRACE(profile, "DOSCONF_Files returning %d\n", DOSCONF_config.files);
+    return 1;
+}
+
+static int DOSCONF_Install(char **confline)
+{
+    int loadhigh = 0;
+
+    *confline += 7; /* strlen("INSTALL") */
+    if (!(DOSCONF_JumpToEntry(confline, '='))) return 0;
+    TRACE(profile, "Installing '%s'\n", *confline);
+#if 0
+    DOSMOD_Install(*confline, loadhigh);
+#endif
+    return 1;
+}
+
+static int DOSCONF_Lastdrive(char **confline)
+{
+    *confline += 9; /* strlen("LASTDRIVE") */
+    if (!(DOSCONF_JumpToEntry(confline, '='))) return 0;
+    DOSCONF_config.lastdrive = toupper(**confline);
+    TRACE(profile, "Lastdrive %c\n", DOSCONF_config.lastdrive);
+    return 1;
+}
+
+static int DOSCONF_Country(char **confline)
+{
+    *confline += 7; /* strlen("COUNTRY") */
+    if (!(DOSCONF_JumpToEntry(confline, '='))) return 0;
+    TRACE(profile, "Country '%s'\n", *confline);
+    if (DOSCONF_config.country == NULL)
+		DOSCONF_config.country = malloc(strlen(*confline) + 1);
+    strcpy(DOSCONF_config.country, *confline);
+    return 1;
+}
+
+static int DOSCONF_Numlock(char **confline)
+{
+    *confline += 7; /* strlen("NUMLOCK") */
+    if (!(DOSCONF_JumpToEntry(confline, '='))) return 0;
+    if (!(strcasecmp(*confline, "ON")))
+        DOSCONF_config.flags |= DOSCONF_NUMLOCK;
+    TRACE(profile, "NUMLOCK is %d\n", (DOSCONF_config.flags & DOSCONF_NUMLOCK) != 0);
+    return 1;
+}
+
+static int DOSCONF_Switches(char **confline)
+{
+    char *p;
+
+    *confline += 8; /* strlen("SWITCHES") */
+    if (!(DOSCONF_JumpToEntry(confline, '='))) return 0;
+    p = strtok(*confline, "/");
+    do
+    {
+	if ( toupper(*p) == 'K')
+	    DOSCONF_config.flags |= DOSCONF_KEYB_CONV;
+    }
+    while ((p = strtok(NULL, "/")));
+    TRACE(profile, "'Force conventional keyboard' is %d\n",
+		(DOSCONF_config.flags & DOSCONF_KEYB_CONV) != 0);
+    return 1;
+}
+
+static int DOSCONF_Shell(char **confline)
+{
+    *confline += 5; /* strlen("SHELL") */
+    if (!(DOSCONF_JumpToEntry(confline, '='))) return 0;
+    TRACE(profile, "Shell '%s'\n", *confline);
+    if (DOSCONF_config.shell == NULL)
+		DOSCONF_config.shell = malloc(strlen(*confline) + 1);
+    strcpy(DOSCONF_config.shell, *confline);
+    return 1;
+}
+
+static int DOSCONF_Stacks(char **confline)
+{
+
+    *confline += 6; /* strlen("STACKS") */
+    if (!(DOSCONF_JumpToEntry(confline, '='))) return 0;
+    DOSCONF_config.stacks_nr = atoi(strtok(*confline, ","));
+    DOSCONF_config.stacks_sz = atoi((strtok(NULL, ",")));
+    TRACE(profile, "%d stacks of size %d\n",
+          DOSCONF_config.stacks_nr, DOSCONF_config.stacks_sz);
+    return 1;
+}
+
+static int DOSCONF_Buffers(char **confline)
+{
+    char *p;
+
+    *confline += 7; /* strlen("BUFFERS") */
+    if (!(DOSCONF_JumpToEntry(confline, '='))) return 0;
+    p = strtok(*confline, ",");
+    DOSCONF_config.buf = atoi(p);
+    if ((p = strtok(NULL, ",")))
+        DOSCONF_config.buf2 = atoi(p);
+    TRACE(profile, "%d primary buffers, %d secondary buffers\n",
+          DOSCONF_config.buf, DOSCONF_config.buf2);
+    return 1;
+}
+
+static int DOSCONF_Menu(char **confline)
+{
+    if (!(strncasecmp(*confline, "[MENU]", 6)))
+	menu_in_listing = 1;
+    else
+    if ((!(strncasecmp(*confline, "[COMMON]", 8)))
+    || (!(strncasecmp(*confline, "[WINE]", 6))))
+	menu_skip = 0;
+    else
+    if (**confline == '[')
+    {
+	(*confline)++;
+	if ((menu_default)
+	&& (!(strncasecmp(*confline, menu_default, strlen(menu_default)))))
+    {
+		free(menu_default);
+		menu_default = NULL;
+	    menu_skip = 0;
+    }
+	else
+	    menu_skip = 1;
+	menu_in_listing = 0;
+    }
+    else
+    if (!(strncasecmp(*confline, "menudefault", 11)) && (menu_in_listing))
+    {
+	if (!(DOSCONF_JumpToEntry(confline, '='))) return 0;
+    *confline = strtok(*confline, ",");
+    menu_default = malloc(strlen(*confline) + 1);
+	strcpy(menu_default, *confline);
+    }
+    return 1;
+}
+
+static int DOSCONF_Include(char **confline)
+{
+    fpos_t oldpos;
+    char *temp;
+    
+    *confline += 7; /* strlen("INCLUDE") */
+    if (!(DOSCONF_JumpToEntry(confline, '='))) return 0;
+    fgetpos(cfg_fd, &oldpos);
+    fseek(cfg_fd, 0, SEEK_SET);
+    TRACE(profile, "Including menu '%s'\n", *confline);
+    temp = malloc(strlen(*confline) + 1);
+    strcpy(temp, *confline);
+    DOSCONF_Parse(temp);
+	free(temp);
+    fsetpos(cfg_fd, &oldpos);
+    return 1;
+}
+
+static void DOSCONF_Parse(char *menuname)
+{
+   char confline[256];
+   char *p, *trail;
+   int i;
+    
+    if (menuname != NULL) /* we need to jump to a certain sub menu */
+    {
+	while (fgets(confline, 255, cfg_fd))
+	{
+	     p = confline;
+	     DOSCONF_skip(&p);
+	     if (*p == '[')
+	     {
+		p++;
+		if (!(trail = strrchr(p, ']')))
+		    return;
+		if (!(strncasecmp(p, menuname, (int)trail - (int)p)))
+		    break;
+	     }
+	}
+    }
+
+    while (fgets(confline, 255, cfg_fd))
+    {
+	p = confline;
+	DOSCONF_skip(&p);
+
+	if ((menuname) && (*p == '['))
+	    /* we were handling a specific sub menu, but now next menu begins */
+	    break;
+
+	if ((trail = strrchr(confline, '\n')))
+		*trail = '\0';
+	if ((trail = strrchr(confline, '\r')))
+		*trail = '\0';
+	if (!(menu_skip))
+	{
+	    for (i = 0; i < sizeof(tag_entries) / sizeof(TAG_ENTRY); i++)
+		if (!(strncasecmp(p, tag_entries[i].tag_name,
+		   strlen(tag_entries[i].tag_name))))
+		{
+		    TRACE(profile, "tag '%s'\n", tag_entries[i].tag_name);
+		    if (tag_entries[i].tag_handler != NULL)
+			    tag_entries[i].tag_handler(&p);
+			break;
+		}
+	}
+	else /* the current menu gets skipped */
+	DOSCONF_Menu(&p);
+    }
+}
+
+int DOSCONF_ReadConfig(void)
+{
+    char buffer[256];
+    DOS_FULL_NAME fullname;
+    char *filename, *menuname;
+    int ret = 1;
+
+    PROFILE_GetWineIniString( "wine", "config.sys", "", buffer, sizeof(buffer) );
+    filename = strtok(buffer, ",");
+    menuname = strtok(NULL,   ",");
+    if (!filename) return ret;
+
+    DOSFS_GetFullName(filename, FALSE, &fullname);
+    if (menuname) menu_default = strdup(menuname);
+    if ((cfg_fd = fopen(fullname.long_name, "r")))
+    {
+        DOSCONF_Parse(NULL);
+        fclose(cfg_fd);
+    }
+    else
+    {
+        MSG("Couldn't open config.sys file given as \"%s\" in" \
+            " wine.conf or .winerc, section [wine] !\n", filename);
+        ret = 0;
+    }
+    if (menu_default) free(menu_default);
+    return ret;
+}
diff --git a/msdos/int10.c b/msdos/int10.c
index c7ac518..23d3763 100644
--- a/msdos/int10.c
+++ b/msdos/int10.c
@@ -212,7 +212,7 @@
         break;
 
     case 0x0f: /* GET CURRENT VIDEO MODE */
-        TRACE(int10, "Get Current Video Mode (0x0%x)\n", AL_reg(context));
+        TRACE(int10, "Get Current Video Mode\n");
         /* Note: This should not be a constant value. */
         AL_reg(context) = 0x07; /* 80x25 text mode */
         AH_reg(context) = 80; /* 80 columns */
@@ -334,8 +334,10 @@
         switch BL_reg(context) {
         case 0x10: /* GET EGA INFO */
             TRACE(int10, "EGA Info Requested\n");
-            BX_reg(context) = 0x0003;
-            CX_reg(context) = 0x0009;
+            BH_reg(context) = 0x00;   /* Color screen */
+            BL_reg(context) = 0x03;   /* 256K EGA card */
+            CH_reg(context) = 0x00;   /* Switch settings?? */
+            CL_reg(context) = 0x09;   /* EGA+ card */
             break;
         case 0x20: /* ALTERNATE PRTSC */
             FIXME(int10, "Install Alternate Print Screen - Not Supported\n");
@@ -374,9 +376,9 @@
         switch AL_reg(context) {
         case 0x00: /* GET DISPLAY COMBINATION CODE */
             TRACE(int10, "Get Display Combination Code\n");
-            /* Why are we saying this? */
-            /* Do we need to check if we are in a windows or text app? */
-            BX_reg(context) = 0x0008; /* VGA w/ color analog display */
+            AL_reg(context) = 0x1a;
+            BH_reg(context) = 0x08; /* VGA w/ color analog display */
+            BL_reg(context) = 0x00; /* No secondary hardware */
             break;
         case 0x01: /* SET DISPLAY COMBINATION CODE */
             FIXME(int10, "Set Display Combination Code - Not Supported\n");
diff --git a/msdos/int21.c b/msdos/int21.c
index 6f7ca49..8315d74 100644
--- a/msdos/int21.c
+++ b/msdos/int21.c
@@ -6,7 +6,9 @@
 #include <fcntl.h>
 #include <errno.h>
 #include <stdlib.h>
-#include <sys/file.h>
+#ifdef HAVE_SYS_FILE_H
+# include <sys/file.h>
+#endif
 #include <string.h>
 #include <sys/stat.h>
 #include <sys/time.h>
@@ -1100,19 +1102,9 @@
 
     switch(AH_reg(context)) 
     {
-    case 0x00: /* TERMINATE PROGRAM */
-        TRACE(int21,"TERMINATE PROGRAM\n");
-        ExitProcess( 0 );
-        break;
-
-    case 0x01: /* READ CHARACTER FROM STANDARD INPUT, WITH ECHO */
-		_lread16(1, (BYTE *)&context->Eax, 1);
-		break;
-
     case 0x03: /* READ CHARACTER FROM STDAUX  */
     case 0x04: /* WRITE CHARACTER TO STDAUX */
     case 0x05: /* WRITE CHARACTER TO PRINTER */
-    case 0x0b: /* GET STDIN STATUS */
     case 0x0f: /* OPEN FILE USING FCB */
     case 0x10: /* CLOSE FILE USING FCB */
     case 0x14: /* SEQUENTIAL READ FROM FCB FILE */		
@@ -1129,6 +1121,15 @@
         INT_BARF( context, 0x21 );
         break;
 
+    case 0x00: /* TERMINATE PROGRAM */
+        TRACE(int21,"TERMINATE PROGRAM\n");
+        ExitProcess( 0 );
+        break;
+
+    case 0x01: /* READ CHARACTER FROM STANDARD INPUT, WITH ECHO */
+                _lread16(1, (BYTE *)&context->Eax, 1);
+                break;
+
     case 0x02: /* WRITE CHARACTER TO STANDARD OUTPUT */
         TRACE(int21, "Write Character to Standard Output\n");
     	CONSOLE_Write(DL_reg(context), 0, 0, 0);
@@ -1176,6 +1177,13 @@
 	break;
       }
 
+    case 0x0b: /* GET STDIN STATUS */
+	{
+	    CHAR dummy;
+
+	    AL_reg(context) = CONSOLE_CheckForKeystroke(&dummy, &dummy);
+	}
+        break;
     case 0x2e: /* SET VERIFY FLAG */
         TRACE(int21,"SET VERIFY FLAG ignored\n");
     	/* we cannot change the behaviour anyway, so just ignore it */
@@ -1319,17 +1327,28 @@
         switch (AL_reg(context))
         {
 	      case 0x00: /* GET CURRENT EXTENDED BREAK STATE */
-		TRACE(int21,"GET CURRENT EXTENDED BREAK STATE stub\n");
-                DL_reg(context) = 0;
+		TRACE(int21,"GET CURRENT EXTENDED BREAK STATE\n");
+                DL_reg(context) = DOSCONF_config.brk_flag;
 		break;
 
 	      case 0x01: /* SET EXTENDED BREAK STATE */
-		TRACE(int21,"SET CURRENT EXTENDED BREAK STATE stub\n");
+		TRACE(int21,"SET CURRENT EXTENDED BREAK STATE\n");
+		DOSCONF_config.brk_flag = (DL_reg(context) > 0);
 		break;		
 		
 	      case 0x02: /* GET AND SET EXTENDED CONTROL-BREAK CHECKING STATE*/
-		TRACE(int21,"GET AND SET EXTENDED CONTROL-BREAK CHECKING STATE stub\n");
-		DL_reg(context) = 0;
+		TRACE(int21,"GET AND SET EXTENDED CONTROL-BREAK CHECKING STATE\n");
+		/* ugly coding in order to stay reentrant */
+		if (DL_reg(context))
+		{
+		    DL_reg(context) = DOSCONF_config.brk_flag;
+		    DOSCONF_config.brk_flag = 1;
+		}
+		else
+		{
+		    DL_reg(context) = DOSCONF_config.brk_flag;
+		    DOSCONF_config.brk_flag = 0;
+		}
 		break;
 
 	      case 0x05: /* GET BOOT DRIVE */
diff --git a/msdos/ioports.c b/msdos/ioports.c
index 1154c3e..d6adf75 100644
--- a/msdos/ioports.c
+++ b/msdos/ioports.c
@@ -2,6 +2,7 @@
  * Emulation of processor ioports.
  *
  * Copyright 1995 Morten Welinder
+ * Copyright 1998 Andreas Mohr, Ove Kaaven
  */
 
 /* Known problems:
@@ -17,9 +18,18 @@
 #include <unistd.h>
 #include "windows.h"
 #include "vga.h"
+#include "dosexe.h"
 #include "options.h"
 #include "debug.h"
 
+static WORD tmr_8253_countmax[3] = {0xffff, 0x12, 1}; /* [2] needs to be 1 ! */
+/* if byte_toggle is TRUE, then hi byte has already been written */
+static BOOL16 tmr_8253_byte_toggle[3] = {FALSE, FALSE, FALSE};
+static BYTE tmr_8253_ctrlbyte_ch[4] = {0x06, 0x44, 0x86, 0};
+static int dummy_ctr = 0;
+
+static BYTE parport_8255[4] = {0x4f, 0x20, 0xff, 0xff};
+
 static BYTE cmosaddress;
 
 static BYTE cmosimage[64] =
@@ -52,7 +62,7 @@
 
 #endif  /* DIRECT_IO_ACCESS */
 
-static void IO_FixCMOSCheckSum()
+static void IO_FixCMOSCheckSum(void)
 {
 	WORD sum = 0;
 	int i;
@@ -64,6 +74,26 @@
 	TRACE(int, "calculated hi %02x, lo %02x\n", cmosimage[0x2e], cmosimage[0x2f]);
 }
 
+static void set_timer_maxval(unsigned timer, unsigned maxval)
+{
+    switch (timer) {
+        case 0: /* System timer counter divisor */
+            DOSVM_SetTimer(maxval);
+            break;
+        case 1: /* RAM refresh */
+            FIXME(int, "RAM refresh counter handling not implemented !");
+            break;
+        case 2: /* cassette & speaker */
+            /* speaker on ? */
+            if (((BYTE)parport_8255[1] & 3) == 3)
+            {
+                TRACE(int, "Beep (freq: %d) !\n", 1193180 / maxval );
+                Beep(1193180 / maxval, 20);
+            }
+            break;
+    }
+}
+
 /**********************************************************************
  *	    IO_port_init
  */
@@ -206,62 +236,99 @@
 
 /**********************************************************************
  *	    IO_inport
+ *
+ * Note: The size argument has to be handled correctly _externally_ 
+ * (as we always return a DWORD)
  */
-DWORD IO_inport( int port, int count )
+DWORD IO_inport( int port, int size )
 {
     DWORD res = 0;
-    BYTE b;    
 
 #ifdef DIRECT_IO_ACCESS    
-    if (do_direct_port_access)
+    if ((do_direct_port_access)
+        /* Make sure we have access to the port */
+        && (port_permissions[port] & IO_READ))
     {
-        /* Make sure we have access to the whole range */
-        int i;
-        for (i = 0; i < count; i++)
-            if (!(port_permissions[port+i] & IO_READ)) break;
-        if (i == count)
+        iopl(3);
+        switch(size)
         {
-            iopl(3);
-            switch(count)
-            {
-                case 1: res = inb( port ); break;
-                case 2: res = inw( port ); break;
-                case 4: res = inl( port ); break;
-                default:
-                    ERR(int, "invalid count %d\n", count);
-            }
-            iopl(0);
-            return res;
+        case 1: res = inb( port ); break;
+        case 2: res = inw( port ); break;
+        case 4: res = inl( port ); break;
+        default:
+            ERR(int, "invalid data size %d\n", size);
         }
+        iopl(0);
+        return res;
     }
 #endif
 
-    TRACE(int, "%d bytes from port 0x%02x\n", count, port );
+    TRACE(int, "%d-byte value from port 0x%02x\n", size, port );
 
-    while (count-- > 0)
+    switch (port)
     {
-        switch (port)
+    case 0x40:
+    case 0x41:
+    case 0x42:
+    {
+        BYTE chan = port & 3;
+        WORD tempval = 0;
+
+        if (chan == 0) /* System timer counter divisor */
+            tempval = (WORD)DOSVM_GetTimer();
+        else
+        {   /* FIXME: intelligent hardware timer emulation needed */
+            dummy_ctr -= 10;
+            tempval = dummy_ctr;
+        }
+        switch (tmr_8253_ctrlbyte_ch[chan] & 0x30)
         {
-        case 0x70:
-            b = cmosaddress;
+        case 0x00:
+            break; /* correct ? */
+        case 0x10: /* read lo byte */
+            res = (BYTE)tempval;
             break;
-        case 0x71:
-            b = cmosimage[cmosaddress & 0x3f];
-            break;
-        case 0x200:
-        case 0x201:
-            b = 0xff; /* no joystick */
-            break;
-        case 0x3da:
-            b = VGA_ioport_in( port );
-            break;
-        default:
-            WARN( int, "Direct I/O read attempted from port %x\n", port);
-            b = 0xff;
+        case 0x30: /* read lo byte, then hi byte */
+            tmr_8253_byte_toggle[chan] ^= TRUE; /* toggle */
+            if (tmr_8253_byte_toggle[chan] == TRUE)
+            {
+                res = (BYTE)tempval;
+                break;
+            }
+            /* else [fall through if read hi byte !] */
+        case 0x20: /* read hi byte */
+            res = (BYTE)tempval>>8;
             break;
         }
-        port++;
-        res = (res << 8) | b;
+        break;
+    }
+    case 0x60:
+        res = (DWORD)parport_8255[0];
+        break;
+    case 0x61:
+        res = (DWORD)parport_8255[1];
+        break;
+    case 0x62:
+        res = (DWORD)parport_8255[2];
+        break;
+    case 0x70:
+        res = (DWORD)cmosaddress;
+        break;
+    case 0x71:
+        res = (DWORD)cmosimage[cmosaddress & 0x3f];
+        break;
+    case 0x200:
+    case 0x201:
+        res = 0xffffffff; /* no joystick */
+        break;
+    case 0x3ba:
+    case 0x3da:
+        res = (DWORD)VGA_ioport_in( port );
+        break;
+    default:
+        WARN( int, "Direct I/O read attempted from port %x\n", port);
+        res = 0xffffffff;
+        break;
     }
     TRACE(int, "  returning ( 0x%lx )\n", res );
     return res;
@@ -271,57 +338,107 @@
 /**********************************************************************
  *	    IO_outport
  */
-void IO_outport( int port, int count, DWORD value )
+void IO_outport( int port, int size, DWORD value )
 {
-    BYTE b;
-
-    TRACE(int, "IO: 0x%lx (%d bytes) to port 0x%02x\n",
-                 value, count, port );
+    TRACE(int, "IO: 0x%lx (%d-byte value) to port 0x%02x\n",
+                 value, size, port );
 
 #ifdef DIRECT_IO_ACCESS
-    if (do_direct_port_access)
+    if ((do_direct_port_access)
+        /* Make sure we have access to the port */
+        && (port_permissions[port] & IO_WRITE))
     {
-        /* Make sure we have access to the whole range */
-        int i;
-        for (i = 0; i < count; i++)
-            if (!(port_permissions[port+i] & IO_WRITE)) break;
-        if (i == count)
+        iopl(3);
+        switch(size)
         {
-            iopl(3);
-            switch(count)
-            {
-                case 1: outb( LOBYTE(value), port ); break;
-                case 2: outw( LOWORD(value), port ); break;
-                case 4: outl( value, port ); break;
-                default:
-                    WARN(int, "Invalid count %d\n", count);
-            }
-            iopl(0);
-            return;
+        case 1: outb( LOBYTE(value), port ); break;
+        case 2: outw( LOWORD(value), port ); break;
+        case 4: outl( value, port ); break;
+        default:
+            WARN(int, "Invalid data size %d\n", size);
         }
+        iopl(0);
+        return;
     }
 #endif
 
-    while (count-- > 0)
+    switch (port)
     {
-        b = value & 0xff;
-        value >>= 8;
-        switch (port)
+    case 0x40:
+    case 0x41:
+    case 0x42:
+    {
+        BYTE chan = port & 3;
+        WORD oldval = 0;
+
+        if ( ((tmr_8253_ctrlbyte_ch[chan] & 0x30) != 0x30) ||
+/* we need to get the oldval before any lo/hi byte change has been made */
+             (tmr_8253_byte_toggle[chan] == FALSE) )
+            oldval = tmr_8253_countmax[chan];
+        switch (tmr_8253_ctrlbyte_ch[chan] & 0x30)
         {
-        case 0x70:
-            cmosaddress = b & 0x7f;
+        case 0x00:
+            break; /* correct ? */
+        case 0x10: /* write lo byte */
+            tmr_8253_countmax[chan] =
+                (tmr_8253_countmax[chan] & 0xff00) | (BYTE)value;
             break;
-        case 0x71:
-            cmosimage[cmosaddress & 0x3f] = b;
-            break;
-        case 0x3c8:
-        case 0x3c9:
-            VGA_ioport_out( port, b );
-            break;
-        default:
-            WARN(int, "Direct I/O write attempted to port %x\n", port );
+        case 0x30: /* write lo byte, then hi byte */
+            tmr_8253_byte_toggle[chan] ^= TRUE; /* toggle */
+            if (tmr_8253_byte_toggle[chan] == TRUE)
+            {
+                tmr_8253_countmax[chan] =
+                    (tmr_8253_countmax[chan] & 0xff00) | (BYTE)value;
+                break;
+            }
+            /* else [fall through if write hi byte !] */
+        case 0x20: /* write hi byte */
+            tmr_8253_countmax[chan] =
+                (tmr_8253_countmax[chan] & 0xff)|((BYTE)value << 8);
             break;
         }
-	port++;
+        if (
+            /* programming finished ? */
+            ( ((tmr_8253_ctrlbyte_ch[chan] & 0x30) != 0x30) ||
+              (tmr_8253_byte_toggle[chan] == FALSE) )
+            /* update to new value ? */
+            && (tmr_8253_countmax[chan] != oldval)
+            )
+            set_timer_maxval(chan, tmr_8253_countmax[chan]);
+    }
+    break;          
+    case 0x43:
+        /* ctrl byte for specific timer channel */
+        tmr_8253_ctrlbyte_ch[((BYTE)value & 0xc0) >> 6] = (BYTE)value;
+        if (((BYTE)value&0xc0)==0xc0) {
+            FIXME(int,"8254 timer readback not implemented yet\n");
+        } else
+            if (((BYTE)value&3)==0) {
+                FIXME(int,"timer counter latch not implemented yet\n");
+            }
+        if ((value & 0x30) == 0x30) /* write lo byte, then hi byte */
+            tmr_8253_byte_toggle[((BYTE)value & 0xc0) >> 6] = FALSE; /* init */
+        break;
+    case 0x61:
+        parport_8255[1] = (BYTE)value;
+        if ((((BYTE)parport_8255[1] & 3) == 3) && (tmr_8253_countmax[2] != 1))
+        {
+            TRACE(int, "Beep (freq: %d) !\n", 1193180 / tmr_8253_countmax[2]);
+            Beep(1193180 / tmr_8253_countmax[2], 20);
+        }
+        break;
+    case 0x70:
+        cmosaddress = (BYTE)value & 0x7f;
+        break;
+    case 0x71:
+        cmosimage[cmosaddress & 0x3f] = (BYTE)value;
+        break;
+    case 0x3c8:
+    case 0x3c9:
+        VGA_ioport_out( port, (BYTE)value );
+        break;
+    default:
+        WARN(int, "Direct I/O write attempted to port %x\n", port );
+        break;
     }
 }
diff --git a/multimedia/dplay.c b/multimedia/dplay.c
index e3a22d7..f460f8a 100644
--- a/multimedia/dplay.c
+++ b/multimedia/dplay.c
@@ -5,13 +5,11 @@
  * <presently under construction - contact hunnise@nortelnetworks.com>
  *
  */
-#include "interfaces.h"
 #include "heap.h"
 #include "winerror.h"
 #include "debug.h"
 #include "winnt.h"
 #include "winreg.h"
-#include "compobj.h"
 #include "dplay.h"
 
 #include "thread.h"
diff --git a/multimedia/dsound.c b/multimedia/dsound.c
index e37a572..54bfc81 100644
--- a/multimedia/dsound.c
+++ b/multimedia/dsound.c
@@ -41,9 +41,9 @@
 #include <math.h>	/* Insomnia - pow() function */
 #include "windows.h"
 #include "winerror.h"
-#include "interfaces.h"
 #include "multimedia.h"
 #include "dsound.h"
+#include "objbase.h"
 #include "thread.h"
 #include "debug.h"
 #include "xmalloc.h"
@@ -2115,7 +2115,8 @@
  * DirectSound ClassFactory
  */
 static HRESULT WINAPI 
-DSCF_QueryInterface(LPCLASSFACTORY this,REFIID riid,LPVOID *ppobj) {
+DSCF_QueryInterface(LPUNKNOWN iface,REFIID riid,LPVOID *ppobj) {
+	ICOM_THIS(IClassFactory,iface);
 	char buf[80];
 
 	if (HIWORD(riid))
@@ -2127,18 +2128,21 @@
 }
 
 static ULONG WINAPI
-DSCF_AddRef(LPCLASSFACTORY this) {
+DSCF_AddRef(LPUNKNOWN iface) {
+	ICOM_THIS(IClassFactory,iface);
 	return ++(this->ref);
 }
 
-static ULONG WINAPI DSCF_Release(LPCLASSFACTORY this) {
+static ULONG WINAPI DSCF_Release(LPUNKNOWN iface) {
+	ICOM_THIS(IClassFactory,iface);
 	/* static class, won't be  freed */
 	return --(this->ref);
 }
 
 static HRESULT WINAPI DSCF_CreateInstance(
-	LPCLASSFACTORY this,LPUNKNOWN pOuter,REFIID riid,LPVOID *ppobj
+	LPCLASSFACTORY iface,LPUNKNOWN pOuter,REFIID riid,LPVOID *ppobj
 ) {
+	ICOM_THIS(IClassFactory,iface);
 	char buf[80];
 
 	WINE_StringFromCLSID(riid,buf);
@@ -2150,19 +2154,22 @@
 	return E_NOINTERFACE;
 }
 
-static HRESULT WINAPI DSCF_LockServer(LPCLASSFACTORY this,BOOL32 dolock) {
+static HRESULT WINAPI DSCF_LockServer(LPCLASSFACTORY iface,BOOL32 dolock) {
+	ICOM_THIS(IClassFactory,iface);
 	FIXME(dsound,"(%p)->(%d),stub!\n",this,dolock);
 	return S_OK;
 }
 
-static IClassFactory_VTable DSCF_VTable = {
+static ICOM_VTABLE(IClassFactory) DSCF_VTable = {
+  {
 	DSCF_QueryInterface,
 	DSCF_AddRef,
-	DSCF_Release,
+    DSCF_Release
+  },
 	DSCF_CreateInstance,
 	DSCF_LockServer
 };
-static IClassFactory DSOUND_CF = {&DSCF_VTable, 1 };
+static _IClassFactory DSOUND_CF = {&DSCF_VTable, 1 };
 
 /*******************************************************************************
  * DllGetClassObject [DSOUND.4]
@@ -2197,7 +2204,7 @@
     TRACE(dsound, "(%p,%p,%p)\n", xbuf, buf, ppv);
     if (!memcmp(riid,&IID_IClassFactory,sizeof(IID_IClassFactory))) {
     	*ppv = (LPVOID)&DSOUND_CF;
-	DSOUND_CF.lpvtbl->fnAddRef(&DSOUND_CF);
+	IClassFactory_AddRef(&DSOUND_CF);
     return S_OK;
     }
     FIXME(dsound, "(%p,%p,%p): no interface found.\n", xbuf, buf, ppv);
diff --git a/objects/dc.c b/objects/dc.c
index 73b303c..981d5d3 100644
--- a/objects/dc.c
+++ b/objects/dc.c
@@ -15,6 +15,7 @@
 #include "font.h"
 #include "winerror.h"
 #include "x11drv.h"
+#include "ts_xlib.h"
 
 /***********************************************************************
  *           DC_Init_DC_INFO
diff --git a/objects/font.c b/objects/font.c
index 01bc8ff..e98ac86 100644
--- a/objects/font.c
+++ b/objects/font.c
@@ -756,7 +756,7 @@
  *
  * FIXME: Should this have a bug for compatibility?
  * Original Windows versions of GetTextExtentPoint{A,W} have documented
- * bugs.
+ * bugs (-> MSDN KB q147647.txt).
  */
 BOOL16 WINAPI GetTextExtentPoint16( HDC16 hdc, LPCSTR str, INT16 count,
                                     LPSIZE16 size )
diff --git a/ole/compobj.c b/ole/compobj.c
index d1264e7..a534994 100644
--- a/ole/compobj.c
+++ b/ole/compobj.c
@@ -5,50 +5,57 @@
  *	Copyright 1998	Justin Bradford
  */
 
-#define INITGUID
-
 #include "config.h"
 #ifdef HAVE_UNISTD_H
-#include <unistd.h>
+# include <unistd.h>
 #endif
 #include <fcntl.h>
 #include <sys/types.h>
 #include <sys/time.h>
 #include <sys/stat.h>
-#include <sys/file.h>
+#ifdef HAVE_SYS_FILE_H
+# include <sys/file.h>
+#endif
 #include <sys/ioctl.h>
 #include <sys/socket.h>
 #ifdef HAVE_SYS_SOCKIO_H
-#include <sys/sockio.h>
+# include <sys/sockio.h>
 #endif
 #ifdef HAVE_NET_IF_H
-#include <net/if.h>
+# include <net/if.h>
 #endif
 #ifdef HAVE_NETINET_IN_H
-#include <netinet/in.h>
+# include <netinet/in.h>
 #endif
 #include <ctype.h>
 #include <stdlib.h>
 #include <string.h>
 #include <time.h>
-#include "ole.h"
-#include "ole2.h"
+#include "windows.h"
 #include "winerror.h"
+#include "ole2.h"
 #include "debug.h"
 #include "file.h"
-#include "compobj.h"
 #include "heap.h"
 #include "ldt.h"
-#include "interfaces.h"
-#include "shlobj.h"
-#include "oleobj.h"
-#include "ddraw.h"
-#include "dsound.h"
-#include "dinput.h"
-#include "d3d.h"
-#include "dplay.h"
-#include "windows.h"
+#include "winreg.h"
 
+#define INITGUID
+
+/* FIXME: we include all the header files containing GUIDs 
+ * so that the corresponding variables get defined. But they 
+ * don't even all belong to the same DLL !!!
+ */
+#include "objbase.h"
+#include "servprov.h"
+#include "shlobj.h"
+#include "ddraw.h"
+#include "d3d.h"
+#include "dinput.h"
+#include "dsound.h"
+#include "dplay.h"
+
+#include "objbase.h"
 
 LPMALLOC16 currentMalloc16=NULL;
 LPMALLOC32 currentMalloc32=NULL;
@@ -87,26 +94,59 @@
  * Set the win16 IMalloc used for memory management
  */
 HRESULT WINAPI CoInitialize16(
-	LPMALLOC16 lpReserved	/* [in] pointer to win16 malloc interface */
+	LPVOID lpReserved	/* [in] pointer to win16 malloc interface */
 ) {
-    currentMalloc16 = lpReserved;
+    currentMalloc16 = (LPMALLOC16)lpReserved;
     return S_OK;
 }
 
 /******************************************************************************
  *		CoInitialize32	[OLE32.26]
+ *
  * Set the win32 IMalloc used for memorymanagement
+ *
+ * RETURNS
+ * S_OK if successful, S_FALSE otherwise, RPC_E_CHANGED_MODE if a previous 
+ * call to CoInitializeEx specified another threading model.
+ *
+ * BUGS
+ * Only the single threaded model is supported. As a result RPC_E_CHANGED_MODE 
+ * is never returned.
  */
 HRESULT WINAPI CoInitialize32(
-	LPMALLOC32 lpReserved	/* [in] pointer to win32 malloc interface */
+	LPVOID lpReserved	/* [in] pointer to win32 malloc interface */
 ) {
     /* FIXME: there really should be something here that incrememts a refcount
      * but I'm supposing that it is a real COM object, so I won't bother
      * creating one here.  (Decrement done in CoUnitialize()) */
-    currentMalloc32 = lpReserved;
+    currentMalloc32 = (LPMALLOC32)lpReserved;
     return S_OK;
 }
 
+/******************************************************************************
+ *		CoInitializeEx32	[OLE32.163]
+ *
+ * Set the win32 IMalloc used for memory management
+ *
+ * RETURNS
+ * S_OK if successful, S_FALSE otherwise, RPC_E_CHANGED_MODE if a previous 
+ * call to CoInitializeEx specified another threading model.
+ *
+ * BUGS
+ * Only the single threaded model is supported. As a result RPC_E_CHANGED_MODE 
+ * is never returned.
+ */
+HRESULT WINAPI CoInitializeEx32(
+	LPVOID lpReserved,	/* [in] pointer to win32 malloc interface */
+	DWORD dwCoInit		/* [in] A value from COINIT specifies the threading model */
+) {
+  if (dwCoInit!=COINIT_APARTMENTTHREADED) {
+    FIXME(ole, ":(%p,%x): unsupported flag %x\n", lpReserved, (int)dwCoInit, (int)dwCoInit);
+    /* Hope for the best and continue anyway */
+  }
+  return CoInitialize32(lpReserved);
+}
+
 /***********************************************************************
  *           CoUnitialize   [COMPOBJ.3]
  * Don't know what it does. 
@@ -153,7 +193,7 @@
 /***********************************************************************
  *           CoCreateStandardMalloc16 [COMPOBJ.71]
  */
-OLESTATUS WINAPI CoCreateStandardMalloc16(DWORD dwMemContext,
+HRESULT WINAPI CoCreateStandardMalloc16(DWORD dwMemContext,
 					  LPMALLOC16 *lpMalloc)
 {
     /* FIXME: docu says we shouldn't return the same allocator as in
@@ -165,25 +205,43 @@
 /******************************************************************************
  *		CoDisconnectObject	[COMPOBJ.15]
  */
-OLESTATUS WINAPI CoDisconnectObject( LPUNKNOWN lpUnk, DWORD reserved )
+HRESULT WINAPI CoDisconnectObject( LPUNKNOWN lpUnk, DWORD reserved )
 {
     TRACE(ole,"%p %lx\n",lpUnk,reserved);
     return S_OK;
 }
 
 /***********************************************************************
- *           IsEqualGUID [COMPOBJ.18]
- * Compares two Unique Identifiers
+ *           IsEqualGUID16 [COMPOBJ.18]
+ *
+ * Compares two Unique Identifiers.
+ *
  * RETURNS
  *	TRUE if equal
  */
-BOOL16 WINAPI IsEqualGUID(
+BOOL16 WINAPI IsEqualGUID16(
 	GUID* g1,	/* [in] unique id 1 */
-	GUID* g2	/* [in] unique id 2 */
+	GUID* g2	/**/
 ) {
     return !memcmp( g1, g2, sizeof(GUID) );
 }
 
+/***********************************************************************
+ *           IsEqualGUID32 [OLE32.76]
+ *
+ * Compares two Unique Identifiers.
+ *
+ * RETURNS
+ *	TRUE if equal
+ */
+BOOL32 WINAPI IsEqualGUID32(
+     REFGUID rguid1, /* [in] unique id 1 */
+     REFGUID rguid2  /* [in] unique id 2 */
+     )
+{
+    return !memcmp(rguid1,rguid2,sizeof(GUID));
+}
+
 /******************************************************************************
  *		CLSIDFromString16	[COMPOBJ.20]
  * Converts a unique identifier from it's string representation into 
@@ -194,7 +252,7 @@
  * RETURNS
  *	the converted GUID
  */
-OLESTATUS WINAPI CLSIDFromString16(
+HRESULT WINAPI CLSIDFromString16(
 	LPCOLESTR16 idstr,	/* [in] string representation of guid */
 	CLSID *id		/* [out] GUID converted from string */
 ) {
@@ -262,11 +320,19 @@
 
 /******************************************************************************
  *		CoCreateGuid[OLE32.6]
+ *
+ * Creates a 128bit GUID.
  * Implemented according the DCE specification for UUID generation.
  * Code is based upon uuid library in e2fsprogs by Theodore Ts'o.
  * Copyright (C) 1996, 1997 Theodore Ts'o.
+ *
+ * RETURNS
+ *
+ *  S_OK if successful.
  */
-int CoCreateGuid(GUID *pguid) {
+HRESULT WINAPI CoCreateGuid(
+	GUID *pguid /* [out] points to the GUID to initialize */
+) {
    static char has_init = 0;
    unsigned char a[6];
    static int                      adjustment = 0;
@@ -458,7 +524,7 @@
  * RETURNS
  *	the converted GUID
  */
-OLESTATUS WINAPI CLSIDFromString32(
+HRESULT WINAPI CLSIDFromString32(
 	LPCOLESTR32 idstr,	/* [in] string representation of GUID */
 	CLSID *id		/* [out] GUID represented by above string */
 ) {
@@ -474,12 +540,11 @@
  * Converts a GUID into the respective string representation.
  *
  * NOTES
- *    Why is this WINAPI?
  *
  * RETURNS
  *	the string representation and OLESTATUS
  */
-OLESTATUS WINAPI WINE_StringFromCLSID(
+HRESULT WINE_StringFromCLSID(
 	const CLSID *id,	/* [in] GUID to be converted */
 	LPSTR idstr		/* [out] pointer to buffer to contain converted guid */
 ) {
@@ -519,7 +584,7 @@
  * RETURNS
  *	the string representation and OLESTATUS
  */
-OLESTATUS WINAPI StringFromCLSID16(
+HRESULT WINAPI StringFromCLSID16(
 	const CLSID *id,	/* [in] the GUID to be converted */
 	LPOLESTR16 *idstr	/* [out] a pointer to a to-be-allocated segmented pointer pointing to the resulting string */
 
@@ -538,7 +603,7 @@
      * everything we need.
      */
     if (!WOWCallback16Ex(
-    	(FARPROC16)((LPMALLOC16_VTABLE)PTR_SEG_TO_LIN(
+    	(FARPROC16)((ICOM_VTABLE(IMalloc16)*)PTR_SEG_TO_LIN(
 		((LPMALLOC16)PTR_SEG_TO_LIN(mllc))->lpvtbl)
 	)->fnAlloc,
 	WCB16_CDECL,
@@ -559,7 +624,7 @@
  * RETURNS
  *	the string representation and OLESTATUS
  */
-OLESTATUS WINAPI StringFromCLSID32(
+HRESULT WINAPI StringFromCLSID32(
 	const CLSID *id,	/* [in] the GUID to be converted */
 	LPOLESTR32 *idstr	/* [out] a pointer to a to-be-allocated pointer pointing to the resulting string */
 ) {
@@ -607,7 +672,7 @@
  * RETURNS
  *	riid associated with the progid
  */
-OLESTATUS WINAPI CLSIDFromProgID16(
+HRESULT WINAPI CLSIDFromProgID16(
 	LPCOLESTR16 progid,	/* [in] program id as found in registry */
 	LPCLSID riid		/* [out] associated CLSID */
 ) {
@@ -638,7 +703,7 @@
  * RETURNS
  *	riid associated with the progid
  */
-OLESTATUS WINAPI CLSIDFromProgID32(
+HRESULT WINAPI CLSIDFromProgID32(
 	LPCOLESTR32 progid,	/* [in] program id as found in registry */
 	LPCLSID riid		/* [out] associated CLSID */
 ) {
@@ -649,6 +714,7 @@
 	return ret;
 }
 
+/* FIXME: this function is not declared in the WINELIB headers. But where should it go ? */
 /***********************************************************************
  *           LookupETask (COMPOBJ.94)
  */
@@ -660,6 +726,7 @@
 	return 0;
 }
 
+/* FIXME: this function is not declared in the WINELIB headers. But where should it go ? */
 /***********************************************************************
  *           SetETask (COMPOBJ.95)
  */
@@ -669,6 +736,7 @@
 	return 0;
 }
 
+/* FIXME: this function is not declared in the WINELIB headers. But where should it go ? */
 /***********************************************************************
  *           CallObjectInWOW (COMPOBJ.201)
  */
@@ -682,11 +750,11 @@
  *
  * Don't know where it registers it ...
  */
-OLESTATUS WINAPI CoRegisterClassObject16(
+HRESULT WINAPI CoRegisterClassObject16(
 	REFCLSID rclsid,
 	LPUNKNOWN pUnk,
-	DWORD dwClsContext,
-	DWORD flags,
+	DWORD dwClsContext, /* [in] CLSCTX flags indicating the context in which to run the executable */
+	DWORD flags,        /* [in] REGCLS flags indicating how connections are made */
 	LPDWORD lpdwRegister
 ) {
 	char	buf[80];
@@ -704,11 +772,11 @@
  *
  * Don't know where it registers it ...
  */
-OLESTATUS WINAPI CoRegisterClassObject32(
+HRESULT WINAPI CoRegisterClassObject32(
 	REFCLSID rclsid,
 	LPUNKNOWN pUnk,
-	DWORD dwClsContext,
-	DWORD flags,
+	DWORD dwClsContext, /* [in] CLSCTX flags indicating the context in which to run the executable */
+	DWORD flags,        /* [in] REGCLS flags indicating how connections are made */
 	LPDWORD lpdwRegister
 ) {
     char buf[80];
@@ -799,7 +867,7 @@
 /******************************************************************************
  *		CoRegisterMessageFilter16	[COMPOBJ.27]
  */
-OLESTATUS WINAPI CoRegisterMessageFilter16(
+HRESULT WINAPI CoRegisterMessageFilter16(
 	LPMESSAGEFILTER lpMessageFilter,
 	LPMESSAGEFILTER *lplpMessageFilter
 ) {
@@ -837,8 +905,8 @@
 
         hres = CoGetClassObject(rclsid, dwClsContext, NULL, (const REFIID) &IID_IClassFactory, (LPVOID)&lpclf);
         if (!SUCCEEDED(hres)) return hres;
-	hres = lpclf->lpvtbl->fnCreateInstance(lpclf, pUnkOuter, iid, ppv);
-	lpclf->lpvtbl->fnRelease(lpclf);
+	hres = IClassFactory_CreateInstance(lpclf, pUnkOuter, iid, ppv);
+	IClassFactory_Release(lpclf);
 	return hres;
 #endif
 }
@@ -968,7 +1036,7 @@
 /***********************************************************************
  *           CoLoadLibrary (OLE32.30)
  */
-HINSTANCE32 WINAPI CoLoadLibrary(LPSTR lpszLibName, BOOL32 bAutoFree)
+HINSTANCE32 WINAPI CoLoadLibrary(LPOLESTR16 lpszLibName, BOOL32 bAutoFree)
 {
     HINSTANCE32 hLibrary;
     OpenDll *ptr;
diff --git a/ole/ifs.c b/ole/ifs.c
index 9e8ebca..5fb8031 100644
--- a/ole/ifs.c
+++ b/ole/ifs.c
@@ -9,24 +9,17 @@
 #include <string.h>
 #include <assert.h>
 #include "winerror.h"
-#include "ole.h"
-#include "ole2.h"
 #include "ldt.h"
 #include "heap.h"
-#include "compobj.h"
-#include "interfaces.h"
-#include "shlobj.h"
+#include "wine/obj_base.h"
+#include "objbase.h"
 #include "local.h"
 #include "module.h"
 #include "debug.h"
 
+
 /* --- IUnknown implementation */
 
-typedef struct _IUnknown {
-        /* IUnknown fields */
-        ICOM_VTABLE(IUnknown)*  lpvtbl;
-        DWORD                   ref;
-} _IUnknown;
 
 /******************************************************************************
  *		IUnknown_AddRef	[VTABLE:IUNKNOWN.1]
@@ -86,30 +79,26 @@
 	return (LPUNKNOWN)unk;
 }
 
-/*
- * IMalloc
- */
 
-/******************************************************************************
- *		IMalloc16_AddRef	[COMPOBJ.501]
- */
-ULONG WINAPI IMalloc16_AddRef(LPMALLOC16 this) {
-	TRACE(relay,"(%p)->AddRef()\n",this);
-	return 1; /* cannot be freed */
-}
+/* --- IMalloc16 implementation */
 
-/******************************************************************************
- *		IMalloc16_Release	[COMPOBJ.502]
+
+typedef struct _IMalloc16 {
+        /* IUnknown fields */
+        ICOM_VTABLE(IMalloc16)* lpvtbl;
+        DWORD                   ref;
+        /* IMalloc16 fields */
+        /* Gmm, I think one is not enough, we should probably manage a list of
+         * heaps
  */
-ULONG WINAPI IMalloc16_Release(LPMALLOC16 this) {
-	TRACE(relay,"(%p)->Release()\n",this);
-	return 1; /* cannot be freed */
-}
+        HGLOBAL16 heap;
+} _IMalloc16;
 
 /******************************************************************************
  *		IMalloc16_QueryInterface	[COMPOBJ.500]
  */
-HRESULT WINAPI IMalloc16_QueryInterface(LPMALLOC16 this,REFIID refiid,LPVOID *obj) {
+HRESULT WINAPI IMalloc16_fnQueryInterface(LPUNKNOWN iface,REFIID refiid,LPVOID *obj) {
+        ICOM_THIS(IMalloc16,iface);
 	char	xrefiid[50];
 
 	WINE_StringFromCLSID((LPCLSID)refiid,xrefiid);
@@ -124,9 +113,28 @@
 }
 
 /******************************************************************************
+ *		IMalloc16_AddRef	[COMPOBJ.501]
+ */
+ULONG WINAPI IMalloc16_fnAddRef(LPUNKNOWN iface) {
+        ICOM_THIS(IMalloc16,iface);
+	TRACE(relay,"(%p)->AddRef()\n",this);
+	return 1; /* cannot be freed */
+}
+
+/******************************************************************************
+ *		IMalloc16_Release	[COMPOBJ.502]
+ */
+ULONG WINAPI IMalloc16_fnRelease(LPUNKNOWN iface) {
+        ICOM_THIS(IMalloc16,iface);
+	TRACE(relay,"(%p)->Release()\n",this);
+	return 1; /* cannot be freed */
+}
+
+/******************************************************************************
  * IMalloc16_Alloc [COMPOBJ.503]
  */
-LPVOID WINAPI IMalloc16_Alloc(LPMALLOC16 this,DWORD cb) {
+LPVOID WINAPI IMalloc16_fnAlloc(IMalloc16* iface,DWORD cb) {
+        ICOM_THIS(IMalloc16,iface);
 	TRACE(relay,"(%p)->Alloc(%ld)\n",this,cb);
 	return (LPVOID)PTR_SEG_OFF_TO_SEGPTR(this->heap,LOCAL_Alloc(this->heap,0,cb));
 }
@@ -134,7 +142,8 @@
 /******************************************************************************
  * IMalloc16_Realloc [COMPOBJ.504]
  */
-LPVOID WINAPI IMalloc16_Realloc(LPMALLOC16 this,LPVOID pv,DWORD cb) {
+LPVOID WINAPI IMalloc16_fnRealloc(IMalloc16* iface,LPVOID pv,DWORD cb) {
+        ICOM_THIS(IMalloc16,iface);
 	TRACE(relay,"(%p)->Realloc(%p,%ld)\n",this,pv,cb);
 	return (LPVOID)PTR_SEG_OFF_TO_SEGPTR(this->heap,LOCAL_ReAlloc(this->heap,0,LOWORD(pv),cb));
 }
@@ -142,7 +151,8 @@
 /******************************************************************************
  * IMalloc16_Free [COMPOBJ.505]
  */
-VOID WINAPI IMalloc16_Free(LPMALLOC16 this,LPVOID pv) {
+VOID WINAPI IMalloc16_fnFree(IMalloc16* iface,LPVOID pv) {
+        ICOM_THIS(IMalloc16,iface);
 	TRACE(relay,"(%p)->Free(%p)\n",this,pv);
 	LOCAL_Free(this->heap,LOWORD(pv));
 }
@@ -150,7 +160,8 @@
 /******************************************************************************
  * IMalloc16_GetSize [COMPOBJ.506]
  */
-DWORD WINAPI IMalloc16_GetSize(LPMALLOC16 this,LPVOID pv) {
+DWORD WINAPI IMalloc16_fnGetSize(const IMalloc16* iface,LPVOID pv) {
+	ICOM_CTHIS(IMalloc16,iface);
 	TRACE(relay,"(%p)->GetSize(%p)\n",this,pv);
 	return LOCAL_Size(this->heap,LOWORD(pv));
 }
@@ -158,7 +169,8 @@
 /******************************************************************************
  * IMalloc16_DidAlloc [COMPOBJ.507]
  */
-INT16 WINAPI IMalloc16_DidAlloc(LPMALLOC16 this,LPVOID pv) {
+INT16 WINAPI IMalloc16_fnDidAlloc(const IMalloc16* iface,LPVOID pv) {
+        ICOM_CTHIS(IMalloc16,iface);
 	TRACE(relay,"(%p)->DidAlloc(%p)\n",this,pv);
 	return (INT16)-1;
 }
@@ -166,52 +178,40 @@
 /******************************************************************************
  * IMalloc16_HeapMinimize [COMPOBJ.508]
  */
-LPVOID WINAPI IMalloc16_HeapMinimize(LPMALLOC16 this) {
+LPVOID WINAPI IMalloc16_fnHeapMinimize(IMalloc16* iface) {
+        ICOM_THIS(IMalloc16,iface);
 	TRACE(relay,"(%p)->HeapMinimize()\n",this);
 	return NULL;
 }
 
-#ifdef OLD_TABLE
-/* FIXME: This is unused */
-static IMalloc16_VTable mvt16 = {
-	IMalloc16_QueryInterface,
-	IMalloc16_AddRef,
-	IMalloc16_Release,
-	IMalloc16_Alloc,
-	IMalloc16_Realloc,
-	IMalloc16_Free,
-	IMalloc16_GetSize,
-	IMalloc16_DidAlloc,
-	IMalloc16_HeapMinimize,
-};
-#endif
-static IMalloc16_VTable *msegvt16 = NULL;
+static ICOM_VTABLE(IMalloc16)* msegvt16 = NULL;
 
 /******************************************************************************
  * IMalloc16_Constructor [VTABLE]
  */
 LPMALLOC16
 IMalloc16_Constructor() {
-	LPMALLOC16	this;
+	_IMalloc16*	this;
         HMODULE16	hcomp = GetModuleHandle16("COMPOBJ");
 
-	this = (LPMALLOC16)SEGPTR_NEW(IMalloc16);
+	this = (_IMalloc16*)SEGPTR_NEW(_IMalloc16);
         if (!msegvt16) {
-            this->lpvtbl = msegvt16 = SEGPTR_NEW(IMalloc16_VTable);
+            this->lpvtbl = msegvt16 = SEGPTR_NEW(ICOM_VTABLE(IMalloc16));
 
-#define FN(x) this->lpvtbl->fn##x = (void*)WIN32_GetProcAddress16(hcomp,"IMalloc16_"#x);assert(this->lpvtbl->fn##x)
-            FN(QueryInterface);
-            FN(AddRef);
-            FN(Release);
-            FN(Alloc);
-            FN(Realloc);
-            FN(Free);
-            FN(GetSize);
-            FN(DidAlloc);
-            FN(HeapMinimize);
-            msegvt16 = (LPMALLOC16_VTABLE)SEGPTR_GET(msegvt16);
-#undef FN
-            this->lpvtbl = msegvt16;
+#define VTENT(x) msegvt16->bvt.fn##x = (void*)WIN32_GetProcAddress16(hcomp,"IMalloc16_"#x);assert(msegvt16->bvt.fn##x)
+            VTENT(QueryInterface);
+            VTENT(AddRef);
+            VTENT(Release);
+#undef VTENT
+#define VTENT(x) msegvt16->fn##x = (void*)WIN32_GetProcAddress16(hcomp,"IMalloc16_"#x);assert(msegvt16->fn##x)
+            VTENT(Alloc);
+            VTENT(Realloc);
+            VTENT(Free);
+            VTENT(GetSize);
+            VTENT(DidAlloc);
+            VTENT(HeapMinimize);
+            msegvt16 = (ICOM_VTABLE(IMalloc16)*)SEGPTR_GET(msegvt16);
+#undef VTENT
 	}
 	this->ref = 1;
 	/* FIXME: implement multiple heaps */
@@ -220,30 +220,20 @@
 	return (LPMALLOC16)SEGPTR_GET(this);
 }
 
-/*
- * IMalloc32
- */
 
-/******************************************************************************
- *		IMalloc32_AddRef	[VTABLE]
- */
-static ULONG WINAPI IMalloc32_AddRef(LPMALLOC32 this) {
-	TRACE(relay,"(%p)->AddRef()\n",this);
-	return 1; /* cannot be freed */
-}
+/* --- IMalloc32 implementation */
 
-/******************************************************************************
- *		IMalloc32_Release	[VTABLE]
- */
-static ULONG WINAPI IMalloc32_Release(LPMALLOC32 this) {
-	TRACE(relay,"(%p)->Release()\n",this);
-	return 1; /* cannot be freed */
-}
+typedef struct _IMalloc32 {
+        /* IUnknown fields */
+        ICOM_VTABLE(IMalloc32)* lpvtbl;
+        DWORD                   ref;
+} _IMalloc32;
 
 /******************************************************************************
  *		IMalloc32_QueryInterface	[VTABLE]
  */
-static HRESULT WINAPI IMalloc32_QueryInterface(LPMALLOC32 this,REFIID refiid,LPVOID *obj) {
+static HRESULT WINAPI IMalloc32_fnQueryInterface(LPUNKNOWN iface,REFIID refiid,LPVOID *obj) {
+	ICOM_THIS(IMalloc32,iface);
 	char	xrefiid[50];
 
 	WINE_StringFromCLSID((LPCLSID)refiid,xrefiid);
@@ -252,15 +242,34 @@
 		!memcmp(&IID_IMalloc,refiid,sizeof(IID_IMalloc))
 	) {
 		*obj = this;
-		return 0;
+		return S_OK;
 	}
 	return OLE_E_ENUM_NOMORE; 
 }
 
 /******************************************************************************
+ *		IMalloc32_AddRef	[VTABLE]
+ */
+static ULONG WINAPI IMalloc32_fnAddRef(LPUNKNOWN iface) {
+	ICOM_THIS(IMalloc32,iface);
+	TRACE(relay,"(%p)->AddRef()\n",this);
+	return 1; /* cannot be freed */
+}
+
+/******************************************************************************
+ *		IMalloc32_Release	[VTABLE]
+ */
+static ULONG WINAPI IMalloc32_fnRelease(LPUNKNOWN iface) {
+	ICOM_THIS(IMalloc32,iface);
+	TRACE(relay,"(%p)->Release()\n",this);
+	return 1; /* cannot be freed */
+}
+
+/******************************************************************************
  * IMalloc32_Alloc [VTABLE]
  */
-static LPVOID WINAPI IMalloc32_Alloc(LPMALLOC32 this,DWORD cb) {
+static LPVOID WINAPI IMalloc32_fnAlloc(LPMALLOC32 iface,DWORD cb) {
+	ICOM_THIS(IMalloc32,iface);
 	TRACE(relay,"(%p)->Alloc(%ld)\n",this,cb);
 	return HeapAlloc(GetProcessHeap(),0,cb);
 }
@@ -268,7 +277,8 @@
 /******************************************************************************
  * IMalloc32_Realloc [VTABLE]
  */
-static LPVOID WINAPI IMalloc32_Realloc(LPMALLOC32 this,LPVOID pv,DWORD cb) {
+static LPVOID WINAPI IMalloc32_fnRealloc(LPMALLOC32 iface,LPVOID pv,DWORD cb) {
+	ICOM_THIS(IMalloc32,iface);
 	TRACE(relay,"(%p)->Realloc(%p,%ld)\n",this,pv,cb);
 	return HeapReAlloc(GetProcessHeap(),0,pv,cb);
 }
@@ -276,7 +286,8 @@
 /******************************************************************************
  * IMalloc32_Free [VTABLE]
  */
-static VOID WINAPI IMalloc32_Free(LPMALLOC32 this,LPVOID pv) {
+static VOID WINAPI IMalloc32_fnFree(LPMALLOC32 iface,LPVOID pv) {
+	ICOM_THIS(IMalloc32,iface);
 	TRACE(relay,"(%p)->Free(%p)\n",this,pv);
 	HeapFree(GetProcessHeap(),0,pv);
 }
@@ -284,7 +295,8 @@
 /******************************************************************************
  * IMalloc32_GetSize [VTABLE]
  */
-static DWORD WINAPI IMalloc32_GetSize(LPMALLOC32 this,LPVOID pv) {
+static DWORD WINAPI IMalloc32_fnGetSize(const IMalloc32* iface,LPVOID pv) {
+	ICOM_CTHIS(IMalloc32,iface);
 	TRACE(relay,"(%p)->GetSize(%p)\n",this,pv);
 	return HeapSize(GetProcessHeap(),0,pv);
 }
@@ -292,7 +304,8 @@
 /******************************************************************************
  * IMalloc32_DidAlloc [VTABLE]
  */
-static INT32 WINAPI IMalloc32_DidAlloc(LPMALLOC32 this,LPVOID pv) {
+static INT32 WINAPI IMalloc32_fnDidAlloc(const IMalloc32* iface,LPVOID pv) {
+	ICOM_CTHIS(IMalloc32,iface);
 	TRACE(relay,"(%p)->DidAlloc(%p)\n",this,pv);
 	return -1;
 }
@@ -300,21 +313,24 @@
 /******************************************************************************
  * IMalloc32_HeapMinimize [VTABLE]
  */
-static LPVOID WINAPI IMalloc32_HeapMinimize(LPMALLOC32 this) {
+static LPVOID WINAPI IMalloc32_fnHeapMinimize(LPMALLOC32 iface) {
+	ICOM_THIS(IMalloc32,iface);
 	TRACE(relay,"(%p)->HeapMinimize()\n",this);
 	return NULL;
 }
 
-static IMalloc32_VTable VT_IMalloc32 = {
-	IMalloc32_QueryInterface,
-	IMalloc32_AddRef,
-	IMalloc32_Release,
-	IMalloc32_Alloc,
-	IMalloc32_Realloc,
-	IMalloc32_Free,
-	IMalloc32_GetSize,
-	IMalloc32_DidAlloc,
-	IMalloc32_HeapMinimize,
+static ICOM_VTABLE(IMalloc32) VT_IMalloc32 = {
+  {
+    IMalloc32_fnQueryInterface,
+    IMalloc32_fnAddRef,
+    IMalloc32_fnRelease
+  },
+  IMalloc32_fnAlloc,
+  IMalloc32_fnRealloc,
+  IMalloc32_fnFree,
+  IMalloc32_fnGetSize,
+  IMalloc32_fnDidAlloc,
+  IMalloc32_fnHeapMinimize
 };
 
 /******************************************************************************
@@ -322,12 +338,12 @@
  */
 LPMALLOC32
 IMalloc32_Constructor() {
-	LPMALLOC32	this;
+	_IMalloc32* this;
 
-	this = (LPMALLOC32)HeapAlloc(GetProcessHeap(),0,sizeof(IMalloc32));
+	this = (_IMalloc32*)HeapAlloc(GetProcessHeap(),0,sizeof(_IMalloc32));
 	this->lpvtbl = &VT_IMalloc32;
 	this->ref = 1;
-	return this;
+	return (LPMALLOC32)this;
 }
 
 /****************************************************************************
diff --git a/ole/moniker.c b/ole/moniker.c
index 7c1d88a..9bc2171 100644
--- a/ole/moniker.c
+++ b/ole/moniker.c
@@ -9,16 +9,9 @@
 #include <string.h>
 #include <assert.h>
 #include "winerror.h"
-#include "ole.h"
-#include "ole2.h"
-#include "ldt.h"
-#include "heap.h"
-#include "compobj.h"
-#include "interfaces.h"
-#include "storage.h"
-#include "shlobj.h"
-#include "local.h"
-#include "module.h"
+#include "wine/obj_base.h"
+#include "wine/obj_storage.h"
+#include "wine/obj_moniker.h"
 #include "debug.h"
 
 /******************************************************************************
diff --git a/ole/ole2.c b/ole/ole2.c
index d0a4706..b472ab3 100644
--- a/ole/ole2.c
+++ b/ole/ole2.c
@@ -9,7 +9,10 @@
 #include "ole2.h"
 #include "process.h"
 #include "debug.h"
-#include "compobj.h"
+#include "wine/obj_base.h"
+#include "wine/obj_clientserver.h"
+#include "wine/obj_storage.h"
+#include "wine/obj_moniker.h"
 
 /******************************************************************************
  *		OleBuildVersion	[OLE2.1]
diff --git a/ole/ole2disp.c b/ole/ole2disp.c
index 2582b44..dea2df1 100644
--- a/ole/ole2disp.c
+++ b/ole/ole2disp.c
@@ -9,7 +9,9 @@
 #include "ole.h"
 #include "ole2.h"
 #include "oleauto.h"
-#include "interfaces.h"
+#include "wtypes.h"
+#include "wine/obj_base.h"
+#include "objbase.h"
 #include "heap.h"
 #include "ldt.h"
 #include "debug.h"
diff --git a/ole/oledlg.c b/ole/oledlg.c
index 8b010f2..8aef25b 100644
--- a/ole/oledlg.c
+++ b/ole/oledlg.c
@@ -9,7 +9,7 @@
 #include "winerror.h"
 #include "ole.h"
 #include "oledlg.h"
-#include "compobj.h"
+#include "wine/obj_base.h"
 #include "debug.h"
 
 /***********************************************************************
diff --git a/ole/oleobj.c b/ole/oleobj.c
index b7802c7..cc4427d 100644
--- a/ole/oleobj.c
+++ b/ole/oleobj.c
@@ -8,10 +8,13 @@
 #include "ole.h"
 #include "ole2.h"
 #include "winerror.h"
-#include "interfaces.h"
+#include "windows.h"
+#include "wine/obj_base.h"
+#include "wine/obj_storage.h"
+#include "wine/obj_moniker.h"
+#include "wine/obj_dataobject.h"
 #include "oleobj.h"
 #include "debug.h"
-#include "windows.h"
 
 
 #define IsEqualGUID(rguid1, rguid2) (!memcmp(rguid1, rguid2, sizeof(GUID)))
diff --git a/ole/storage.c b/ole/storage.c
index 1e9de4c..736449b 100644
--- a/ole/storage.c
+++ b/ole/storage.c
@@ -14,15 +14,46 @@
 #include "winerror.h"
 #include "file.h"
 #include "ole.h"
-#include "ole2.h"
-#include "compobj.h"
-#include "interfaces.h"
-#include "storage.h"
+#include "wine/obj_base.h"
+#include "wine/obj_storage.h"
+#include "objbase.h"
 #include "heap.h"
 #include "module.h"
 #include "ldt.h"
 #include "debug.h"
 
+struct storage_header {
+	BYTE	magic[8];	/* 00: magic */
+	BYTE	unknown1[36];	/* 08: unknown */
+	DWORD	num_of_bbd_blocks;/* 2C: length of big datablocks */
+	DWORD	root_startblock;/* 30: root storage first big block */
+	DWORD	unknown2[2];	/* 34: unknown */
+	DWORD	sbd_startblock;	/* 3C: small block depot first big block */
+	DWORD	unknown3[3];	/* 40: unknown */
+	DWORD	bbd_list[109];	/* 4C: big data block list (up to end of sector)*/
+};
+struct storage_pps_entry {
+	WCHAR	pps_rawname[32];/* 00: \0 terminated widechar name */
+	WORD	pps_sizeofname;	/* 40: namelength in bytes */
+	BYTE	pps_type;	/* 42: flags, 1 storage/dir, 2 stream, 5 root */
+	BYTE	pps_unknown0;	/* 43: unknown */
+	DWORD	pps_prev;	/* 44: previous pps */
+	DWORD	pps_next;	/* 48: next pps */
+	DWORD	pps_dir;	/* 4C: directory pps */
+	GUID	pps_guid;	/* 50: class ID */
+	DWORD	pps_unknown1;	/* 60: unknown */
+	FILETIME pps_ft1;	/* 64: filetime1 */
+	FILETIME pps_ft2;	/* 70: filetime2 */
+	DWORD	pps_sb;		/* 74: data startblock */
+	DWORD	pps_size;	/* 78: datalength. (<0x1000)?small:big blocks*/
+	DWORD	pps_unknown2;	/* 7C: unknown */
+};
+
+#define STORAGE_CHAINENTRY_FAT		0xfffffffd
+#define STORAGE_CHAINENTRY_ENDOFCHAIN	0xfffffffe
+#define STORAGE_CHAINENTRY_FREE		0xffffffff
+
+
 static const BYTE STORAGE_magic[8]   ={0xd0,0xcf,0x11,0xe0,0xa1,0xb1,0x1a,0xe1};
 static const BYTE STORAGE_notmagic[8]={0x0e,0x11,0xfc,0x0d,0xd0,0xcf,0x11,0xe0};
 static const BYTE STORAGE_oldmagic[8]={0xd0,0xcf,0x11,0xe0,0x0e,0x11,0xfc,0x0d};
@@ -732,14 +763,14 @@
 	if (this->offset.LowPart>this->stde.pps_size)
 		this->offset.LowPart=this->stde.pps_size;
 	if (newpos) *newpos = this->offset;
-	return OLE_OK;
+	return S_OK;
 }
 
 /******************************************************************************
  *		IStream16_Read	[STORAGE.521]
  */
 HRESULT WINAPI IStream16_fnRead(
-        LPSTREAM16 iface,void  *pv,ULONG cb,ULONG  *pcbRead
+        LPSEQUENTIALSTREAM iface,void  *pv,ULONG cb,ULONG  *pcbRead
 ) {
 	ICOM_THIS(IStream16,iface);
 	BYTE	block[BIGSIZE];
@@ -793,14 +824,14 @@
 			blocknr=STORAGE_get_next_big_blocknr(this->hf,blocknr);
 		}
 	}
-	return OLE_OK;
+	return S_OK;
 }
 
 /******************************************************************************
  *		IStream16_Write	[STORAGE.522]
  */
 HRESULT WINAPI IStream16_fnWrite(
-        LPSTREAM16 iface,const void *pv,ULONG cb,ULONG *pcbWrite
+        LPSEQUENTIALSTREAM iface,const void *pv,ULONG cb,ULONG *pcbWrite
 ) {
 	ICOM_THIS(IStream16,iface);
 	BYTE	block[BIGSIZE];
@@ -1055,7 +1086,7 @@
 			blocknr = STORAGE_get_next_big_blocknr(hf,blocknr);
 		}
 	}
-	return OLE_OK;
+	return S_OK;
 }
 
 /******************************************************************************
@@ -1064,50 +1095,54 @@
 static void _create_istream16(LPSTREAM16 *str) {
 	_IStream16*	lpst;
 
-	if (!strvt16.bvt.fnQueryInterface) {
+	if (!strvt16.bvt.bvt.fnQueryInterface) {
 		HMODULE16	wp = GetModuleHandle16("STORAGE");
 		if (wp>=32) {
 		  /* FIXME: what is this WIN32_GetProcAddress16. Should the name be IStream16_QueryInterface of IStream16_fnQueryInterface */
-#define VTENT(xfn)  strvt16.bvt.fn##xfn = (void*)WIN32_GetProcAddress16(wp,"IStream16_"#xfn);
-			VTENT(QueryInterface)
-			VTENT(AddRef)
-			VTENT(Release)
+#define VTENT(xfn)  strvt16.bvt.bvt.fn##xfn = (void*)WIN32_GetProcAddress16(wp,"IStream16_"#xfn);assert(strvt16.bvt.bvt.fn##xfn)
+			VTENT(QueryInterface);
+			VTENT(AddRef);
+			VTENT(Release);
 #undef VTENT
-#define VTENT(xfn)  strvt16.fn##xfn = (void*)WIN32_GetProcAddress16(wp,"IStream16_"#xfn);
-			VTENT(Read)
-			VTENT(Write)
-			VTENT(Seek)
-			VTENT(SetSize)
-			VTENT(CopyTo)
-			VTENT(Commit)
-			VTENT(Revert)
-			VTENT(LockRegion)
-			VTENT(UnlockRegion)
-			VTENT(Stat)
-			VTENT(Clone)
+#define VTENT(xfn)  strvt16.bvt.fn##xfn = (void*)WIN32_GetProcAddress16(wp,"IStream16_"#xfn);assert(strvt16.bvt.fn##xfn)
+			VTENT(Read);
+			VTENT(Write);
+#undef VTENT
+#define VTENT(xfn)  strvt16.fn##xfn = (void*)WIN32_GetProcAddress16(wp,"IStream16_"#xfn);assert(strvt16.fn##xfn)
+			VTENT(Seek);
+			VTENT(SetSize);
+			VTENT(CopyTo);
+			VTENT(Commit);
+			VTENT(Revert);
+			VTENT(LockRegion);
+			VTENT(UnlockRegion);
+			VTENT(Stat);
+			VTENT(Clone);
 #undef VTENT
 			segstrvt16 = SEGPTR_NEW(ICOM_VTABLE(IStream16));
 			memcpy(segstrvt16,&strvt16,sizeof(strvt16));
 			segstrvt16 = (ICOM_VTABLE(IStream16)*)SEGPTR_GET(segstrvt16);
 		} else {
+#define VTENT(xfn) strvt16.bvt.bvt.fn##xfn = IStream16_fn##xfn;
+			VTENT(QueryInterface);
+			VTENT(AddRef);
+			VTENT(Release);
+#undef VTENT
 #define VTENT(xfn) strvt16.bvt.fn##xfn = IStream16_fn##xfn;
-			VTENT(QueryInterface)
-			VTENT(AddRef)
-			VTENT(Release)
+			VTENT(Read);
+			VTENT(Write);
 #undef VTENT
 #define VTENT(xfn) strvt16.fn##xfn = IStream16_fn##xfn;
-			VTENT(Read)
-			VTENT(Write)
-			VTENT(Seek)
+			VTENT(Seek);
 	/*
-			VTENT(CopyTo)
-			VTENT(Commit)
-			VTENT(SetSize)
-			VTENT(Revert)
-			VTENT(LockRegion)
-			VTENT(UnlockRegion)
-			VTENT(Stat)
-			VTENT(Clone)
+			VTENT(CopyTo);
+			VTENT(Commit);
+			VTENT(SetSize);
+			VTENT(Revert);
+			VTENT(LockRegion);
+			VTENT(UnlockRegion);
+			VTENT(Stat);
+			VTENT(Clone);
 	*/
 #undef VTENT
 			segstrvt16 = &strvt16;
@@ -1178,12 +1213,14 @@
 
 static ICOM_VTABLE(IStream32) strvt32 = {
 	{
+	  {
 	  IStream32_fnQueryInterface,
 	  IStream32_fnAddRef,
 	  IStream32_fnRelease
 	},
 	(void*)0xdead0004,
-	(void*)0xdead0005,
+	  (void*)0xdead0005
+	},
 	(void*)0xdead0006,
 	(void*)0xdead0007,
 	(void*)0xdead0008,
@@ -1266,7 +1303,7 @@
 	pstatstg->clsid		= this->stde.pps_guid;
 	pstatstg->grfStateBits	= 0; /* FIXME */
 	pstatstg->reserved	= 0;
-	return OLE_OK;
+	return S_OK;
 }
 
 /******************************************************************************
@@ -1279,7 +1316,7 @@
 	FIXME(ole,"(%p)->(0x%08lx),STUB!\n",
 		this,commitflags
 	);
-	return OLE_OK;
+	return S_OK;
 }
 
 /******************************************************************************
@@ -1296,7 +1333,7 @@
 	FIXME(ole,"IStorage16(%p)->(0x%08lx,%s,%p,%p),stub!\n",
 		this,ciidExclude,xguid,SNB16Exclude,pstgDest
 	);
-	return OLE_OK;
+	return S_OK;
 }
 
 
@@ -1357,7 +1394,7 @@
 	/* FIXME: timestamps? */
 	if (!STORAGE_put_pps_entry(lpstg->hf,ppsent,&(lpstg->stde)))
 		return E_FAIL;
-	return OLE_OK;
+	return S_OK;
 }
 
 /******************************************************************************
@@ -1410,7 +1447,7 @@
 	/* FIXME: timestamps? */
 	if (!STORAGE_put_pps_entry(lpstr->hf,ppsent,&(lpstr->stde)))
 		return E_FAIL;
-	return OLE_OK;
+	return S_OK;
 }
 
 /******************************************************************************
@@ -1445,7 +1482,7 @@
 		return E_FAIL;
 	}
 	lpstg->ppsent		= newpps;
-	return OLE_OK;
+	return S_OK;
 }
 
 /******************************************************************************
@@ -1482,7 +1519,7 @@
 	lpstr->offset.LowPart	= 0;
 	lpstr->offset.HighPart	= 0;
 	lpstr->ppsent		= newpps;
-	return OLE_OK;
+	return S_OK;
 }
 
 /******************************************************************************
@@ -1620,7 +1657,7 @@
 	((_IStream32*)(*ppstm))->lpvtbl= &strvt32;
 	((_IStream32*)(*ppstm))->ref	= 1;
 
-	return OLE_OK;
+	return S_OK;
 }
 
 /******************************************************************************
@@ -1636,7 +1673,7 @@
 	*ppstm = (IStream32*)HeapAlloc(GetProcessHeap(),0,sizeof(IStream32));
 	((_IStream32*)(*ppstm))->lpvtbl= &strvt32;
 	((_IStream32*)(*ppstm))->ref	= 1;
-	return OLE_OK;
+	return S_OK;
 }
 
 static ICOM_VTABLE(IStorage32) stvt32 = {
@@ -1669,7 +1706,7 @@
 /******************************************************************************
  *		StgCreateDocFile16	[STORAGE.1]
  */
-OLESTATUS WINAPI StgCreateDocFile16(
+HRESULT WINAPI StgCreateDocFile16(
 	LPCOLESTR16 pwcsName,DWORD grfMode,DWORD reserved,IStorage16 **ppstgOpen
 ) {
 	HFILE32		hf;
@@ -1707,13 +1744,13 @@
 		IStorage16_fnRelease((IUnknown*)lpstg); /* will remove it */
 		return E_FAIL;
 	}
-	return OLE_OK;
+	return S_OK;
 }
 
 /******************************************************************************
- *		StgCreateDocFile32	[OLE32.144]
+ *		StgCreateDocfile32	[OLE32.144]
  */
-OLESTATUS WINAPI StgCreateDocFile32(
+HRESULT WINAPI StgCreateDocfile32(
 	LPCOLESTR32 pwcsName,DWORD grfMode,DWORD reserved,IStorage32 **ppstgOpen
 ) {
 	TRACE(ole,"(%p,0x%08lx,0x%08lx,%p)\n",
@@ -1722,13 +1759,13 @@
 	*ppstgOpen = (IStorage32*)HeapAlloc(GetProcessHeap(),0,sizeof(IStorage32));
 	((_IStorage32*)(*ppstgOpen))->ref = 1;
 	((_IStorage32*)(*ppstgOpen))->lpvtbl = &stvt32;
-	return OLE_OK;
+	return S_OK;
 }
 
 /******************************************************************************
  * StgIsStorageFile16 [STORAGE.5]
  */
-OLESTATUS WINAPI StgIsStorageFile16(LPCOLESTR16 fn) {
+HRESULT WINAPI StgIsStorageFile16(LPCOLESTR16 fn) {
 	HFILE32		hf;
 	OFSTRUCT	ofs;
 	BYTE		magic[24];
@@ -1765,7 +1802,7 @@
 /******************************************************************************
  * StgIsStorageFile32 [OLE32.146]
  */
-OLESTATUS WINAPI 
+HRESULT WINAPI 
 StgIsStorageFile32(LPCOLESTR32 fn) 
 {
 	LPOLESTR16	xfn = HEAP_strdupWtoA(GetProcessHeap(),0,fn);
@@ -1779,7 +1816,7 @@
 /******************************************************************************
  * StgOpenStorage16 [STORAGE.3]
  */
-OLESTATUS WINAPI StgOpenStorage16(
+HRESULT WINAPI StgOpenStorage16(
 	const OLECHAR16 * pwcsName,IStorage16 *pstgPriority,DWORD grfMode,
 	SNB16 snbExclude,DWORD reserved, IStorage16 **ppstgOpen
 ) {
@@ -1813,14 +1850,14 @@
 		IStorage16_fnRelease((IUnknown*)lpstg); /* will remove it */
 		return E_FAIL;
 	}
-	return OLE_OK;
+	return S_OK;
 	
 }
 
 /******************************************************************************
  *		StgOpenStorage32	[OLE32.148]
  */
-OLESTATUS WINAPI StgOpenStorage32(
+HRESULT WINAPI StgOpenStorage32(
 	const OLECHAR32 * pwcsName,IStorage32 *pstgPriority,DWORD grfMode,
 	SNB32 snbExclude,DWORD reserved, IStorage32 **ppstgOpen
 ) {
@@ -1830,7 +1867,7 @@
 	*ppstgOpen = (IStorage32*)HeapAlloc(GetProcessHeap(),0,sizeof(IStorage32));
 	((_IStorage32*)(*ppstgOpen))->ref = 1;
 	((_IStorage32*)(*ppstgOpen))->lpvtbl = &stvt32;
-	return OLE_OK;
+	return S_OK;
 }
 
 
diff --git a/ole/typelib.c b/ole/typelib.c
index 913a839..98a3b04 100644
--- a/ole/typelib.c
+++ b/ole/typelib.c
@@ -12,10 +12,9 @@
 #include "windows.h"
 #include "winreg.h"
 #include "winerror.h"
-#include "ole.h"
-#include "ole2.h"
 #include "oleauto.h"
-#include "compobj.h"
+#include "wine/obj_base.h"
+#include "objbase.h"
 #include "debug.h"
 #include "winversion.h"
 
diff --git a/ole/variant.c b/ole/variant.c
index 6729e19..52a9e3e 100644
--- a/ole/variant.c
+++ b/ole/variant.c
@@ -333,17 +333,7 @@
 		double decimalPart = 0.0;
 		double wholePart = 0.0;
 
-		pTm->tm_sec = 0;
-		pTm->tm_min = 0;
-		pTm->tm_hour = 0;
-		pTm->tm_mday = 0;
-		pTm->tm_mon = 0;
-		pTm->tm_year = 0;
-		pTm->tm_wday = 0;
-		pTm->tm_yday = 0;
-		pTm->tm_isdst = 0;
-		pTm->tm_gmtoff = 0;
-		pTm->tm_zone = 0;
+		memset(pTm,0,sizeof(*pTm));
 	
 		/* Because of the nature of DATE format witch
 		 * associates 2.0 to January 1, 1900. We will
diff --git a/programs/clock/language.c b/programs/clock/language.c
index 7c42191..3dbf11a 100644
--- a/programs/clock/language.c
+++ b/programs/clock/language.c
@@ -187,7 +187,7 @@
   if (Globals.lpszLanguage == "En") {
         PROFILE_GetWineIniString("programs", "language", "En", szBuffer, 
                                   sizeof(szBuffer));       
-        Globals.lpszLanguage = LocalLock(LocalAlloc(LMEM_FIXED, lstrlen(szBuffer)));
+        Globals.lpszLanguage = LocalLock(LocalAlloc(LMEM_FIXED, lstrlen(szBuffer)+1));
 
 /*        hmemcpy(Globals.lpszLanguage, szBuffer, 1+lstrlen(szBuffer));  */
         lstrcpyn(Globals.lpszLanguage, szBuffer, strlen(szBuffer)+1); 
diff --git a/programs/notepad/language.c b/programs/notepad/language.c
index 8cd0983..68372d6 100644
--- a/programs/notepad/language.c
+++ b/programs/notepad/language.c
@@ -147,7 +147,7 @@
 
     PROFILE_GetWineIniString("programs", "language", "language", 
                              buffer, sizeof(buffer));
-  Globals.lpszLanguage = p = LocalLock(LocalAlloc(LMEM_FIXED, lstrlen(buffer)));
+  Globals.lpszLanguage = p = LocalLock(LocalAlloc(LMEM_FIXED, lstrlen(buffer)+1));
   strcpy(p, buffer);
   /* hmemcpy(p, buffer, 1 + lstrlen(buffer)); */
   #endif
diff --git a/programs/progman/main.c b/programs/progman/main.c
index 6f0e985..4023c46 100644
--- a/programs/progman/main.c
+++ b/programs/progman/main.c
@@ -64,13 +64,13 @@
     /* Redirect `progman.ini' */
     PROFILE_GetWineIniString("progman", "progman.ini", "progman.ini", 
 			     buffer, sizeof(buffer));
-    Globals.lpszIniFile = p = LocalLock(LocalAlloc(LMEM_FIXED, lstrlen(buffer)));
+    Globals.lpszIniFile = p = LocalLock(LocalAlloc(LMEM_FIXED, lstrlen(buffer)+1));
     hmemcpy(p, buffer, 1 + lstrlen(buffer));
 
     /* Redirect `progman.ico' */
     PROFILE_GetWineIniString("progman", "progman.ico", "progman.ico", 
 			     buffer, sizeof(buffer));
-    Globals.lpszIcoFile = p = LocalLock(LocalAlloc(LMEM_FIXED, lstrlen(buffer)));
+    Globals.lpszIcoFile = p = LocalLock(LocalAlloc(LMEM_FIXED, lstrlen(buffer)+1));
     hmemcpy(p, buffer, 1 + lstrlen(buffer));
   }
 #endif
diff --git a/relay32/builtin32.c b/relay32/builtin32.c
index 55f3fcf..c066e22 100644
--- a/relay32/builtin32.c
+++ b/relay32/builtin32.c
@@ -10,6 +10,7 @@
 #include "peexe.h"
 #include "heap.h"
 #include "debug.h"
+#include "main.h"
 
 typedef struct
 {
diff --git a/relay32/comctl32.spec b/relay32/comctl32.spec
index 3a2f96e..6eabd41 100644
--- a/relay32/comctl32.spec
+++ b/relay32/comctl32.spec
@@ -23,7 +23,7 @@
  15 stub DrawInsert
  16 stdcall CreateUpDownControl(long long long long long long long long long long long long) CreateUpDownControl
  17 stdcall InitCommonControls() InitCommonControls
- 18 stub CreatePropertySheetPage
+ 18 stdcall CreatePropertySheetPage(ptr) CreatePropertySheetPage32AW
  19 stdcall CreatePropertySheetPageA(ptr) CreatePropertySheetPage32A
  20 stdcall CreatePropertySheetPageW(ptr) CreatePropertySheetPage32W
  21 stdcall CreateStatusWindow(long str long long) CreateStatusWindow32AW
@@ -34,16 +34,16 @@
  26 stub DllInstall
  27 stdcall DrawStatusText(long ptr ptr long) DrawStatusText32AW
  28 stdcall DrawStatusTextW(long ptr wstr long) DrawStatusText32W
- 29 stub FlatSB_EnableScrollBar
- 30 stub FlatSB_GetScrollInfo
- 31 stub FlatSB_GetScrollPos
- 32 stub FlatSB_GetScrollProp
- 33 stub FlatSB_GetScrollRange
- 34 stub FlatSB_SetScrollInfo
- 35 stub FlatSB_SetScrollPos
- 36 stub FlatSB_SetScrollProp
- 37 stub FlatSB_SetScrollRange
- 38 stub FlatSB_ShowScrollBar
+ 29 stdcall FlatSB_EnableScrollBar (long long long) FlatSB_EnableScrollBar
+ 30 stdcall FlatSB_GetScrollInfo (long long ptr) FlatSB_GetScrollInfo
+ 31 stdcall FlatSB_GetScrollPos (long long) FlatSB_GetScrollPos
+ 32 stdcall FlatSB_GetScrollProp (long long ptr) FlatSB_GetScrollProp
+ 33 stdcall FlatSB_GetScrollRange (long long ptr ptr) FlatSB_GetScrollRange
+ 34 stdcall FlatSB_SetScrollInfo (long long ptr long) FlatSB_SetScrollInfo
+ 35 stdcall FlatSB_SetScrollPos (long long long long) FlatSB_SetScrollPos
+ 36 stdcall FlatSB_SetScrollProp (long long long long) FlatSB_SetScrollProp
+ 37 stdcall FlatSB_SetScrollRange (long long long long long) FlatSB_SetScrollRange
+ 38 stdcall FlatSB_ShowScrollBar (long long long) FlatSB_ShowScrollBar
  39 stdcall ImageList_Add(ptr long long) ImageList_Add
  40 stdcall ImageList_AddIcon(ptr long) ImageList_AddIcon
  41 stdcall ImageList_AddMasked(ptr long long) ImageList_AddMasked
@@ -87,11 +87,11 @@
  79 stdcall ImageList_SetOverlayImage(ptr long long) ImageList_SetOverlayImage
  80 stdcall ImageList_Write(ptr ptr) ImageList_Write
  81 stdcall InitCommonControlsEx(ptr) InitCommonControlsEx
- 82 stub InitializeFlatSB
- 83 stub PropertySheet
+ 82 stdcall InitializeFlatSB(long) InitializeFlatSB
+ 83 stdcall PropertySheet(ptr) PropertySheet32AW
  84 stdcall PropertySheetA(ptr) PropertySheet32A
  85 stdcall PropertySheetW(ptr) PropertySheet32W
- 86 stub UninitializeFlatSB
+ 86 stdcall UninitializeFlatSB(long) UninitializeFlatSB
  87 stub _TrackMouseEvent
 
 151 stdcall CreateMRUListA(ptr) CreateMRUList32A
diff --git a/relay32/ntdll.spec b/relay32/ntdll.spec
index ccbae37..c7b0681 100644
--- a/relay32/ntdll.spec
+++ b/relay32/ntdll.spec
@@ -25,7 +25,7 @@
 017 stub CsrSetPriorityClass
 018 stub CsrpProcessCallbackRequest
 019 stub DbgBreakPoint
-020 stub DbgPrint
+020 cdecl DbgPrint(str long) DbgPrint
 021 stub DbgPrompt
 022 stub DbgSsHandleKmApiMsg
 023 stub DbgSsInitialize
@@ -882,7 +882,7 @@
 874 stub _strlwr
 875 cdecl _strnicmp(str str long) CRTDLL__strnicmp
 876 cdecl _strupr(str) CRTDLL__strupr
-877 stub _ultoa
+877 cdecl _ultoa(long ptr long) CRTDLL__ultoa
 878 stub _vsnprintf
 879 cdecl _wcsicmp(wstr wstr) CRTDLL__wcsicmp
 880 cdecl _wcslwr(wstr) CRTDLL__wcslwr
diff --git a/relay32/ole32.spec b/relay32/ole32.spec
index 4a4ff32..0a83668 100644
--- a/relay32/ole32.spec
+++ b/relay32/ole32.spec
@@ -26,7 +26,7 @@
  23 stub CoGetStandardMarshal
  24 stub CoGetState
  25 stub CoGetTreatAsClass
- 26 stdcall CoInitialize(long) CoInitialize32
+ 26 stdcall CoInitialize(ptr) CoInitialize32
  27 stdcall CoInitializeWOW(long long) CoInitializeWOW
  28 stub CoIsHandlerConnected
  29 stub CoIsOle1Class
@@ -76,7 +76,7 @@
  73 stdcall GetRunningObjectTable(long ptr) GetRunningObjectTable32
  74 stub IIDFromString
  75 stub IsAccelerator
- 76 stub IsEqualGUID
+ 76 stdcall IsEqualGUID(ptr ptr) IsEqualGUID32
  77 stub IsValidIid
  78 stdcall IsValidInterface(ptr) IsValidInterface32
  79 stub IsValidPtrIn
@@ -144,7 +144,7 @@
 141 stdcall RevokeDragDrop(long) RevokeDragDrop32
 142 stub SetConvertStg
 143 stub SetDocumentBitStg
-144 stdcall StgCreateDocfile(wstr long long ptr) StgCreateDocFile32
+144 stdcall StgCreateDocfile(wstr long long ptr) StgCreateDocfile32
 145 stub StgCreateDocfileOnILockBytes
 146 stdcall StgIsStorageFile(wstr) StgIsStorageFile32
 147 stub StgIsStorageILockBytes
@@ -163,7 +163,7 @@
 160 stub WriteFmtUserTypeStg
 161 stub WriteOleStg
 162 stub WriteStringStream
-163 stub CoInitializeEx
+163 stdcall CoInitializeEx(ptr long) CoInitializeEx32
 164 stub CoInitializeSecurity
 165 stub CoCreateInstanceEx
 166 stub PropVariantClear
diff --git a/relay32/relay386.c b/relay32/relay386.c
index 52873dd..082c302 100644
--- a/relay32/relay386.c
+++ b/relay32/relay386.c
@@ -14,6 +14,7 @@
 #include "selectors.h"
 #include "debugstr.h"
 #include "debug.h"
+#include "main.h"
 
 char **debug_relay_excludelist = NULL, **debug_relay_includelist = NULL;
 
diff --git a/relay32/winspool.spec b/relay32/winspool.spec
index a99a998..35e0329 100644
--- a/relay32/winspool.spec
+++ b/relay32/winspool.spec
@@ -20,8 +20,8 @@
 117 stdcall AddPrinterA(str long ptr) AddPrinter32A
 118 stub AddPrinterConnectionA
 119 stub AddPrinterConnectionW
-120 stub AddPrinterDriverA
-121 stub AddPrinterDriverW
+120 stdcall AddPrinterDriverA(str long ptr) AddPrinterDriver32A
+121 stdcall AddPrinterDriverW(wstr long ptr) AddPrinterDriver32W
 122 stdcall AddPrinterW(wstr long ptr) AddPrinter32W
 123 stub AdvancedDocumentPropertiesA
 124 stub AdvancedDocumentPropertiesW
diff --git a/scheduler/k32obj.c b/scheduler/k32obj.c
index 3d67e95..35f5be3 100644
--- a/scheduler/k32obj.c
+++ b/scheduler/k32obj.c
@@ -9,6 +9,7 @@
 #include "k32obj.h"
 #include "heap.h"
 #include "process.h"
+#include "server.h"
 
 
 /* The declarations are here to avoid including a lot of unnecessary files */
diff --git a/scheduler/syslevel.c b/scheduler/syslevel.c
index 3b4f0a6..8babea4 100644
--- a/scheduler/syslevel.c
+++ b/scheduler/syslevel.c
@@ -31,6 +31,7 @@
     segpWin16Mutex = SEGPTR_GET(w16Mutex);
 
     InitializeCriticalSection(&Win16Mutex);
+    MakeCriticalSectionGlobal(&Win16Mutex);
 }
 
 /************************************************************************
diff --git a/server/console.c b/server/console.c
index b7cd57b..d9cfae3 100644
--- a/server/console.c
+++ b/server/console.c
@@ -69,7 +69,7 @@
         file_set_error();
         return 0;
     }
-    if ((write_fd = (fd != -1) ? dup(fd) : dup(0)) == -1)
+    if ((write_fd = (fd != -1) ? dup(fd) : dup(1)) == -1)
     {
         file_set_error();
         close( read_fd );
diff --git a/server/file.c b/server/file.c
index 760902d..c786807 100644
--- a/server/file.c
+++ b/server/file.c
@@ -304,18 +304,19 @@
 
 static void file_destroy( struct object *obj )
 {
-    struct file **pptr;
     struct file *file = (struct file *)obj;
     assert( obj->ops == &file_ops );
 
-    /* remove it from the hashing list */
-    pptr = &file_hash[get_name_hash( file->name )];
-    while (*pptr && *pptr != file) pptr = &(*pptr)->next;
-    assert( *pptr );
-    *pptr = (*pptr)->next;
-
+    if (file->name)
+    {
+        /* remove it from the hashing list */
+        struct file **pptr = &file_hash[get_name_hash( file->name )];
+        while (*pptr && *pptr != file) pptr = &(*pptr)->next;
+        assert( *pptr );
+        *pptr = (*pptr)->next;
+        free( file->name );
+    }
     close( file->fd );
-    free( file->name );
     free( file );
 }
 
diff --git a/tools/wrc/CHANGES b/tools/wrc/CHANGES
index 6f3bc36..7848237 100644
--- a/tools/wrc/CHANGES
+++ b/tools/wrc/CHANGES
@@ -1,4 +1,44 @@
 ---------------------------------------------------------------------------
+Version 1.0.8 (10-Jan-1999)
+
+Albert den Haan <albertd@corel.ca>:
+- Added TOOLBAR support.
+- Buffer overflow fix in strncpyWtoA.
+- Open embedded files in resource definitions through the include path from
+  the commandline.
+- Support named icons in dialogs with unquoted names
+
+Bertho Stultiens <bertho@akhphd.au.dk>
+- Fixed a major bug in the language propagation in the parser. The parser
+  did not copy the current language while binding it to a resource structure
+  causing wrong sorting if multiple global languages were in use and was a
+  potential segfault because the pointer might not be valid.
+- Added language/version/characteristics support for toolbar.
+- Moved some defines from wrc.h to wrctypes.h to support in toolbars.
+- Removed function stricmp from source and replaced with native function
+  strcasecmp.
+- Allocate cursor and icon ordinals according to the language of the item to
+  decrease the amount of ordinals in use. This reduces the resource
+  directory size by reducing the tree size.
+- Versions 1.0.5 through 1.0.7 were never commited to cvs but were available
+  for download from an alternate site for elf-dll test generation.
+
+---------------------------------------------------------------------------
+Version 1.0.7 (19-Dec-1998)
+- Changed a couple of labels that are used by dllglue. Also reversed a patch
+  that made wrc's generated code dependent on dllglue's code.
+
+---------------------------------------------------------------------------
+Version 1.0.6 (12-Dec-1998)
+- Fixed the _PEResTab table where incorrect RVA's were put in the table.
+  The dllglue should now be merged into wrc for correct labels and the least
+  number of loadtime fixups.
+
+---------------------------------------------------------------------------
+Version 1.0.5 (12-Dec-1998)
+- Fixed an omited .globl statement for dllglue linking.
+
+---------------------------------------------------------------------------
 Version 1.0.4 (10-Dec-1998)
 - Added a global label for elf-dll linking and a long with the resource
   size and a long with the directory size.
diff --git a/tools/wrc/dumpres.c b/tools/wrc/dumpres.c
index 6814a3b..3a46bfe 100644
--- a/tools/wrc/dumpres.c
+++ b/tools/wrc/dumpres.c
@@ -42,6 +42,7 @@
 	case res_usr:   return "UserResource";
 	case res_msg:	return "MESSAGETABLE";
 	case res_ver:	return "VERSIONINFO";
+	case res_toolbar: return "TOOLBAR";
 	default: 	return "Unknown";
 	}
 }
@@ -64,7 +65,8 @@
 char *strncpyWtoA(char *cs, short *ws, int maxlen)
 {
 	char *cptr = cs;
-	while(*ws && maxlen-1)
+	short *wsMax = ws + maxlen;
+	while(ws < wsMax)
 	{
 		if(*ws < -128 || *ws > 127)
 			printf("***Warning: Unicode string contains non-printable chars***");
@@ -821,6 +823,49 @@
 
 /*
  *****************************************************************************
+ * Function	: dump_toolbar_item
+ * Syntax	: void dump_toolbar_item(toolbar_item_t *item)
+ * Input	:
+ * Output	:
+ * Description	:
+ * Remarks	:
+ *****************************************************************************
+*/
+void dump_toolbar_items(toolbar_item_t *items)
+{
+	while(items)
+	{
+	        if(items->id)
+			printf("   BUTTON %d", items->id );
+		else
+	      		printf("   SEPARATOR");
+
+		printf("\n");
+	      
+		items = items->next;
+	}
+}
+
+/*
+ *****************************************************************************
+ * Function	: dump_toolbar
+ * Syntax	: void dump_toolbar(dialogex_t *toolbar)
+ * Input	:
+ *	toolbar	- Toolbar resource descriptor
+ * Output	:
+ * Description	:
+ * Remarks	:
+ *****************************************************************************
+*/
+void dump_toolbar(toolbar_t *toolbar)
+{
+	dump_memopt(toolbar->memopt);
+	dump_lvc(&(toolbar->lvc));
+	dump_toolbar_items(toolbar->items);
+}
+
+/*
+ *****************************************************************************
  * Function	:
  * Syntax	:
  * Input	:
@@ -899,6 +944,9 @@
 		case res_ver:
 			dump_versioninfo(top->res.ver);
 			break;
+		case res_toolbar:
+			dump_toolbar(top->res.tbt);
+			break;
 		default:
 			printf("Report this: Unknown resource type parsed %08x\n", top->type);
 		}
diff --git a/tools/wrc/genres.c b/tools/wrc/genres.c
index 0f863d4..abffb11 100644
--- a/tools/wrc/genres.c
+++ b/tools/wrc/genres.c
@@ -1425,6 +1425,72 @@
 
 /*
  *****************************************************************************
+ * Function	: toolbaritem2res
+ * Syntax	: void toolbaritem2res(res_t *res, toolbar_item_t *tbitem)
+ * Input	:
+ * Output	: nop
+ * Description	:
+ * Remarks	: Self recursive
+ *****************************************************************************
+*/
+void toolbaritem2res(res_t *res, toolbar_item_t *tbitem)
+{
+	toolbar_item_t *itm = tbitem;
+	assert(win32 != 0);
+	while(itm)
+	{
+		put_word(res, itm->id);
+		itm = itm->next;
+	}
+
+}
+
+/*
+ *****************************************************************************
+ * Function	: toolbar2res
+ * Syntax	: res_t *toolbar2res(name_id_t *name, toolbar_t *toolbar)
+ * Input	:
+ *	name	- Name/ordinal of the resource
+ *	toolbar	- The toolbar descriptor
+ * Output	: New .res format structure
+ * Description	:
+ * Remarks	:
+ *****************************************************************************
+*/
+res_t *toolbar2res(name_id_t *name, toolbar_t *toolbar)
+{
+	int restag;
+	res_t *res;
+	assert(name != NULL);
+	assert(toolbar != NULL);
+
+	res = new_res();
+	if(win32)
+	{
+		restag = put_res_header(res, WRC_RT_TOOLBAR, NULL, name, toolbar->memopt, &(toolbar->lvc));
+
+		put_word(res, 1);		/* Menuheader: Version */
+		put_word(res, toolbar->button_width); /* (in pixels?) */
+		put_word(res, toolbar->button_height); /* (in pixels?) */
+		put_word(res, toolbar->nitems); 
+		put_pad(res);
+		toolbaritem2res(res, toolbar->items);
+		/* Set ResourceSize */
+		SetResSize(res, restag);
+		put_pad(res);
+	}
+	else /* win16 */
+	{
+		/* Do not generate anything in 16-bit mode */
+		free(res->data);
+		free(res);
+		return NULL;
+	}
+	return res;
+}
+
+/*
+ *****************************************************************************
  * Function	: prep_nid_for_label
  * Syntax	: char *prep_nid_for_label(name_id_t *nid)
  * Input	:
@@ -1546,6 +1612,7 @@
 	case res_usr:	return "Usr";
 	case res_msg:	return "MsgTab";
 	case res_ver:	return "VerInf";
+	case res_toolbar:	return "TlBr";
 	default:	return "Oops";
 	}
 }
@@ -1631,6 +1698,10 @@
 			if(!top->binres)
 				top->binres = versioninfo2res(top->name, top->res.ver);
 			break;
+		case res_toolbar:
+			if(!top->binres)
+				top->binres = toolbar2res(top->name, top->res.tbt);
+			break;
 		default:
 			internal_error(__FILE__, __LINE__, "Unknown resource type encountered %d in binary res generation", top->type);
 		}
diff --git a/tools/wrc/newstruc.c b/tools/wrc/newstruc.c
index 3fb9941..05d9ee0 100644
--- a/tools/wrc/newstruc.c
+++ b/tools/wrc/newstruc.c
@@ -37,6 +37,7 @@
 __NEW_STRUCT_FUNC(lvc)
 __NEW_STRUCT_FUNC(res_count)
 __NEW_STRUCT_FUNC(string)
+__NEW_STRUCT_FUNC(toolbar_item)
 
 /* New instances for all types of structures */
 /* Very inefficient (in size), but very functional :-]
@@ -250,4 +251,12 @@
 	return stt;
 }
 
-
+toolbar_t *new_toolbar(int button_width, int button_height, toolbar_item_t *items, int nitems)
+{
+	toolbar_t *tb = (toolbar_t *)xmalloc(sizeof(toolbar_t));
+	tb->button_width = button_width;
+	tb->button_height = button_height;
+	tb->nitems = nitems;
+	tb->items = items;
+	return tb;
+}
diff --git a/tools/wrc/newstruc.h b/tools/wrc/newstruc.h
index 61d3907..3e79a3a 100644
--- a/tools/wrc/newstruc.h
+++ b/tools/wrc/newstruc.h
@@ -40,6 +40,7 @@
 __NEW_STRUCT_PROTO(lvc);
 __NEW_STRUCT_PROTO(res_count);
 __NEW_STRUCT_PROTO(string);
+__NEW_STRUCT_PROTO(toolbar_item);
 
 resource_t *new_resource(enum res_e t, void *res, int memopt, language_t *lan);
 version_t *new_version(DWORD v);
@@ -61,6 +62,7 @@
 void copy_raw_data(raw_data_t *dst, raw_data_t *src, int offs, int len);
 int *new_int(int i);
 stringtable_t *new_stringtable(lvc_t *lvc);
+toolbar_t *new_toolbar(int button_width, int button_Height, toolbar_item_t *items, int nitems);
 
 #endif
 
diff --git a/tools/wrc/parser.l b/tools/wrc/parser.l
index bc11b4e..9b132d6 100644
--- a/tools/wrc/parser.l
+++ b/tools/wrc/parser.l
@@ -261,6 +261,7 @@
 	{ "BEGIN", tBEGIN, 0, 0, 1},
 	{ "BITMAP", tBITMAP, 0, 0, 0},
 	{ "BLOCK", BLOCK, 0, 0, 1},
+	{ "BUTTON", BUTTON, 1, 0, 0},
 	{ "CAPTION", CAPTION, 0, 0, 0},
 	{ "CHARACTERISTICS", CHARACTERISTICS, 1, 0, 0},
 	{ "CHECKBOX", CHECKBOX, 0, 0, 0},
@@ -321,6 +322,7 @@
 	{ "STRING", tSTRING, 0, 0, 0},
 	{ "STRINGTABLE", STRINGTABLE, 0, 0, 1},
 	{ "STYLE", STYLE, 0, 0, 0},
+	{ "TOOLBAR", TOOLBAR, 1, 0, 0},
 	{ "typedef", tTYPEDEF, 0, 1, 1},
 	{ "VALUE", VALUE, 0, 0, 0},
 	{ "VERSION", VERSION, 1, 0, 0},
@@ -333,7 +335,7 @@
 int kw_cmp_func(const void *s1, const void *s2)
 {
 	int ret;
-	ret = stricmp(KWP(s1)->keyword, KWP(s2)->keyword);
+	ret = strcasecmp(KWP(s1)->keyword, KWP(s2)->keyword);
 	if(!ret && (KWP(s1)->needcase || KWP(s2)->needcase))
 		return strcmp(KWP(s1)->keyword, KWP(s2)->keyword);
 	else
@@ -804,10 +806,12 @@
 #ifndef yywrap
 int yywrap(void)
 {
-//	if(bufferstackidx > 0)
-//	{
-//		return 0;
-//	}
+#if 0
+	if(bufferstackidx > 0)
+	{
+		return 0;
+ 	}
+#endif
 	return 1;
 }
 #endif
diff --git a/tools/wrc/parser.y b/tools/wrc/parser.y
index 7f5d877..0d5baf1 100644
--- a/tools/wrc/parser.y
+++ b/tools/wrc/parser.y
@@ -3,6 +3,14 @@
  * Copyright  Martin von Loewis, 1994
  * Copyright 1998 Bertho A. Stultiens (BS)
  *
+ * 29-Dec-1998 AdH	- Grammar and function extensions.
+ *			     grammar: TOOLBAR resources, Named ICONs in 
+ *				DIALOGS
+ *			     functions: semantic actions for the grammar 
+ *				changes, resource files can now be anywhere
+ *				on the include path instead of just in the
+ *				current directory
+ *
  * 20-Jun-1998 BS	- Fixed a bug in load_file() where the name was not
  *			  printed out correctly.
  *
@@ -82,6 +90,7 @@
 #include <stdarg.h>
 #include <assert.h>
 #include <ctype.h>
+#include <string.h>
 
 #include <config.h>
 #include "wrc.h"
@@ -114,8 +123,8 @@
 /* Prototypes of here defined functions */
 void split_cursors(raw_data_t *rd, cursor_group_t *curg, int *ncur);
 void split_icons(raw_data_t *rd, icon_group_t *icog, int *nico);
-int alloc_cursor_id(void);
-int alloc_icon_id(void);
+int alloc_cursor_id(language_t *);
+int alloc_icon_id(language_t *);
 void ins_stt_entry(stt_entry_t *ste);
 int check_stt_entry(stringtable_t *tabs, stt_entry_t *ste);
 event_t *get_event_head(event_t *p);
@@ -156,6 +165,8 @@
 dialog_t *dialog_style(int st, dialog_t *dlg);
 resource_t *build_stt_resources(stringtable_t *stthead);
 stringtable_t *find_stringtable(lvc_t *lvc);
+toolbar_item_t *ins_tlbr_button(toolbar_item_t *prev, toolbar_item_t *idrec);
+toolbar_item_t *get_tlbr_buttons_head(toolbar_item_t *p, int *nitems);
 
 %}
 %union{
@@ -195,6 +206,8 @@
 	ver_value_t	*val;
 	ver_block_t	*blk;
 	ver_words_t	*verw;
+	toolbar_t	*tlbar;
+	toolbar_item_t	*tlbarItems;
 }
 
 %token tIF tIFDEF tIFNDEF tELSE tELIF tENDIF tDEFINED tNL
@@ -217,6 +230,7 @@
 %token MENUBARBREAK MENUBREAK MENUITEM POPUP SEPARATOR
 %token HELP
 %token tSTRING IDENT RAWDATA
+%token TOOLBAR BUTTON
 %token tBEGIN tEND
 %left LOGOR
 %left LOGAND
@@ -267,6 +281,8 @@
 %type <num>	expr xpr dummy
 %type <iptr>	e_expr
 %type <iptr>	pp_expr pp_constant
+%type <tlbar>	toolbar
+%type <tlbarItems>	toolbar_items
 
 %%
 
@@ -432,14 +448,14 @@
 /* get the value for a single resource*/
 resource_definition
 	: accelerators	{ $$ = new_resource(res_acc, $1, $1->memopt, $1->lvc.language); }
-	| bitmap	{ $$ = new_resource(res_bmp, $1, $1->memopt, currentlanguage); }
+	| bitmap	{ $$ = new_resource(res_bmp, $1, $1->memopt, dup_language(currentlanguage)); }
 	| cursor {
 		resource_t *rsc;
 		cursor_t *cur;
-		$$ = rsc = new_resource(res_curg, $1, $1->memopt, currentlanguage);
+		$$ = rsc = new_resource(res_curg, $1, $1->memopt, dup_language(currentlanguage));
 		for(cur = $1->cursorlist; cur; cur = cur->next)
 		{
-			rsc->prev = new_resource(res_cur, cur, $1->memopt, currentlanguage);
+			rsc->prev = new_resource(res_cur, cur, $1->memopt, dup_language(currentlanguage));
 			rsc->prev->next = rsc;
 			rsc = rsc->prev;
 			rsc->name = new_name_id();
@@ -454,14 +470,14 @@
 		else
 			$$ = NULL;
 		}
-	| font		{ $$=new_resource(res_fnt, $1, $1->memopt, currentlanguage); }
+	| font		{ $$=new_resource(res_fnt, $1, $1->memopt, dup_language(currentlanguage)); }
 	| icon {
 		resource_t *rsc;
 		icon_t *ico;
-		$$ = rsc = new_resource(res_icog, $1, $1->memopt, currentlanguage);
+		$$ = rsc = new_resource(res_icog, $1, $1->memopt, dup_language(currentlanguage));
 		for(ico = $1->iconlist; ico; ico = ico->next)
 		{
-			rsc->prev = new_resource(res_ico, ico, $1->memopt, currentlanguage);
+			rsc->prev = new_resource(res_ico, ico, $1->memopt, dup_language(currentlanguage));
 			rsc->prev->next = rsc;
 			rsc = rsc->prev;
 			rsc->name = new_name_id();
@@ -476,10 +492,11 @@
 		else
 			$$ = NULL;
 		}
-	| messagetable	{ $$ = new_resource(res_msg, $1, WRC_MO_MOVEABLE | WRC_MO_DISCARDABLE, currentlanguage); }
+	| messagetable	{ $$ = new_resource(res_msg, $1, WRC_MO_MOVEABLE | WRC_MO_DISCARDABLE, dup_language(currentlanguage)); }
 	| rcdata	{ $$ = new_resource(res_rdt, $1, $1->memopt, $1->lvc.language); }
-	| userres	{ $$ = new_resource(res_usr, $1, $1->memopt, currentlanguage); }
-	| versioninfo	{ $$ = new_resource(res_ver, $1, WRC_MO_MOVEABLE | WRC_MO_DISCARDABLE, currentlanguage); }
+	| toolbar	{ $$ = new_resource(res_toolbar, $1, $1->memopt, $1->lvc.language); }
+	| userres	{ $$ = new_resource(res_usr, $1, $1->memopt, dup_language(currentlanguage)); }
+	| versioninfo	{ $$ = new_resource(res_ver, $1, WRC_MO_MOVEABLE | WRC_MO_DISCARDABLE, dup_language(currentlanguage)); }
 	;
 
 /* ------------------------------ Bitmap ------------------------------ */
@@ -673,8 +690,15 @@
 	| ctrls CTEXT		lab_ctrl	{ $$=ins_ctrl(CT_STATIC, SS_CENTER, $3, $1); }
 	| ctrls RTEXT		lab_ctrl	{ $$=ins_ctrl(CT_STATIC, SS_RIGHT, $3, $1); }
 	/* special treatment for icons, as the extent is optional */
-	| ctrls ICON tSTRING ',' expr ',' expr ',' expr iconinfo {
-		$10->title = $3;
+	| ctrls ICON nameid_s ',' expr ',' expr ',' expr iconinfo {
+		if($3->type == name_str)
+		{
+			$10->title = $3->name.s_name;
+		}
+		else
+		{
+			$10->title = NULL;
+		}
 		$10->id = $5;
 		$10->x = $7;
 		$10->y = $9;
@@ -1380,6 +1404,46 @@
 	| ver_words ',' expr	{ $$ = add_ver_words($1, $3); }
 	;
 
+/* ------------------------------ Toolbar ------------------------------ */
+toolbar: TOOLBAR loadmemopts expr ',' expr opt_lvc tBEGIN toolbar_items tEND {
+		int nitems;
+		toolbar_item_t *items = get_tlbr_buttons_head($8, &nitems);
+		$$ = new_toolbar($3, $5, items, nitems);
+		if($2)
+		{
+			$$->memopt = *($2);
+			free($2); 
+		}
+		else
+		{
+			$$->memopt = WRC_MO_MOVEABLE | WRC_MO_PURE;
+		}
+		if($6)
+		{
+			$$->lvc = *($6);
+			free($6);
+		}
+		if(!$$->lvc.language)
+		{
+			$$->lvc.language = dup_language(currentlanguage);
+		}
+		}
+	;
+
+toolbar_items
+	:  /* Empty */			{ $$ = NULL; }
+	| toolbar_items BUTTON expr	{         
+		toolbar_item_t *idrec = new_toolbar_item();
+		idrec->id = $3;
+		$$ = ins_tlbr_button($1, idrec); 
+		}
+	| toolbar_items SEPARATOR	{         
+		toolbar_item_t *idrec = new_toolbar_item();
+		idrec->id = 0;
+		$$ = ins_tlbr_button($1, idrec); 
+	}
+	;
+
 /* ------------------------------ Memory options ------------------------------ */
 loadmemopts
 	: /* Empty */		{ $$ = NULL; }
@@ -1714,17 +1778,17 @@
 	else
 		cc = cls->name.s_name->str.cstr;
 
-	if(!stricmp("BUTTON", cc))
+	if(!strcasecmp("BUTTON", cc))
 		iclass = CT_BUTTON;
-	else if(!stricmp("COMBOBOX", cc))
+	else if(!strcasecmp("COMBOBOX", cc))
 		iclass = CT_COMBOBOX;
-	else if(!stricmp("LISTBOX", cc))
+	else if(!strcasecmp("LISTBOX", cc))
 		iclass = CT_LISTBOX;
-	else if(!stricmp("EDIT", cc))
+	else if(!strcasecmp("EDIT", cc))
 		iclass = CT_EDIT;
-	else if(!stricmp("STATIC", cc))
+	else if(!strcasecmp("STATIC", cc))
 		iclass = CT_STATIC;
-	else if(!stricmp("SCROLLBAR", cc))
+	else if(!strcasecmp("SCROLLBAR", cc))
 		iclass = CT_SCROLLBAR;
 	else
 		return cls;	/* No default, return user controlclass */
@@ -1896,7 +1960,7 @@
 	if(name->type != str_char)
 		yyerror("Filename must be ASCII string");
 		
-	fp = fopen(name->str.cstr, "rb");
+	fp = open_include(name->str.cstr, 1);
 	if(!fp)
 		yyerror("Cannot open file %s", name->str.cstr);
 	rd = new_raw_data();
@@ -2028,7 +2092,7 @@
 	assert(lvc != NULL);
 
 	if(!lvc->language)
-		lvc->language = currentlanguage;
+		lvc->language = dup_language(currentlanguage);
 
 	for(stt = sttres; stt; stt = stt->next)
 	{
@@ -2162,16 +2226,54 @@
 }
 
 /* Cursor and icon splitter functions */
-int alloc_icon_id(void)
+typedef struct {
+	language_t	lan;
+	int		id;
+} id_alloc_t;
+
+static int get_new_id(id_alloc_t **list, int *n, language_t *lan)
 {
-	static int icon_id = 1;
-	return icon_id++;
+	int i;
+	assert(lan != NULL);
+	assert(list != NULL);
+	assert(n != NULL);
+
+	if(!*list)
+	{
+		*list = (id_alloc_t *)xmalloc(sizeof(id_alloc_t));
+		*n = 1;
+		(*list)[0].lan = *lan;
+		(*list)[0].id = 1;
+		return 1;
+	}
+
+	for(i = 0; i < *n; i++)
+	{
+		if((*list)[i].lan.id == lan->id && (*list)[i].lan.sub == lan->sub)
+			return ++((*list)[i].id);
+	}
+
+	*list = (id_alloc_t *)xrealloc(*list, sizeof(id_alloc_t) * (*n+1));
+	(*list)[*n].lan = *lan;
+	(*list)[*n].id = 1;
+	*n += 1;
+	return 1;
 }
 
-int alloc_cursor_id(void)
+int alloc_icon_id(language_t *lan)
 {
-	static int cursor_id = 1;
-	return cursor_id++;
+	static id_alloc_t *idlist = NULL;
+	static int nid = 0;
+
+	return get_new_id(&idlist, &nid, lan);
+}
+
+int alloc_cursor_id(language_t *lan)
+{
+	static id_alloc_t *idlist = NULL;
+	static int nid = 0;
+
+	return get_new_id(&idlist, &nid, lan);
 }
 
 #define BPTR(base)	((char *)(rd->data + (base)))
@@ -2193,7 +2295,7 @@
 	for(i = 0; i < cnt; i++)
 	{
 		ico = new_icon();
-		ico->id = alloc_icon_id();
+		ico->id = alloc_icon_id(icog->lvc.language);
 		ico->lvc.language = dup_language(icog->lvc.language);
 		if(ide[i].offset > rd->size
 		|| ide[i].offset + ide[i].ressize > rd->size)
@@ -2246,7 +2348,7 @@
 	for(i = 0; i < cnt; i++)
 	{
 		cur = new_cursor();
-		cur->id = alloc_cursor_id();
+		cur->id = alloc_cursor_id(curg->lvc.language);
 		cur->lvc.language = dup_language(curg->lvc.language);
 		if(cde[i].offset > rd->size
 		|| cde[i].offset + cde[i].ressize > rd->size)
@@ -2283,3 +2385,31 @@
 #undef	DPTR
 
 
+toolbar_item_t *ins_tlbr_button(toolbar_item_t *prev, toolbar_item_t *idrec)
+{
+	idrec->prev = prev;
+	if(prev)
+		prev->next = idrec;
+
+	return idrec;
+}
+
+toolbar_item_t *get_tlbr_buttons_head(toolbar_item_t *p, int *nitems)
+{
+	if(!p)
+	{
+		*nitems = 0;
+		return NULL;
+	} 
+
+	*nitems = 1;
+
+	while(p->prev)
+	{
+		(*nitems)++;
+		p = p->prev;
+	}
+
+	return p;
+}
+
diff --git a/tools/wrc/readres.c b/tools/wrc/readres.c
index c2fdc6d..8fcb3c7 100644
--- a/tools/wrc/readres.c
+++ b/tools/wrc/readres.c
@@ -108,6 +108,7 @@
 	case WRC_RT_GROUP_CURSOR:	return res_curg;
 	case WRC_RT_GROUP_ICON:		return res_icog;
 	case WRC_RT_VERSION:		return res_ver;
+	case WRC_RT_TOOLBAR:		return res_toolbar;
 
 	default:
 	case WRC_RT_DLGINCLUDE:
diff --git a/tools/wrc/utils.c b/tools/wrc/utils.c
index 7d1b67e..55ce0af 100644
--- a/tools/wrc/utils.c
+++ b/tools/wrc/utils.c
@@ -137,7 +137,7 @@
 	/* +4 for later extension and +1 for '\0' */
 	base = (char *)xmalloc(namelen +4 +1);
 	strcpy(base, name);
-	if(!stricmp(name + namelen-extlen, ext))
+	if(!strcasecmp(name + namelen-extlen, ext))
 	{
 		base[namelen - extlen] = '\0';
 	}
@@ -184,7 +184,7 @@
 {
 	if(s1->type == str_char && s2->type == str_char)
 	{
-		return stricmp(s1->str.cstr, s2->str.cstr);
+		return strcasecmp(s1->str.cstr, s2->str.cstr);
 	}
 	else
 	{
@@ -213,7 +213,7 @@
 {
 	char *cs1 = dupwstr2cstr(s1);
 	char *cs2 = dupwstr2cstr(s2);
-	int retval = stricmp(cs1, cs2);
+	int retval = strcasecmp(cs1, cs2);
 	free(cs1);
 	free(cs2);
 	warning("Comparing unicode strings without case -> converting to ascii");
@@ -248,15 +248,3 @@
 	return cs;
 }
 
-#ifndef HAVE_STRICMP
-int stricmp(const char *s1, const char *s2)
-{
-	while(*s1 && *s2 && !(toupper(*s1) - toupper(*s2)))
-	{
-		s1++;
-		s2++;
-	}
-	return *s2 - *s1;
-}
-#endif
-
diff --git a/tools/wrc/utils.h b/tools/wrc/utils.h
index e16613a..6ddd10c 100644
--- a/tools/wrc/utils.h
+++ b/tools/wrc/utils.h
@@ -33,8 +33,4 @@
 char *dupwstr2cstr(const short *str);
 short *dupcstr2wstr(const char *str);
 
-#ifndef HAVE_STRICMP
-int stricmp(const char *s1, const char *s2);
-#endif
-
 #endif
diff --git a/tools/wrc/wrc.h b/tools/wrc/wrc.h
index 1201c6c..b634062 100644
--- a/tools/wrc/wrc.h
+++ b/tools/wrc/wrc.h
@@ -12,48 +12,13 @@
 #include "wrctypes.h"
 #endif
 
-#define WRC_VERSION	"1.0.4"
-#define WRC_RELEASEDATE	"(10-Dec-1998)"
+#define WRC_VERSION	"1.0.8"
+#define WRC_RELEASEDATE	"(10-Jan-1999)"
 #define WRC_FULLVERSION WRC_VERSION " " WRC_RELEASEDATE
 
 /* Only used in heavy debugging sessions */
 #define HEAPCHECK()
 
-/* Memory/load flags */
-#define WRC_MO_MOVEABLE		0x0010
-#define WRC_MO_PURE		0x0020
-#define WRC_MO_PRELOAD		0x0040
-#define WRC_MO_DISCARDABLE	0x1000
-
-/* Resource type IDs */
-#define WRC_RT_CURSOR		(1)
-#define WRC_RT_BITMAP		(2)
-#define WRC_RT_ICON		(3)
-#define WRC_RT_MENU		(4)
-#define WRC_RT_DIALOG		(5)
-#define WRC_RT_STRING		(6)
-#define WRC_RT_FONTDIR		(7)
-#define WRC_RT_FONT		(8)
-#define WRC_RT_ACCELERATOR	(9)
-#define WRC_RT_RCDATA		(10)
-#define WRC_RT_MESSAGETABLE	(11)
-#define WRC_RT_GROUP_CURSOR	(12)
-#define WRC_RT_GROUP_ICON	(14)
-#define WRC_RT_VERSION		(16)
-#define WRC_RT_DLGINCLUDE	(17)
-#define WRC_RT_PLUGPLAY		(19)
-#define WRC_RT_VXD		(20)
-#define WRC_RT_ANICURSOR	(21)
-#define WRC_RT_ANIICON		(22)
-
-/* Default class type IDs */
-#define CT_BUTTON	0x80
-#define CT_EDIT		0x81
-#define CT_STATIC 	0x82
-#define CT_LISTBOX	0x83
-#define CT_SCROLLBAR	0x84
-#define CT_COMBOBOX	0x85
-
 /* From wrc.c */
 extern int debuglevel;
 #define DEBUGLEVEL_NONE		0x0000
diff --git a/tools/wrc/wrctypes.h b/tools/wrc/wrctypes.h
index eebdb56..1d81d94 100644
--- a/tools/wrc/wrctypes.h
+++ b/tools/wrc/wrctypes.h
@@ -21,6 +21,42 @@
 #include "ver.h"
 #endif
 
+/* Memory/load flags */
+#define WRC_MO_MOVEABLE		0x0010
+#define WRC_MO_PURE		0x0020
+#define WRC_MO_PRELOAD		0x0040
+#define WRC_MO_DISCARDABLE	0x1000
+
+/* Resource type IDs */
+#define WRC_RT_CURSOR		(1)
+#define WRC_RT_BITMAP		(2)
+#define WRC_RT_ICON		(3)
+#define WRC_RT_MENU		(4)
+#define WRC_RT_DIALOG		(5)
+#define WRC_RT_STRING		(6)
+#define WRC_RT_FONTDIR		(7)
+#define WRC_RT_FONT		(8)
+#define WRC_RT_ACCELERATOR	(9)
+#define WRC_RT_RCDATA		(10)
+#define WRC_RT_MESSAGETABLE	(11)
+#define WRC_RT_GROUP_CURSOR	(12)
+#define WRC_RT_GROUP_ICON	(14)
+#define WRC_RT_VERSION		(16)
+#define WRC_RT_DLGINCLUDE	(17)
+#define WRC_RT_PLUGPLAY		(19)
+#define WRC_RT_VXD		(20)
+#define WRC_RT_ANICURSOR	(21)
+#define WRC_RT_ANIICON		(22)
+#define WRC_RT_TOOLBAR		(241)  
+
+/* Default class type IDs */
+#define CT_BUTTON	0x80
+#define CT_EDIT		0x81
+#define CT_STATIC 	0x82
+#define CT_LISTBOX	0x83
+#define CT_SCROLLBAR	0x84
+#define CT_COMBOBOX	0x85
+
 
 /* Binary resource structure */
 #define RES_BLOCKSIZE	512
@@ -112,6 +148,8 @@
 	res_anicur,	/* Not implemented, no layout available */
 	res_aniico,	/* Not implemented, no layout available */
 
+	res_toolbar = WRC_RT_TOOLBAR,	/* 241 */
+
 	res_menex = 256 + 4,
 	res_dlgex,
 	res_usr,
@@ -419,6 +457,22 @@
 	event_t		*events;
 } accelerator_t;
 
+/* Toolbar structures */
+typedef struct toolbar_item {
+	struct toolbar_item	*next;
+	struct toolbar_item	*prev;        
+	int			id;
+} toolbar_item_t;
+
+typedef struct toolbar {
+	DWORD		memopt;
+	lvc_t		lvc;
+	int		button_width;
+	int		button_height;
+	int		nitems;
+	toolbar_item_t	*items;
+} toolbar_t;
+
 /* A top-level resource node */
 typedef struct resource {
 	struct resource	*next;
@@ -441,6 +495,7 @@
 		messagetable_t	*msg;
 		rcdata_t	*rdt;
 		stringtable_t	*stt;
+		toolbar_t	*tbt;
 		user_t		*usr;
 		versioninfo_t	*ver;
 		void		*overlay; /* To catch all types at once... */
diff --git a/tools/wrc/writeres.c b/tools/wrc/writeres.c
index b87f465..2e17143 100644
--- a/tools/wrc/writeres.c
+++ b/tools/wrc/writeres.c
@@ -299,7 +299,7 @@
 		if(n1->name.s_name->type == str_char
 		&& n2->name.s_name->type == str_char)
 		{
-			return stricmp(n1->name.s_name->str.cstr, n2->name.s_name->str.cstr);
+			return strcasecmp(n1->name.s_name->str.cstr, n2->name.s_name->str.cstr);
 		}
 		else if(n1->name.s_name->type == str_unicode
 		&& n2->name.s_name->type == str_unicode)
@@ -571,6 +571,7 @@
 void write_pe_segment(FILE *fp, resource_t *top)
 {
 	int i;
+	int direntries;
 
 	fprintf(fp, "\t.align\t4\n");
 	fprintf(fp, "%s%s:\n", prefix, _PEResTab);
@@ -704,6 +705,9 @@
 	}
 
 	/* Write the resource table itself */
+	fprintf(fp, "%s_ResourceDirectory:\n", prefix);
+	fprintf(fp, "\t.globl\t%s_ResourceDirectory\n", prefix);
+	direntries = 0;
 
 	for(i = 0; i < rccount; i++)
 	{
@@ -746,6 +750,8 @@
 				fprintf(fp, "\t.long\t%ld\n", codepage);
 				/* Reserved */
 				fprintf(fp, "\t.long\t0\n");
+
+				direntries++;
 			}
 			free(namelabel);
 		}
@@ -753,9 +759,9 @@
 	}
 
 	fprintf(fp, "\t.align\t4\n");
-	fprintf(fp, "%s_ResourceDirectorySize:\n", Underscore);
-	fprintf(fp, "\t.globl\t%s_ResourceDirectorySize\n", Underscore);
-	fprintf(fp, "\t.long\t. - %s%s\n", prefix, _PEResTab);
+	fprintf(fp, "%s_NumberOfResources:\n", prefix);
+	fprintf(fp, "\t.globl\t%s_NumberOfResources\n", prefix);
+	fprintf(fp, "\t.long\t%d\n", direntries);
 }
 
 /*
@@ -988,7 +994,8 @@
 		if(create_dir)
 		{
 			/* Add the size of the entire resource section for elf-dlls */
-			fprintf(fo, "%s_ResourceSectionSize:\n", Underscore);
+			fprintf(fo, "%s_ResourceSectionSize:\n", prefix);
+			fprintf(fo, "\t.globl\t%s_ResourceSectionSize\n", prefix);
 			fprintf(fo, "\t.long\t. - %s%s\n", prefix, _PEResTab);
 		}
 	}
diff --git a/win32/console.c b/win32/console.c
index aa9a17f..f82afc4 100644
--- a/win32/console.c
+++ b/win32/console.c
@@ -567,7 +567,7 @@
 static BOOL32 CONSOLE_make_complex(HANDLE32 handle,CONSOLE *console)
 {
 	struct termios term;
-	char buf[30];
+	char buf[30],*title;
 	char c = '\0';
 	int status = 0;
 	int i,xpid;
@@ -611,6 +611,12 @@
 	/* enable mouseclicks */
 	sprintf(buf,"%c[?1001s%c[?1000h",27,27);
 	WriteFile(handle,buf,strlen(buf),&xlen,NULL);
+	if (console->title) {
+	    title = HeapAlloc(GetProcessHeap(),0,strlen("\033]2;\a")+1+strlen(console->title));
+	    sprintf(title,"\033]2;%s\a",console->title);
+	    WriteFile(handle,title,strlen(title),&xlen,NULL);
+	    HeapFree(GetProcessHeap(),0,title);
+	}
 	return TRUE;
 
 }
@@ -966,9 +972,7 @@
     );
     CONSOLE_get_input(hConsoleInput);
 
-    /* FIXME:	should this drain everything from the input queue and just 
-     * 		put the keypresses in the buffer? Needs further thought.
-     */
+    /* FIXME: should we read at least 1 char? The SDK does not say */
     for (i=0;(i<console->nrofirs)&&(charsread<nNumberOfCharsToRead);i++) {
     	if (console->irs[i].EventType != KEY_EVENT)
 		continue;
@@ -977,6 +981,7 @@
 	*xbuf++ = console->irs[i].Event.KeyEvent.uChar.AsciiChar; 
 	charsread++;
     }
+    /* SDK says: Drains all other input events from queue. */
     CONSOLE_drain_input(console,i);
     if (lpNumberOfCharsRead)
     	*lpNumberOfCharsRead = charsread;
@@ -1034,9 +1039,27 @@
     if (!console) {
     	FIXME(console, "(%d,%p,%ld,%p), No console handle!\n",hConsoleInput,
 		lpBuffer, nLength, lpNumberOfEventsRead);
+
+        /* Indicate that nothing was read */
+        *lpNumberOfEventsRead = 0;
+
 	return FALSE;
     }
     CONSOLE_get_input(hConsoleInput);
+    /* SDK: return at least 1 input record */
+    while (!console->nrofirs) {
+    	DWORD res;
+
+    	res=WaitForSingleObject(hConsoleInput,0);
+	switch (res) {
+	case STATUS_TIMEOUT:	continue;
+	case 0:			break; /*ok*/
+	case WAIT_FAILED:	return 0;/*FIXME: SetLastError?*/
+	default:		break;	/*hmm*/
+	}
+	CONSOLE_get_input(hConsoleInput);
+    }
+    
     if (nLength>console->nrofirs)
     	nLength = console->nrofirs;
     memcpy(lpBuffer,console->irs,sizeof(INPUT_RECORD)*nLength);
@@ -1081,11 +1104,13 @@
     }
 
     sprintf(titlestring,titleformat,title);
-    /* FIXME: hmm, should use WriteFile probably... */
-    /*CONSOLE_Write(&console->header,titlestring,strlen(titlestring),&written,NULL);*/
-    WriteFile(GetStdHandle(STD_OUTPUT_HANDLE),titlestring,strlen(titlestring),&written,NULL);
-    if (written == strlen(titlestring))
-	ret =TRUE;
+    /* only set title for complex console (own xterm) */
+    if (console->pid != -1) {
+	WriteFile(GetStdHandle(STD_OUTPUT_HANDLE),titlestring,strlen(titlestring),&written,NULL);
+	if (written == strlen(titlestring))
+	    ret =TRUE;
+    } else
+    	ret = TRUE;
     HeapFree( GetProcessHeap(), 0, titlestring );
     K32OBJ_DecCount(&console->header);
     return ret;
@@ -1215,6 +1240,10 @@
 
     if (!console) {
         FIXME(console,"(%d,%p,%ld,%p), No console handle passed!\n",hConsoleInput, pirBuffer, cInRecords, lpcRead);
+
+        /* Indicate that nothing was read */
+        *lpcRead = 0; 
+
     	return FALSE;
     }
     TRACE(console,"(%d,%p,%ld,%p)\n",hConsoleInput, pirBuffer, cInRecords, lpcRead);
diff --git a/win32/device.c b/win32/device.c
index dcfdb38..9a6b1df 100644
--- a/win32/device.c
+++ b/win32/device.c
@@ -348,7 +348,7 @@
 		{
 			/* FIXME: Set appropriate error */
 			FIXME( win32, "Unimplemented control %ld for VxD device %s\n", 
-				          dwIoControlCode, dev->info->name );
+                               dwIoControlCode, dev->info ? dev->info->name : "???" );
 		}
 	}
 	else
diff --git a/windows/dialog.c b/windows/dialog.c
index 1f765ca..9a1ed9c 100644
--- a/windows/dialog.c
+++ b/windows/dialog.c
@@ -869,6 +869,7 @@
     }
     retval = dlgInfo->idResult;
     EnableWindow32( owner, TRUE );
+    dlgInfo->flags |= DF_ENDING;   /* try to stop it being destroyed twice */
     DestroyWindow32( hwnd );
     return retval;
 }
diff --git a/windows/dinput.c b/windows/dinput.c
index 85b2246..7e504ff 100644
--- a/windows/dinput.c
+++ b/windows/dinput.c
@@ -27,13 +27,11 @@
 #include "windows.h"
 #include "winerror.h"
 #include "shell.h"
-#include "ole.h"
-#include "compobj.h"
-#include "interfaces.h"
 #include "gdi.h"
 #include "heap.h"
 #include "win.h"
 #include "dinput.h"
+#include "objbase.h"
 #include "debug.h"
 #include "message.h"
 
diff --git a/windows/hook.c b/windows/hook.c
index e7b5302..5261b6b 100644
--- a/windows/hook.c
+++ b/windows/hook.c
@@ -860,7 +860,12 @@
     {
 	if ((id == WH_JOURNALRECORD) || (id == WH_JOURNALPLAYBACK) ||
 	    (id == WH_SYSMSGFILTER)) return 0;  /* System-only hooks */
-        if (!(hQueue = GetTaskQueue( hTask ))) return 0;
+        if (!(hQueue = GetTaskQueue( hTask )))
+        {
+            /* FIXME: shouldn't this be done somewhere else? */
+            if (hTask != GetCurrentTask()) return 0;
+            if (!(hQueue = GetFastQueue())) return 0;
+        }
     }
 
     /* Create the hook structure */
diff --git a/windows/queue.c b/windows/queue.c
index 2ef76e8..f83647a 100644
--- a/windows/queue.c
+++ b/windows/queue.c
@@ -828,6 +828,13 @@
 HQUEUE16 WINAPI InitThreadInput( WORD unknown, WORD flags )
 {
     HQUEUE16 hQueue = GetTaskQueue( 0 );
+    if ( !hQueue )
+    {
+        /* Create task message queue */
+        int queueSize = GetProfileInt32A( "windows", "DefaultQueueSize", 8 );
+        SetMessageQueue32( queueSize );
+        return GetTaskQueue( 0 );
+    }
 
     FIXME( msg, "(%04X,%04X): should create thread-local message queue!\n",
                 unknown, flags );
diff --git a/windows/sysmetrics.c b/windows/sysmetrics.c
index 6b626a6..eb97bda 100644
--- a/windows/sysmetrics.c
+++ b/windows/sysmetrics.c
@@ -18,6 +18,18 @@
  *           SYSMETRICS_Init
  *
  * Initialisation of the system metrics array.
+ *
+ * Differences in return values between 3.1 and 95 apps under Win95 (FIXME ?):
+ * SM_CXVSCROLL        x+1      x
+ * SM_CYHSCROLL        x+1      x
+ * SM_CXDLGFRAME       x-1      x
+ * SM_CYDLGFRAME       x-1      x
+ * SM_CYCAPTION        x+1      x
+ * SM_CYMENU           x-1      x
+ * SM_CYFULLSCREEN     x-1      x
+ * 
+ * (collides with TWEAK_WineLook sometimes,
+ * so changing anything might be difficult) 
  */
 void SYSMETRICS_Init(void)
 {
diff --git a/windows/win.c b/windows/win.c
index 10b1612..e34bd6e 100644
--- a/windows/win.c
+++ b/windows/win.c
@@ -1702,9 +1702,15 @@
  * Do not use GWL_HWNDPARENT to reset the window's parent, use
  * SetParent() instead.
  *
+ * Win95:
+ * When offset is GWL_STYLE and the calling app's ver is 4.0,
+ * it sends WM_STYLECHANGING before changing the settings
+ * and WM_STYLECHANGED afterwards.
+ * App ver 4.0 can't use SetWindowLong to change WS_EX_TOPMOST.
+ *
  * BUGS
  *
- * GWL_STYLE does not dispatch WM_STYLE_... messages.
+ * GWL_STYLE does not dispatch WM_STYLE... messages.
  *
  * CONFORMANCE
  *
diff --git a/windows/winpos.c b/windows/winpos.c
index a5fba13..2593483 100644
--- a/windows/winpos.c
+++ b/windows/winpos.c
@@ -1273,6 +1273,9 @@
 
 /***********************************************************************
  *           GetWindowPlacement32   (USER32.307)
+ *
+ * Win95:
+ * Fails if wndpl->length of Win95 (!) apps is invalid.
  */
 BOOL32 WINAPI GetWindowPlacement32( HWND32 hwnd, WINDOWPLACEMENT32 *pwpl32 )
 {
@@ -1355,6 +1358,9 @@
 
 /***********************************************************************
  *           SetWindowPlacement32   (USER32.519)
+ *
+ * Win95:
+ * Fails if wndpl->length of Win95 (!) apps is invalid.
  */
 BOOL32 WINAPI SetWindowPlacement32( HWND32 hwnd, const WINDOWPLACEMENT32 *pwpl32 )
 {
diff --git a/windows/winproc.c b/windows/winproc.c
index 8ab0f54..59a2675 100644
--- a/windows/winproc.c
+++ b/windows/winproc.c
@@ -15,6 +15,8 @@
 #include "debug.h"
 #include "spy.h"
 #include "commctrl.h"
+#include "task.h"
+#include "thread.h"
 
 /* Window procedure 16-to-32-bit thunk,
  * see BuildSpec16Files() in tools/build.c */
@@ -1080,6 +1082,17 @@
     case WM_NOTIFY:
     	*plparam = (LPARAM)PTR_SEG_TO_LIN(*plparam);
     	return 1;
+    case WM_ACTIVATEAPP:
+    	if (*plparam)
+	{ /* We need this when SetActiveWindow sends a Sendmessage16() to
+	     a 32bit window. Might be superflous with 32bit interprocess
+	     message queues.
+	  */
+	  HTASK16 htask = (HTASK16) *plparam;
+	  DWORD idThread = THDB_TO_THREAD_ID(((TDB*)GlobalLock16(htask))->thdb);
+	  *plparam = (LPARAM) idThread;
+	}
+	return 1;
     case WM_ASKCBFORMATNAME:
     case WM_DEVMODECHANGE:
     case WM_PAINTCLIPBOARD:
@@ -1763,6 +1776,7 @@
         }
         return 0;
 
+    case WM_ACTIVATEAPP:
     case WM_ASKCBFORMATNAME:
     case WM_DEVMODECHANGE:
     case WM_PAINTCLIPBOARD: