/**
 * This file has no copyright assigned and is placed in the Public Domain.
 * This file is part of the mingw-w64 runtime package.
 * No warranty is given; refer to the file DISCLAIMER.PD within this package.
 */

import "basetsd.h";
import "guiddef.h";

[
  uuid(D3980A60-910C-1068-9341-00DD010F2F1C),
  version(0.1),
  pointer_default(unique)
]

interface IWinTypes
{
    typedef struct tagRemHGLOBAL {
        long fNullHGlobal;
        unsigned long cbData;
        [size_is(cbData)] byte data[];
    } RemHGLOBAL;

    typedef struct tagRemHMETAFILEPICT {
        long mm;
        long xExt;
        long yExt;
        unsigned long cbData;
        [size_is(cbData)] byte data[];
    } RemHMETAFILEPICT;

    typedef struct tagRemHENHMETAFILE {
        unsigned long cbData;
        [size_is(cbData)] byte data[];
    } RemHENHMETAFILE;

    typedef struct tagRemHBITMAP {
        unsigned long cbData;
        [size_is(cbData)] byte data[];
    } RemHBITMAP;

    typedef struct tagRemHPALETTE {
        unsigned long cbData;
        [size_is(cbData)] byte data[];
    } RemHPALETTE;

    typedef struct tagRemBRUSH {
        unsigned long cbData;
        [size_is(cbData)] byte data[];
    } RemHBRUSH;

cpp_quote("#if 0")

    typedef byte BYTE;
    typedef unsigned short WORD;
    typedef unsigned int UINT;
    typedef int INT;

#ifdef BOOL
#undef BOOL
    typedef long BOOL;
    typedef long WINBOOL;
#define BOOL WINBOOL
#else
    typedef long BOOL;
#endif

    typedef long LONG;
    typedef UINT_PTR WPARAM;
    typedef unsigned long DWORD;
    typedef LONG_PTR LPARAM;
    typedef LONG_PTR LRESULT;

    typedef void *HANDLE;

#define DECLARE_WIREM_HANDLE(name) \
    typedef [wire_marshal(wire ## name)] void *name
#define DECLARE_HANDLE(name) \
    typedef void *name

    DECLARE_HANDLE(HMODULE);
    DECLARE_HANDLE(HINSTANCE);
    DECLARE_HANDLE(HTASK);
    DECLARE_HANDLE(HKEY);
    DECLARE_HANDLE(HDESK);
    DECLARE_HANDLE(HMF);
    DECLARE_HANDLE(HEMF);
    DECLARE_HANDLE(HPEN);
    DECLARE_HANDLE(HRSRC);
    DECLARE_HANDLE(HSTR);
    DECLARE_HANDLE(HWINSTA);
    DECLARE_HANDLE(HKL);
    DECLARE_HANDLE(HGDIOBJ);

    typedef HANDLE HDWP;
    typedef INT HFILE;
    typedef WORD *LPWORD;
    typedef DWORD *LPDWORD;

    typedef char CHAR;
    typedef [string] CHAR *LPSTR;
    typedef [string] const CHAR *LPCSTR;

    typedef wchar_t WCHAR;
    typedef [string] WCHAR *LPWSTR;
    typedef [string] const WCHAR *LPCWSTR;

    typedef WCHAR TCHAR;
    typedef [string] TCHAR *LPTSTR;
    typedef [string] const TCHAR *LPCTSTR;

    typedef DWORD COLORREF;
    typedef DWORD *LPCOLORREF;

    typedef HANDLE *LPHANDLE;

    typedef struct _RECTL {
        LONG left;
        LONG top;
        LONG right;
        LONG bottom;
    } RECTL, *PRECTL, *LPRECTL;

    typedef struct tagPOINT {
        LONG x;
        LONG y;
    } POINT, *PPOINT, *LPPOINT;

    typedef struct tagPOINTL {
        LONG x;
        LONG y;
    } POINTL, *PPOINTL;

    typedef struct tagSIZE {
        LONG cx;
        LONG cy;
    } SIZE, *PSIZE, *LPSIZE;

    typedef struct tagSIZEL {
        LONG cx;
        LONG cy;
    } SIZEL, *PSIZEL, *LPSIZEL;

cpp_quote("#endif")

cpp_quote("#ifndef _PALETTEENTRY_DEFINED")
cpp_quote("#define _PALETTEENTRY_DEFINED")
    typedef struct tagPALETTEENTRY {
        BYTE peRed;
        BYTE peGreen;
        BYTE peBlue;
        BYTE peFlags;
    } PALETTEENTRY, *PPALETTEENTRY, *LPPALETTEENTRY;
cpp_quote("#endif")

cpp_quote("#ifndef _LOGPALETTE_DEFINED")
cpp_quote("#define _LOGPALETTE_DEFINED")
    typedef struct tagLOGPALETTE {
        WORD palVersion;
        WORD palNumEntries;
        [size_is(palNumEntries)] PALETTEENTRY palPalEntry[];
    } LOGPALETTE, *PLOGPALETTE, *LPLOGPALETTE;
cpp_quote("#endif")

cpp_quote("#ifndef OLE2ANSI")
    typedef WCHAR OLECHAR;
    typedef OLECHAR *LPOLESTR;
    typedef const OLECHAR *LPCOLESTR;
cpp_quote("#define OLESTR(str) L##str")
cpp_quote("#else")
cpp_quote("  typedef char OLECHAR;")
cpp_quote("  typedef LPSTR LPOLESTR;")
cpp_quote("  typedef LPCSTR LPCOLESTR;")
cpp_quote("#define OLESTR(str) str")
cpp_quote("#endif")

cpp_quote("#ifndef _WINDEF_")

    typedef const RECTL *LPCRECTL;
    typedef void *PVOID, *LPVOID;
    typedef float FLOAT;

    typedef struct tagRECT {
        LONG left;
        LONG top;
        LONG right;
        LONG bottom;
    } RECT, *PRECT, *LPRECT;
    typedef const RECT *LPCRECT;

cpp_quote("#endif")

cpp_quote("#ifndef BASETYPES")
cpp_quote("#define BASETYPES")

    typedef unsigned char UCHAR;
    typedef short SHORT;
    typedef unsigned short USHORT;
    typedef DWORD ULONG;

cpp_quote("  typedef ULONG *PULONG;")
cpp_quote("  typedef USHORT *PUSHORT;")
cpp_quote("  typedef UCHAR *PUCHAR;")
cpp_quote("  typedef char *PSZ;")

cpp_quote("#endif")

    typedef double DOUBLE;

cpp_quote("#ifndef _DWORDLONG_")
cpp_quote("#define _DWORDLONG_")
cpp_quote("  __MINGW_EXTENSION")
    typedef unsigned __int64 DWORDLONG;
    typedef DWORDLONG *PDWORDLONG;
cpp_quote("#endif")

cpp_quote("#ifndef _ULONGLONG_")
cpp_quote("  __MINGW_EXTENSION")
    typedef __int64 LONGLONG;
    cpp_quote("  __MINGW_EXTENSION")
    typedef unsigned __int64 ULONGLONG;
    typedef LONGLONG *PLONGLONG;
    typedef ULONGLONG *PULONGLONG;
cpp_quote("#endif")

cpp_quote("#if 0")
    typedef struct _LARGE_INTEGER {
        LONGLONG QuadPart;
    } LARGE_INTEGER, *PLARGE_INTEGER;

    typedef struct _ULARGE_INTEGER {
        ULONGLONG QuadPart;
    } ULARGE_INTEGER;
cpp_quote("#endif")

cpp_quote("#ifndef _WINBASE_")

cpp_quote("#ifndef _FILETIME_")
cpp_quote("#define _FILETIME_")
    typedef struct _FILETIME {
        DWORD dwLowDateTime;
        DWORD dwHighDateTime;
    } FILETIME, *PFILETIME, *LPFILETIME;
cpp_quote("#endif")

cpp_quote("#ifndef _SYSTEMTIME_")
cpp_quote("#define _SYSTEMTIME_")
    typedef struct _SYSTEMTIME {
        WORD wYear;
        WORD wMonth;
        WORD wDayOfWeek;
        WORD wDay;
        WORD wHour;
        WORD wMinute;
        WORD wSecond;
        WORD wMilliseconds;
    } SYSTEMTIME, *PSYSTEMTIME, *LPSYSTEMTIME;
cpp_quote("#endif")

cpp_quote("#ifndef _SECURITY_ATTRIBUTES_")
cpp_quote("#define _SECURITY_ATTRIBUTES_")
    typedef struct _SECURITY_ATTRIBUTES {
        DWORD nLength;
        LPVOID lpSecurityDescriptor;
        BOOL bInheritHandle;
    } SECURITY_ATTRIBUTES, *PSECURITY_ATTRIBUTES, *LPSECURITY_ATTRIBUTES;
cpp_quote("#endif")

cpp_quote("#ifndef SECURITY_DESCRIPTOR_REVISION")
    typedef USHORT SECURITY_DESCRIPTOR_CONTROL, *PSECURITY_DESCRIPTOR_CONTROL;
    typedef PVOID PSID;

    typedef struct _ACL {
        UCHAR AclRevision;
        UCHAR Sbz1;
        USHORT AclSize;
        USHORT AceCount;
        USHORT Sbz2;
    } ACL, *PACL;

    typedef struct _SECURITY_DESCRIPTOR {
        UCHAR Revision;
        UCHAR Sbz1;
        SECURITY_DESCRIPTOR_CONTROL Control;
        PSID Owner;
        PSID Group;
        PACL Sacl;
        PACL Dacl;
    } SECURITY_DESCRIPTOR, *PISECURITY_DESCRIPTOR;

cpp_quote("#endif")
cpp_quote("#endif")

    typedef struct _COAUTHIDENTITY {
        [size_is(UserLength+1)] USHORT *User;
        [range(0,256)] ULONG UserLength;
        [size_is(DomainLength+1)] USHORT *Domain;
        [range(0,256)] ULONG DomainLength;
        [size_is(PasswordLength+1)] USHORT *Password;
        [range(0,256)] ULONG PasswordLength;
        ULONG Flags;
    } COAUTHIDENTITY;

    typedef struct _COAUTHINFO {
        DWORD dwAuthnSvc;
        DWORD dwAuthzSvc;
        LPWSTR pwszServerPrincName;
        DWORD dwAuthnLevel;
        DWORD dwImpersonationLevel;
        COAUTHIDENTITY *pAuthIdentityData;
        DWORD dwCapabilities;
    } COAUTHINFO;

    typedef LONG SCODE;
    typedef SCODE *PSCODE;

cpp_quote("#ifndef _HRESULT_DEFINED")
cpp_quote("#define _HRESULT_DEFINED")
    typedef LONG HRESULT;
cpp_quote("#endif")

cpp_quote("#ifndef __OBJECTID_DEFINED")
cpp_quote("#define __OBJECTID_DEFINED")
cpp_quote("#define _OBJECTID_DEFINED")
    typedef struct _OBJECTID {
        GUID Lineage;
        unsigned long Uniquifier;
    } OBJECTID;
cpp_quote("#endif")

cpp_quote("#if 0")
    typedef GUID *REFGUID;
    typedef IID *REFIID;
    typedef CLSID *REFCLSID;
    typedef FMTID *REFFMTID;
cpp_quote("#endif")

    typedef enum tagMEMCTX {
        MEMCTX_TASK = 1,
        MEMCTX_SHARED = 2,
        MEMCTX_MACSYSTEM = 3,
        MEMCTX_UNKNOWN = -1,
        MEMCTX_SAME = -2
    } MEMCTX;

cpp_quote("#ifndef _ROTFLAGS_DEFINED")
cpp_quote("#define _ROTFLAGS_DEFINED")
cpp_quote("#define ROTFLAGS_REGISTRATIONKEEPSALIVE 0x1")
cpp_quote("#define ROTFLAGS_ALLOWANYCLIENT 0x2")
cpp_quote("#endif")

cpp_quote("#ifndef _ROT_COMPARE_MAX_DEFINED")
cpp_quote("#define _ROT_COMPARE_MAX_DEFINED")
cpp_quote("#define ROT_COMPARE_MAX 2048")
cpp_quote("#endif")

    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_RESERVED1 = 0x40,
        CLSCTX_RESERVED2 = 0x80,
        CLSCTX_RESERVED3 = 0x100,
        CLSCTX_RESERVED4 = 0x200,
        CLSCTX_NO_CODE_DOWNLOAD = 0x400,
        CLSCTX_RESERVED5 = 0x800,
        CLSCTX_NO_CUSTOM_MARSHAL = 0x1000,
        CLSCTX_ENABLE_CODE_DOWNLOAD = 0x2000,
        CLSCTX_NO_FAILURE_LOG = 0x4000,
        CLSCTX_DISABLE_AAA = 0x8000,
        CLSCTX_ENABLE_AAA = 0x10000,
        CLSCTX_FROM_DEFAULT_CONTEXT = 0x20000,
        CLSCTX_ACTIVATE_32_BIT_SERVER = 0x40000,
        CLSCTX_ACTIVATE_64_BIT_SERVER = 0x80000
    } CLSCTX;

    typedef enum tagMSHLFLAGS {
        MSHLFLAGS_NORMAL = 0,
        MSHLFLAGS_TABLESTRONG = 1,
        MSHLFLAGS_TABLEWEAK = 2,
        MSHLFLAGS_NOPING = 4,
        MSHLFLAGS_RESERVED1 = 8,
        MSHLFLAGS_RESERVED2 = 16,
        MSHLFLAGS_RESERVED3 = 32,
        MSHLFLAGS_RESERVED4 = 64
    } MSHLFLAGS;

    typedef enum tagMSHCTX {
        MSHCTX_LOCAL = 0,
        MSHCTX_NOSHAREDMEM = 1,
        MSHCTX_DIFFERENTMACHINE = 2,
        MSHCTX_INPROC = 3,
        MSHCTX_CROSSCTX = 4
    } MSHCTX;

    typedef enum tagDVASPECT {
        DVASPECT_CONTENT = 1,
        DVASPECT_THUMBNAIL = 2,
        DVASPECT_ICON = 4,DVASPECT_DOCPRINT = 8
    } DVASPECT;

    typedef enum tagSTGC {
        STGC_DEFAULT = 0,
        STGC_OVERWRITE = 1,
        STGC_ONLYIFCURRENT = 2,
        STGC_DANGEROUSLYCOMMITMERELYTODISKCACHE = 4,
        STGC_CONSOLIDATE = 8
    } STGC;

    typedef enum tagSTGMOVE {
        STGMOVE_MOVE = 0,
        STGMOVE_COPY = 1,
        STGMOVE_SHALLOWCOPY = 2
    } STGMOVE;

    typedef enum tagSTATFLAG {
        STATFLAG_DEFAULT = 0,
        STATFLAG_NONAME = 1,
        STATFLAG_NOOPEN = 2
    } STATFLAG;

    typedef [context_handle] void *HCONTEXT;

cpp_quote("#ifndef _LCID_DEFINED")
cpp_quote("#define _LCID_DEFINED")
    typedef DWORD LCID;
cpp_quote("#endif")

cpp_quote("#ifndef _LANGID_DEFINED")
cpp_quote("#define _LANGID_DEFINED")
    typedef USHORT LANGID;
cpp_quote("#endif")

    typedef struct _BYTE_BLOB {
        unsigned long clSize;
        [size_is(clSize)] byte abData[];
    } BYTE_BLOB;

    typedef [unique] BYTE_BLOB *UP_BYTE_BLOB;

    typedef struct _WORD_BLOB {
        unsigned long clSize;
        [size_is(clSize)] unsigned short asData[];
    } WORD_BLOB;

    typedef [unique] WORD_BLOB *UP_WORD_BLOB;

    typedef struct _DWORD_BLOB {
        unsigned long clSize;
        [size_is(clSize)] unsigned long alData[];
    } DWORD_BLOB;

    typedef [unique] DWORD_BLOB *UP_DWORD_BLOB;

    typedef struct _FLAGGED_BYTE_BLOB {
        unsigned long fFlags;
        unsigned long clSize;
        [size_is(clSize)] byte abData[];
    } FLAGGED_BYTE_BLOB;

    typedef [unique] FLAGGED_BYTE_BLOB *UP_FLAGGED_BYTE_BLOB;

    typedef struct _FLAGGED_WORD_BLOB {
        unsigned long fFlags;
        unsigned long clSize;
        [size_is(clSize)] unsigned short asData[];
    } FLAGGED_WORD_BLOB;

    typedef [unique] FLAGGED_WORD_BLOB *UP_FLAGGED_WORD_BLOB;

    typedef struct _BYTE_SIZEDARR {
        unsigned long clSize;
        [size_is(clSize)] byte *pData;
    } BYTE_SIZEDARR;

    typedef struct _SHORT_SIZEDARR {
        unsigned long clSize;
        [size_is(clSize)] unsigned short *pData;
    } WORD_SIZEDARR;

    typedef struct _LONG_SIZEDARR {
        unsigned long clSize;
        [size_is(clSize)] unsigned long *pData;
    } DWORD_SIZEDARR;

    typedef struct _HYPER_SIZEDARR {
        unsigned long clSize;
        [size_is(clSize)] hyper *pData;
    } HYPER_SIZEDARR;

    const long WDT_INPROC_CALL = 0x48746457;
    const long WDT_REMOTE_CALL = 0x52746457;
    const long WDT_INPROC64_CALL = 0x50746457;

    typedef union _userCLIPFORMAT switch (long fContext) u {
        case WDT_INPROC_CALL: DWORD dwValue;
        case WDT_REMOTE_CALL: [string] wchar_t *pwszName;
    } userCLIPFORMAT;

    typedef [unique] userCLIPFORMAT *wireCLIPFORMAT;
    typedef [wire_marshal(wireCLIPFORMAT)] WORD CLIPFORMAT;

    typedef union _GDI_NONREMOTE switch(long fContext) u {
        case WDT_INPROC_CALL: long hInproc;
        case WDT_REMOTE_CALL: DWORD_BLOB *hRemote;
    } GDI_NONREMOTE;

    typedef union _userHGLOBAL switch(long fContext) {
        case WDT_INPROC_CALL: long hInproc;
        case WDT_REMOTE_CALL: FLAGGED_BYTE_BLOB *hRemote;
        case WDT_INPROC64_CALL: __int64 hInproc64;
    } userHGLOBAL;

    typedef [unique] userHGLOBAL *wireHGLOBAL;

    typedef union _userHMETAFILE switch(long fContext) {
        case WDT_INPROC_CALL: long hInproc;
        case WDT_REMOTE_CALL: BYTE_BLOB *hRemote;
        case WDT_INPROC64_CALL: __int64 hInproc64;
    } userHMETAFILE;

    typedef struct _remoteMETAFILEPICT {
        long mm;
        long xExt;
        long yExt;
        userHMETAFILE *hMF;
    } remoteMETAFILEPICT;

    typedef union _userHMETAFILEPICT switch(long fContext) {
        case WDT_INPROC_CALL: long hInproc;
        case WDT_REMOTE_CALL: remoteMETAFILEPICT *hRemote;
        case WDT_INPROC64_CALL: __int64 hInproc64;
    } userHMETAFILEPICT;

    typedef union _userHENHMETAFILE switch(long fContext) {
        case WDT_INPROC_CALL: long hInproc;
        case WDT_REMOTE_CALL: BYTE_BLOB *hRemote;
        case WDT_INPROC64_CALL: __int64 hInproc64;
    } userHENHMETAFILE;

    typedef struct _userBITMAP {
        LONG bmType;
        LONG bmWidth;
        LONG bmHeight;
        LONG bmWidthBytes;
        WORD bmPlanes;
        WORD bmBitsPixel;
        ULONG cbSize;
        [size_is(cbSize)] byte pBuffer[];
    } userBITMAP;

    typedef union _userHBITMAP switch(long fContext) u {
        case WDT_INPROC_CALL: long hInproc;
        case WDT_REMOTE_CALL: userBITMAP *hRemote;
        case WDT_INPROC64_CALL: __int64 hInproc64;
    } userHBITMAP;

    typedef union _userHPALETTE switch(long fContext) u {
        case WDT_INPROC_CALL: long hInproc;
        case WDT_REMOTE_CALL: LOGPALETTE *hRemote;
        case WDT_INPROC64_CALL: __int64 hInproc64;
    } userHPALETTE;

    typedef union _RemotableHandle switch(long fContext) {
        case WDT_INPROC_CALL: long hInproc;
        case WDT_REMOTE_CALL: long hRemote;
    } RemotableHandle;

    typedef [unique] RemotableHandle *wireHWND;
    typedef [unique] RemotableHandle *wireHMENU;
    typedef [unique] RemotableHandle *wireHACCEL;
    typedef [unique] RemotableHandle *wireHBRUSH;
    typedef [unique] RemotableHandle *wireHFONT;
    typedef [unique] RemotableHandle *wireHDC;
    typedef [unique] RemotableHandle *wireHICON;
    typedef [unique] RemotableHandle *wireHRGN;

cpp_quote("#if 0")
#ifndef _MIDL_DECLARE_WIREM_HANDLE
    DECLARE_WIREM_HANDLE(HWND);
    DECLARE_WIREM_HANDLE(HMENU);
    DECLARE_WIREM_HANDLE(HACCEL);
    DECLARE_WIREM_HANDLE(HBRUSH);
    DECLARE_WIREM_HANDLE(HFONT);
    DECLARE_WIREM_HANDLE(HDC);
    DECLARE_WIREM_HANDLE(HICON);
    DECLARE_WIREM_HANDLE(HRGN);
#endif

    typedef HICON HCURSOR;

cpp_quote("#endif")

cpp_quote("#ifndef _TEXTMETRIC_DEFINED")
cpp_quote("#define _TEXTMETRIC_DEFINED")
    typedef struct tagTEXTMETRICW {
        LONG tmHeight;
        LONG tmAscent;
        LONG tmDescent;
        LONG tmInternalLeading;
        LONG tmExternalLeading;
        LONG tmAveCharWidth;
        LONG tmMaxCharWidth;
        LONG tmWeight;
        LONG tmOverhang;
        LONG tmDigitizedAspectX;
        LONG tmDigitizedAspectY;
        WCHAR tmFirstChar;
        WCHAR tmLastChar;
        WCHAR tmDefaultChar;
        WCHAR tmBreakChar;
        BYTE tmItalic;
        BYTE tmUnderlined;
        BYTE tmStruckOut;
        BYTE tmPitchAndFamily;
        BYTE tmCharSet;
    } TEXTMETRICW, *PTEXTMETRICW, *LPTEXTMETRICW;
cpp_quote("#endif")

cpp_quote("#if 0")
    typedef struct tagMSG {
        HWND hwnd;
        UINT message;
        WPARAM wParam;
        LPARAM lParaml;
        DWORD time;
        POINT pt;
    } MSG, *PMSG, *NPMSG, *LPMSG;
cpp_quote("#endif")

    typedef [unique] userHBITMAP *wireHBITMAP;
    typedef [unique] userHPALETTE *wireHPALETTE;
    typedef [unique] userHENHMETAFILE *wireHENHMETAFILE;
    typedef [unique] userHMETAFILE *wireHMETAFILE;
    typedef [unique] userHMETAFILEPICT *wireHMETAFILEPICT;

cpp_quote("#if 0")
    DECLARE_WIREM_HANDLE(HGLOBAL);
    typedef HGLOBAL HLOCAL;
    DECLARE_WIREM_HANDLE(HBITMAP);
    DECLARE_WIREM_HANDLE(HPALETTE);
    DECLARE_WIREM_HANDLE(HENHMETAFILE);
    DECLARE_WIREM_HANDLE(HMETAFILE);
cpp_quote("#endif")

    DECLARE_WIREM_HANDLE(HMETAFILEPICT);

} /* IWinTypes */

typedef double DATE;

cpp_quote("#ifndef _tagCY_DEFINED")
cpp_quote("#define _tagCY_DEFINED")
cpp_quote("#define _CY_DEFINED")

cpp_quote("#if 0")

typedef struct tagCY {
    LONGLONG int64;
} CY;

cpp_quote("#else")

cpp_quote("  typedef union tagCY {")
cpp_quote("    __C89_NAMELESS struct {")
cpp_quote("      ULONG Lo;")
cpp_quote("      LONG Hi;")
cpp_quote("    } DUMMYSTRUCTNAME;")
cpp_quote("    LONGLONG int64;")
cpp_quote("  } CY;")

cpp_quote("#endif")
cpp_quote("#endif")

typedef CY *LPCY;

cpp_quote("#if 0")

typedef struct tagDEC {
    USHORT wReserved;
    BYTE scale;
    BYTE sign;
    ULONG Hi32;
    ULONGLONG Lo64;
} DECIMAL;

cpp_quote("#else")

cpp_quote("  typedef struct tagDEC {")
cpp_quote("    USHORT wReserved;")
cpp_quote("    __C89_NAMELESS union {")
cpp_quote("      __C89_NAMELESS struct {")
cpp_quote("	BYTE scale;")
cpp_quote("	BYTE sign;")
cpp_quote("      } DUMMYSTRUCTNAME;")
cpp_quote("      USHORT signscale;")
cpp_quote("    } DUMMYUNIONNAME;")
cpp_quote("    ULONG Hi32;")
cpp_quote("    __C89_NAMELESS union {")
cpp_quote("      __C89_NAMELESS struct {")
cpp_quote("	ULONG Lo32;")
cpp_quote("	ULONG Mid32;")
cpp_quote("      } DUMMYSTRUCTNAME2;")
cpp_quote("      ULONGLONG Lo64;")
cpp_quote("    } DUMMYUNIONNAME2;")
cpp_quote("  } DECIMAL;")

cpp_quote("#define DECIMAL_NEG ((BYTE)0x80)")
cpp_quote("#define DECIMAL_SETZERO(dec) {(dec).Lo64 = 0; (dec).Hi32 = 0; (dec).signscale = 0;}")

cpp_quote("#endif")

typedef DECIMAL *LPDECIMAL;

typedef [unique] FLAGGED_WORD_BLOB *wireBSTR;
typedef [wire_marshal(wireBSTR)] OLECHAR *BSTR;
typedef BSTR *LPBSTR;

typedef short VARIANT_BOOL;
typedef VARIANT_BOOL _VARIANT_BOOL;

cpp_quote("#ifndef _BOOLEAN_")
cpp_quote("#define _BOOLEAN_")
typedef boolean BOOLEAN;
cpp_quote("#endif")

cpp_quote("#ifndef _tagBSTRBLOB_DEFINED")
cpp_quote("#define _tagBSTRBLOB_DEFINED")
typedef struct tagBSTRBLOB {
    ULONG cbSize;
    [size_is(cbSize)] BYTE *pData;
} BSTRBLOB, *LPBSTRBLOB;
cpp_quote("#endif")

cpp_quote("#define VARIANT_TRUE ((VARIANT_BOOL)-1)")
cpp_quote("#define VARIANT_FALSE ((VARIANT_BOOL)0)")

cpp_quote("#ifndef _tagBLOB_DEFINED")
cpp_quote("#define _tagBLOB_DEFINED")
cpp_quote("#define _BLOB_DEFINED")
cpp_quote("#define _LPBLOB_DEFINED")
typedef struct tagBLOB {
    ULONG cbSize;
    [size_is(cbSize)] BYTE *pBlobData;
} BLOB, *LPBLOB;
cpp_quote("#endif")

typedef struct tagCLIPDATA {
    ULONG cbSize;
    long ulClipFmt;
    [size_is(cbSize-4)] BYTE *pClipData;
} CLIPDATA;

cpp_quote("#define CBPCLIPDATA(clipdata) ((clipdata).cbSize - sizeof((clipdata).ulClipFmt))")

typedef unsigned short VARTYPE;

#include <psdk_inc/_varenum.h>

typedef ULONG PROPID;

cpp_quote("#ifndef PROPERTYKEY_DEFINED")
cpp_quote("#define PROPERTYKEY_DEFINED")
typedef struct _tagpropertykey {
    GUID  fmtid;
    DWORD pid;
} PROPERTYKEY;
cpp_quote("#endif")

cpp_quote("#ifndef SID_IDENTIFIER_AUTHORITY_DEFINED")
cpp_quote("#define SID_IDENTIFIER_AUTHORITY_DEFINED")
typedef struct _SID_IDENTIFIER_AUTHORITY {
    UCHAR Value[6];
} SID_IDENTIFIER_AUTHORITY, *PSID_IDENTIFIER_AUTHORITY;
cpp_quote("#endif")

cpp_quote("#ifndef SID_DEFINED")
cpp_quote("#define SID_DEFINED")
typedef struct _SID {
    BYTE Revision;
    BYTE SubAuthorityCount;
    SID_IDENTIFIER_AUTHORITY IdentifierAuthority;
    [size_is(SubAuthorityCount)] ULONG SubAuthority[*];
} SID, *PISID;

typedef struct _SID_AND_ATTRIBUTES {
    SID *Sid;
    DWORD Attributes;
} SID_AND_ATTRIBUTES, *PSID_AND_ATTRIBUTES;
cpp_quote("#endif")

typedef struct tagCSPLATFORM {
    DWORD dwPlatformId;
    DWORD dwVersionHi;
    DWORD dwVersionLo;
    DWORD dwProcessorArch;
} CSPLATFORM;

typedef struct tagQUERYCONTEXT {
    DWORD dwContext;
    CSPLATFORM Platform;
    LCID Locale;
    DWORD dwVersionHi;
    DWORD dwVersionLo;
} QUERYCONTEXT;

typedef [v1_enum] enum tagTYSPEC {
    TYSPEC_CLSID = 0,
    TYSPEC_FILEEXT,
    TYSPEC_MIMETYPE,
    TYSPEC_FILENAME,
    TYSPEC_PROGID,
    TYSPEC_PACKAGENAME,
    TYSPEC_OBJECTID
} TYSPEC;

typedef union switch(DWORD tyspec) {
 case TYSPEC_CLSID:
     CLSID clsid;
 case TYSPEC_FILEEXT:
     LPOLESTR pFileExt;
 case TYSPEC_MIMETYPE:
     LPOLESTR pMimeType;
 case TYSPEC_PROGID:
     LPOLESTR pProgId;
 case TYSPEC_FILENAME:
     LPOLESTR pFileName;
 case TYSPEC_PACKAGENAME:
     struct {
         LPOLESTR pPackageName;
         GUID PolicyId;
     } ByName;
 case TYSPEC_OBJECTID:
     struct {
         GUID ObjectId;
         GUID PolicyId;
     } ByObjectId;
} uCLSSPEC;
