Mercurial > projects > dwt-win
changeset 97:2e6eb5bd2c16
starting OLE
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Fri, 08 Feb 2008 19:49:32 +0100 |
parents | aee1890f38c3 |
children | ecba636b634e |
files | dwt/dwthelper/utils.d dwt/internal/ole/win32/COM.d dwt/internal/ole/win32/COMAPI.d dwt/internal/ole/win32/COMTYPES.d dwt/internal/ole/win32/DOCOBJ.d dwt/internal/ole/win32/EXDISP.d dwt/internal/ole/win32/MSHTMHST.d dwt/internal/ole/win32/OAIDL.d dwt/internal/ole/win32/OBJIDL.d dwt/internal/ole/win32/OLEIDL.d dwt/internal/ole/win32/extras.d dwt/internal/ole/win32/ifs.d dwt/internal/win32/OS.d dwt/internal/win32/WINTYPES.d dwt/ole/win32/OLE.d dwt/ole/win32/OleAutomation.d dwt/ole/win32/OleClientSite.d dwt/ole/win32/OleControlSite.d dwt/ole/win32/Variant.d |
diffstat | 19 files changed, 12047 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/dwt/dwthelper/utils.d Fri Feb 08 11:57:24 2008 +0100 +++ b/dwt/dwthelper/utils.d Fri Feb 08 19:49:32 2008 +0100 @@ -6,12 +6,13 @@ public import dwt.dwthelper.System; public import Math = tango.math.Math; +public import tango.core.Exception : IllegalArgumentException; + import tango.io.Stdout; import tango.stdc.stringz; import tango.text.Util; import tango.text.Unicode; import tango.text.convert.Utf; -import tango.core.Exception; import tango.stdc.stdlib : exit; void implMissing( char[] file, uint line ){
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/ole/win32/COM.d Fri Feb 08 19:49:32 2008 +0100 @@ -0,0 +1,818 @@ + +/* + * COM types, constants and APIs + * + * all API are aliased from other modules + * + * author : Shawn Liu + */ + +module dwt.internal.ole.win32.COM; + + +private import dwt.internal.ole.win32.COMTYPES; +private import dwt.internal.ole.win32.OAIDL; +private import dwt.internal.ole.win32.OBJIDL; +private import dwt.internal.ole.win32.OLEIDL; +private import dwt.internal.ole.win32.DOCOBJ; +private import dwt.internal.ole.win32.EXDISP; +private import dwt.internal.ole.win32.MSHTMHST; +private import dwt.internal.ole.win32.extras; +private import dwt.internal.ole.win32.ifs; +private import dwt.internal.ole.win32.COMAPI; + +private alias dwt.internal.ole.win32.COMAPI COMAPI; + + +public import dwt.internal.win32.OS; + +public class COM : OS { + + //private import std.c.windows.com; + + // all the GUID + // GUIDs for Home Page Browser + public static const GUID IIDJavaBeansBridge = { 0x8AD9C840, 0x044E, 0x11D1, [ 0xB3, 0xE9, 0x00, 0x80, 0x5F, 0x49, 0x9D, 0x93]}; //$NON-NLS-1$ + public static const GUID IIDShockwaveActiveXControl = { 0x166B1BCA, 0x3F9C, 0x11CF, [ 0x80, 0x75, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00]}; //$NON-NLS-1$ + public const GUID IIDIEditorSiteTime = { 0x6BD2AEFE, 0x7876, 0x45e6, [0xA6, 0xE7, 0x3B, 0xFC, 0xDF, 0x65, 0x40, 0xAA]}; + public const GUID IIDIEditorSiteProperty = { 0xD381A1F4, 0x2326, 0x4f3c, [0xAF, 0xB9, 0xB7, 0x53, 0x7D, 0xB9, 0xE2, 0x38]}; + public const GUID IIDIEditorBaseProperty = { 0x61E55B0B, 0x2647, 0x47c4, [0x8C, 0x89, 0xE7, 0x36, 0xEF, 0x15, 0xD6, 0x36]}; + public const GUID IIDIEditorSite = { 0xCDD88AB9, 0xB01D, 0x426E, [0xB0, 0xF0, 0x30, 0x97, 0x3E, 0x9A, 0x07, 0x4B]}; + public const GUID IIDIEditorService = { 0xBEE283FE, 0x7B42, 0x4FF3, [0x82, 0x32, 0x0F, 0x07, 0xD4, 0x3A, 0xBC, 0xF1]}; + public const GUID IIDIEditorManager = { 0xEFDE08C4, 0xBE87, 0x4B1A, [0xBF, 0x84, 0x15, 0xFC, 0x30, 0x20, 0x71, 0x80]}; + + public const GUID IIDIAccessible = { 0x618736E0, 0x3C3D, 0x11CF, [0x81, 0x0C, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71]}; + //public const GUID IIDIAccessibleHandler = { 0x03022430, 0xABC4, 0x11D0, [0xBD, 0xE2, 0x00, 0xAA, 0x00, 0x1A, 0x19, 0x53]}; + //public const GUID IIDIAccessor = { 0x0C733A8C, 0x2A1C, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]}; + + public const GUID IIDIAdviseSink = { 0x0000010F, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]}; + //public const GUID IIDIAdviseSink2 = { 0x00000125, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]}; + //public const GUID IIDIBindCtx = { 0x0000000E, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]}; + //public const GUID IIDIClassFactory = { 0x00000001, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]}; + public const GUID IIDIClassFactory2 = { 0xB196B28F, 0xBAB4, 0x101A, [0xB6, 0x9C, 0x00, 0xAA, 0x00, 0x34, 0x1D, 0x07]}; + public const GUID IIDIConnectionPoint = { 0xB196B286, 0xBAB4, 0x101A, [0xB6, 0x9C, 0x00, 0xAA, 0x00, 0x34, 0x1D, 0x07]}; + public const GUID IIDIConnectionPointContainer = { 0xB196B284, 0xBAB4, 0x101A, [0xB6, 0x9C, 0x00, 0xAA, 0x00, 0x34, 0x1D, 0x07]}; + //public const GUID IIDICreateErrorInfo = { 0x22F03340, 0x547D, 0x101B, [0x8E, 0x65, 0x08, 0x00, 0x2B, 0x2B, 0xD1, 0x19]}; + //public const GUID IIDICreateTypeInfo = { 0x00020405, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]}; + //public const GUID IIDICreateTypeLib = { 0x00020406, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]}; + //public const GUID IIDIDataAdviseHolder = { 0x00000110, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]}; + public const GUID IIDIDataObject = { 0x0000010E, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]}; + public const GUID IIDIDispatch = { 0x00020400, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]}; + public const GUID IIDIDocHostUIHandler = { 0xBD3F23C0, 0xD43E, 0x11CF, [0x89, 0x3B, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x1A]}; + public const GUID IIDIDocHostShowUI = { 0xC4D244B0, 0xD43E, 0x11CF, [0x89, 0x3B, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x1A]}; + public const GUID IIDIDropSource = { 0x00000121, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]}; + public const GUID IIDIDropTarget = { 0x00000122, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]}; + //public const GUID IIDIEnumConnectionPoints = { 0xB196B285, 0xBAB4, 0x101A, [0xB6, 0x9C, 0x00, 0xAA, 0x00, 0x34, 0x1D, 0x07]}; + //public const GUID IIDIEnumConnections = { 0xB196B287, 0xBAB4, 0x101A, [0xB6, 0x9C, 0x00, 0xAA, 0x00, 0x34, 0x1D, 0x07]}; + public const GUID IIDIEnumFORMATETC = { 0x00000103, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]}; + //public const GUID IIDIEnumMoniker = { 0x00000102, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]}; + //public const GUID IIDIEnumOLEVERB = { 0x00000104, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]}; + //public const GUID IIDIEnumSTATDATA = { 0x00000105, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]}; + //public const GUID IIDIEnumSTATSTG = { 0x0000000D, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]}; + //public const GUID IIDIEnumString = { 0x00000101, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]}; + //public const GUID IIDIEnumUnknown = { 0x00000100, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]}; + public const GUID IIDIEnumVARIANT = { 0x00020404, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]}; + //public const GUID IIDIErrorInfo = { 0x1CF2B120, 0x547D, 0x101B, [0x8E, 0x65, 0x08, 0x00, 0x2B, 0x2B, 0xD1, 0x19]}; + //public const GUID IIDIErrorLog = { 0x3127CA40, 0x446E, 0x11CE, [0x81, 0x35, 0x00, 0xAA, 0x00, 0x4B, 0xB8, 0x51]}; + //public const GUID IIDIExternalConnection = { 0x00000019, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]}; + public const GUID IIDIFont = { 0xBEF6E002, 0xA874, 0x101A, [0x8B, 0xBA, 0x00, 0xAA, 0x00, 0x30, 0x0C, 0xAB]}; + //public const GUID IIDIFontDisp = { 0xBEF6E003, 0xA874, 0x101A, [0x8B, 0xBA, 0x00, 0xAA, 0x00, 0x30, 0x0C, 0xAB]}; + public static const /*GUID*/ char[] IIDIHTMLDocumentEvents2 = /*IIDFromString(*/"{3050F613-98B5-11CF-BB82-00AA00BDCE0B}"/*)*/; + public const GUID IIDIInternetSecurityManager = { 0x79eac9ee, 0xbaf9, 0x11ce, [0x8c, 0x82, 0x00, 0xaa, 0x00, 0x4b, 0xa9, 0x0b]}; + //public const GUID IIDILockBytes = { 0x0000000A, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]}; + //public const GUID IIDIMalloc = { 0x00000002, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]}; + //public const GUID IIDIMallocSpy = { 0x0000001D, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]}; + //public const GUID IIDIMarshal = { 0x00000003, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]}; + //public const GUID IIDIMessageFilter = { 0x00000016, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]}; + //public const GUID IIDIMoniker = { 0x0000000F, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]}; + //public const GUID IIDIOleAdviseHolder = { 0x00000111, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]}; + //public const GUID IIDIOleCache = { 0x0000011E, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]}; + //public const GUID IIDIOleCache2 = { 0x00000128, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]}; + //public const GUID IIDIOleCacheControl = { 0x00000129, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]}; + public const GUID IIDIOleClientSite = { 0x00000118, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]}; + public const GUID IIDIOleCommandTarget = { 0xB722BCCB, 0x4E68, 0x101B, [0xA2, 0xBC, 0x00, 0xAA, 0x00, 0x40, 0x47, 0x70]}; + public const GUID IIDIOleContainer = { 0x0000011B, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]}; + public const GUID IIDIOleControl = { 0xB196B288, 0xBAB4, 0x101A, [0xB6, 0x9C, 0x00, 0xAA, 0x00, 0x34, 0x1D, 0x07]}; + public const GUID IIDIOleControlSite = { 0xB196B289, 0xBAB4, 0x101A, [0xB6, 0x9C, 0x00, 0xAA, 0x00, 0x34, 0x1D, 0x07]}; + public const GUID IIDIOleDocument = { 0xB722BCC5, 0x4E68, 0x101B, [0xA2, 0xBC, 0x00, 0xAA, 0x00, 0x40, 0x47, 0x70]}; + public const GUID IIDIOleDocumentSite = { 0xB722BCC7, 0x4E68, 0x101B, [0xA2, 0xBC, 0x00, 0xAA, 0x00, 0x40, 0x47, 0x70]}; + public const GUID IIDIOleInPlaceActiveObject = { 0x00000117, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]}; + public const GUID IIDIOleInPlaceFrame = { 0x00000116, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]}; + public const GUID IIDIOleInPlaceObject = { 0x00000113, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]}; + public const GUID IIDIOleInPlaceSite = { 0x00000119, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]}; + public const GUID IIDIOleInPlaceUIWindow = { 0x00000115, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]}; + //public const GUID IIDIOleItemContainer = { 0x0000011C, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]}; + public const GUID IIDIOleLink = { 0x0000011D, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]}; + public const GUID IIDIOleObject = { 0x00000112, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]}; + public const GUID IIDIOleWindow = { 0x00000114, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]}; + //public const GUID IIDIParseDisplayName = { 0x0000011A, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]}; + //public const GUID IIDIPerPropertyBrowsing = { 0x376BD3AA, 0x3845, 0x101B, [0x84, 0xED, 0x08, 0x00, 0x2B, 0x2E, 0xC7, 0x13]}; + public const GUID IIDIPersist = { 0x0000010C, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]}; + public const GUID IIDIPersistFile = { 0x0000010B, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]}; + //public const GUID IIDIPersistMemory = { 0xBD1AE5E0, 0xA6AE, 0x11CE, [0xBD, 0x37, 0x50, 0x42, 0x00, 0xC1, 0x00, 0x00]}; + //public const GUID IIDIPersistPropertyBag = { 0x37D84F60, 0x42CB, 0x11CE, [0x81, 0x35, 0x00, 0xAA, 0x00, 0x4B, 0xB8, 0x51]}; + public const GUID IIDIPersistStorage = { 0x0000010A, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]}; + public const GUID IIDIPersistStream = { 0x00000109, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]}; + public const GUID IIDIPersistStreamInit = { 0x7FD52380, 0x4E07, 0x101B, [0xAE, 0x2D, 0x08, 0x00, 0x2B, 0x2E, 0xC7, 0x13]}; + //public const GUID IIDIPicture = { 0x7BF80980, 0xBF32, 0x101A, [0x8B, 0xBB, 0x00, 0xAA, 0x00, 0x30, 0x0C, 0xAB]}; + //public const GUID IIDIPictureDisp = { 0x7BF80981, 0xBF32, 0x101A, [0x8B, 0xBB, 0x00, 0xAA, 0x00, 0x30, 0x0C, 0xAB]}; + //public const GUID IIDIPropertyBag = { 0x55272A00, 0x42CB, 0x11CE, [0x81, 0x35, 0x00, 0xAA, 0x00, 0x4B, 0xB8, 0x51]}; + public const GUID IIDIPropertyNotifySink = { 0x9BFBBC02, 0xEFF1, 0x101A, [0x84, 0xED, 0x00, 0xAA, 0x00, 0x34, 0x1D, 0x07]}; + //public const GUID IIDIPropertyPage = { 0xB196B28D, 0xBAB4, 0x101A, [0xB6, 0x9C, 0x00, 0xAA, 0x00, 0x34, 0x1D, 0x07]}; + //public const GUID IIDIPropertyPage2 = { 0x01E44665, 0x24AC, 0x101B, [0x84, 0xED, 0x08, 0x00, 0x2B, 0x2E, 0xC7, 0x13]}; + //public const GUID IIDIPropertyPageSite = { 0xB196B28C, 0xBAB4, 0x101A, [0xB6, 0x9C, 0x00, 0xAA, 0x00, 0x34, 0x1D, 0x07]}; + public const GUID IIDIProvideClassInfo = { 0xB196B283, 0xBAB4, 0x101A, [0xB6, 0x9C, 0x00, 0xAA, 0x00, 0x34, 0x1D, 0x07]}; + public const GUID IIDIProvideClassInfo2 = { 0xA6BC3AC0, 0xDBAA, 0x11CE, [0x9D, 0xE3, 0x00, 0xAA, 0x00, 0x4B, 0xB8, 0x51]}; + //public const GUID IIDIPSFactoryBuffer = { 0xD5F569D0, 0x593B, 0x101A, [0xB5, 0x69, 0x08, 0x00, 0x2B, 0x2D, 0xBF, 0x7A]}; + //public const GUID IIDIRootStorage = { 0x00000012, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]}; + //public const GUID IIDIROTData = { 0xF29F6BC0, 0x5021, 0x11CE, [0xAA, 0x15, 0x00, 0x00, 0x69, 0x01, 0x29, 0x3F]}; + //public const GUID IIDIRpcChannelBuffer = { 0xD5F56B60, 0x593B, 0x101A, [0xB5, 0x69, 0x08, 0x00, 0x2B, 0x2D, 0xBF, 0x7A]}; + //public const GUID IIDIRpcProxyBuffer = { 0xD5F56A34, 0x593B, 0x101A, [0xB5, 0x69, 0x08, 0x00, 0x2B, 0x2D, 0xBF, 0x7A]}; + //public const GUID IIDIRpcStubBuffer = { 0xD5F56AFC, 0x593B, 0x101A, [0xB5, 0x69, 0x08, 0x00, 0x2B, 0x2D, 0xBF, 0x7A]}; + //public const GUID IIDIRunnableObject = { 0x00000126, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]}; + //public const GUID IIDIRunningObjectTable = { 0x00000010, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]}; + //public const GUID IIDISimpleFrameSite = { 0x742B0E01, 0x14E6, 0x101B, [0x91, 0x4E, 0x00, 0xAA, 0x00, 0x30, 0x0C, 0xAB]}; + public const GUID IIDIServiceProvider = { 0x6d5140c1, 0x7436, 0x11ce, [0x80, 0x34, 0x00, 0xaa, 0x00, 0x60, 0x09, 0xfa]}; + public const GUID IIDISpecifyPropertyPages = { 0xB196B28B, 0xBAB4, 0x101A, [0xB6, 0x9C, 0x00, 0xAA, 0x00, 0x34, 0x1D, 0x07]}; + //public const GUID IIDIStdMarshalInfo = { 0x00000018, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]}; + public const GUID IIDIStorage = { 0x0000000B, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]}; + public const GUID IIDIStream = { 0x0000000C, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]}; + //public const GUID IIDISupportErrorInfo = { 0xDF0B3D60, 0x548F, 0x101B, [0x8E, 0x65, 0x08, 0x00, 0x2B, 0x2B, 0xD1, 0x19]}; + //public const GUID IIDITypeComp = { 0x00020403, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]}; + //public const GUID IIDITypeLib = { 0x00020402, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]}; + public const GUID IIDIUnknown = { 0x00000000, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]}; + //public const GUID IIDIViewObject = { 0x0000010D, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]}; + public const GUID IIDIViewObject2 = { 0x00000127, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]}; + public static const GUID CGID_DocHostCommandHandler = { 0xf38bc242, 0xb950, 0x11d1, [0x89, 0x18, 0x00, 0xc0, 0x4f, 0xc2, 0xc8, 0x36]}; //$NON-NLS-1$ + public static const GUID CGID_Explorer = { 0x000214D0, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]}; //$NON-NLS-1$ + + /* Constants */ + //public static const int ADVF_DATAONSTOP = 64; + //public static const int ADVF_NODATA = 1; + //public static const int ADVF_ONLYONCE = 2; + //public static const int ADVF_PRIMEFIRST = 4; + //public static const int ADVFCACHE_FORCEBUILTIN = 16; + //public static const int ADVFCACHE_NOHANDLER = 8; + //public static const int ADVFCACHE_ONSAVE = 32; + public static const int CF_TEXT = 1; + public static const int CF_BITMAP = 2; + public static const int CF_METAFILEPICT = 3; + public static const int CF_SYLK = 4; + public static const int CF_DIF = 5; + public static const int CF_TIFF = 6; + public static const int CF_OEMTEXT = 7; + public static const int CF_DIB = 8; + public static const int CF_PALETTE = 9; + public static const int CF_PENDATA = 10; + public static const int CF_RIFF = 11; + public static const int CF_WAVE = 12; + public static const int CF_UNICODETEXT = 13; + public static const int CF_ENHMETAFILE = 14; + public static const int CF_HDROP = 15; + public static const int CF_LOCALE = 16; + public static const int CF_MAX = 17; + public static const int CLSCTX_INPROC_HANDLER = 2; + public static const int CLSCTX_INPROC_SERVER = 1; + public static const int CLSCTX_LOCAL_SERVER = 4; + public static const int CLSCTX_REMOTE_SERVER = 16; + public static const int CO_E_CLASSSTRING = -2147221005; + //public static const int COINIT_APARTMENTTHREADED = 2; + //public static const int COINIT_DISABLE_OLE1DDE = 4; + //public static const int COINIT_MULTITHREADED = 0; + //public static const int COINIT_SPEED_OVER_MEMORY = 8; + public static const int DATADIR_GET = 1; + public static const int DATADIR_SET = 2; + public static const int DISP_E_EXCEPTION = 0x80020009; + public static const int DISP_E_MEMBERNOTFOUND = -2147352573; + public static const int DISP_E_UNKNOWNINTERFACE = 0x80020001; + //public static const int DISPID_AMBIENT_APPEARANCE = -716; + //public static const int DISPID_AMBIENT_AUTOCLIP = -715; + public static const int DISPID_AMBIENT_BACKCOLOR = -701; + //public static const int DISPID_AMBIENT_CHARSET = -727; + //public static const int DISPID_AMBIENT_CODEPAGE = -725; + //public static const int DISPID_AMBIENT_DISPLAYASDEFAULT = -713; + //public static const int DISPID_AMBIENT_DISPLAYNAME = -702; + public static const int DISPID_AMBIENT_FONT = -703; + public static const int DISPID_AMBIENT_FORECOLOR = -704; + public static const int DISPID_AMBIENT_LOCALEID = -705; + public static const int DISPID_AMBIENT_MESSAGEREFLECT = -706; + public static const int DISPID_AMBIENT_OFFLINEIFNOTCONNECTED = -5501; + //public static const int DISPID_AMBIENT_PALETTE = -726; + //public static const int DISPID_AMBIENT_RIGHTTOLEFT = -732; + //public static const int DISPID_AMBIENT_SCALEUNITS = -707; + public static const int DISPID_AMBIENT_SHOWGRABHANDLES = -711; + public static const int DISPID_AMBIENT_SHOWHATCHING = -712; + public static const int DISPID_AMBIENT_SILENT = -5502; + public static const int DISPID_AMBIENT_SUPPORTSMNEMONICS = -714; + //public static const int DISPID_AMBIENT_TEXTALIGN = -708; + //public static const int DISPID_AMBIENT_TOPTOBOTTOM = -733; + //public static const int DISPID_AMBIENT_TRANSFERPRIORITY = -728; + public static const int DISPID_AMBIENT_UIDEAD = -710; + public static const int DISPID_AMBIENT_USERMODE = -709; + public static const int DISPID_BACKCOLOR = -501; + public static const int DISPID_FONT = -512; + public static const int DISPID_FONT_BOLD = 3; + public static const int DISPID_FONT_CHARSET = 8; + public static const int DISPID_FONT_ITALIC = 4; + public static const int DISPID_FONT_NAME = 0; + public static const int DISPID_FONT_SIZE = 2; + public static const int DISPID_FONT_STRIKE = 6; + public static const int DISPID_FONT_UNDER = 5; + public static const int DISPID_FONT_WEIGHT = 7; + public static const int DISPID_FORECOLOR = -513; + public static const int DISPID_HTMLDOCUMENTEVENTS_ONDBLCLICK = 0xFFFFFDA7; + public static const int DISPID_HTMLDOCUMENTEVENTS_ONDRAGSTART = 0x8001000B; + public static const int DISPID_HTMLDOCUMENTEVENTS_ONMOUSEOUT = 0x80010009; + public static const int DISPID_HTMLDOCUMENTEVENTS_ONMOUSEOVER = 0x80010008; + public static const int DISPID_HTMLDOCUMENTEVENTS_ONMOUSEMOVE = 0xFFFFFDA2; + public static const int DISPID_HTMLDOCUMENTEVENTS_ONMOUSEDOWN = 0xFFFFFDA3; + public static const int DISPID_HTMLDOCUMENTEVENTS_ONMOUSEUP = 0xFFFFFDA1; + public static const int DISPID_HTMLDOCUMENTEVENTS_ONSTOP = 0x00000402; + + //public static const int DISPID_READYSTATE = -525; + //public static const int DISPID_READYSTATECHANGE = -609; + public static const int DRAGDROP_S_DROP = 0x00040100; + public static const int DRAGDROP_S_CANCEL = 0x00040101; + public static const int DRAGDROP_S_USEDEFAULTCURSORS = 0x00040102; + public static const int DROPEFFECT_NONE = 0; + public static const int DROPEFFECT_COPY = 1; + public static const int DROPEFFECT_MOVE = 2; + public static const int DROPEFFECT_LINK = 4; + public static const int DROPEFFECT_SCROLL = 0x80000000; + public static const int DV_E_FORMATETC = -2147221404; + public static const int DV_E_STGMEDIUM = -2147221402; + public static const int DV_E_TYMED = -2147221399; + public static const int DVASPECT_CONTENT = 1; + //public static const int DVASPECT_DOCPRINT = 8; + //public static const int DVASPECT_ICON = 4; + //public static const int DVASPECT_THUMBNAIL = 2; + public static const int E_FAIL = -2147467259; + public static const int E_INVALIDARG = -2147024809; + public static const int E_NOINTERFACE = -2147467262; + public static const int E_NOTIMPL = -2147467263; + public static const int E_NOTSUPPORTED = 0x80040100; + //public static const int E_NOTLICENSED = -2147221230; + public static const int E_OUTOFMEMORY = -2147024882; + //public static const int E_POINTER = -2147467261; + public static const int GMEM_FIXED = 0; + //public static const int GMEM_MOVABLE = 2; + //public static const int GMEM_NODISCARD = 32; + public static const int GMEM_ZEROINIT = 64; + public static const int GUIDKIND_DEFAULT_SOURCE_DISP_IID = 1; + public static const int IMPLTYPEFLAG_FDEFAULT = 1; + //public static const int IMPLTYPEFLAG_FDEFAULTVTABLE = 2048; + public static const int IMPLTYPEFLAG_FRESTRICTED = 4; + public static const int IMPLTYPEFLAG_FSOURCE = 2; + public static const int LOCALE_SYSTEM_DEFAULT = 1024; + public static const int LOCALE_USER_DEFAULT = 2048; + //public static const int MEMCTX_TASK = 1; + //public static const int OLEACTIVATEAUTO = 3; + //public static const int OLEACTIVATEDOUBLECLICK = 2; + //public static const int OLEACTIVATEGETFOCUS = 1; + //public static const int OLEACTIVATEMANUAL = 0; + //public static const int OLEAUTOMATIC = 0; + //public static const int OLECHANGED = 0; + public static const int OLECLOSE_NOSAVE = 1; + //public static const int OLECLOSE_PROMPTSAVE = 2; + public static const int OLECLOSE_SAVEIFDIRTY = 0; + //public static const int OLECLOSED = 2; + //public static const int OLECONTF_EMBEDDINGS = 1; + //public static const int OLECONTF_LINKS = 2; + //public static const int OLECONTF_ONLYIFRUNNING = 16; + //public static const int OLECONTF_ONLYUSER = 8; + //public static const int OLECONTF_OTHERS = 4; + //public static const int OLEDEACTIVATEMANUAL = 1; + //public static const int OLEDEACTIVATEONLOSEFOCUS = 0; + //public static const int OLEDECBORDER = 1; + //public static const int OLEDECBORDERANDNIBS = 3; + //public static const int OLEDECNIBS = 2; + //public static const int OLEDECNONE = 0; + //public static const int OLEDISPLAYCONTENT = 0; + //public static const int OLEDISPLAYICON = 1; + //public static const int OLEEITHER = 2; + public static const int OLEEMBEDDED = 1; + //public static const int OLEFROZEN = 1; + public static const int OLEIVERB_DISCARDUNDOSTATE = -6; + //public static const int OLEIVERB_HIDE = -3; + public static const int OLEIVERB_INPLACEACTIVATE = -5; + //public static const int OLEIVERB_OPEN = -2; + public static const int OLEIVERB_PRIMARY = 0; + //public static const int OLEIVERB_PROPERTIES = -7; + //public static const int OLEIVERB_SHOW = -1; + //public static const int OLEIVERB_UIACTIVATE = -4; + public static const int OLELINKED = 0; + //public static const int OLEMANUAL = 2; + //public static const int OLEMISC_ACTIVATEWHENVISIBLE = 256; + //public static const int OLEMISC_ACTSLIKEBUTTON = 4096; + //public static const int OLEMISC_ACTSLIKELABEL = 8192; + //public static const int OLEMISC_ALIGNABLE = 32768; + //public static const int OLEMISC_ALWAYSRUN = 2048; + //public static const int OLEMISC_CANLINKBYOLE1 = 32; + //public static const int OLEMISC_CANTLINKINSIDE = 16; + //public static const int OLEMISC_IGNOREACTIVATEWHENVISIBLE = 524288; + //public static const int OLEMISC_IMEMODE = 262144; + //public static const int OLEMISC_INSERTNOTREPLACE = 4; + //public static const int OLEMISC_INSIDEOUT = 128; + //public static const int OLEMISC_INVISIBLEATRUNTIME = 1024; + //public static const int OLEMISC_ISLINKOBJECT = 64; + //public static const int OLEMISC_NOUIACTIVATE = 16384; + //public static const int OLEMISC_ONLYICONIC = 2; + //public static const int OLEMISC_RECOMPOSEONRESIZE = 1; + //public static const int OLEMISC_RENDERINGISDEVICEINDEPENDENT = 512; + //public static const int OLEMISC_SETCLIENTSITEFIRST = 131072; + //public static const int OLEMISC_SIMPLEFRAME = 65536; + //public static const int OLEMISC_STATIC = 8; + //public static const int OLEMISC_SUPPORTSMULTILEVELUNDO = 2097152; + //public static const int OLEMISC_WANTSTOMENUMERGE = 1048576; + //public static const int OLENONE = 3; + //public static const int OLERENAMED = 3; + //public static const int OLERENDER_ASIS = 3; + public static const int OLERENDER_DRAW = 1; + //public static const int OLERENDER_FORMAT = 2; + //public static const int OLERENDER_NONE = 0; + //public static const int OLESAVED = 1; + //public static const int OLESIZEAUTOSIZE = 2; + //public static const int OLESIZECLIP = 0; + //public static const int OLESIZESTRETCH = 1; + //public static const int OLESIZEZOOM = 3; + //public static const int OLEWHICHMK_CONTAINER = 1; + //public static const int OLEWHICHMK_OBJFULL = 3; + //public static const int OLEWHICHMK_OBJREL = 2; + public static const int S_FALSE = 1; + public static const int S_OK = 0; + public static const int STG_E_FILENOTFOUND = 0x80030002; + public static const int STG_S_CONVERTED = 0x00030200; + //public static const int STGC_CONSOLIDATE = 8; + //public static const int STGC_DANGEROUSLYCOMMITMERELYTODISKCACHE = 4; + public static const int STGC_DEFAULT = 0; + //public static const int STGC_ONLYIFCURRENT = 2; + //public static const int STGC_OVERWRITE = 1; + public static const int STGM_CONVERT = 0x00020000; + public static const int STGM_CREATE = 0x00001000; + public static const int STGM_DELETEONRELEASE = 0x04000000; + public static const int STGM_DIRECT = 0x00000000; + public static const int STGM_DIRECT_SWMR = 0x00400000; + public static const int STGM_FAILIFTHERE = 0x00000000; + public static const int STGM_NOSCRATCH = 0x00100000; + public static const int STGM_NOSNAPSHOT = 0x00200000; + public static const int STGM_PRIORITY = 0x00040000; + public static const int STGM_READ = 0x00000000; + public static const int STGM_READWRITE = 0x00000002; + public static const int STGM_SHARE_DENY_NONE = 0x00000040; + public static const int STGM_SHARE_DENY_READ = 0x00000030; + public static const int STGM_SHARE_DENY_WRITE = 0x00000020; + public static const int STGM_SHARE_EXCLUSIVE = 0x00000010; + public static const int STGM_SIMPLE = 0x08000000; + public static const int STGM_TRANSACTED = 0x00010000; + public static const int STGM_WRITE = 0x00000001; + public static const int STGTY_STORAGE = 1; + public static const int STGTY_STREAM = 2; + public static const int STGTY_LOCKBYTES = 3; + public static const int STGTY_PROPERTY = 4; + //public static const int TYMED_ENHMF = 64; + //public static const int TYMED_FILE = 2; + //public static const int TYMED_GDI = 16; + public static const int TYMED_HGLOBAL = 1; + //public static const int TYMED_ISTORAGE = 8; + //public static const int TYMED_ISTREAM = 4; + //public static const int TYMED_MFPICT = 32; + //public static const int TYMED_NULL = 0; + public static const short DISPATCH_METHOD = 0x1; + public static const short DISPATCH_PROPERTYGET = 0x2; + public static const short DISPATCH_PROPERTYPUT = 0x4; + public static const short DISPATCH_PROPERTYPUTREF = 0x8; + //public static const short DISPID_CONSTRUCTOR = -6; + //public static const short DISPID_DESTRUCTOR = -7; + //public static const short DISPID_EVALUATE = -5; + //public static const short DISPID_NEWENUM = -4; + public static const short DISPID_PROPERTYPUT = -3; + //public static const short DISPID_UNKNOWN = -1; + //public static const short DISPID_VALUE = 0; + public static const short VT_BOOL = 11; + public static const short VT_BSTR = 8; + public static const short VT_BYREF = 16384; + public static const short VT_CY = 6; + public static const short VT_DATE = 7; + public static const short VT_DISPATCH = 9; + public static const short VT_EMPTY = 0; + public static const short VT_ERROR = 10; + public static const short VT_I1 = 16; + public static const short VT_I2 = 2; + public static const short VT_I4 = 3; + public static const short VT_I8 = 20; + public static const short VT_NULL = 1; + public static const short VT_R4 = 4; + public static const short VT_R8 = 5; + public static const short VT_UI1 = 17; + public static const short VT_UI2 = 18; + public static const short VT_UI4 = 19; + public static const short VT_UNKNOWN = 13; + public static const short VT_VARIANT = 12; + public static const short VARIANT_TRUE = -1; + public static const short VARIANT_FALSE = 0; + + +// alias dwt.internal.ole.win32.comapi. +// public static GUID* IIDFromString(char[] lpsz) { +// GUID* lpiid = new GUID(); +// if (COM.IIDFromString(Converter.StrToWCHARz(lpsz), lpiid) == COM.S_OK) +// return lpiid; +// return null; +// } + +alias COMAPI.CLSIDFromProgID CLSIDFromProgID; +alias COMAPI.CLSIDFromString CLSIDFromString; +alias COMAPI.CoCreateInstance CoCreateInstance; +alias COMAPI.CoFreeUnusedLibraries CoFreeUnusedLibraries; +alias COMAPI.CoGetClassObject CoGetClassObject; +alias COMAPI.CoLockObjectExternal CoLockObjectExternal; +alias COMAPI.CoTaskMemAlloc CoTaskMemAlloc; +alias COMAPI.CoTaskMemFree CoTaskMemFree; +alias COMAPI.CreateStdAccessibleObject CreateStdAccessibleObject; +alias COMAPI.CreateStreamOnHGlobal CreateStreamOnHGlobal; +alias COMAPI.DoDragDrop DoDragDrop; +alias COMAPI.GetClassFile GetClassFile; +alias COMAPI.IIDFromString IIDFromString; +alias COMAPI.IsEqualGUID IsEqualGUID; +alias COMAPI.LresultFromObject LresultFromObject; +alias COMAPI.OleCreate OleCreate; +alias COMAPI.OleCreateFromFile OleCreateFromFile; +alias COMAPI.OleCreatePropertyFrame OleCreatePropertyFrame; +alias COMAPI.OleDraw OleDraw; +alias COMAPI.OleFlushClipboard OleFlushClipboard; +alias COMAPI.OleGetClipboard OleGetClipboard; +alias COMAPI.OleIsCurrentClipboard OleIsCurrentClipboard; +alias COMAPI.OleIsRunning OleIsRunning; +alias COMAPI.OleLoad OleLoad; +alias COMAPI.OleRun OleRun; +alias COMAPI.OleSave OleSave; +alias COMAPI.OleSetClipboard OleSetClipboard; +alias COMAPI.OleSetContainedObject OleSetContainedObject; +alias COMAPI.OleSetMenuDescriptor OleSetMenuDescriptor; +alias COMAPI.OleTranslateColor OleTranslateColor; +alias COMAPI.ProgIDFromCLSID ProgIDFromCLSID; +alias COMAPI.RegisterDragDrop RegisterDragDrop; +alias COMAPI.ReleaseStgMedium ReleaseStgMedium; +alias COMAPI.RevokeDragDrop RevokeDragDrop; +alias COMAPI.StgCreateDocfile StgCreateDocfile; +alias COMAPI.StgIsStorageFile StgIsStorageFile; +alias COMAPI.StgOpenStorage StgOpenStorage; +alias COMAPI.StringFromCLSID StringFromCLSID; +alias COMAPI.SysAllocString SysAllocString; +alias COMAPI.SysFreeString SysFreeString; +alias COMAPI.SysStringByteLen SysStringByteLen; +alias COMAPI.VariantChangeType VariantChangeType; +alias COMAPI.VariantClear VariantClear; +alias COMAPI.VariantCopy VariantCopy; +alias COMAPI.VariantInit VariantInit; +alias COMAPI.WriteClassStg WriteClassStg; + +/** + * <Shawn Liu> + * VtbCall partially kept, use VtbCall instead of automation can promote performace + * and VtbCall doesn't need prototype of interface declaration + */ + +public static int VtblCall(int fnNumber, void* ppVtbl) { + Function1 fn = cast(Function1)(*cast(int **)ppVtbl)[fnNumber]; + return fn(ppVtbl); +} + +public static int VtblCall(int fnNumber, void* ppVtbl, int arg0){ + Function2 fn = cast(Function2)(*cast(int **)ppVtbl)[fnNumber]; + return fn(ppVtbl, arg0); +} + +public static int VtblCall(int fnNumber, void* ppVtbl, int arg0, int arg1){ + Function3 fn = cast(Function3)(*cast(int **)ppVtbl)[fnNumber]; + return fn(ppVtbl, arg0, arg1); +} + +public static int VtblCall(int fnNumber, void* ppVtbl, int arg0, int arg1, int arg2){ + Function4 fn = cast(Function4)(*cast(int **)ppVtbl)[fnNumber]; + return fn(ppVtbl, arg0, arg1, arg2); +} +public static int VtblCall(int fnNumber, void* ppVtbl, int arg0, int arg1, int arg2, int arg3){ + Function5 fn = cast(Function5)(*cast(int **)ppVtbl)[fnNumber]; + return fn(ppVtbl, arg0, arg1, arg2, arg3); +} + +public static int VtblCall(int fnNumber, void* ppVtbl, int arg0, int arg1, int arg2, int arg3, int arg4){ + Function6 fn = cast(Function6)(*cast(int **)ppVtbl)[fnNumber]; + return fn(ppVtbl, arg0, arg1, arg2, arg3, arg4); +} + +public static int VtblCall(int fnNumber, void* ppVtbl, int arg0, int arg1, int arg2, int arg3, int arg4, int arg5){ + Function7 fn = cast(Function7)(*cast(int **)ppVtbl)[fnNumber]; + return fn(ppVtbl, arg0, arg1, arg2, arg3, arg4, arg5); +} + +public static int VtblCall(int fnNumber, void* ppVtbl, int arg0, int arg1, int arg2, int arg3, int arg4, int arg5, int arg6){ + Function8 fn = cast(Function8)(*cast(int **)ppVtbl)[fnNumber]; + return fn(ppVtbl, arg0, arg1, arg2, arg3, arg4, arg5, arg6); +} + +public static int VtblCall(int fnNumber, void* ppVtbl, int arg0, int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, int arg7){ + Function9 fn = cast(Function9)(*cast(int **)ppVtbl)[fnNumber]; + return fn(ppVtbl, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7); +} + +/* +public static int VtblCall(int fnNumber, void* ppVtbl) { + Function1 fn = cast(Function1)(*cast(int **)ppVtbl)[fnNumber]; + return fn(ppVtbl); +} + +public static int VtblCall(int fnNumber, void* ppVtbl, int arg0){ + Function2 fn = cast(Function2)(*cast(int **)ppVtbl)[fnNumber]; + return fn(ppVtbl, arg0); +} + +public static int VtblCall(int fnNumber, void* ppVtbl, void* arg0){ + Function2 fn = cast(Function2)(*cast(int **)ppVtbl)[fnNumber]; + return fn(ppVtbl, cast(int)arg0); +} + +public static int VtblCall(int fnNumber, void* ppVtbl, wchar* arg0) { + Function2 fn = cast(Function2)(*cast(int **)ppVtbl)[fnNumber]; + return fn(ppVtbl, cast(int)arg0); +} +public static int VtblCall(int fnNumber, void* ppVtbl, wchar* arg0, wchar* arg1){ + Function3 fn = cast(Function3)(*cast(int **)ppVtbl)[fnNumber]; + return fn(ppVtbl, cast(int)arg0, cast(int)arg1); +} +public static int VtblCall(int fnNumber, void* ppVtbl, wchar* arg0, int arg1) { + Function3 fn = cast(Function3)(*cast(int **)ppVtbl)[fnNumber]; + return fn(ppVtbl, cast(int)arg0, arg1); +} +public static int VtblCall(int fnNumber, void* ppVtbl, wchar* arg0, int arg1, int arg2, int arg3, int[] arg4) { + Function6 fn = cast(Function6)(*cast(int **)ppVtbl)[fnNumber]; + return fn(ppVtbl, cast(int)arg0, arg1, arg2, arg3, cast(int)cast(int*)arg4); +} +public static int VtblCall(int fnNumber, void* ppVtbl, wchar* arg0, int arg1, int arg2, int arg3, int arg4, int[] arg5) { + Function7 fn = cast(Function7)(*cast(int **)ppVtbl)[fnNumber]; + return fn(ppVtbl, cast(int)arg0, arg1, arg2, arg3, arg4, cast(int)cast(int*)arg5); +} +public static int VtblCall(int fnNumber, void* ppVtbl, int[] arg0) { + Function2 fn = cast(Function2)(*cast(int **)ppVtbl)[fnNumber]; + return fn(ppVtbl, cast(int)cast(int*)arg0); +} +public static int VtblCall(int fnNumber, void* ppVtbl, int arg0, int[] arg1) { + Function3 fn = cast(Function3)(*cast(int **)ppVtbl)[fnNumber]; + return fn(ppVtbl, arg0, cast(int)cast(int*)arg1); +} +public static int VtblCall(int fnNumber, void* ppVtbl, int arg0, int arg1) { + Function3 fn = cast(Function3)(*cast(int **)ppVtbl)[fnNumber]; + return fn(ppVtbl, arg0, arg1); +} +public static int VtblCall(int fnNumber, void* ppVtbl, int arg0, int arg1, int[] arg2) { + Function4 fn = cast(Function4)(*cast(int **)ppVtbl)[fnNumber]; + return fn(ppVtbl, arg0, arg1, cast(int)cast(int*)arg2); +} +public static int VtblCall(int fnNumber, void* ppVtbl, int arg0, int arg1, int arg2) { + Function4 fn = cast(Function4)(*cast(int **)ppVtbl)[fnNumber]; + return fn(ppVtbl, arg0, arg1, arg2); +} +public static int VtblCall(int fnNumber, void* ppVtbl, int arg0, int arg1, int arg2, int[] arg3) { + Function5 fn = cast(Function5)(*cast(int **)ppVtbl)[fnNumber]; + return fn(ppVtbl, arg0, arg1, arg2, cast(int)cast(int*)arg3); +} +public static int VtblCall(int fnNumber, void* ppVtbl, int arg0, int arg1, DVTARGETDEVICE* arg2, SIZE* arg3) { + Function5 fn = cast(Function5)(*cast(int **)ppVtbl)[fnNumber]; + return fn(ppVtbl, arg0, arg1, cast(int)(arg2), cast(int)(arg3)); +} +public static int VtblCall(int fnNumber, void* ppVtbl, int arg0, int arg1, GUID* arg2, int arg3, int[] arg4) { + Function6 fn = cast(Function6)(*cast(int **)ppVtbl)[fnNumber]; + return fn(ppVtbl, arg0, arg1, cast(int)(arg2), arg3, cast(int)cast(int*)arg4); +} +public static int VtblCall(int fnNumber, void* ppVtbl, int arg0, FORMATETC* arg1, int[] arg2) { + Function4 fn = cast(Function4)(*cast(int **)ppVtbl)[fnNumber]; + return fn(ppVtbl, arg0, cast(int)(arg1), cast(int)cast(int*)arg2); +} +public static int VtblCall(int fnNumber, void* ppVtbl, int arg0, GUID* arg1) { + Function3 fn = cast(Function3)(*cast(int **)ppVtbl)[fnNumber]; + return fn(ppVtbl, arg0, cast(int)(arg1)); +} +public static int VtblCall(int fnNumber, void* ppVtbl, int arg0, GUID* arg1, int arg2, int arg3) { + Function5 fn = cast(Function5)(*cast(int **)ppVtbl)[fnNumber]; + return fn(ppVtbl, arg0, cast(int)(arg1), arg2, arg3); +} +public static int VtblCall(int fnNumber, void* ppVtbl, int arg0, GUID* arg1, int arg2, int arg3, DISPPARAMS* arg4, int arg5, EXCEPINFO* arg6, int[] arg7) { + Function9 fn = cast(Function9)(*cast(int **)ppVtbl)[fnNumber]; + return fn(ppVtbl, arg0, cast(int)(arg1), arg2, arg3, cast(int)(arg4), arg5, cast(int)(arg6), cast(int)cast(int*)arg7); +} +public static int VtblCall(int fnNumber, void* ppVtbl, int arg0, STATSTG* arg1, int[] arg2) { + Function4 fn = cast(Function4)(*cast(int **)ppVtbl)[fnNumber]; + return fn(ppVtbl, arg0, cast(int)(arg1), cast(int)cast(int*)arg2); +} +public static int VtblCall(int fnNumber, void* ppVtbl, MSG* arg0) { + Function2 fn = cast(Function2)(*cast(int **)ppVtbl)[fnNumber]; + return fn(ppVtbl, cast(int)(arg0)); +} +public static int VtblCall(int fnNumber, void* ppVtbl, int arg0, MSG* arg1, int arg2, int arg3, int arg4, RECT* arg5) { + Function7 fn = cast(Function7)(*cast(int **)ppVtbl)[fnNumber]; + return fn(ppVtbl, arg0, cast(int)(arg1), arg2, arg3, arg4, cast(int)(arg5)); +} +public static int VtblCall(int fnNumber, void* ppVtbl, int arg0, SIZE* arg1) { + Function3 fn = cast(Function3)(*cast(int **)ppVtbl)[fnNumber]; + return fn(ppVtbl, arg0, cast(int)(arg1)); +} + +// TODO: the type of BOOL ??? +// conflict with VtblCall(int, int, int, int); +public static int VtblCall(int fnNumber, void* ppVtbl, int arg0, bool arg1) { + Function3 fn = cast(Function3)(*cast(int **)ppVtbl)[fnNumber]; + return fn(ppVtbl, arg0, cast(int)arg1); +} +public static int VtblCall(int fnNumber, void* ppVtbl, CAUUID* arg0) { + Function2 fn = cast(Function2)(*cast(int **)ppVtbl)[fnNumber]; + return fn(ppVtbl, cast(int)(arg0)); +} +public static int VtblCall(int fnNumber, void* ppVtbl, CONTROLINFO* arg0) { + Function2 fn = cast(Function2)(*cast(int **)ppVtbl)[fnNumber]; + return fn(ppVtbl, cast(int)(arg0)); +} +public static int VtblCall(int fnNumber, void* ppVtbl, FORMATETC* arg0) { + Function2 fn = cast(Function2)(*cast(int **)ppVtbl)[fnNumber]; + return fn(ppVtbl, cast(int)(arg0)); +} +public static int VtblCall(int fnNumber, void* ppVtbl, FORMATETC* arg0, STGMEDIUM* arg1) { + Function3 fn = cast(Function3)(*cast(int **)ppVtbl)[fnNumber]; + return fn(ppVtbl, cast(int)(arg0), cast(int)(arg1)); +} +// TODO: BOOL type ??? +public static int VtblCall(int fnNumber, void* ppVtbl, FORMATETC* arg0, STGMEDIUM* arg1, int arg2) { + Function4 fn = cast(Function4)(*cast(int **)ppVtbl)[fnNumber]; + return fn(ppVtbl, cast(int)(arg0), cast(int)(arg1), arg2); +} +public static int VtblCall(int fnNumber, void* ppVtbl, GUID* arg0) { + Function2 fn = cast(Function2)(*cast(int **)ppVtbl)[fnNumber]; + return fn(ppVtbl, cast(int)(arg0)); +} + +public static int VtblCall(int fnNumber, void* ppVtbl, GUID* arg0, int[] arg1) { + Function3 fn = cast(Function3)(*cast(int **)ppVtbl)[fnNumber]; + return fn(ppVtbl, cast(int)(arg0), cast(int)cast(int*)arg1); +} + +public static int VtblCall(int fnNumber, void* ppVtbl, GUID* arg0, int arg1, int arg2, int arg3, int[] arg4) { + Function6 fn = cast(Function6)(*cast(int **)ppVtbl)[fnNumber]; + return fn(ppVtbl, cast(int)(arg0), arg1, arg2, arg3, cast(int)cast(int*)arg4); +} +public static int VtblCall(int fnNumber, void* ppVtbl, GUID* arg0, int arg1, int arg2, int arg3, int arg4) { + Function6 fn = cast(Function6)(*cast(int **)ppVtbl)[fnNumber]; + return fn(ppVtbl, cast(int)(arg0), arg1, arg2, arg3, arg4); +} +public static int VtblCall(int fnNumber, void* ppVtbl, GUID* arg0, int arg1, OLECMD* arg2, OLECMDTEXT* arg3) { + Function5 fn = cast(Function5)(*cast(int **)ppVtbl)[fnNumber]; + return fn(ppVtbl, cast(int)(arg0), arg1, cast(int)(arg2), cast(int)(arg3)); +} +public static int VtblCall(int fnNumber, void* ppVtbl, LICINFO* arg0) { + Function2 fn = cast(Function2)(*cast(int **)ppVtbl)[fnNumber]; + return fn(ppVtbl, cast(int)(arg0)); +} +public static int VtblCall(int fnNumber, void* ppVtbl, RECT* arg0, int arg1, int arg2) { + Function4 fn = cast(Function4)(*cast(int **)ppVtbl)[fnNumber]; + return fn(ppVtbl, cast(int)(arg0), arg1, arg2); +} +public static int VtblCall(int fnNumber, void* ppVtbl, RECT* arg0, RECT* arg1) { + Function3 fn = cast(Function3)(*cast(int **)ppVtbl)[fnNumber]; + return fn(ppVtbl, cast(int)(arg0), cast(int)(arg1)); +} +public static int VtblCall(int fnNumber, void* ppVtbl, RECT* arg0) { + Function2 fn = cast(Function2)(*cast(int **)ppVtbl)[fnNumber]; + return fn(ppVtbl, cast(int)(arg0)); +} +public static int VtblCall(int fnNumber, void* ppVtbl, int arg0, int[] arg1, int[] arg2, int[] arg3, int[] arg4) { + Function6 fn = cast(Function6)(*cast(int **)ppVtbl)[fnNumber]; + return fn(ppVtbl, arg0, cast(int)cast(int*)arg1, cast(int)cast(int*)arg2, cast(int)cast(int*)arg3, cast(int)cast(int*)arg4); +} +public static int VtblCall(int fnNumber, void* ppVtbl, int arg0, int[] arg1, int arg2, int[] arg3) { + Function5 fn = cast(Function5)(*cast(int **)ppVtbl)[fnNumber]; + return fn(ppVtbl, arg0, cast(int)cast(int*)arg1, arg2, cast(int)cast(int*)arg3); +} + + +// Start ACCESSIBILITY +public static int VtblCall(int fnNumber, void* ppVtbl, int arg0, int arg1, int arg2, int arg3) { + Function5 fn = cast(Function5)(*cast(int **)ppVtbl)[fnNumber]; + return fn(ppVtbl, arg0, arg1, arg2, arg3); +} +public static int VtblCall(int fnNumber, void* ppVtbl, int arg0, int arg1, int arg2, int arg3, int arg4) { + Function6 fn = cast(Function6)(*cast(int **)ppVtbl)[fnNumber]; + return fn(ppVtbl, arg0, arg1, arg2, arg3, arg4); +} +public static int VtblCall(int fnNumber, void* ppVtbl, int arg0, int arg1, int arg2, int arg3, int arg4, int arg5) { + Function7 fn = cast(Function7)(*cast(int **)ppVtbl)[fnNumber]; + return fn(ppVtbl, arg0, arg1, arg2, arg3, arg4, arg5); +} +public static int VtblCall(int fnNumber, void* ppVtbl, int arg0, int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, int arg7) { + Function9 fn = cast(Function9)(*cast(int **)ppVtbl)[fnNumber]; + return fn(ppVtbl, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7); +} + +*/ + +public static const int CO_E_OBJNOTCONNECTED = 0x800401FD; + +public static const int STATE_SYSTEM_NORMAL = 0; +//public static const int STATE_SYSTEM_UNAVAILABLE = 0x1; +public static const int STATE_SYSTEM_SELECTED = 0x2; +public static const int STATE_SYSTEM_FOCUSED = 0x4; +public static const int STATE_SYSTEM_PRESSED = 0x8; +public static const int STATE_SYSTEM_CHECKED = 0x10; +//public static const int STATE_SYSTEM_MIXED = 0x20; +//public static const int STATE_SYSTEM_INDETERMINATE = STATE_SYSTEM_MIXED; +public static const int STATE_SYSTEM_READONLY = 0x40; +public static const int STATE_SYSTEM_HOTTRACKED = 0x80; +//public static const int STATE_SYSTEM_DEFAULT = 0x100; +public static const int STATE_SYSTEM_EXPANDED = 0x200; +public static const int STATE_SYSTEM_COLLAPSED = 0x400; +public static const int STATE_SYSTEM_BUSY = 0x800; +//public static const int STATE_SYSTEM_FLOATING = 0x1000; +//public static const int STATE_SYSTEM_MARQUEED = 0x2000; +//public static const int STATE_SYSTEM_ANIMATED = 0x4000; +public static const int STATE_SYSTEM_INVISIBLE = 0x8000; +public static const int STATE_SYSTEM_OFFSCREEN = 0x10000; +public static const int STATE_SYSTEM_SIZEABLE = 0x20000; +//public static const int STATE_SYSTEM_MOVEABLE = 0x40000; +//public static const int STATE_SYSTEM_SELFVOICING = 0x80000; +public static const int STATE_SYSTEM_FOCUSABLE = 0x100000; +public static const int STATE_SYSTEM_SELECTABLE = 0x200000; +public static const int STATE_SYSTEM_LINKED = 0x400000; +//public static const int STATE_SYSTEM_TRAVERSED = 0x800000; +public static const int STATE_SYSTEM_MULTISELECTABLE = 0x1000000; +//public static const int STATE_SYSTEM_EXTSELECTABLE = 0x2000000; +//public static const int STATE_SYSTEM_ALERT_LOW = 0x4000000; +//public static const int STATE_SYSTEM_ALERT_MEDIUM = 0x8000000; +//public static const int STATE_SYSTEM_ALERT_HIGH = 0x10000000; +//public static const int STATE_SYSTEM_PROTECTED = 0x20000000; +//public static const int STATE_SYSTEM_VALID = 0x3fffffff; + +//public static const int ROLE_SYSTEM_TITLEBAR = 0x1; +public static const int ROLE_SYSTEM_MENUBAR = 0x2; +public static const int ROLE_SYSTEM_SCROLLBAR = 0x3; +//public static const int ROLE_SYSTEM_GRIP = 0x4; +//public static const int ROLE_SYSTEM_SOUND = 0x5; +//public static const int ROLE_SYSTEM_CURSOR = 0x6; +//public static const int ROLE_SYSTEM_CARET = 0x7; +//public static const int ROLE_SYSTEM_ALERT = 0x8; +public static const int ROLE_SYSTEM_WINDOW = 0x9; +public static const int ROLE_SYSTEM_CLIENT = 0xa; +public static const int ROLE_SYSTEM_MENUPOPUP = 0xb; +public static const int ROLE_SYSTEM_MENUITEM = 0xc; +public static const int ROLE_SYSTEM_TOOLTIP = 0xd; +//public static const int ROLE_SYSTEM_APPLICATION = 0xe; +//public static const int ROLE_SYSTEM_DOCUMENT = 0xf; +//public static const int ROLE_SYSTEM_PANE = 0x10; +//public static const int ROLE_SYSTEM_CHART = 0x11; +public static const int ROLE_SYSTEM_DIALOG = 0x12; +//public static const int ROLE_SYSTEM_BORDER = 0x13; +//public static const int ROLE_SYSTEM_GROUPING = 0x14; +public static const int ROLE_SYSTEM_SEPARATOR = 0x15; +public static const int ROLE_SYSTEM_TOOLBAR = 0x16; +//public static const int ROLE_SYSTEM_STATUSBAR = 0x17; +public static const int ROLE_SYSTEM_TABLE = 0x18; +public static const int ROLE_SYSTEM_COLUMNHEADER = 0x19; +public static const int ROLE_SYSTEM_ROWHEADER = 0x1a; +//public static const int ROLE_SYSTEM_COLUMN = 0x1b; +//public static const int ROLE_SYSTEM_ROW = 0x1c; +public static const int ROLE_SYSTEM_CELL = 0x1d; +public static const int ROLE_SYSTEM_LINK = 0x1e; +//public static const int ROLE_SYSTEM_HELPBALLOON = 0x1f; +//public static const int ROLE_SYSTEM_CHARACTER = 0x20; +public static const int ROLE_SYSTEM_LIST = 0x21; +public static const int ROLE_SYSTEM_LISTITEM = 0x22; +public static const int ROLE_SYSTEM_OUTLINE = 0x23; +public static const int ROLE_SYSTEM_OUTLINEITEM = 0x24; +public static const int ROLE_SYSTEM_PAGETAB = 0x25; +//public static const int ROLE_SYSTEM_PROPERTYPAGE = 0x26; +//public static const int ROLE_SYSTEM_INDICATOR = 0x27; +//public static const int ROLE_SYSTEM_GRAPHIC = 0x28; +public static const int ROLE_SYSTEM_STATICTEXT = 0x29; +public static const int ROLE_SYSTEM_TEXT = 0x2a; +public static const int ROLE_SYSTEM_PUSHBUTTON = 0x2b; +public static const int ROLE_SYSTEM_CHECKBUTTON = 0x2c; +public static const int ROLE_SYSTEM_RADIOBUTTON = 0x2d; +public static const int ROLE_SYSTEM_COMBOBOX = 0x2e; +//public static const int ROLE_SYSTEM_DROPLIST = 0x2f; +public static const int ROLE_SYSTEM_PROGRESSBAR = 0x30; +//public static const int ROLE_SYSTEM_DIAL = 0x31; +//public static const int ROLE_SYSTEM_HOTKEYFIELD = 0x32; +public static const int ROLE_SYSTEM_SLIDER = 0x33; +//public static const int ROLE_SYSTEM_SPINBUTTON = 0x34; +//public static const int ROLE_SYSTEM_DIAGRAM = 0x35; +//public static const int ROLE_SYSTEM_ANIMATION = 0x36; +//public static const int ROLE_SYSTEM_EQUATION = 0x37; +//public static const int ROLE_SYSTEM_BUTTONDROPDOWN = 0x38; +//public static const int ROLE_SYSTEM_BUTTONMENU = 0x39; +//public static const int ROLE_SYSTEM_BUTTONDROPDOWNGRID = 0x3a; +//public static const int ROLE_SYSTEM_WHITESPACE = 0x3b; +public static const int ROLE_SYSTEM_PAGETABLIST = 0x3c; +//public static const int ROLE_SYSTEM_CLOCK = 0x3d; + +public static const int CHILDID_SELF = 0; + +/* End ACCESSIBILITY */ + +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/ole/win32/COMAPI.d Fri Feb 08 19:49:32 2008 +0100 @@ -0,0 +1,277 @@ +/* + * All COM APIs required by DWT, all APIs prototype copied from MSDN 2003 + * don't import this module directly, import std.internal.ole.win32.com instead + * + * author : Shawn Liu + */ + + +module dwt.internal.ole.win32.COMAPI; + + +//private import std.c.windows.windows; +//private import std.c.windows.com; +private import dwt.internal.win32.WINTYPES; +private import dwt.internal.ole.win32.COMTYPES; +private import dwt.internal.ole.win32.OBJIDL; +private import dwt.internal.ole.win32.OLEIDL; +private import dwt.internal.ole.win32.OAIDL; +private import dwt.internal.ole.win32.extras; + +extern(Windows){ + +WINOLEAPI CreateStreamOnHGlobal( + HGLOBAL hGlobal, //Memory handle for the stream object + BOOL fDeleteOnRelease, //Whether to free memory when the object + // is released + LPSTREAM * ppstm //Address of output variable that + // receives the IStream interface pointer +); +HRESULT CLSIDFromProgID( + LPCOLESTR lpszProgID, + LPCLSID pclsid +); +HRESULT CLSIDFromString( + LPOLESTR lpsz, + LPCLSID pclsid +); +STDAPI CoCreateInstance( + REFCLSID rclsid, + LPUNKNOWN pUnkOuter, + DWORD dwClsContext, + REFIID riid, + LPVOID * ppv +); +void CoFreeUnusedLibraries(); +STDAPI CoGetClassObject( + REFCLSID rclsid, + DWORD dwClsContext, + COSERVERINFO * pServerInfo, + REFIID riid, + LPVOID * ppv +); +STDAPI CoLockObjectExternal( + LPUNKNOWN pUnk, + BOOL fLock, + BOOL fLastUnlockReleases +); +LPVOID CoTaskMemAlloc( + ULONG cb +); +void CoTaskMemFree( + void * pv +); + +WINOLEAPI DoDragDrop( + LPDATAOBJECT pDataObject, //Pointer to the data object + LPDROPSOURCE pDropSource, //Pointer to the source + DWORD dwOKEffect, //Effects allowed by the source + DWORD * pdwEffect //Pointer to effects on the source +); + +WINOLEAPI GetClassFile( + LPCWSTR szFileName, + CLSID * pclsid +); +WINOLEAPI IIDFromString( + LPOLESTR lpsz, + LPIID lpiid +); +BOOL IsEqualGUID( + REFGUID rguid1, + REFGUID rguid2 +); +WINOLEAPI OleCreate( + REFCLSID rclsid, //CLSID of embedded object to be created + REFIID riid, //Reference to the identifier of the interface + // used to communicate with new object + DWORD renderopt, //RENDEROPT value indicating cached capabilities + FORMATETC * pFormatEtc, + //Pointer to a FORMATETC structure + IOleClientSite * pClientSite, + //Pointer to request services from the container + LPSTORAGE pStg, //Pointer to storage for the object + void ** ppvObject //Address of output variable that receives the + // interface pointer requested in riid +); +WINOLEAPI OleCreateFromFile( + REFCLSID rclsid, //Reserved. Must be CLSID_NULL + LPCOLESTR lpszFileName, //Pointer to full path of file used to + // create object + REFIID riid, //Reference to the identifier of the + // interface to be used to communicate with + // new object + DWORD renderopt, //Value from OLERENDER + LPFORMATETC pFormatEtc, //Pointer to the FORMATETC structure + LPOLECLIENTSITE pClientSite, + //Pointer to an interface + LPSTORAGE pStg, //Pointer tothe interface to be used as + // object storage + LPVOID * ppvObj //Address of output variable that + // receives the interface pointer requested + // in riid +); + +STDAPI OleCreatePropertyFrame( + HWND hwndOwner, //Parent window of property sheet dialog box + UINT x, //Horizontal position for dialog box + UINT y, //Vertical position for dialog box + LPCOLESTR lpszCaption, + //Pointer to the dialog box caption + ULONG cObjects, //Number of object pointers in lplpUnk + LPUNKNOWN * lplpUnk, + //Pointer to the objects for property sheet + ULONG cPages, //Number of property pages in lpPageClsID + LPCLSID lpPageClsID, + //Array of CLSIDs for each property page + LCID lcid, //Locale identifier for property sheet locale + DWORD dwReserved, //Reserved + LPVOID lpvReserved //Reserved +); +WINOLEAPI OleDraw( + LPUNKNOWN pUnk, //Pointer to the view object to be drawn + DWORD dwAspect, //How the object is to be represented + HDC hdcDraw, //Device context on which to draw + LPCRECT lprcBounds //Pointer to the rectangle in which the object + // is drawn +); +WINOLEAPI OleFlushClipboard(); +WINOLEAPI OleGetClipboard( + LPDATAOBJECT * ppDataObj //Address of output variable that + // receives the IDataObject interface + // pointer +); +WINOLEAPI OleIsCurrentClipboard( + LPDATAOBJECT pDataObject //Pointer to the data object previously + // copied or cut +); +BOOL OleIsRunning( + LPOLEOBJECT pObject //Pointer to the interface +); +WINOLEAPI OleLoad( + LPSTORAGE pStg, //Pointer to the storage object from which to + // load + REFIID riid, //Reference to the identifier of the interface + IOleClientSite * pClientSite, + //Pointer to the client site for the object + LPVOID * ppvObj //Address of output variable that receives the + // interface pointer requested in riid +); +WINOLEAPI OleRun( + LPUNKNOWN pUnknown //Pointer to interface on the object +); +WINOLEAPI OleSave( + LPPERSISTSTORAGE pPS, //Pointer to the object to be saved + LPSTORAGE pStg, //Pointer to the destination storage to + // which pPS is saved + BOOL fSameAsLoad //Whether the object was loaded from pstg + // or not +); +WINOLEAPI OleSetClipboard( + LPDATAOBJECT pDataObj //Pointer to the data object being copied + // or cut +); +WINOLEAPI OleSetContainedObject( + LPUNKNOWN pUnk, //Pointer to the interface on the embedded object + BOOL fContained //Indicates if the object is embedded +); +WINOLEAPI OleSetMenuDescriptor( + HOLEMENU holemenu, //Handle to the composite menu descriptor + HWND hwndFrame, //Handle to the container's frame window + HWND hwndActiveObject, //Handle to the object's in-place + // activation window + LPOLEINPLACEFRAME lpFrame, //Pointer to the container's frame + // window + LPOLEINPLACEACTIVEOBJECT lpActiveObj + //Active in-place object +); +STDAPI OleTranslateColor ( + OLE_COLOR clr, //Color to be converted into a COLORREF + HPALETTE hpal, //Palette used for conversion + COLORREF *pcolorref //Pointer to the caller's variable that + // receives the converted result +); +WINOLEAPI ProgIDFromCLSID( + REFCLSID clsid, + LPOLESTR * lplpszProgID +); + +WINOLEAPI RegisterDragDrop( + HWND hwnd, //Handle to a window that can accept drops + LPDROPTARGET pDropTarget + //Pointer to object that is to be target of drop +); +void ReleaseStgMedium( + STGMEDIUM * pmedium //Pointer to storage medium to be freed +); +WINOLEAPI RevokeDragDrop( + HWND hwnd //Handle to a window that can accept drops +); +HRESULT StgCreateDocfile( + WCHAR* pwcsName, + DWORD grfMode, + DWORD reserved, + LPSTORAGE* ppstgOpen +); + +WINOLEAPI StgIsStorageFile( + WCHAR* pwcsName +); + +HRESULT StgOpenStorage( + WCHAR* pwcsName, + LPSTORAGE pstgPriority, + DWORD grfMode, + SNB snbExclude, + DWORD reserved, + LPSTORAGE * ppstgOpen +); + +WINOLEAPI StringFromCLSID( + REFCLSID rclsid, + LPOLESTR * ppsz +); +BSTR SysAllocString( + OLECHAR * sz +); +VOID SysFreeString( + BSTR bstr +); +UINT SysStringByteLen( + BSTR bstr +); +HRESULT VariantChangeType( + VARIANTARG * pvargDest, + VARIANTARG * pvarSrc, + ushort wFlags, + VARTYPE vt +); + +HRESULT VariantClear( + VARIANTARG * pvarg +); +HRESULT VariantCopy( + VARIANTARG * pvargDest, + VARIANTARG * pvargSrc +); +VOID VariantInit( + VARIANTARG * pvarg +); +WINOLEAPI WriteClassStg( + LPSTORAGE pStg, + REFCLSID rclsid +); + +STDAPI CreateStdAccessibleObject( + HWND hwnd, + LONG idObject, + REFIID riidInterface, + void** ppvObject +); +LRESULT LresultFromObject( + REFIID riid, + WPARAM_I wParam, + LPUNKNOWN pAcc +); + +} // end of comapi
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/ole/win32/COMTYPES.d Fri Feb 08 19:49:32 2008 +0100 @@ -0,0 +1,60 @@ +/* + * extra COM types not define in any other modules + * don't import this module directly, import std.internal.ole.win32.com instead + * + * author : Shawn Liu + */ + +module dwt.internal.ole.win32.COMTYPES; + +private import dwt.internal.win32.WINTYPES; +private import dwt.internal.ole.win32.extras; +//private import std.c.windows.windows; +//private import std.c.windows.com; + +// private import dwt.internal.ole.win32.extras; + + + +alias IID* LPIID; +alias HRESULT STDAPI; +alias DWORD OLE_COLOR; + +// for temp use +// alias void* ComObj; + +struct CAUUID { + ULONG cElems; + GUID* pElems; +} +struct CONNECTDATA +{ + LPUNKNOWN pUnk; + DWORD dwCookie; +} + +struct CONTROLINFO { + ULONG cb; + HACCEL hAccel; + USHORT cAccel; + DWORD dwFlags; +} + +struct LICINFO { + ULONG cbLicInfo; + BOOL fRuntimeKeyAvail; + BOOL fLicVerified; +} + +struct POINTF +{ + FLOAT x; + FLOAT y; +} + + + + + + +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/ole/win32/DOCOBJ.d Fri Feb 08 19:49:32 2008 +0100 @@ -0,0 +1,407 @@ +module dwt.internal.ole.win32.DOCOBJ; + +//private import std.c.windows.windows; +//private import std.c.windows.com; +private import tango_sys_win32.Types; +private import dwt.internal.win32.OS; +private import dwt.internal.ole.win32.extras; +private import dwt.internal.ole.win32.OLEIDL; +private import dwt.internal.ole.win32.OAIDL; +private import dwt.internal.ole.win32.OBJIDL; + +extern( Windows ) { + +alias wchar wchar_t; + +//+--------------------------------------------------------------------------- +// +// Copyright 1995 - 1998 Microsoft Corporation. All Rights Reserved. +// +// Contents: OLE Document Object interfaces +// +//---------------------------------------------------------------------------- + + +/* +#define HWND UserHWND +#define HACCEL UserHACCEL +#define HDC UserHDC +#define HFONT UserHFONT +#define MSG UserMSG +#define BSTR UserBSTR +#define EXCEPINFO UserEXCEPINFO +#define VARIANT UserVARIANT +*/ +/* +interface IOleDocument; +interface IOleDocumentSite; +interface IOleDocumentView; +interface IEnumOleDocumentViews; +interface IContinueCallback; +interface IPrint; +interface IOleCommandTarget; + */ + + + +//+--------------------------------------------------------------------------- +// +// Copyright (C) Microsoft Corporation, 1995-1997. +// +// Contents: IOleDocument interface definition +// +//---------------------------------------------------------------------------- +enum DOCMISC { + DOCMISC_CANCREATEMULTIPLEVIEWS = 1, + DOCMISC_SUPPORTCOMPLEXRECTANGLES = 2, + DOCMISC_CANTOPENEDIT = 4, // fails the IOleDocumentView::Open method + DOCMISC_NOFILESUPPORT = 8, // does not support read/writing to a file +} + +interface IOleDocument : IUnknown +{ + HRESULT CreateView(IOleInPlaceSite pIPSite,IStream pstm,DWORD dwReserved,IOleDocumentView *ppView); + + HRESULT GetDocMiscStatus(DWORD *pdwStatus); + + HRESULT EnumViews( IEnumOleDocumentViews * ppEnum, IOleDocumentView * ppView); +} +alias IOleDocument LPOLEDOCUMENT; + + +//+--------------------------------------------------------------------------- +// +// Copyright (C) Microsoft Corporation, 1995-1997. +// +// Contents: IOleDocumentSite interface definition +// +//---------------------------------------------------------------------------- +interface IOleDocumentSite : IUnknown +{ + HRESULT ActivateMe(IOleDocumentView pViewToActivate); +} +alias IOleDocumentSite LPOLEDOCUMENTSITE; + + +//+--------------------------------------------------------------------------- +// +// Copyright (C) Microsoft Corporation, 1995-1997. +// +// Contents: IOleDocumentView interface definition +// +//---------------------------------------------------------------------------- +interface IOleDocumentView : IUnknown +{ + HRESULT SetInPlaceSite(IOleInPlaceSite pIPSite); + + HRESULT GetInPlaceSite(IOleInPlaceSite * ppIPSite); + + HRESULT GetDocument(IUnknown *ppunk); + + HRESULT SetRect(LPRECT prcView); + + HRESULT GetRect(LPRECT prcView); + + HRESULT SetRectComplex(LPRECT prcView,LPRECT prcHScroll,LPRECT prcVScroll,LPRECT prcSizeBox); + + HRESULT Show(BOOL fShow); + + HRESULT UIActivate(BOOL fUIActivate); + + HRESULT Open(); + + HRESULT CloseView(DWORD dwReserved); + + HRESULT SaveViewState(LPSTREAM pstm); + + HRESULT ApplyViewState(LPSTREAM pstm); + + HRESULT Clone(IOleInPlaceSite pIPSiteNew,IOleDocumentView *ppViewNew); +} +alias IOleDocumentView LPOLEDOCUMENTVIEW; + + +//+--------------------------------------------------------------------------- +// +// Copyright (C) Microsoft Corporation, 1995-1997. +// +// Contents: IEnumOleDocumentViews interface definition +// +//---------------------------------------------------------------------------- +interface IEnumOleDocumentViews : IUnknown +{ + HRESULT Next( + ULONG cViews, + IOleDocumentView * rgpView, + ULONG *pcFetched); + + HRESULT Skip(ULONG cViews); + + HRESULT Reset(); + + HRESULT Clone(IEnumOleDocumentViews *ppEnum); +} +alias IEnumOleDocumentViews LPENUMOLEDOCUMENTVIEWS; + + + +//+--------------------------------------------------------------------------- +// +// Copyright (C) Microsoft Corporation, 1995-1997. +// +// Contents: IContinueCallback interface definition +// +//---------------------------------------------------------------------------- + +interface IContinueCallback : IUnknown +{ + HRESULT FContinue(); + + HRESULT FContinuePrinting(LONG nCntPrinted,LONG nCurPage, wchar_t * pwszPrintStatus); +} +alias IContinueCallback LPCONTINUECALLBACK; + + +//+--------------------------------------------------------------------------- +// +// Copyright (C) Microsoft Corporation, 1995-1997. +// +// Contents: IPrint interface definition +// +//---------------------------------------------------------------------------- +enum PRINTFLAG + { + PRINTFLAG_MAYBOTHERUSER = 1, + PRINTFLAG_PROMPTUSER = 2, + PRINTFLAG_USERMAYCHANGEPRINTER = 4, + PRINTFLAG_RECOMPOSETODEVICE = 8, + PRINTFLAG_DONTACTUALLYPRINT = 16, + PRINTFLAG_FORCEPROPERTIES = 32, + PRINTFLAG_PRINTTOFILE = 64 + } ; + +struct PAGERANGE + { + LONG nFromPage; + LONG nToPage; + } + +struct PAGESET + { + ULONG cbStruct; + BOOL fOddPages; + BOOL fEvenPages; + ULONG cPageRange; + PAGERANGE[1] rgPages; + } + +interface IPrint : IUnknown +{ + + HRESULT SetInitialPageNum(LONG nFirstPage); + + HRESULT GetPageInfo(LONG *pnFirstPage,LONG *pcPages); + + HRESULT Print( + DWORD grfFlags, +DVTARGETDEVICE **pptd, +PAGESET ** ppPageSet, +STGMEDIUM * pstgmOptions, +IContinueCallback pcallback, +LONG nFirstPage, +LONG *pcPagesPrinted, +LONG *pnLastPage); +} +alias IPrint LPPRINT; + + +//+--------------------------------------------------------------------------- +// +// Copyright (C) Microsoft Corporation, 1995-1997. +// +// Contents: IOleCommandTarget interface definition +// +//---------------------------------------------------------------------------- +enum OLECMDF + { + OLECMDF_SUPPORTED = 0x00000001, + OLECMDF_ENABLED = 0x00000002, + OLECMDF_LATCHED = 0x00000004, + OLECMDF_NINCHED = 0x00000008, + } + + + + +struct OLECMD { + ULONG cmdID; + DWORD cmdf; + } + +struct OLECMDTEXT{ + DWORD cmdtextf; + ULONG cwActual; + ULONG cwBuf; /* size in wide chars of the buffer for text */ + wchar_t[1] rgwz; /* Array into which callee writes the text */ +} + +enum OLECMDTEXTF + { + OLECMDTEXTF_NONE = 0, + OLECMDTEXTF_NAME = 1, + OLECMDTEXTF_STATUS = 2, + } + +enum OLECMDEXECOPT + { + OLECMDEXECOPT_DODEFAULT = 0, + OLECMDEXECOPT_PROMPTUSER = 1, + OLECMDEXECOPT_DONTPROMPTUSER = 2, + OLECMDEXECOPT_SHOWHELP = 3 + } +enum OLECMDID { + OLECMDID_OPEN = 1, + OLECMDID_NEW = 2, + OLECMDID_SAVE = 3, + OLECMDID_SAVEAS = 4, + OLECMDID_SAVECOPYAS = 5, + OLECMDID_PRINT = 6, + OLECMDID_PRINTPREVIEW = 7, + OLECMDID_PAGESETUP = 8, + OLECMDID_SPELL = 9, + OLECMDID_PROPERTIES = 10, + OLECMDID_CUT = 11, + OLECMDID_COPY = 12, + OLECMDID_PASTE = 13, + OLECMDID_PASTESPECIAL = 14, + OLECMDID_UNDO = 15, + OLECMDID_REDO = 16, + OLECMDID_SELECTALL = 17, + OLECMDID_CLEARSELECTION = 18, + OLECMDID_ZOOM = 19, + OLECMDID_GETZOOMRANGE = 20, + OLECMDID_UPDATECOMMANDS = 21, + OLECMDID_REFRESH = 22, + OLECMDID_STOP = 23, + OLECMDID_HIDETOOLBARS = 24, + OLECMDID_SETPROGRESSMAX = 25, + OLECMDID_SETPROGRESSPOS = 26, + OLECMDID_SETPROGRESSTEXT = 27, + OLECMDID_SETTITLE = 28, + OLECMDID_SETDOWNLOADSTATE = 29, + OLECMDID_STOPDOWNLOAD = 30, + OLECMDID_ONTOOLBARACTIVATED = 31, + OLECMDID_FIND = 32, + OLECMDID_DELETE = 33, + OLECMDID_HTTPEQUIV = 34, + OLECMDID_HTTPEQUIV_DONE = 35, + OLECMDID_ENABLE_INTERACTION = 36, + OLECMDID_ONUNLOAD = 37, + OLECMDID_PROPERTYBAG2 = 38, + OLECMDID_PREREFRESH = 39 + } + +interface IOleCommandTarget : IUnknown +{ + +/* error codes */ +/* +cpp_quote("#define OLECMDERR_E_FIRST (OLE_E_LAST+1)") +cpp_quote("#define OLECMDERR_E_NOTSUPPORTED (OLECMDERR_E_FIRST)") +cpp_quote("#define OLECMDERR_E_DISABLED (OLECMDERR_E_FIRST+1)") +cpp_quote("#define OLECMDERR_E_NOHELP (OLECMDERR_E_FIRST+2)") +cpp_quote("#define OLECMDERR_E_CANCELED (OLECMDERR_E_FIRST+3)") +cpp_quote("#define OLECMDERR_E_UNKNOWNGROUP (OLECMDERR_E_FIRST+4)") + +cpp_quote("#define MSOCMDERR_E_FIRST OLECMDERR_E_FIRST") +cpp_quote("#define MSOCMDERR_E_NOTSUPPORTED OLECMDERR_E_NOTSUPPORTED") +cpp_quote("#define MSOCMDERR_E_DISABLED OLECMDERR_E_DISABLED") +cpp_quote("#define MSOCMDERR_E_NOHELP OLECMDERR_E_NOHELP") +cpp_quote("#define MSOCMDERR_E_CANCELED OLECMDERR_E_CANCELED") +cpp_quote("#define MSOCMDERR_E_UNKNOWNGROUP OLECMDERR_E_UNKNOWNGROUP") + */ + HRESULT QueryStatus( + GUID *pguidCmdGroup, + ULONG cCmds, + OLECMD * prgCmds, + OLECMDTEXT *pCmdText); + + + HRESULT Exec( + GUID *pguidCmdGroup, + DWORD nCmdID, + DWORD nCmdexecopt, + VARIANT *pvaIn, + VARIANT *pvaOut); +} +alias IOleCommandTarget LPOLECOMMANDTARGET; +/* +cpp_quote("typedef enum") +cpp_quote("{") +cpp_quote(" OLECMDIDF_REFRESH_NORMAL = 0,") +cpp_quote(" OLECMDIDF_REFRESH_IFEXPIRED = 1,") +cpp_quote(" OLECMDIDF_REFRESH_CONTINUE = 2,") +cpp_quote(" OLECMDIDF_REFRESH_COMPLETELY = 3,") +cpp_quote(" OLECMDIDF_REFRESH_NO_CACHE = 4,") +cpp_quote(" OLECMDIDF_REFRESH_RELOAD = 5,") +cpp_quote(" OLECMDIDF_REFRESH_LEVELMASK = 0x00FF,") +cpp_quote(" OLECMDIDF_REFRESH_CLEARUSERINPUT = 0x1000,") +cpp_quote(" OLECMDIDF_REFRESH_PROMPTIFOFFLINE = 0x2000,") +cpp_quote("} OLECMDID_REFRESHFLAG;") + +cpp_quote("") +cpp_quote("////////////////////////////////////////////////////////////////////////////") +cpp_quote("// Aliases to original office-compatible names") +cpp_quote("#define IMsoDocument IOleDocument") +cpp_quote("#define IMsoDocumentSite IOleDocumentSite") +cpp_quote("#define IMsoView IOleDocumentView") +cpp_quote("#define IEnumMsoView IEnumOleDocumentViews") +cpp_quote("#define IMsoCommandTarget IOleCommandTarget") +cpp_quote("#define LPMSODOCUMENT LPOLEDOCUMENT") +cpp_quote("#define LPMSODOCUMENTSITE LPOLEDOCUMENTSITE") +cpp_quote("#define LPMSOVIEW LPOLEDOCUMENTVIEW") +cpp_quote("#define LPENUMMSOVIEW LPENUMOLEDOCUMENTVIEWS") +cpp_quote("#define LPMSOCOMMANDTARGET LPOLECOMMANDTARGET") +cpp_quote("#define MSOCMD OLECMD") +cpp_quote("#define MSOCMDTEXT OLECMDTEXT") +cpp_quote("#define IID_IMsoDocument IID_IOleDocument") +cpp_quote("#define IID_IMsoDocumentSite IID_IOleDocumentSite") +cpp_quote("#define IID_IMsoView IID_IOleDocumentView") +cpp_quote("#define IID_IEnumMsoView IID_IEnumOleDocumentViews") +cpp_quote("#define IID_IMsoCommandTarget IID_IOleCommandTarget") +cpp_quote("#define MSOCMDF_SUPPORTED OLECMDF_SUPPORTED") +cpp_quote("#define MSOCMDF_ENABLED OLECMDF_ENABLED") +cpp_quote("#define MSOCMDF_LATCHED OLECMDF_LATCHED") +cpp_quote("#define MSOCMDF_NINCHED OLECMDF_NINCHED") +cpp_quote("#define MSOCMDTEXTF_NONE OLECMDTEXTF_NONE") +cpp_quote("#define MSOCMDTEXTF_NAME OLECMDTEXTF_NAME") +cpp_quote("#define MSOCMDTEXTF_STATUS OLECMDTEXTF_STATUS") +cpp_quote("#define MSOCMDEXECOPT_DODEFAULT OLECMDEXECOPT_DODEFAULT") +cpp_quote("#define MSOCMDEXECOPT_PROMPTUSER OLECMDEXECOPT_PROMPTUSER") +cpp_quote("#define MSOCMDEXECOPT_DONTPROMPTUSER OLECMDEXECOPT_DONTPROMPTUSER") +cpp_quote("#define MSOCMDEXECOPT_SHOWHELP OLECMDEXECOPT_SHOWHELP") +cpp_quote("#define MSOCMDID_OPEN OLECMDID_OPEN") +cpp_quote("#define MSOCMDID_NEW OLECMDID_NEW") +cpp_quote("#define MSOCMDID_SAVE OLECMDID_SAVE") +cpp_quote("#define MSOCMDID_SAVEAS OLECMDID_SAVEAS") +cpp_quote("#define MSOCMDID_SAVECOPYAS OLECMDID_SAVECOPYAS") +cpp_quote("#define MSOCMDID_PRINT OLECMDID_PRINT") +cpp_quote("#define MSOCMDID_PRINTPREVIEW OLECMDID_PRINTPREVIEW") +cpp_quote("#define MSOCMDID_PAGESETUP OLECMDID_PAGESETUP") +cpp_quote("#define MSOCMDID_SPELL OLECMDID_SPELL") +cpp_quote("#define MSOCMDID_PROPERTIES OLECMDID_PROPERTIES") +cpp_quote("#define MSOCMDID_CUT OLECMDID_CUT") +cpp_quote("#define MSOCMDID_COPY OLECMDID_COPY") +cpp_quote("#define MSOCMDID_PASTE OLECMDID_PASTE") +cpp_quote("#define MSOCMDID_PASTESPECIAL OLECMDID_PASTESPECIAL") +cpp_quote("#define MSOCMDID_UNDO OLECMDID_UNDO") +cpp_quote("#define MSOCMDID_REDO OLECMDID_REDO") +cpp_quote("#define MSOCMDID_SELECTALL OLECMDID_SELECTALL") +cpp_quote("#define MSOCMDID_CLEARSELECTION OLECMDID_CLEARSELECTION") +cpp_quote("#define MSOCMDID_ZOOM OLECMDID_ZOOM") +cpp_quote("#define MSOCMDID_GETZOOMRANGE OLECMDID_GETZOOMRANGE") + +cpp_quote("EXTERN_C const GUID SID_SContainerDispatch;") + */ +} // extern( Windows) +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/ole/win32/EXDISP.d Fri Feb 08 19:49:32 2008 +0100 @@ -0,0 +1,911 @@ +module dwt.internal.ole.win32.EXDISP; +//+------------------------------------------------------------------------- +// +// Microsoft Windows +// Copyright 1995 - 1998 Microsoft Corporation. All Rights Reserved. +// +//-------------------------------------------------------------------------- +//private import std.c.windows.windows; +//private import std.c.windows.com; +private import dwt.internal.ole.win32.OAIDL; +private import dwt.internal.ole.win32.OLEIDL; +private import dwt.internal.ole.win32.DOCOBJ; +private import dwt.internal.ole.win32.extras; +import dwt.internal.win32.WINTYPES; + +extern (Windows) { + + enum BrowserNavConstants { + navOpenInNewWindow = 0x0001, + navNoHistory = 0x0002, + navNoReadFromCache = 0x0004, + navNoWriteToCache = 0x0008, + navAllowAutosearch = 0x0010, + navBrowserBar = 0x0020, + }; + enum RefreshConstants { // must map to these in sdk\inc\docobj.h + REFRESH_NORMAL = 0, //== OLECMDIDF_REFRESH_NORMAL + REFRESH_IFEXPIRED = 1, //== OLECMDIDF_REFRESH_IFEXPIRED + REFRESH_COMPLETELY = 3 //== OLECMDIDF_REFRESH_COMPLETELY + }; + +interface IWebBrowser : IDispatch +{ + HRESULT GoBack(); + HRESULT GoForward(); + HRESULT GoHome(); + HRESULT GoSearch(); + + HRESULT Navigate( BSTR URL, + VARIANT * Flags, + VARIANT * TargetFrameName, + VARIANT * PostData, + VARIANT * Headers); + + HRESULT Refresh(); + + HRESULT Refresh2(VARIANT * Level); + + HRESULT Stop(); + + HRESULT Application( IDispatch* ppDisp); + + HRESULT Parent( IDispatch* ppDisp); + + HRESULT Container( IDispatch* ppDisp); + + HRESULT Document( IDispatch* ppDisp); + + HRESULT TopLevelContainer( VARIANT_BOOL* pBool); + + HRESULT Type( BSTR* Type); + + // Window stuff... + HRESULT Left( LONG *pl); + HRESULT Put_Left( LONG Left); + HRESULT Top( LONG *pl); + HRESULT Put_Top( LONG Top); + HRESULT Width(LONG *pl); + HRESULT Put_Width(LONG Width); + HRESULT Height(LONG *pl); + HRESULT Put_Height(LONG Height); + + // WebBrowser stuff... + HRESULT LocationName( BSTR *LocationName); + + HRESULT LocationURL( BSTR * LocationURL); + + HRESULT Busy( VARIANT_BOOL *pBool); + } + +/* //not sure how to process this + dispinterface DWebBrowserEvents + { + properties: + methods: + [id(DISPID_BEFORENAVIGATE), helpstring("Fired when a new hyperlink is being navigated to."), helpcontext(0x0000)] + void BeforeNavigate([in] BSTR URL, long Flags, BSTR TargetFrameName, VARIANT * PostData, BSTR Headers, [in, out]VARIANT_BOOL * Cancel); + + [id(DISPID_NAVIGATECOMPLETE), helpstring("Fired when the document being navigated to becomes visible and enters the navigation stack."), helpcontext(0x0000)] + void NavigateComplete([in] BSTR URL ); + + [id(DISPID_STATUSTEXTCHANGE), helpstring("Statusbar text changed."), helpcontext(0x0000)] + void StatusTextChange([in]BSTR Text); + + [id(DISPID_PROGRESSCHANGE), helpstring("Fired when download progress is updated."), helpcontext(0x0000)] + void ProgressChange([in] long Progress, [in] long ProgressMax); + + [id(DISPID_DOWNLOADCOMPLETE), helpstring("Download of page complete."), helpcontext(0x0000)] + void DownloadComplete(); + + [id(DISPID_COMMANDSTATECHANGE), helpstring("The enabled state of a command changed"), helpcontext(0x0000)] + void CommandStateChange([in] long Command, [in] VARIANT_BOOL Enable); + + [id(DISPID_DOWNLOADBEGIN), helpstring("Download of a page started."), helpcontext(0x000)] + void DownloadBegin(); + + [id(DISPID_NEWWINDOW), helpstring("Fired when a new window should be created."), helpcontext(0x0000)] + void NewWindow([in] BSTR URL, [in] long Flags, [in] BSTR TargetFrameName, [in] VARIANT * PostData, [in] BSTR Headers, [in,out] VARIANT_BOOL * Processed); + + [id(DISPID_TITLECHANGE), helpstring("Document title changed."), helpcontext(0x0000)] + void TitleChange([in]BSTR Text); + + [id(DISPID_FRAMEBEFORENAVIGATE), helpstring("Fired when a new hyperlink is being navigated to in a frame."), helpcontext(0x0000)] + void FrameBeforeNavigate([in] BSTR URL, long Flags, BSTR TargetFrameName, VARIANT * PostData, BSTR Headers, [in, out]VARIANT_BOOL * Cancel); + + [id(DISPID_FRAMENAVIGATECOMPLETE), helpstring("Fired when a new hyperlink is being navigated to in a frame."), helpcontext(0x0000)] + void FrameNavigateComplete([in] BSTR URL ); + + [id(DISPID_FRAMENEWWINDOW), helpstring("Fired when a new window should be created."), helpcontext(0x0000)] + void FrameNewWindow([in] BSTR URL, [in] long Flags, [in] BSTR TargetFrameName, [in] VARIANT * PostData, [in] BSTR Headers, [in,out] VARIANT_BOOL * Processed); + + // The following are IWebBrowserApp specific: + // + [id(DISPID_QUIT), helpstring("Fired when application is quiting."), helpcontext(0x0000)] + void Quit([in, out] VARIANT_BOOL * Cancel); + + [id(DISPID_WINDOWMOVE), helpstring("Fired when window has been moved."), helpcontext(0x0000)] + void WindowMove(); + + [id(DISPID_WINDOWRESIZE), helpstring("Fired when window has been sized."), helpcontext(0x0000)] + void WindowResize(); + + [id(DISPID_WINDOWACTIVATE), helpstring("Fired when window has been activated."), helpcontext(0x0000)] + void WindowActivate(); + + [id(DISPID_PROPERTYCHANGE), helpstring("Fired when the PutProperty method has been called."), helpcontext(0x0000)] + void PropertyChange([in] BSTR Property); + } + */ + + enum CommandStateChangeConstants : uint { + CSC_UPDATECOMMANDS = 0xFFFFFFFF, + CSC_NAVIGATEFORWARD = 0x00000001, + CSC_NAVIGATEBACK = 0x00000002, + } + + interface IWebBrowserApp : IWebBrowser + { + HRESULT Quit(); + + HRESULT ClientToWindow( int* pcx, int* pcy); + + HRESULT PutProperty( BSTR Property, VARIANT vtValue); + HRESULT GetProperty( BSTR Property, VARIANT *pvtValue); + + HRESULT Name( BSTR* Name); + + HRESULT HWND(LONG *pHWND); + + HRESULT FullName( BSTR* FullName); + + HRESULT Path( BSTR* Path); + + HRESULT Visible( VARIANT_BOOL* pBool); + HRESULT Visible( VARIANT_BOOL Value); + + HRESULT StatusBar( VARIANT_BOOL* pBool); + HRESULT StatusBar( VARIANT_BOOL Value); + + HRESULT StatusText( BSTR *StatusText); + HRESULT StatusText( BSTR StatusText); + + HRESULT ToolBar( int * Value); + HRESULT ToolBar( int Value); + + HRESULT MenuBar( VARIANT_BOOL * Value); + HRESULT MenuBar( VARIANT_BOOL Value); + + HRESULT FullScreen( VARIANT_BOOL * pbFullScreen); + HRESULT FullScreen( VARIANT_BOOL bFullScreen); + } + + interface IWebBrowser2 : IWebBrowserApp + { + HRESULT Navigate2( VARIANT * URL, + VARIANT * Flags, + VARIANT * TargetFrameName, + VARIANT * PostData, + VARIANT * Headers); + + + HRESULT QueryStatusWB( OLECMDID cmdID, OLECMDF * pcmdf); + HRESULT ExecWB( OLECMDID cmdID, OLECMDEXECOPT cmdexecopt, VARIANT * pvaIn, VARIANT * pvaOut); + HRESULT ShowBrowserBar( VARIANT * pvaClsid, + VARIANT * pvarShow, + VARIANT * pvarSize ); + + HRESULT ReadyState(READYSTATE * plReadyState); + + HRESULT Offline(VARIANT_BOOL * pbOffline); + HRESULT Offline( VARIANT_BOOL bOffline); + + HRESULT Silent(VARIANT_BOOL * pbSilent); + HRESULT Silent(VARIANT_BOOL bSilent); + + HRESULT RegisterAsBrowser(VARIANT_BOOL * pbRegister); + HRESULT RegisterAsBrowser(VARIANT_BOOL bRegister); + + HRESULT RegisterAsDropTarget(VARIANT_BOOL * pbRegister); + HRESULT RegisterAsDropTarget(VARIANT_BOOL bRegister); + + HRESULT TheaterMode(VARIANT_BOOL * pbRegister); + HRESULT TheaterMode(VARIANT_BOOL bRegister); + + HRESULT AddressBar(VARIANT_BOOL * Value); + HRESULT AddressBar(VARIANT_BOOL Value); + + HRESULT Resizable(VARIANT_BOOL * Value); + HRESULT Resizable(VARIANT_BOOL Value); + } + + /* + dispinterface DWebBrowserEvents2 + { + properties: + methods: + [id(DISPID_STATUSTEXTCHANGE), helpstring("Statusbar text changed."), helpcontext(0x0000)] + void StatusTextChange([in]BSTR Text); + + [id(DISPID_PROGRESSCHANGE), helpstring("Fired when download progress is updated."), helpcontext(0x0000)] + void ProgressChange([in] long Progress, [in] long ProgressMax); + + [id(DISPID_COMMANDSTATECHANGE), helpstring("The enabled state of a command changed."), helpcontext(0x0000)] + void CommandStateChange([in] long Command, [in] VARIANT_BOOL Enable); + + [id(DISPID_DOWNLOADBEGIN), helpstring("Download of a page started."), helpcontext(0x000)] + void DownloadBegin(); + + [id(DISPID_DOWNLOADCOMPLETE), helpstring("Download of page complete."), helpcontext(0x0000)] + void DownloadComplete(); + + [id(DISPID_TITLECHANGE), helpstring("Document title changed."), helpcontext(0x0000)] + void TitleChange([in] BSTR Text); + + [id(DISPID_PROPERTYCHANGE), helpstring("Fired when the PutProperty method has been called."), helpcontext(0x0000)] + void PropertyChange([in] BSTR szProperty); + + // New events for IE40: + // + [id(DISPID_BEFORENAVIGATE2), helpstring("Fired before navigate occurs in the given WebBrowser (window or frameset element). The processing of this navigation may be modified."), helpcontext(0x0000)] + void BeforeNavigate2([in] IDispatch* pDisp, + [in] VARIANT * URL, [in] VARIANT * Flags, [in] VARIANT * TargetFrameName, [in] VARIANT * PostData, [in] VARIANT * Headers, + [in,out] VARIANT_BOOL * Cancel); + + [id(DISPID_NEWWINDOW2), helpstring("A new, hidden, non-navigated WebBrowser window is needed."), helpcontext(0x0000)] + void NewWindow2([in, out] IDispatch** ppDisp, [in, out] VARIANT_BOOL * Cancel); + + [id(DISPID_NAVIGATECOMPLETE2), helpstring("Fired when the document being navigated to becomes visible and enters the navigation stack."), helpcontext(0x0000)] + void NavigateComplete2([in] IDispatch* pDisp, [in] VARIANT * URL ); + + [id(DISPID_DOCUMENTCOMPLETE), helpstring("Fired when the document being navigated to reaches ReadyState_Complete."), helpcontext(0x0000)] + void DocumentComplete([in] IDispatch* pDisp, [in] VARIANT * URL ); + + [id(DISPID_ONQUIT), helpstring("Fired when application is quiting."), helpcontext(0x0000)] + void OnQuit(); + + [id(DISPID_ONVISIBLE), helpstring("Fired when the window should be shown/hidden"), helpcontext(0x0000)] + void OnVisible([in] VARIANT_BOOL Visible); + + [id(DISPID_ONTOOLBAR), helpstring("Fired when the toolbar should be shown/hidden"), helpcontext(0x0000)] + void OnToolBar([in] VARIANT_BOOL ToolBar); + + [id(DISPID_ONMENUBAR), helpstring("Fired when the menubar should be shown/hidden"), helpcontext(0x0000)] + void OnMenuBar([in] VARIANT_BOOL MenuBar); + + [id(DISPID_ONSTATUSBAR), helpstring("Fired when the statusbar should be shown/hidden"), helpcontext(0x0000)] + void OnStatusBar([in] VARIANT_BOOL StatusBar); + + [id(DISPID_ONFULLSCREEN), helpstring("Fired when fullscreen mode should be on/off"), helpcontext(0x0000)] + void OnFullScreen([in] VARIANT_BOOL FullScreen); + + [id(DISPID_ONTHEATERMODE), helpstring("Fired when theater mode should be on/off"), helpcontext(0x0000)] + void OnTheaterMode([in] VARIANT_BOOL TheaterMode); + } + */ + + /* + + [ + uuid(EAB22AC3-30C1-11CF-A7EB-0000C05BAE0B), // v.1 clsid CLSID_WebBrowser_V1 + control, + helpstring("WebBrowser Control") + ] + coclass WebBrowser_V1 + { + interface IWebBrowser2; + [default] interface IWebBrowser; + [source] dispinterface DWebBrowserEvents2; + [default, source] dispinterface DWebBrowserEvents; + } + + [ + uuid(8856F961-340A-11D0-A96B-00C04FD705A2), // v.2 clsid CLSID_WebBrowser + control, + helpstring("WebBrowser Control") + ] + coclass WebBrowser + { + [default] interface IWebBrowser2; + interface IWebBrowser; + [default, source] dispinterface DWebBrowserEvents2; + [source] dispinterface DWebBrowserEvents; + } + + [ + uuid(0002DF01-0000-0000-C000-000000000046), // CLSID_InternetExplorer + helpstring("Internet Explorer Application."), + ] + coclass InternetExplorer + { + [default] interface IWebBrowser2; + interface IWebBrowserApp; + [default, source] dispinterface DWebBrowserEvents2; + [source] dispinterface DWebBrowserEvents; + } + + */ + + + interface IFolderViewOC : IDispatch + { + HRESULT SetFolderView(IDispatch pdisp); + } + + interface DShellFolderViewEvents + { + void SelectionChanged(); + } + +/* [ + uuid(9BA05971-F6A8-11CF-A442-00A0C90A8F39), // CLSID_ShellFolderViewOC + helpstring("Shell Folder View Events Router."), + hidden + ] + coclass ShellFolderViewOC + { + [default] interface IFolderViewOC; + [default, source] dispinterface DShellFolderViewEvents; + }*/ + enum ShellWindowTypeConstants { + SWC_EXPLORER = 0x0, + SWC_BROWSER = 0x00000001, + SWC_3RDPARTY = 0x00000002, + SWC_CALLBACK = 0x00000004, + } + + enum ShellWindowFindWindowOptions { + SWFO_NEEDDISPATCH = 0x00000001, + SWFO_INCLUDEPENDING = 0x00000002, + SWFO_COOKIEPASSED = 0x00000004, + } + + interface DShellWindowsEvents + { + void WindowRegistered(LONG lCookie); + + void WindowRevoked(LONG lCookie); + } + + interface IShellWindows : IDispatch + { + //Properties + HRESULT Count(LONG *Count); + + HRESULT Item(VARIANT index, IDispatch *Folder); + + HRESULT _NewEnum(IUnknown *ppunk); + + // Some private hidden members to allow shell windows to add and + // remove themself from the list. We mark them hidden to keep + // random VB apps from trying to Register... + HRESULT Register( IDispatch pid, + LONG hwnd, + int swClass, + LONG *plCookie); + + HRESULT RegisterPending(LONG lThreadId, + VARIANT* pvarloc, // will hold pidl that is being opened. + VARIANT* pvarlocRoot, // Optional root pidl + int swClass, + LONG *plCookie); + + HRESULT Revoke(LONG lCookie); + // As an optimization, each window notifies the new location + // only when + // (1) it's being deactivated + // (2) getFullName is called (we overload it to force update) + HRESULT OnNavigate(LONG lCookie, VARIANT* pvarLoc); + HRESULT OnActivated(LONG lCookie, VARIANT_BOOL fActive); + HRESULT FindWindow(VARIANT* pvarLoc, + VARIANT* pvarLocRoot, + int swClass, + LONG * phwnd, + int swfwOptions, + IDispatch* ppdispOut); + HRESULT OnCreated(LONG lCookie,IUnknown punk); + + HRESULT ProcessAttachDetach(VARIANT_BOOL fAttach); + } + + /* + [ + uuid(9BA05972-F6A8-11CF-A442-00A0C90A8F39), // CLSID_ShellWindows + helpstring("ShellDispatch Load in Shell Context") + ] + coclass ShellWindows + { + [default] interface IShellWindows; + [default, source] dispinterface DShellWindowsEvents; + } + */ + + /* + + [ + uuid(88A05C00-F000-11CE-8350-444553540000), // IID_IShellLinkDual + helpstring("Definition of Shell Link IDispatch interface"), + oleautomation, + dual, + odl, + hidden, + ] + interface IShellLinkDual : IDispatch + { + [propget, helpstring("Get the path of the link")] + HRESULT Path([out, retval] BSTR *pbs); + + [propput, helpstring("Set the path of the link")] + HRESULT Path([in] BSTR bs); + + [propget, helpstring("Get the description for the link")] + HRESULT Description([out, retval] BSTR *pbs); + + [propput, helpstring("Set the description for the link")] + HRESULT Description([in] BSTR bs); + + [propget, helpstring("Get the working directory for the link")] + HRESULT WorkingDirectory([out, retval] BSTR *pbs); + + [propput, helpstring("Set the working directory for the link")] + HRESULT WorkingDirectory([in] BSTR bs); + + [propget, helpstring("Get the arguments for the link")] + HRESULT Arguments([out, retval] BSTR *pbs); + + [propput, helpstring("Set the arguments for the link")] + HRESULT Arguments([in] BSTR bs); + + + [propget, helpstring("Get the Hotkey for the link")] + HRESULT Hotkey([out, retval] int *piHK); + + [propput, helpstring("Set the Hotkey for the link")] + HRESULT Hotkey([in] int iHK); + + [propget, helpstring("Get the Show Command for the link")] + HRESULT ShowCommand([out, retval] int *piShowCommand); + + [propput, helpstring("Set the Show Command for the link")] + HRESULT ShowCommand([in] int iShowCommand); + + // STDMETHOD(SetRelativePath)(THIS_ LPCSTR pszPathRel, DWORD dwReserved) PURE; + //Methods + [helpstring("Tell the link to resolve itself")] + HRESULT Resolve([in] int fFlags); + + [helpstring("Get the IconLocation for the link")] + HRESULT GetIconLocation([out] BSTR *pbs, [out,retval] int *piIcon); + + [helpstring("Set the IconLocation for the link")] + HRESULT SetIconLocation([in] BSTR bs, [in] int iIcon); + + [helpstring("Tell the link to save the changes")] + HRESULT Save ([in, optional] VARIANT vWhere); + } + + [ + uuid(11219420-1768-11d1-95BE-00609797EA4F), // CLSID_ShellLinkObject + helpstring("Shell Link object") + ] + coclass ShellLinkObject // funny name so we don't conflict with CLSID_ShellLink + { + [default] interface IShellLinkDual; + } + + [ + uuid(08EC3E00-50B0-11CF-960C-0080C7F4EE85), // IID_FolderItemVerb + helpstring("Definition of interface FolderItemVerb"), + oleautomation, + dual, + odl, + ] + interface FolderItemVerb : IDispatch + { + [propget, helpstring("Get Application object")] + HRESULT Application ([out, retval] IDispatch **ppid); + + [propget, helpstring("Get Parent object")] + HRESULT Parent([out, retval] IDispatch **ppid); + + [id(0), propget, helpstring("Get display name for item")] + HRESULT Name([out, retval] BSTR *pbs); + + [helpstring("Execute the verb")] + HRESULT DoIt(); + } + + [ + uuid(1F8352C0-50B0-11CF-960C-0080C7F4EE85), // IID_FolderItemVerbs + helpstring("Definition of interface FolderItemVerbs"), + oleautomation, + dual, + odl, + ] + interface FolderItemVerbs : IDispatch + { + //Properties + [propget, helpstring("Get count of open folder windows")] + HRESULT Count([out, retval] long *plCount); + + [propget, helpstring("Get Application object")] + HRESULT Application ([out, retval] IDispatch **ppid); + + [propget, helpstring("Get Parent object")] + HRESULT Parent([out, retval] IDispatch **ppid); + + //Methods + //Standard Methods + [helpstring("Return the specified verb")] + HRESULT Item([in,optional] VARIANT index, [out, retval]FolderItemVerb **ppid); + + [id(-4), helpstring("Enumerates the figures")] + HRESULT _NewEnum([out, retval] IUnknown **ppunk); + } + + interface Folder; // forward reference + + [ + uuid(FAC32C80-CBE4-11CE-8350-444553540000), // IID_FolderItem + helpstring("Definition of interface FolderItem"), + oleautomation, + dual, + odl, + ] + interface FolderItem : IDispatch + { + [propget, helpstring("Get Application object")] + HRESULT Application ([out, retval] IDispatch **ppid); + + [propget, helpstring("Get Parent object")] + HRESULT Parent([out, retval] IDispatch **ppid); + + [id(0), propget, helpstring("Get display name for item")] + HRESULT Name([out, retval] BSTR *pbs); + + [id(0), propput, helpstring("Set the name for the item")] + HRESULT Name([in] BSTR bs); + + [propget, helpstring("Get the pathname to the item")] + HRESULT Path([out, retval]BSTR *pbs); + + [propget, helpstring("If item is link return link object")] + HRESULT GetLink([out, retval] IDispatch **ppid); + + [propget, helpstring("If item is a folder return folder object")] + HRESULT GetFolder([out, retval] IDispatch **ppid); + + [propget, helpstring("Is the item a link?")] + HRESULT IsLink([out, retval] VARIANT_BOOL *pb); + + [propget, helpstring("Is the item a Folder?")] + HRESULT IsFolder([out, retval] VARIANT_BOOL *pb); + + [propget, helpstring("Is the item a file system object?")] + HRESULT IsFileSystem([out, retval] VARIANT_BOOL *pb); + + [propget, helpstring("Is the item browsable?")] + HRESULT IsBrowsable([out, retval] VARIANT_BOOL *pb); + + [propget, helpstring("Modification Date?")] + HRESULT ModifyDate([out, retval] DATE *pdt); + + [propput, helpstring("Modification Date?")] + HRESULT ModifyDate([in] DATE dt); + + [propget, helpstring("Size")] + HRESULT Size([out, retval] LONG *pul); + + [propget, helpstring("Type")] + HRESULT Type([out, retval] BSTR *pbs); + + [helpstring("Get the list of verbs for the object")] + HRESULT Verbs([out, retval] FolderItemVerbs **ppfic); + + [helpstring("Execute a command on the item")] + HRESULT InvokeVerb([in,optional] VARIANT vVerb); + } + + [ + uuid(744129E0-CBE5-11CE-8350-444553540000), // IID_FolderItems + helpstring("Definition of interface FolderItems"), + oleautomation, + dual, + odl, + ] + interface FolderItems : IDispatch + { + //Properties + [propget, helpstring("Get count of items in the folder")] + HRESULT Count([out, retval] long *plCount); + + [propget, helpstring("Get Application object")] + HRESULT Application ([out, retval] IDispatch **ppid); + + [propget, helpstring("Get Parent object")] + HRESULT Parent([out, retval] IDispatch **ppid); + + //Methods + //Standard Methods + [helpstring("Return the figure for the given index")] + HRESULT Item([in,optional] VARIANT index, [out, retval]FolderItem **ppid); + + [id(-4), helpstring("Enumerates the figures")] + HRESULT _NewEnum([out, retval] IUnknown **ppunk); + } + + [ + uuid(BBCBDE60-C3FF-11CE-8350-444553540000), // IID_Folder + helpstring("Definition of interface Folder"), + oleautomation, + dual, + odl, + ] + interface Folder : IDispatch + { + //Properties + [id(0), propget, helpstring("Get the display name for the window")] + HRESULT Title([out, retval] BSTR *pbs); + + [propget, helpstring("Get Application object")] + HRESULT Application ([out, retval] IDispatch **ppid); + + [propget, helpstring("Get Parent object")] + HRESULT Parent([out, retval] IDispatch **ppid); + + [propget, helpstring("Get Parent object")] + HRESULT ParentFolder([out, retval] Folder **ppsf); + + //Methods + [helpstring("The collection of Items in folder")] + HRESULT Items([out, retval] FolderItems **ppid); + + [helpstring("Parse the name to get an item.")] + HRESULT ParseName([in] BSTR bName, [out, retval] FolderItem **ppid); + + [helpstring("Create a new sub folder in this folder.")] + HRESULT NewFolder([in] BSTR bName, [in, optional] VARIANT vOptions); + + [helpstring("Move Items to this folder.")] + HRESULT MoveHere([in] VARIANT vItem, [in, optional] VARIANT vOptions); + + [helpstring("Copy Items to this folder.")] + HRESULT CopyHere([in] VARIANT vItem, [in, optional] VARIANT vOptions); + + [helpstring("Get the details about an item.")] + HRESULT GetDetailsOf([in] VARIANT vItem, [in] int iColumn, [out, retval]BSTR *pbs); + } + + [ + uuid(E7A1AF80-4D96-11CF-960C-0080C7F4EE85), // IID_IShellFolderViewDual + helpstring("definition of interface IShellFolderViewDual"), + oleautomation, + hidden, + dual, + odl, + ] + interface IShellFolderViewDual : IDispatch + { + [propget, helpstring("Get Application object")] + HRESULT Application([out, retval] IDispatch **ppid); + + [propget, helpstring("Get Parent object")] + HRESULT Parent([out, retval] IDispatch **ppid); + + [propget, helpstring("Get the folder being viewed")] + HRESULT Folder([out, retval] Folder **ppid); + + [helpstring("The collection of Selected Items in folder")] + HRESULT SelectedItems([out, retval] FolderItems **ppid); + + [propget, helpstring("The currently focused item in the folder")] + HRESULT FocusedItem([out, retval] FolderItem **ppid); + + [helpstring("Select the item")] + HRESULT SelectItem([in]VARIANT *pvfi, [in] int dwFlags); + + [helpstring("Show items menu and return command selected")] + HRESULT PopupItemMenu([in]FolderItem *pfi, [in, optional]VARIANT vx, [in, optional]VARIANT vy, [out, retval] BSTR *pbs); + + [propget, helpstring("Returns the scripting automation model."), helpcontext(0x0000)] + HRESULT Script([out,retval] IDispatch** ppDisp); + + [propget, helpstring("Returns the view options for showing a folder."), helpcontext(0x0000)] + HRESULT ViewOptions([out,retval] long * plViewOptions); + } + + [ + uuid(62112AA1-EBE4-11cf-A5FB-0020AFE7292D), // CLSID_ShellFolderView + helpstring("Shell Folder View Object") + ] + coclass ShellFolderView + { + [default] interface IShellFolderViewDual; + [source,default] dispinterface DShellFolderViewEvents; + } + + typedef + [ + uuid(742A99A0-C77E-11D0-A32C-00A0C91EEDBA), + helpstring("Constants for ViewOptions") + ] + enum ShellFolderViewOptions { + [helpstring("Show All Objects")] SFVVO_SHOWALLOBJECTS = 0x00000001, + [helpstring("Show File Extensions")] SFVVO_SHOWEXTENSIONS = 0x00000002, + [helpstring("Color encode Compressed files")] SFVVO_SHOWCOMPCOLOR = 0x00000008, + [helpstring("Show System Files")] SFVVO_SHOWSYSFILES = 0x00000020, + [helpstring("Use Windows 95 UI settings")] SFVVO_WIN95CLASSIC = 0x00000040, + [helpstring("User needs to double click in web View")] SFVVO_DOUBLECLICKINWEBVIEW = 0x00000080, + [helpstring("Is Desktop HTML enabled")] SFVVO_DESKTOPHTML = 0x00000200, + } ShellFolderViewOptions; + + [ + uuid(D8F015C0-C278-11CE-A49E-444553540000), // IID_IShellDispatch + helpstring("Definition of interface IShellDispatch"), + oleautomation, + hidden, + dual, + odl, + ] + interface IShellDispatch : IDispatch + { + [propget, helpstring("Get Application object")] + HRESULT Application ([out, retval] IDispatch **ppid); + + [propget, helpstring("Get Parent object")] + HRESULT Parent([out, retval] IDispatch **ppid); + + //========================================================= + // Name Space methods and properties + + [helpstring("Enum the contents of a folder")] + HRESULT NameSpace([in] VARIANT vDir, [out, retval] Folder **ppsdf); + + [helpstring("Browse the name space for a Folder")] + HRESULT BrowseForFolder([in] long Hwnd, + [in] BSTR Title, + [in] long Options, + [in,optional] VARIANT RootFolder, + [out, retval] FOLDER **ppsdf); + + [helpstring("The collection of open folder windows")] + HRESULT Windows([out, retval] IDispatch **ppid); + + [helpstring("Open a folder")] + HRESULT Open([in] VARIANT vDir); + + [helpstring("Explore a folder")] + HRESULT Explore([in] VARIANT vDir); + + [helpstring("Minimize all windows")] + HRESULT MinimizeAll(void); + + [helpstring("Undo Minimize All")] + HRESULT UndoMinimizeALL(void); + + [helpstring("Bring up the file run")] + HRESULT FileRun(void); + + [helpstring("Cascade Windows")] + HRESULT CascadeWindows(void); + + [helpstring("Tile windows vertically")] + HRESULT TileVertically(void); + + [helpstring("Tile windows horizontally")] + HRESULT TileHorizontally(void); + + [helpstring("Exit Windows")] + HRESULT ShutdownWindows(void); + + [helpstring("Suspend the pc")] + HRESULT Suspend(void); + + [helpstring("Eject the pc")] + HRESULT EjectPC(void); + + [helpstring("Bring up the Set time dialog")] + HRESULT SetTime(void); + + [helpstring("Handle Tray properties")] + HRESULT TrayProperties(void); + + [helpstring("Display shell help")] + HRESULT Help(void); + + [helpstring("Find Files")] + HRESULT FindFiles(void); + + [helpstring("Find a computer")] + HRESULT FindComputer(void); + + [helpstring("Refresh the menu")] + HRESULT RefreshMenu(void); + + [helpstring("Run a controlpanelItem")] + HRESULT ControlPanelItem([in] BSTR szDir); + } + + [ + uuid(13709620-C279-11CE-A49E-444553540000), // CLSID_Shell + helpstring("Shell Object Type Information") + ] + coclass Shell + { + [default] interface IShellDispatch; + } + + [ + uuid(0A89A860-D7B1-11CE-8350-444553540000), // CLSID_ShellDispatchInproc + helpstring("ShellDispatch Load in Shell Context"), + hidden + ] + coclass ShellDispatchInproc + { + interface IUnknown; + } + + [ + uuid(1820FED0-473E-11D0-A96C-00C04FD705A2), // CLSID_WebViewFolderContents + hidden + ] + coclass WebViewFolderContents + { + [default] interface IShellFolderViewDual; + [source,default] dispinterface DShellFolderViewEvents; + } + + typedef + [ + uuid(CA31EA20-48D0-11CF-8350-444553540000), + helpstring("Constants for Special Folders for open/Explore") + ] + enum ShellSpecialFolderConstants { + [helpstring("Special Folder DESKTOP")] ssfDESKTOP = 0x0000, + [helpstring("Special Folder PROGRAMS")] ssfPROGRAMS = 0x0002, + [helpstring("Special Folder CONTROLS")] ssfCONTROLS = 0x0003, + [helpstring("Special Folder PRINTERS")] ssfPRINTERS = 0x0004, + [helpstring("Special Folder PERSONAL")] ssfPERSONAL = 0x0005, + [helpstring("Special Folder FAVORITES")] ssfFAVORITES = 0x0006, + [helpstring("Special Folder STARTUP")] ssfSTARTUP = 0x0007, + [helpstring("Special Folder RECENT")] ssfRECENT = 0x0008, + [helpstring("Special Folder SENDTO")] ssfSENDTO = 0x0009, + [helpstring("Special Folder BITBUCKET")] ssfBITBUCKET = 0x000a, + [helpstring("Special Folder STARTMENU")] ssfSTARTMENU = 0x000b, + [helpstring("Special Folder DESKTOPDIRECTORY")] ssfDESKTOPDIRECTORY = 0x0010, + [helpstring("Special Folder DRIVES")] ssfDRIVES = 0x0011, + [helpstring("Special Folder NETWORK")] ssfNETWORK = 0x0012, + [helpstring("Special Folder NETHOOD")] ssfNETHOOD = 0x0013, + [helpstring("Special Folder FONTS")] ssfFONTS = 0x0014, + [helpstring("Special Folder TEMPLATES")] ssfTEMPLATES = 0x0015, + } ShellSpecialFolderConstants; + + [ + uuid(729FE2F8-1EA8-11d1-8F85-00C04FC2FBE1), // IID_IShellUIHelper + helpstring("Shell UI Helper Control Interface"), + oleautomation, dual + ] + interface IShellUIHelper : IDispatch + { + [hidden, id(DISPID_RESETFIRSTBOOTMODE)] HRESULT ResetFirstBootMode(); + [hidden, id(DISPID_RESETSAFEMODE)] HRESULT ResetSafeMode(); + [hidden, id(DISPID_REFRESHOFFLINEDESKTOP)] HRESULT RefreshOfflineDesktop(); + [id(DISPID_ADDFAVORITE)] HRESULT AddFavorite([in] BSTR URL, [optional, in] VARIANT *Title); + [id(DISPID_ADDCHANNEL)] HRESULT AddChannel([in] BSTR URL); + [id(DISPID_ADDDESKTOPCOMPONENT)] HRESULT AddDesktopComponent([in] BSTR URL, [in] BSTR Type, + [optional, in] VARIANT *Left, + [optional, in] VARIANT *Top, + [optional, in] VARIANT *Width, + [optional, in] VARIANT *Height); + [id(DISPID_ISSUBSCRIBED)] HRESULT IsSubscribed([in] BSTR URL, [out,retval] VARIANT_BOOL* pBool); + } + [ + uuid(64AB4BB7-111E-11d1-8F79-00C04FC2FBE1) // CLSID_ShellUIHelper + ] + coclass ShellUIHelper + { + [default] interface IShellUIHelper; + } +*/ +} // extern (Windows) +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/ole/win32/MSHTMHST.d Fri Feb 08 19:49:32 2008 +0100 @@ -0,0 +1,209 @@ +module dwt.internal.ole.win32.MSHTMHST; +//+------------------------------------------------------------------------ +// +// Microsoft Forms +// Copyright 1996 - 1998 Microsoft Corporation. +// +// File: mshtmhst.idl +// +// Contents: MSHTML advanced host interfaces +// +//------------------------------------------------------------------------- + +//private import std.c.windows.windows; +//private import std.c.windows.com; +import dwt.internal.win32.OS; + +//import win32.oleextra; +private import dwt.internal.ole.win32.extras; +private import dwt.internal.ole.win32.OAIDL; +private import dwt.internal.ole.win32.OBJIDL; +private import dwt.internal.ole.win32.OLEIDL; +private import dwt.internal.ole.win32.DOCOBJ; + +extern( Windows ) { +/* +cpp_quote("#define CONTEXT_MENU_DEFAULT 0") +cpp_quote("#define CONTEXT_MENU_IMAGE 1") +cpp_quote("#define CONTEXT_MENU_CONTROL 2") +cpp_quote("#define CONTEXT_MENU_TABLE 3") +cpp_quote("// in browse mode") +cpp_quote("#define CONTEXT_MENU_TEXTSELECT 4") +cpp_quote("#define CONTEXT_MENU_ANCHOR 5") +cpp_quote("#define CONTEXT_MENU_UNKNOWN 6") +cpp_quote("//;begin_internal") +cpp_quote("// These 2 are mapped to IMAGE for the public") +cpp_quote("#define CONTEXT_MENU_IMGDYNSRC 7") +cpp_quote("#define CONTEXT_MENU_IMGART 8") +cpp_quote("#define CONTEXT_MENU_DEBUG 9") +cpp_quote("//;end_internal") + +cpp_quote("#define MENUEXT_SHOWDIALOG 0x1") + +cpp_quote("#define DOCHOSTUIFLAG_BROWSER DOCHOSTUIFLAG_DISABLE_HELP_MENU | DOCHOSTUIFLAG_DISABLE_SCRIPT_INACTIVE ") + +import "ocidl.idl"; +import "objidl.idl"; +import "oleidl.idl"; +import "oaidl.idl"; +import "docobj.idl"; +import "mshtml.idl"; + +cpp_quote("EXTERN_C const GUID CGID_MSHTML;") +cpp_quote("#define CMDSETID_Forms3 CGID_MSHTML") +cpp_quote("#define SZ_HTML_CLIENTSITE_OBJECTPARAM L\"{d4db6850-5385-11d0-89e9-00a0c90a90ac}\"") +#pragma midl_echo("typedef HRESULT STDAPICALLTYPE SHOWHTMLDIALOGFN (HWND hwndParent, IMoniker *pmk, VARIANT *pvarArgIn, TCHAR* pchOptions, VARIANT *pvArgOut);") +#pragma midl_echo("STDAPI ShowHTMLDialog( ") +#pragma midl_echo(" HWND hwndParent, ") +#pragma midl_echo(" IMoniker * pMk, ") +#pragma midl_echo(" VARIANT * pvarArgIn, ") +#pragma midl_echo(" TCHAR * pchOptions, ") +#pragma midl_echo(" VARIANT * pvarArgOut ") +#pragma midl_echo(" ); ") +*/ + +//------------------------------------------------------------------------- +// IDocHostUIHandler +// +//------------------------------------------------------------------------- + +enum DOCHOSTUITYPE { + DOCHOSTUITYPE_BROWSE = 0, + DOCHOSTUITYPE_AUTHOR = 1, + BROWSE = 0, + AUTHOR = 1, +} + +enum DOCHOSTUIDBLCLK { + DOCHOSTUIDBLCLK_DEFAULT = 0, + DOCHOSTUIDBLCLK_SHOWPROPERTIES = 1, + DOCHOSTUIDBLCLK_SHOWCODE = 2, + + DEFAULT = 0, + SHOWPROPERTIES = 1, + SHOWCODE = 2, +} + +enum DOCHOSTUIFLAG { + DOCHOSTUIFLAG_DIALOG = 1, + DOCHOSTUIFLAG_DISABLE_HELP_MENU = 2, + DOCHOSTUIFLAG_NO3DBORDER = 4, + DOCHOSTUIFLAG_SCROLL_NO = 8, + DOCHOSTUIFLAG_DISABLE_SCRIPT_INACTIVE = 16, + DOCHOSTUIFLAG_OPENNEWWIN = 32, + DOCHOSTUIFLAG_DISABLE_OFFSCREEN = 64, + DOCHOSTUIFLAG_FLAT_SCROLLBAR = 128, + DOCHOSTUIFLAG_DIV_BLOCKDEFAULT = 256, + DOCHOSTUIFLAG_ACTIVATE_CLIENTHIT_ONLY = 512, + DOCHOSTUIFLAG_DISABLE_COOKIE = 1024, +// +// DOCHOSTUIFLAG.name versions +// + DIALOG = 1, + DISABLE_HELP_MENU = 2, + NO3DBORDER = 4, + SCROLL_NO = 8, + DISABLE_SCRIPT_INACTIVE = 16, + OPENNEWWIN = 32, + DISABLE_OFFSCREEN = 64, + FLAT_SCROLLBAR = 128, + DIV_BLOCKDEFAULT = 256, + ACTIVATE_CLIENTHIT_ONLY = 512, + DISABLE_COOKIE = 1024, +} +/* polute the global namespace */ +enum { + DOCHOSTUITYPE_BROWSE = 0, + DOCHOSTUITYPE_AUTHOR = 1, + + DOCHOSTUIDBLCLK_DEFAULT = 0, + DOCHOSTUIDBLCLK_SHOWPROPERTIES = 1, + DOCHOSTUIDBLCLK_SHOWCODE = 2, + + DOCHOSTUIFLAG_DIALOG = 1, + DOCHOSTUIFLAG_DISABLE_HELP_MENU = 2, + DOCHOSTUIFLAG_NO3DBORDER = 4, + DOCHOSTUIFLAG_SCROLL_NO = 8, + DOCHOSTUIFLAG_DISABLE_SCRIPT_INACTIVE = 16, + DOCHOSTUIFLAG_OPENNEWWIN = 32, + DOCHOSTUIFLAG_DISABLE_OFFSCREEN = 64, + DOCHOSTUIFLAG_FLAT_SCROLLBAR = 128, + DOCHOSTUIFLAG_DIV_BLOCKDEFAULT = 256, + DOCHOSTUIFLAG_ACTIVATE_CLIENTHIT_ONLY = 512, + DOCHOSTUIFLAG_DISABLE_COOKIE = 1024, +} + +struct DOCHOSTUIINFO +{ + ULONG cbSize; + DWORD dwFlags; + DWORD dwDoubleClick; +} + +interface IDocHostUIHandler : IUnknown +{ + HRESULT ShowContextMenu( DWORD dwID, POINT* ppt, IUnknown pcmdtReserved, IDispatch pdispReserved); + HRESULT GetHostInfo( DOCHOSTUIINFO * pInfo ); + HRESULT ShowUI( DWORD dwID, IOleInPlaceActiveObject pActiveObject, IOleCommandTarget pCommandTarget, IOleInPlaceFrame pFrame, IOleInPlaceUIWindow pDoc ); + HRESULT HideUI(); + HRESULT UpdateUI(); + HRESULT EnableModeless( BOOL fEnable ); + HRESULT OnDocWindowActivate( BOOL fActivate ); + HRESULT OnFrameWindowActivate( BOOL fActivate ); + HRESULT ResizeBorder(LPRECT prcBorder, IOleInPlaceUIWindow pUIWindow, BOOL fRameWindow ); + HRESULT TranslateAccelerator( LPMSG lpMsg, GUID * pguidCmdGroup, DWORD nCmdID ); + HRESULT GetOptionKeyPath( LPOLESTR * pchKey, DWORD dw ); + HRESULT GetDropTarget( IDropTarget pDropTarget, IDropTarget * ppDropTarget ); + HRESULT GetExternal( IDispatch * ppDispatch ); + HRESULT TranslateUrl( DWORD dwTranslate, OLECHAR * pchURLIn, OLECHAR ** ppchURLOut ); + HRESULT FilterDataObject( IDataObject pDO, IDataObject * ppDORet ); +} + + +//------------------------------------------------------------------------- +// ICustomDoc +// +//------------------------------------------------------------------------- + +interface ICustomDoc : IUnknown +{ + HRESULT SetUIHandler( IDocHostUIHandler pUIHandler ); +} + +//------------------------------------------------------------------------- +// IDocHostShowUI +// +//------------------------------------------------------------------------- + +interface IDocHostShowUI : IUnknown +{ + HRESULT ShowMessage( HWND hwnd, LPOLESTR lpstrText, LPOLESTR lpstrCaption, DWORD dwType, LPOLESTR lpstrHelpFile, DWORD dwHelpContext, LRESULT * plResult); + HRESULT ShowHelp( HWND hwnd, LPOLESTR pszHelpFile, UINT uCommand, DWORD dwData, POINT ptMouse, IDispatch pDispatchObjectHit ); +} + +/* + +//------------------------------------------------------------------------- +// ICSSFilterSite +// +//------------------------------------------------------------------------- +interface ICSSFilterSite : IUnknown +{ + HRESULT GetElement( IHTMLElement * ppElem ); + HRESULT FireOnFilterChangeEvent(); +} + + +//------------------------------------------------------------------------- +// ICSSFilter +// +//------------------------------------------------------------------------- +interface ICSSFilter : IUnknown +{ + HRESULT SetSite( ICSSFilterSite * pSink ); + HRESULT OnAmbientPropertyChange( LONG dispid ); +} + +*/ + +} // extern( Windows )
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/ole/win32/OAIDL.d Fri Feb 08 19:49:32 2008 +0100 @@ -0,0 +1,1158 @@ +module dwt.internal.ole.win32.OAIDL; + +//+--------------------------------------------------------------------------- +// +// Microsoft Windows +// Copyright 1992 - 1998 Microsoft Corporation. +// +// File: oaidl.idl +// +//---------------------------------------------------------------------------- + +//private import std.c.windows.windows; +//private import std.c.windows.com; +private import dwt.internal.ole.win32.OBJIDL; +private import dwt.internal.ole.win32.extras; +private import dwt.internal.win32.WINTYPES; +private import dwt.ole.win32.Variant; + +extern(Windows) { + +struct DECIMAL + { + USHORT wReserved; + BYTE scale; + BYTE sign; + ULONG Hi32; + ulong Lo64; + } ; + +alias wchar * BSTR; +struct FLAGGED_WORD_BLOB + { + ULONG fFlags; + ULONG clSize; + ushort[1] asData; + } + +alias FLAGGED_WORD_BLOB *wireBSTR; + + struct BYTE_SIZEDARR + { + ULONG clSize; + byte *pData; + } ; + + struct WORD_SIZEDARR + { + ULONG clSize; + ushort *pData; + } ; + +struct DWORD_SIZEDARR + { + ULONG clSize; + ULONG * pData; + } ; + +struct HYPER_SIZEDARR + { + ULONG clSize; + long *pData; + } + + +enum +{ VT_EMPTY = 0, + VT_NULL = 1, + VT_I2 = 2, + VT_I4 = 3, + VT_R4 = 4, + VT_R8 = 5, + VT_CY = 6, + VT_DATE = 7, + VT_BSTR = 8, + VT_DISPATCH = 9, + VT_ERROR = 10, + VT_BOOL = 11, + VT_VARIANT = 12, + VT_UNKNOWN = 13, + VT_DECIMAL = 14, + VT_I1 = 16, + VT_UI1 = 17, + VT_UI2 = 18, + VT_UI4 = 19, + VT_I8 = 20, + VT_UI8 = 21, + VT_INT = 22, + VT_UINT = 23, + VT_VOID = 24, + VT_HRESULT = 25, + VT_PTR = 26, + VT_SAFEARRAY = 27, + VT_CARRAY = 28, + VT_USERDEFINED = 29, + VT_LPSTR = 30, + VT_LPWSTR = 31, + VT_RECORD = 36, + VT_FILETIME = 64, + VT_BLOB = 65, + VT_STREAM = 66, + VT_STORAGE = 67, + VT_STREAMED_OBJECT = 68, + VT_STORED_OBJECT = 69, + VT_BLOB_OBJECT = 70, + VT_CF = 71, + VT_CLSID = 72, + VT_BSTR_BLOB = 0xfff, + VT_VECTOR = 0x1000, + VT_ARRAY = 0x2000, + VT_BYREF = 0x4000, + VT_RESERVED = 0x8000, + VT_ILLEGAL = 0xffff, + VT_ILLEGALMASKED = 0xfff, + VT_TYPEMASK = 0xfff +}; + + +/* +cpp_quote("//+-------------------------------------------------------------------------") +cpp_quote("//") +cpp_quote("// Microsoft Windows") +cpp_quote("// Copyright 1992 - 1998 Microsoft Corporation.") +cpp_quote("//") +cpp_quote("//--------------------------------------------------------------------------") + +cpp_quote("#if ( _MSC_VER >= 800 )") +*/ +//cpp_quote("#pragma warning(disable:4201) /* Nameless struct/union */") +/* +cpp_quote("#endif") + +#ifndef DO_NO_IMPORTS +import "objidl.idl"; +#endif + +interface ICreateTypeInfo; +interface ICreateTypeInfo2; +interface ICreateTypeLib; +interface ICreateTypeLib2; +interface IDispatch; +interface IEnumVARIANT; +interface ITypeComp; +interface ITypeInfo; +interface ITypeInfo2; +interface ITypeLib; +interface ITypeLib2; +interface ITypeChangeEvents; +interface IErrorInfo; +interface ICreateErrorInfo; +interface ISupportErrorInfo; +interface ITypeFactory; +interface ITypeMarshal; +interface IRecordInfo; + + +[ + version(1.0), pointer_default(unique) +] + +interface IOleAutomationTypes +{ + +typedef CY CURRENCY; + +// ######################################################################### +// SAFEARRAY +// ######################################################################### +*/ +struct SAFEARRAYBOUND { + ULONG cElements; + LONG lLbound; +} +alias SAFEARRAYBOUND * LPSAFEARRAYBOUND; + +struct _wireVARIANT { +} +struct _wireBRECORD { +} +// Forward references. +alias _wireVARIANT * wireVARIANT; +alias _wireBRECORD * wireBRECORD; + +struct SAFEARR_BSTR { + ULONG Size; + wireBSTR * aBstr; +} +struct SAFEARR_UNKNOWN { + ULONG Size; + IUnknown * apUnknown; +} + +struct SAFEARR_DISPATCH { + ULONG Size; + IDispatch * apDispatch; +} + +struct SAFEARR_VARIANT { + ULONG Size; + wireVARIANT * aVariant; +} + +struct SAFEARR_BRECORD { + ULONG Size; + wireBRECORD * aRecord; +} + +struct SAFEARR_HAVEIID { + ULONG Size; + IUnknown * apUnknown; + IID iid; +} + +enum SF_TYPE { + SF_ERROR = VT_ERROR, + SF_I1 = VT_I1, + SF_I2 = VT_I2, + SF_I4 = VT_I4, + SF_I8 = VT_I8, + SF_BSTR = VT_BSTR, + SF_UNKNOWN = VT_UNKNOWN, + SF_DISPATCH = VT_DISPATCH, + SF_VARIANT = VT_VARIANT, + SF_RECORD = VT_RECORD, + SF_HAVEIID = VT_UNKNOWN|VT_RESERVED, +} + +union uSAFEARRAY_UNION { +SAFEARR_BSTR BstrStr; +SAFEARR_UNKNOWN UnknownStr; +SAFEARR_DISPATCH DispatchStr; +SAFEARR_VARIANT VariantStr; +SAFEARR_BRECORD RecordStr; +SAFEARR_HAVEIID HaveIidStr; +BYTE_SIZEDARR ByteStr; +WORD_SIZEDARR WordStr; +DWORD_SIZEDARR LongStr; +HYPER_SIZEDARR HyperStr; +} + +struct SAFEARRAY_UNION { + ULONG sfType; + uSAFEARRAY_UNION u; +} + +alias SAFEARRAY_UNION SAFEARRAYUNION; + +struct wireSAFEARRAY { + USHORT cDims; + USHORT fFeatures; + ULONG cbElements; + ULONG cLocks; + SAFEARRAYUNION uArrayStructs; + SAFEARRAYBOUND[1] rgsabound; +} +alias wireSAFEARRAY SAFEARRAY ; + +alias wireSAFEARRAY * wirePSAFEARRAY; + + +struct tagSAFEARRAY { + USHORT cDims; + USHORT fFeatures; + ULONG cbElements; + ULONG cLocks; + PVOID pvData; + SAFEARRAYBOUND[1] rgsabound; +} + +alias SAFEARRAY * LPSAFEARRAY; + +const USHORT FADF_AUTO = 0x0001; /* array is allocated on the stack */ +const USHORT FADF_STATIC = 0x0002; /* array is staticly allocated */ +const USHORT FADF_EMBEDDED = 0x0004; /* array is embedded in a structure */ +const USHORT FADF_FIXEDSIZE = 0x0010; /* may not be resized or reallocated */ +const USHORT FADF_RECORD = 0x0020; /* an array of records */ +const USHORT FADF_HAVEIID = 0x0040; /* with FADF_DISPATCH, FADF_UNKNOWN */ + /* array has an IID for interfaces */ +const USHORT FADF_HAVEVARTYPE= 0x0080; /* array has a VT type */ +const USHORT FADF_BSTR = 0x0100; /* an array of BSTRs */ +const USHORT FADF_UNKNOWN = 0x0200; /* an array of IUnknown* */ +const USHORT FADF_DISPATCH = 0x0400; /* an array of IDispatch* */ +const USHORT FADF_VARIANT = 0x0800; /* an array of VARIANTs */ +const USHORT FADF_RESERVED = 0xF008; /* reserved bits */ + + +// ######################################################################### +// VARIANT +// ######################################################################### +/* +cpp_quote("#if (__STDC__ && !defined(_FORCENAMELESSUNION)) || defined(NONAMELESSUNION)") +cpp_quote("#define __VARIANT_NAME_1 n1") +cpp_quote("#define __VARIANT_NAME_2 n2") +cpp_quote("#define __VARIANT_NAME_3 n3") +cpp_quote("#define __VARIANT_NAME_4 brecVal") +cpp_quote("#else") +cpp_quote("#define __tagVARIANT") +cpp_quote("#define __VARIANT_NAME_1") +cpp_quote("#define __VARIANT_NAME_2") +cpp_quote("#define __VARIANT_NAME_3") +cpp_quote("#define __tagBRECORD") +cpp_quote("#define __VARIANT_NAME_4") +cpp_quote("#endif") +*/ + +/*struct brecVal_t { + PVOID pvRecord; + IRecordInfo * pRecInfo; +}*/ +struct brecVal_t { + PVOID pvRecord; + IUnknown * pRecInfo; +} + +alias double DOUBLE; +alias double DATE; +alias VARIANT_BOOL _VARIANT_BOOL; +alias long CY; + + +union n3_t { + LONG lVal; /* VT_I4 */ + BYTE bVal; /* VT_UI1 */ + SHORT iVal; /* VT_I2 */ + FLOAT fltVal; /* VT_R4 */ + DOUBLE dblVal; /* VT_R8 */ + VARIANT_BOOL boolVal; /* VT_BOOL */ + _VARIANT_BOOL BOOLval; /* (obsolete) */ + SCODE scode; /* VT_ERROR */ + CY cyVal; /* VT_CY */ + DATE date; /* VT_DATE */ + BSTR bstrVal; /* VT_BSTR */ + IUnknown punkVal; /* VT_UNKNOWN */ + IDispatch pdispVal; /* VT_DISPATCH */ + SAFEARRAY * parray; /* VT_ARRAY */ + BYTE * pbVal; /* VT_BYREF|VT_UI1 */ + SHORT * piVal; /* VT_BYREF|VT_I2 */ + LONG * plVal; /* VT_BYREF|VT_I4 */ + FLOAT * pfltVal; /* VT_BYREF|VT_R4 */ + DOUBLE * pdblVal; /* VT_BYREF|VT_R8 */ + VARIANT_BOOL *pboolVal; /* VT_BYREF|VT_BOOL */ + _VARIANT_BOOL *pbool; /* (obsolete) */ + SCODE * pscode; /* VT_BYREF|VT_ERROR */ + CY * pcyVal; /* VT_BYREF|VT_CY */ + DATE * pdate; /* VT_BYREF|VT_DATE */ + BSTR * pbstrVal; /* VT_BYREF|VT_BSTR */ + IUnknown * ppunkVal; /* VT_BYREF|VT_UNKNOWN */ + IDispatch * ppdispVal; /* VT_BYREF|VT_DISPATCH */ + SAFEARRAY ** pparray; /* VT_BYREF|VT_ARRAY */ + VARIANT * pvarVal; /* VT_BYREF|VT_VARIANT */ + PVOID byref; /* Generic ByRef */ + CHAR cVal; /* VT_I1 */ + USHORT uiVal; /* VT_UI2 */ + ULONG ulVal; /* VT_UI4 */ + INT intVal; /* VT_INT */ + UINT uintVal; /* VT_UINT */ + DECIMAL * pdecVal; /* VT_BYREF|VT_DECIMAL */ + CHAR * pcVal; /* VT_BYREF|VT_I1 */ + USHORT * puiVal; /* VT_BYREF|VT_UI2 */ + ULONG * pulVal; /* VT_BYREF|VT_UI4 */ + INT * pintVal; /* VT_BYREF|VT_INT */ + UINT * puintVal; /* VT_BYREF|VT_UINT */ + brecVal_t brecVal; /* VT_RECORD */ +} + +struct n2_t { + VARTYPE vt; + WORD wReserved1; + WORD wReserved2; + WORD wReserved3; + n3_t n3; +}; +union n1_t { + n2_t n2; + DECIMAL decVal; +}; + +// in tango.sys.win32.Types +/+ +struct VARIANT { + n1_t n1; + + VARTYPE vt() { return n1.n2.vt; }; + void vt(VARTYPE val) { n1.n2.vt = val; } + LONG lVal() { return n1.n2.n3.lVal; } + void lVal(LONG val) { return n1.n2.n3.lVal = val; } + FLOAT fltVal() { return n1.n2.n3.fltVal; } + void fltVal(FLOAT val) { return n1.n2.n3.fltVal = val; } + IDispatch pdispVal() { return n1.n2.n3.pdispVal; } + void pdispVal(IDispatch val) { n1.n2.n3.pdispVal = val; } + IUnknown punkVal() { return n1.n2.n3.punkVal; } + void punkVal(IUnknown val) { n1.n2.n3.punkVal = val; } + VARIANT_BOOL boolVal() { return n1.n2.n3.boolVal; } + void boolVal(VARIANT_BOOL val) { n1.n2.n3.boolVal = val; } + SHORT iVal() { return n1.n2.n3.iVal; } + void iVal(SHORT val) { n1.n2.n3.iVal = val; } + BSTR bstrVal() { return n1.n2.n3.bstrVal; } + void bstrVal(BSTR val) { n1.n2.n3.bstrVal = val; } + +}; ++/ + + +/* +struct VARIANT { + LONG[4] mmmm; +} +*/ +alias VARIANT * LPVARIANT; +alias VARIANT VARIANTARG; +alias VARIANT * LPVARIANTARG; + +/+ +struct _wireBRECORD { + ULONG fFlags; + ULONG clSize; + IRecordInfo pRecInfo; + byte * pRecord; +}; +++++++++++++++++++++/ + + +/+ +struct _wireVARIANT { + DWORD clSize; + DWORD rpcReserved; + USHORT vt; + USHORT wReserved1; + USHORT wReserved2; + USHORT wReserved3; + [switch_type(ULONG), switch_is(vt)] union { + [case(VT_I4)] LONG lVal; /* VT_I4 */ + [case(VT_UI1)] BYTE bVal; /* VT_UI1 */ + [case(VT_I2)] SHORT iVal; /* VT_I2 */ + [case(VT_R4)] FLOAT fltVal; /* VT_R4 */ + [case(VT_R8)] DOUBLE dblVal; /* VT_R8 */ + [case(VT_BOOL)] VARIANT_BOOL boolVal; /* VT_BOOL */ + [case(VT_ERROR)] SCODE scode; /* VT_ERROR */ + [case(VT_CY)] CY cyVal; /* VT_CY */ + [case(VT_DATE)] DATE date; /* VT_DATE */ + [case(VT_BSTR)] wireBSTR bstrVal; /* VT_BSTR */ + [case(VT_UNKNOWN)] IUnknown * punkVal; /* VT_UNKNOWN */ + [case(VT_DISPATCH)] IDispatch * pdispVal; /* VT_DISPATCH */ + [case(VT_ARRAY)] wireSAFEARRAY parray; /* VT_ARRAY */ + + [case(VT_RECORD, VT_RECORD|VT_BYREF)] + wireBRECORD brecVal; /* VT_RECORD */ + + [case(VT_UI1|VT_BYREF)] + BYTE * pbVal; /* VT_BYREF|VT_UI1 */ + [case(VT_I2|VT_BYREF)] + SHORT * piVal; /* VT_BYREF|VT_I2 */ + [case(VT_I4|VT_BYREF)] + LONG * plVal; /* VT_BYREF|VT_I4 */ + [case(VT_R4|VT_BYREF)] + FLOAT * pfltVal; /* VT_BYREF|VT_R4 */ + [case(VT_R8|VT_BYREF)] + DOUBLE * pdblVal; /* VT_BYREF|VT_R8 */ + [case(VT_BOOL|VT_BYREF)] + VARIANT_BOOL *pboolVal; /* VT_BYREF|VT_BOOL */ + [case(VT_ERROR|VT_BYREF)] + SCODE * pscode; /* VT_BYREF|VT_ERROR */ + [case(VT_CY|VT_BYREF)] + CY * pcyVal; /* VT_BYREF|VT_CY */ + [case(VT_DATE|VT_BYREF)] + DATE * pdate; /* VT_BYREF|VT_DATE */ + [case(VT_BSTR|VT_BYREF)] + wireBSTR * pbstrVal; /* VT_BYREF|VT_BSTR */ + [case(VT_UNKNOWN|VT_BYREF)] + IUnknown ** ppunkVal; /* VT_BYREF|VT_UNKNOWN */ + [case(VT_DISPATCH|VT_BYREF)] + IDispatch ** ppdispVal; /* VT_BYREF|VT_DISPATCH */ + [case(VT_ARRAY|VT_BYREF)] + wireSAFEARRAY *pparray; /* VT_BYREF|VT_ARRAY */ + [case(VT_VARIANT|VT_BYREF)] + wireVARIANT * pvarVal; /* VT_BYREF|VT_VARIANT */ + + [case(VT_I1)] CHAR cVal; /* VT_I1 */ + [case(VT_UI2)] USHORT uiVal; /* VT_UI2 */ + [case(VT_UI4)] ULONG ulVal; /* VT_UI4 */ + [case(VT_INT)] INT intVal; /* VT_INT */ + [case(VT_UINT)] UINT uintVal; /* VT_UINT */ + [case(VT_DECIMAL)] DECIMAL decVal; /* VT_DECIMAL */ + + [case(VT_BYREF|VT_DECIMAL)] + DECIMAL * pdecVal; /* VT_BYREF|VT_DECIMAL */ + [case(VT_BYREF|VT_I1)] + CHAR * pcVal; /* VT_BYREF|VT_I1 */ + [case(VT_BYREF|VT_UI2)] + USHORT * puiVal; /* VT_BYREF|VT_UI2 */ + [case(VT_BYREF|VT_UI4)] + ULONG * pulVal; /* VT_BYREF|VT_UI4 */ + [case(VT_BYREF|VT_INT)] + INT * pintVal; /* VT_BYREF|VT_INT */ + [case(VT_BYREF|VT_UINT)] + UINT * puintVal; /* VT_BYREF|VT_UINT */ + [case(VT_EMPTY)] ; /* nothing */ + [case(VT_NULL)] ; /* nothing */ + }; +}; ++/ + +//######################################################################## +// End of VARIANT & SAFEARRAY +//######################################################################## + + +//TypeInfo stuff. + +alias LONG DISPID; +alias DISPID MEMBERID; +alias DWORD HREFTYPE; + +enum TYPEKIND { + TKIND_ENUM = 0, + TKIND_RECORD, + TKIND_MODULE, + TKIND_INTERFACE, + TKIND_DISPATCH, + TKIND_COCLASS, + TKIND_ALIAS, + TKIND_UNION, + TKIND_MAX /* end of enum marker */ +} +union TD_00{ + TYPEDESC * lptdesc; + ARRAYDESC * lpadesc; + HREFTYPE hreftype; +}; + +struct TYPEDESC { + TD_00 u; + VARTYPE vt; +} + +struct ARRAYDESC { + TYPEDESC tdescElem; /* element type */ + USHORT cDims; /* dimension count */ + SAFEARRAYBOUND[1] rgbounds; /* var len array of bounds */ +} + +// parameter description +struct PARAMDESCEX { + ULONG cBytes; /* size of this structure */ + VARIANTARG varDefaultValue; /* default value of this parameter */ +} +alias PARAMDESCEX * LPPARAMDESCEX; + +struct PARAMDESC { + LPPARAMDESCEX pparamdescex; /* valid if PARAMFLAG_FHASDEFAULT bit is set */ + USHORT wParamFlags; /* IN, OUT, etc */ +} +alias PARAMDESC * LPPARAMDESC; + +const USHORT PARAMFLAG_NONE = 0x00; +const USHORT PARAMFLAG_FIN = 0x01; +const USHORT PARAMFLAG_FOUT = 0x02; +const USHORT PARAMFLAG_FLCID = 0x04; +const USHORT PARAMFLAG_FRETVAL = 0x08; +const USHORT PARAMFLAG_FOPT = 0x10; +const USHORT PARAMFLAG_FHASDEFAULT = 0x20; +const USHORT PARAMFLAG_FHASCUSTDATA = 0x40; + +struct IDLDESC { + ULONG dwReserved; + USHORT wIDLFlags; /* IN, OUT, etc */ +} +alias IDLDESC * LPIDLDESC; + +const USHORT IDLFLAG_NONE = PARAMFLAG_NONE; +const USHORT IDLFLAG_FIN = PARAMFLAG_FIN; +const USHORT IDLFLAG_FOUT = PARAMFLAG_FOUT; +const USHORT IDLFLAG_FLCID = PARAMFLAG_FLCID; +const USHORT IDLFLAG_FRETVAL = PARAMFLAG_FRETVAL; + + +struct ELEMDESC { /* a format that MIDL likes */ + TYPEDESC tdesc; /* the type of the element */ + PARAMDESC paramdesc; /* IDLDESC is a subset of PARAMDESC */ +} + +struct TYPEATTR { + GUID guid; /* the GUID of the TypeInfo */ + LCID lcid; /* locale of member names and doc strings */ + DWORD dwReserved; + MEMBERID memidConstructor; /* ID of constructor, MEMBERID_NIL if none */ + MEMBERID memidDestructor; /* ID of destructor, MEMBERID_NIL if none */ + LPOLESTR lpstrSchema; + ULONG cbSizeInstance; /* the size of an instance of this type */ + TYPEKIND typekind; /* the kind of type this typeinfo describes */ + WORD cFuncs; /* number of functions */ + WORD cVars; /* number of variables / data members */ + WORD cImplTypes; /* number of implemented interfaces */ + WORD cbSizeVft; /* the size of this types virtual func table */ + WORD cbAlignment; /* specifies the alignment requirements for + an instance of this type, + 0 = align on 64k boundary + 1 = byte align + 2 = word align + 4 = dword align... */ + WORD wTypeFlags; + WORD wMajorVerNum; /* major version number */ + WORD wMinorVerNum; /* minor version number */ + TYPEDESC tdescAlias; /* if typekind == TKIND_ALIAS this field + specifies the type for which this type + is an alias */ + IDLDESC idldescType; /* IDL attributes of the described type */ +} +alias TYPEATTR * LPTYPEATTR; + + +struct DISPPARAMS { + VARIANTARG * rgvarg; + DISPID * rgdispidNamedArgs; + UINT cArgs; + UINT cNamedArgs; +} + +struct EXCEPINFO { + WORD wCode; /* An error code describing the error. */ + WORD wReserved; + BSTR bstrSource; /* A source of the exception */ + BSTR bstrDescription; /* A description of the error */ + BSTR bstrHelpFile; /* Fully qualified drive, path, and file name */ + DWORD dwHelpContext; /* help context of topic within the help file */ + ULONG pvReserved; + ULONG pfnDeferredFillIn; + SCODE scode; +} +/+ + +cpp_quote("#else /* 0 */") +cpp_quote("typedef struct tagEXCEPINFO {") +cpp_quote(" WORD wCode;") +cpp_quote(" WORD wReserved;") +cpp_quote(" BSTR bstrSource;") +cpp_quote(" BSTR bstrDescription;") +cpp_quote(" BSTR bstrHelpFile;") +cpp_quote(" DWORD dwHelpContext;") +cpp_quote(" PVOID pvReserved;") +cpp_quote(" HRESULT (__stdcall *pfnDeferredFillIn)(struct tagEXCEPINFO *);") +cpp_quote(" SCODE scode;") +cpp_quote("} EXCEPINFO, * LPEXCEPINFO;") +cpp_quote("#endif /* 0 */") ++/ + +enum CALLCONV { + CC_FASTCALL = 0, + CC_CDECL = 1, + CC_MSCPASCAL, + CC_PASCAL = CC_MSCPASCAL, + CC_MACPASCAL, + CC_STDCALL, + CC_FPFASTCALL, + CC_SYSCALL, + CC_MPWCDECL, + CC_MPWPASCAL, + CC_MAX /* end of enum marker */ +} +enum FUNCKIND { + FUNC_VIRTUAL, + FUNC_PUREVIRTUAL, + FUNC_NONVIRTUAL, + FUNC_STATIC, + FUNC_DISPATCH +} + +enum INVOKEKIND { + INVOKE_FUNC = 1, + INVOKE_PROPERTYGET = 2, + INVOKE_PROPERTYPUT = 4, + INVOKE_PROPERTYPUTREF = 8 +} + +struct FUNCDESC { + MEMBERID memid; + SCODE * lprgscode; + ELEMDESC * lprgelemdescParam; /* array of param types */ + FUNCKIND funckind; + INVOKEKIND invkind; + CALLCONV callconv; + SHORT cParams; + SHORT cParamsOpt; + SHORT oVft; + SHORT cScodes; + ELEMDESC elemdescFunc; + WORD wFuncFlags; +} +alias FUNCDESC * LPFUNCDESC; + +enum VARKIND { + VAR_PERINSTANCE, + VAR_STATIC, + VAR_CONST, + VAR_DISPATCH +} +/* IMPLTYPE Flags */ +const USHORT IMPLTYPEFLAG_FDEFAULT = 0x1; +const USHORT IMPLTYPEFLAG_FSOURCE = 0x2; +const USHORT IMPLTYPEFLAG_FRESTRICTED = 0x4; +const USHORT IMPLTYPEFLAG_FDEFAULTVTABLE= 0x8; + +union VD_u { + /* offset of variable within the instance */ + ULONG oInst; + VARIANT * lpvarValue; /* the value of the constant */ +} +struct VARDESC { + MEMBERID memid; + LPOLESTR lpstrSchema; + VD_u u; + ELEMDESC elemdescVar; + WORD wVarFlags; + VARKIND varkind; +} +alias VARDESC * LPVARDESC; + +enum TYPEFLAGS { + TYPEFLAG_FAPPOBJECT = 0x01, + TYPEFLAG_FCANCREATE = 0x02, + TYPEFLAG_FLICENSED = 0x04, + TYPEFLAG_FPREDECLID = 0x08, + TYPEFLAG_FHIDDEN = 0x10, + TYPEFLAG_FCONTROL = 0x20, + TYPEFLAG_FDUAL = 0x40, + TYPEFLAG_FNONEXTENSIBLE = 0x80, + TYPEFLAG_FOLEAUTOMATION = 0x100, + TYPEFLAG_FRESTRICTED = 0x200, + TYPEFLAG_FAGGREGATABLE = 0x400, + TYPEFLAG_FREPLACEABLE = 0x800, + TYPEFLAG_FDISPATCHABLE = 0x1000, + TYPEFLAG_FREVERSEBIND = 0x2000 +} + +enum FUNCFLAGS { + FUNCFLAG_FRESTRICTED = 0x1, + FUNCFLAG_FSOURCE = 0x2, + FUNCFLAG_FBINDABLE = 0x4, + FUNCFLAG_FREQUESTEDIT = 0x8, + FUNCFLAG_FDISPLAYBIND = 0x10, + FUNCFLAG_FDEFAULTBIND = 0x20, + FUNCFLAG_FHIDDEN = 0x40, + FUNCFLAG_FUSESGETLASTERROR = 0x80, + FUNCFLAG_FDEFAULTCOLLELEM = 0x100, + FUNCFLAG_FUIDEFAULT = 0x200, + FUNCFLAG_FNONBROWSABLE = 0x400, + FUNCFLAG_FREPLACEABLE = 0x800, + FUNCFLAG_FIMMEDIATEBIND = 0x1000 +} + +enum VARFLAGS { + VARFLAG_FREADONLY = 0x1, + VARFLAG_FSOURCE = 0x2, + VARFLAG_FBINDABLE = 0x4, + VARFLAG_FREQUESTEDIT = 0x8, + VARFLAG_FDISPLAYBIND = 0x10, + VARFLAG_FDEFAULTBIND = 0x20, + VARFLAG_FHIDDEN = 0x40, + VARFLAG_FRESTRICTED = 0x80, + VARFLAG_FDEFAULTCOLLELEM = 0x100, + VARFLAG_FUIDEFAULT = 0x200, + VARFLAG_FNONBROWSABLE = 0x400, + VARFLAG_FREPLACEABLE = 0x800, + VARFLAG_FIMMEDIATEBIND = 0x1000 +} + +struct CLEANLOCALSTORAGE { + IUnknown pInterface; /* interface that is responsible for storage */ + PVOID pStorage; /* the storage being managed by interface */ + DWORD flags; /* which interface, what storage */ +} + +struct CUSTDATAITEM { + GUID guid; /* guid identifying this custom data item */ + VARIANTARG varValue; /* value of this custom data item */ +} +alias CUSTDATAITEM * LPCUSTDATAITEM; + +struct CUSTDATA { + DWORD cCustData; /* number of custom data items in rgCustData */ + LPCUSTDATAITEM prgCustData; + /* array of custom data items */ +} +alias CUSTDATA * LPCUSTDATA; + + +interface ICreateTypeInfo: IUnknown +{ + HRESULT SetGuid( REFGUID guid ); + HRESULT SetTypeFlags( UINT uTypeFlags ); + HRESULT SetDocString( LPOLESTR pStrDoc ); + HRESULT SetHelpContext( DWORD dwHelpContext); + HRESULT SetVersion( WORD wMajorVerNum, WORD wMinorVerNum ); + HRESULT AddRefTypeInfo( ITypeInfo pTInfo, HREFTYPE * phRefType ); + HRESULT AddFuncDesc( UINT index, FUNCDESC * pFuncDesc ); + HRESULT AddImplType( UINT index, HREFTYPE hRefType ); + HRESULT SetImplTypeFlags( UINT index, INT implTypeFlags ); + HRESULT SetAlignment( WORD cbAlignment ); + HRESULT SetSchema( LPOLESTR pStrSchema ); + HRESULT AddVarDesc( UINT index, VARDESC * pVarDesc ); + HRESULT SetFuncAndParamNames( UINT index, LPOLESTR * rgszNames, UINT cNames ); + HRESULT SetVarName( UINT index, LPOLESTR szName ); + HRESULT SetTypeDescAlias( TYPEDESC * pTDescAlias ); + HRESULT DefineFuncAsDllEntry( UINT index,LPOLESTR szDllName,LPOLESTR szProcName ); + HRESULT SetFuncDocString( UINT index, LPOLESTR szDocString ); + HRESULT SetVarDocString(UINT index,LPOLESTR szDocString ); + HRESULT SetFuncHelpContext(UINT index,DWORD dwHelpContext ); + HRESULT SetVarHelpContext(UINT index,DWORD dwHelpContext ); + HRESULT SetMops(UINT index,BSTR bstrMops ); + HRESULT SetTypeIdldesc(IDLDESC * pIdlDesc ); + HRESULT LayOut(); +} +alias ICreateTypeInfo LPCREATETYPEINFO; + +interface ICreateTypeInfo2: ICreateTypeInfo +{ + HRESULT DeleteFuncDesc(UINT index); + HRESULT DeleteFuncDescByMemId(MEMBERID memid,INVOKEKIND invKind); + HRESULT DeleteVarDesc(UINT index); + HRESULT DeleteVarDescByMemId(MEMBERID memid); + HRESULT DeleteImplType(UINT index); + HRESULT SetCustData(REFGUID guid,VARIANT * pVarVal); + HRESULT SetFuncCustData(UINT index,REFGUID guid,VARIANT * pVarVal); + HRESULT SetParamCustData(UINT indexFunc,UINT indexParam,REFGUID guid,VARIANT * pVarVal); + HRESULT SetVarCustData(UINT index,REFGUID guid,VARIANT * pVarVal); + HRESULT SetImplTypeCustData(UINT index,REFGUID guid,VARIANT * pVarVal); + HRESULT SetHelpStringContext(ULONG dwHelpStringContext); + HRESULT SetFuncHelpStringContext(UINT index,ULONG dwHelpStringContext); + HRESULT SetVarHelpStringContext(UINT index,ULONG dwHelpStringContext); + HRESULT Invalidate(); + HRESULT SetName(LPOLESTR szName); +} +alias ICreateTypeInfo2 LPCREATETYPEINFO2; + +interface ICreateTypeLib : IUnknown +{ + HRESULT CreateTypeInfo(LPOLESTR szName,TYPEKIND tkind,ICreateTypeInfo * ppCTInfo); + HRESULT SetName(LPOLESTR szName); + HRESULT SetVersion(WORD wMajorVerNum,WORD wMinorVerNum); + HRESULT SetGuid(REFGUID guid); + HRESULT SetDocString( LPOLESTR szDoc); + HRESULT SetHelpFileName(LPOLESTR szHelpFileName); + HRESULT SetHelpContext(DWORD dwHelpContext); + HRESULT SetLcid(LCID lcid); + HRESULT SetLibFlags(UINT uLibFlags); + HRESULT SaveAllChanges(); +} +alias ICreateTypeLib LPCREATETYPELIB; + +interface ICreateTypeLib2 : ICreateTypeLib +{ + HRESULT DeleteTypeInfo(LPOLESTR szName); + HRESULT SetCustData(REFGUID guid,VARIANT * pVarVal); + HRESULT SetHelpStringContext(ULONG dwHelpStringContext); + HRESULT SetHelpStringDll(LPOLESTR szFileName); +} + +interface IDispatch : IUnknown +{ +HRESULT GetTypeInfoCount(UINT * pctinfo); +HRESULT GetTypeInfo(UINT iTInfo, LCID lcid, ITypeInfo * ppTInfo); +HRESULT GetIDsOfNames(REFIID riid, LPOLESTR * rgszNames, UINT cNames, LCID lcid, DISPID * rgDispId); +HRESULT Invoke(DISPID dispIdMember,REFIID riid,LCID lcid,WORD wFlags,DISPPARAMS* pDispParams,VARIANT* pVarResult,EXCEPINFO* pExcepInfo,UINT* puArgErr); +} +alias IDispatch LPDISPATCH; +const DISPID DISPID_UNKNOWN = cast(DISPID)-1; +const DISPID DISPID_VALUE = cast(DISPID)0; +const DISPID DISPID_PROPERTYPUT = cast(DISPID)-3; +const DISPID DISPID_NEWENUM = cast(DISPID)-4; +const DISPID DISPID_EVALUATE = cast(DISPID)-5; +const DISPID DISPID_CONSTRUCTOR = cast(DISPID)-6; +const DISPID DISPID_DESTRUCTOR = cast(DISPID)-7; +const DISPID DISPID_COLLECT = cast(DISPID)-8; + +/+++++++++++++++++++++++++++++++++++++++ + +[ + object, + uuid(00020404-0000-0000-C000-000000000046), + pointer_default(unique) +] + +interface IEnumVARIANT : IUnknown +{ + typedef [unique] IEnumVARIANT* LPENUMVARIANT; + + [local] + HRESULT Next( + [in] ULONG celt, + [out, size_is(celt), length_is(*pCeltFetched)] VARIANT * rgVar, + [out] ULONG * pCeltFetched + ); + + [call_as(Next)] + HRESULT RemoteNext( + [in] ULONG celt, + [out, size_is(celt), length_is(*pCeltFetched)] VARIANT * rgVar, + [out] ULONG * pCeltFetched + ); + + HRESULT Skip( + [in] ULONG celt + ); + + HRESULT Reset( + ); + + HRESULT Clone( + [out] IEnumVARIANT ** ppEnum + ); +} + + ++/ +enum DESCKIND { + DESCKIND_NONE = 0, + DESCKIND_FUNCDESC, + DESCKIND_VARDESC, + DESCKIND_TYPECOMP, + DESCKIND_IMPLICITAPPOBJ, + DESCKIND_MAX +} + + +union BINDPTR { + FUNCDESC * lpfuncdesc; + VARDESC * lpvardesc; + ITypeComp lptcomp; +} +alias BINDPTR * LPBINDPTR; + +interface ITypeComp : IUnknown +{ + + HRESULT Bind(LPOLESTR szName,ULONG lHashVal,WORD wFlags, +ITypeInfo * ppTInfo,DESCKIND * pDescKind,BINDPTR * pBindPtr + ); + + + HRESULT BindType( LPOLESTR szName,ULONG lHashVal, + ITypeInfo * ppTInfo, + ITypeComp * ppTComp + ); + +} + +interface ITypeInfo : IUnknown +{ + HRESULT GetTypeAttr(TYPEATTR ** ppTypeAttr); + HRESULT GetTypeComp( ITypeComp * ppTComp ); + HRESULT GetFuncDesc( UINT index, FUNCDESC ** ppFuncDesc ); + HRESULT GetVarDesc( UINT index,VARDESC ** ppVarDesc); + HRESULT GetNames(MEMBERID memid,BSTR * rgBstrNames,UINT cMaxNames,UINT * pcNames); + HRESULT GetRefTypeOfImplType(UINT index,HREFTYPE * pRefType); + HRESULT GetImplTypeFlags(UINT index,INT * pImplTypeFlags); + HRESULT GetIDsOfNames(LPOLESTR * rgszNames,UINT cNames,MEMBERID * pMemId); + HRESULT Invoke(PVOID pvInstance,MEMBERID memid,WORD wFlags,DISPPARAMS * pDispParams,VARIANT * pVarResult,EXCEPINFO * pExcepInfo,UINT * puArgErr); + HRESULT GetDocumentation(MEMBERID memid,BSTR * pBstrName,BSTR * pBstrDocString,DWORD * pdwHelpContext,BSTR * pBstrHelpFile); + HRESULT GetDllEntry(MEMBERID memid,INVOKEKIND invKind,BSTR * pBstrDllName,BSTR * pBstrName,WORD * pwOrdinal); + HRESULT GetRefTypeInfo(HREFTYPE hRefType,ITypeInfo * ppTInfo); + HRESULT AddressOfMember(MEMBERID memid,INVOKEKIND invKind,PVOID * ppv); + HRESULT CreateInstance(IUnknown pUnkOuter,REFIID riid,PVOID * ppvObj); + HRESULT GetMops(MEMBERID memid,BSTR * pBstrMops); + HRESULT GetContainingTypeLib( ITypeLib ** ppTLib,UINT * pIndex); + void ReleaseTypeAttr(TYPEATTR * pTypeAttr ); + void ReleaseFuncDesc( FUNCDESC * pFuncDesc ); + void ReleaseVarDesc(VARDESC * pVarDesc ); +} +alias ITypeInfo LPTYPEINFO; + +interface ITypeInfo2 : ITypeInfo +{ + HRESULT GetTypeKind(TYPEKIND * pTypeKind); + HRESULT GetTypeFlags(ULONG * pTypeFlags); + HRESULT GetFuncIndexOfMemId(MEMBERID memid,INVOKEKIND invKind,UINT * pFuncIndex); + HRESULT GetVarIndexOfMemId(MEMBERID memid,UINT * pVarIndex); + HRESULT GetCustData(REFGUID guid,VARIANT * pVarVal); + HRESULT GetFuncCustData(UINT index,REFGUID guid,VARIANT * pVarVal); + HRESULT GetParamCustData(UINT indexFunc,UINT indexParam,REFGUID guid,VARIANT * pVarVal); + HRESULT GetVarCustData(UINT index,REFGUID guid,VARIANT * pVarVal); + HRESULT GetImplTypeCustData(UINT index,REFGUID guid,VARIANT * pVarVal); + HRESULT GetDocumentation2(MEMBERID memid,LCID lcid,BSTR *pbstrHelpString,DWORD *pdwHelpStringContext,BSTR *pbstrHelpStringDll); + HRESULT GetAllCustData(CUSTDATA * pCustData); + HRESULT GetAllFuncCustData(UINT index,CUSTDATA * pCustData); + HRESULT GetAllParamCustData(UINT indexFunc,UINT indexParam,CUSTDATA * pCustData); + HRESULT GetAllVarCustData(UINT index,CUSTDATA * pCustData); + HRESULT GetAllImplTypeCustData(UINT index,CUSTDATA * pCustData); +} + +alias ITypeInfo2 LPTYPEINFO2; + +enum SYSKIND { + SYS_WIN16 = 0, + SYS_WIN32, + SYS_MAC +} + +enum LIBFLAGS { + LIBFLAG_FRESTRICTED = 0x01, + LIBFLAG_FCONTROL = 0x02, + LIBFLAG_FHIDDEN = 0x04, + LIBFLAG_FHASDISKIMAGE = 0x08 +} + +struct TLIBATTR { + GUID guid; + LCID lcid; + SYSKIND syskind; + WORD wMajorVerNum; + WORD wMinorVerNum; + WORD wLibFlags; +} +alias TLIBATTR * LPTLIBATTR; + +interface ITypeLib : IUnknown +{ + UINT GetTypeInfoCount( + ); + + HRESULT GetTypeInfo( + UINT index, +ITypeInfo * ppTInfo + ); + +HRESULT GetTypeInfoType( + UINT index, + TYPEKIND * pTKind + ); + + HRESULT GetTypeInfoOfGuid( + REFGUID guid, + ITypeInfo * ppTinfo + ); + + HRESULT GetLibAttr( + TLIBATTR ** ppTLibAttr +); + + HRESULT GetTypeComp(ITypeComp * ppTComp ); + + HRESULT GetDocumentation(INT index,BSTR * pBstrName,BSTR * pBstrDocString,DWORD * pdwHelpContext,BSTR * pBstrHelpFile + ); + + HRESULT IsName(LPOLESTR szNameBuf,ULONG lHashVal,BOOL * pfName + ); + + HRESULT FindName( + LPOLESTR szNameBuf, + ULONG lHashVal, + ITypeInfo * ppTInfo, + MEMBERID * rgMemId, + USHORT * pcFound + ); + + void ReleaseTLibAttr( TLIBATTR * pTLibAttr ); +} + +alias ITypeLib LPTYPELIB; + +interface ITypeLib2 : ITypeLib +{ + HRESULT GetCustData(REFGUID guid,VARIANT * pVarVal); + HRESULT GetLibStatistics(ULONG * pcUniqueNames,ULONG * pcchUniqueNames); + HRESULT GetDocumentation2(INT index,LCID lcid,BSTR *pbstrHelpString,DWORD *pdwHelpStringContext,BSTR *pbstrHelpStringDll); + HRESULT GetAllCustData(CUSTDATA * pCustData); +} +alias ITypeLib2 LPTYPELIB2; + +enum CHANGEKIND { + CHANGEKIND_ADDMEMBER, + CHANGEKIND_DELETEMEMBER, + CHANGEKIND_SETNAMES, + CHANGEKIND_SETDOCUMENTATION, + CHANGEKIND_GENERAL, + CHANGEKIND_INVALIDATE, + CHANGEKIND_CHANGEFAILED, + CHANGEKIND_MAX, + ADDMEMBER = CHANGEKIND_ADDMEMBER, + DELETEMEMBER = CHANGEKIND_DELETEMEMBER, + SETNAMES = CHANGEKIND_SETNAMES, + SETDOCUMENTATION = CHANGEKIND_SETDOCUMENTATION, + GENERAL = CHANGEKIND_GENERAL, + INVALIDATE = CHANGEKIND_INVALIDATE, + CHANGEFAILED = CHANGEKIND_CHANGEFAILED, + MAX = CHANGEKIND_MAX +} + +interface ITypeChangeEvents: IUnknown +{ + // notification messages used by the dynamic typeinfo protocol. + HRESULT RequestTypeChange(CHANGEKIND changeKind,ITypeInfo pTInfoBefore,LPOLESTR pStrName,INT * pfCancel); + HRESULT AfterTypeChange(CHANGEKIND changeKind,ITypeInfo pTInfoAfter,LPOLESTR pStrName); +} +alias ITypeChangeEvents LPTYPECHANGEEVENTS; + +interface IErrorInfo: IUnknown +{ + HRESULT GetGUID( GUID * pGUID ); + HRESULT GetSource(BSTR * pBstrSource); + HRESULT GetDescription(BSTR * pBstrDescription); + HRESULT GetHelpFile(BSTR * pBstrHelpFile); + HRESULT GetHelpContext(DWORD * pdwHelpContext); +} +alias IErrorInfo LPERRORINFO; + +interface ICreateErrorInfo: IUnknown +{ + HRESULT SetGUID(REFGUID rguid); + HRESULT SetSource(LPOLESTR szSource); + HRESULT SetDescription(LPOLESTR szDescription); + HRESULT SetHelpFile(LPOLESTR szHelpFile); + HRESULT SetHelpContext(DWORD dwHelpContext); +} +alias ICreateErrorInfo LPCREATEERRORINFO; + +interface ISupportErrorInfo: IUnknown +{ + HRESULT InterfaceSupportsErrorInfo(REFIID riid); +} +alias ISupportErrorInfo LPSUPPORTERRORINFO; + +interface ITypeFactory : IUnknown +{ + HRESULT CreateFromTypeInfo(ITypeInfo pTypeInfo,REFIID riid, IUnknown *ppv); +} + +interface ITypeMarshal : IUnknown +{ + HRESULT Size(PVOID pvType,DWORD dwDestContext,PVOID pvDestContext,ULONG * pSize); + HRESULT Marshal(PVOID pvType,DWORD dwDestContext,PVOID pvDestContext,ULONG cbBufferLength,BYTE * pBuffer,ULONG * pcbWritten); + HRESULT Unmarshal(PVOID pvType,DWORD dwFlags,ULONG cbBufferLength,BYTE * pBuffer,ULONG * pcbRead); + HRESULT Free(PVOID pvType); +} + + +interface IRecordInfo: IUnknown +{ + HRESULT RecordInit(PVOID pvNew); + HRESULT RecordClear(PVOID pvExisting); + HRESULT RecordCopy(PVOID pvExisting,PVOID pvNew); + HRESULT GetGuid(GUID * pguid); + HRESULT GetName(BSTR * pbstrName); + HRESULT GetSize(ULONG * pcbSize); + HRESULT GetTypeInfo(ITypeInfo * ppTypeInfo); + HRESULT GetField(PVOID pvData,LPCOLESTR szFieldName,VARIANT * pvarField); + HRESULT GetFieldNoCopy(PVOID pvData,LPCOLESTR szFieldName,VARIANT * pvarField,PVOID * ppvDataCArray); + HRESULT PutField(ULONG wFlags,PVOID pvData,LPCOLESTR szFieldName,VARIANT * pvarField); + HRESULT PutFieldNoCopy(ULONG wFlags,PVOID pvData,LPCOLESTR szFieldName,VARIANT * pvarField); + HRESULT GetFieldNames(ULONG * pcNames,BSTR * rgBstrNames); + BOOL IsMatchingType(IRecordInfo pRecordInfo); + PVOID RecordCreate(); + HRESULT RecordCreateCopy(PVOID pvSource,PVOID * ppvDest); + HRESULT RecordDestroy(PVOID pvRecord); +} +alias IRecordInfo LPRECORDINFO; + +} // extern(WIndows); + +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/ole/win32/OBJIDL.d Fri Feb 08 19:49:32 2008 +0100 @@ -0,0 +1,2744 @@ +module dwt.internal.ole.win32.OBJIDL; +//+------------------------------------------------------------------------- +// +// Microsoft Windows +// Copyright (C) Microsoft Corporation, 1992-1997. +// +// File: objidl.idl +// +//-------------------------------------------------------------------------- + + +private import dwt.internal.ole.win32.extras; +private import dwt.internal.win32.WINTYPES; +// private import std.c.windows.windows; +// private import std.c.windows.com; +// private import dwt.internal.win32.os; + + +/* *NEED* to port wtypes.h */ + +extern( Windows ) { + + + + +//#ifndef DO_NO_IMPORTS +//import "unknwn.idl"; +//import "wtypes.idl"; +//#endif + +enum SRVINFO +{ + SRVINFO_F_COSERVERINFO = 0, + SRVINFO_F_COSERVERINFO2 = 1 +} + +struct COSERVERINFO +{ + DWORD dwReserved1; + LPWSTR pwszName; + COAUTHINFO * pAuthInfo; + DWORD dwReserved2; +} + +struct COSERVERINFO2 { + DWORD dwFlags; + LPWSTR pwszName; + COAUTHINFO* pAuthInfo; + IUnknown* ppCall; + LPWSTR pwszCodeURL; + DWORD dwFileVersionMS; + DWORD dwFileVersionLS; + LPWSTR pwszContentType; +} + + +/**************************************************************************** + * Component Object Interfaces + ****************************************************************************/ + +interface IMarshal : IUnknown +{ + HRESULT GetUnmarshalClass( REFIID riid, void *pv, DWORD dwDestContext, void *pvDestContext, DWORD mshlflags, CLSID *pCid ); + HRESULT GetMarshalSizeMax( REFIID riid, void *pv, DWORD dwDestContext, void *pvDestContext, DWORD mshlflags, DWORD *pSize ); + HRESULT MarshalInterface( IStream pStm, REFIID riid, void *pv, DWORD dwDestContext, void *pvDestContext, DWORD mshlflags ); + HRESULT UnmarshalInterface( IStream pStm, REFIID riid, void **ppv ); + HRESULT ReleaseMarshalData( IStream pStm ); + HRESULT DisconnectObject( DWORD dwReserved ); +} +alias IMarshal LPMARSHAL; + +interface IMalloc : IUnknown +{ + void * Alloc( ULONG cb ); + void * Realloc( void * pv, ULONG cb ); + void Free( void * pv ); + ULONG GetSize( void * pv ); + int DidAlloc( void * pv ); + void HeapMinimize(); +} +alias IMalloc LPMALLOC; + +interface IMallocSpy : IUnknown +{ + ULONG PreAlloc( ULONG cbRequest ); + void * PostAlloc( void * pActual ); + void * PreFree( void *pRequest, BOOL fSpyed ); + void PostFree( BOOL fSpyed ); + ULONG PreRealloc( void *pRequest, ULONG cbRequest, void **ppNewRequest, BOOL fSpyed ); + void * PostRealloc( void *pActual, BOOL fSpyed ); + void * PreGetSize( void *pRequest, BOOL fSpyed ); + ULONG PostGetSize( ULONG cbActual, BOOL fSpyed ); + void * PreDidAlloc( void * pRequest, BOOL fSpyed ); + int PostDidAlloc( void *pRequest, BOOL fSpyed, int fActual ); + void PreHeapMinimize(); + void PostHeapMinimize(); +} +alias IMallocSpy LPMALLOCSPY; + +interface IStdMarshalInfo : IUnknown +{ + HRESULT GetClassForHandler( DWORD dwDestContext, void *pvDestContext, CLSID *pClsid ); +} +alias IStdMarshalInfo LPSTDMARSHALINFO; + + // bit flags for IExternalConnection +enum EXTCONN +{ + EXTCONN_STRONG = 0x0001, // strong connection + EXTCONN_WEAK = 0x0002, // weak connection (table, container) + EXTCONN_CALLABLE = 0x0004, // table .vs. callable +} + +interface IExternalConnection : IUnknown +{ + // *** IExternalConnection methods *** + DWORD AddConnection( DWORD extconn, DWORD reserved ); + DWORD ReleaseConnection( DWORD extconn, DWORD reserved, BOOL fLastReleaseCloses ); +} +alias IExternalConnection LPEXTERNALCONNECTION; + + +struct MULTI_QI +{ + const IID *pIID; // pass this one in + IUnknown pItf; // get these out (you must set to NULL before calling) + HRESULT hr; +} + +interface IMultiQI : IUnknown +{ + HRESULT QueryMultipleInterfaces( ULONG cMQIs, MULTI_QI *pMQIs ); +} +alias IMultiQI LPMULTIQI; + +interface IEnumUnknown : IUnknown +{ + HRESULT Next( ULONG celt, IUnknown * rgelt, ULONG *pceltFetched); + HRESULT Skip( ULONG celt ); + HRESULT Reset(); + HRESULT Clone( IEnumUnknown * ppenum ); +} +alias IEnumUnknown LPENUMUNKNOWN; + + + +/**************************************************************************** + * Binding Interfaces + ****************************************************************************/ + +struct BIND_OPTS { + DWORD cbStruct; // sizeof(BIND_OPTS) + DWORD grfFlags; + DWORD grfMode; + DWORD dwTickCountDeadline; +} +alias BIND_OPTS * LPBIND_OPTS; + +struct BIND_OPTS2 { + DWORD cbStruct; // sizeof(BIND_OPTS2) + DWORD grfFlags; + DWORD grfMode; + DWORD dwTickCountDeadline; + DWORD dwTrackFlags; + DWORD dwClassContext; + LCID locale; + COSERVERINFO * pServerInfo; +} +alias BIND_OPTS2 * LPBIND_OPTS2; + +enum BIND_FLAGS +{ + BIND_MAYBOTHERUSER = 1, + BIND_JUSTTESTEXISTENCE = 2 +} + +interface IBindCtx : IUnknown +{ + HRESULT RegisterObjectBound( IUnknown punk ); + HRESULT RevokeObjectBound( IUnknown punk ); + HRESULT ReleaseBoundObjects(); + HRESULT SetBindOptions( BIND_OPTS * pbindopts ); + HRESULT GetBindOptions( BIND_OPTS * pbindopts ); + HRESULT GetRunningObjectTable( IRunningObjectTable * pprot ); + HRESULT RegisterObjectParam( LPOLESTR pszKey, IUnknown punk ); + HRESULT GetObjectParam( LPOLESTR pszKey, IUnknown * ppunk ); + HRESULT EnumObjectParam( IEnumString * ppenum ); + HRESULT RevokeObjectParam( LPOLESTR pszKey ); +} +alias IBindCtx LPBC; +alias IBindCtx LPBINDCTX; + +interface IEnumMoniker : IUnknown +{ + HRESULT Next( ULONG celt, IMoniker * rgelt, ULONG *pceltFetched ); + HRESULT Skip( ULONG celt ); + HRESULT Reset(); + HRESULT Clone( IEnumMoniker * ppenum ); +} +alias IEnumMoniker LPENUMMONIKER; + +interface IRunnableObject : IUnknown +{ + HRESULT GetRunningClass( LPCLSID lpClsid ); + HRESULT Run( LPBINDCTX pbc ); + BOOL IsRunning(); + HRESULT LockRunning( BOOL fLock, BOOL fLastUnlockCloses ); + HRESULT SetContainedObject( BOOL fContained ); +} +alias IRunnableObject LPRUNNABLEOBJECT; + +interface IRunningObjectTable : IUnknown +{ + HRESULT Register( DWORD grfFlags, IUnknown punkObject, IMoniker pmkObjectName, DWORD *pdwRegister ); + HRESULT Revoke ( DWORD dwRegister ); + HRESULT IsRunning( IMoniker pmkObjectName ); + HRESULT GetObject( IMoniker pmkObjectName, IUnknown * ppunkObject ); + HRESULT NoteChangeTime( DWORD dwRegister, FILETIME *pfiletime ); + HRESULT GetTimeOfLastChange( IMoniker pmkObjectName, FILETIME *pfiletime ); + HRESULT EnumRunning( IEnumMoniker * ppenumMoniker ); +} +alias IRunningObjectTable LPRUNNINGOBJECTTABLE; + +interface IPersist : IUnknown +{ + HRESULT GetClassID( CLSID * pClassID ); +} +alias IPersist LPPERSIST; + +interface IPersistStream : IPersist +{ + HRESULT IsDirty( ); + HRESULT Load( IStream pStm ); + HRESULT Save( IStream pStm, BOOL fClearDirty ); + HRESULT GetSizeMax( ULARGE_INTEGER *pcbSize ); +} +alias IPersistStream LPPERSISTSTREAM; + + // system moniker types; returned from IsSystemMoniker. +enum MKSYS +{ + MKSYS_NONE = 0, + MKSYS_GENERICCOMPOSITE = 1, + MKSYS_FILEMONIKER = 2, + MKSYS_ANTIMONIKER = 3, + MKSYS_ITEMMONIKER = 4, + MKSYS_POINTERMONIKER = 5, + // MKSYS_URLMONIKER = 6, + MKSYS_CLASSMONIKER = 7 +} + +enum MKREDUCE +{ + MKRREDUCE_ONE = 3<<16, + MKRREDUCE_TOUSER = 2<<16, + MKRREDUCE_THROUGHUSER = 1<<16, + MKRREDUCE_ALL = 0 +} + +interface IMoniker : IPersistStream +{ + HRESULT BindToObject( IBindCtx pbc, IMoniker pmkToLeft, REFIID riidResult, void **ppvResult ); + HRESULT BindToStorage( IBindCtx pbc, IMoniker pmkToLeft, REFIID riid, void * ppvObj ); + HRESULT Reduce( IBindCtx pbc, DWORD dwReduceHowFar, IMoniker * ppmkToLeft, IMoniker * ppmkReduced ); + HRESULT ComposeWith( IMoniker pmkRight, BOOL fOnlyIfNotGeneric, IMoniker * ppmkComposite ); + HRESULT Enum( BOOL fForward, IEnumMoniker * ppenumMoniker ); + HRESULT IsEqual( IMoniker pmkOtherMoniker ); + HRESULT Hash( DWORD *pdwHash ); + HRESULT IsRunning( IBindCtx pbc, IMoniker pmkToLeft, IMoniker pmkNewlyRunning ); + HRESULT GetTimeOfLastChange( IBindCtx pbc, IMoniker pmkToLeft, FILETIME *pFileTime ); + HRESULT Inverse( IMoniker * ppmk ); + HRESULT CommonPrefixWith( IMoniker pmkOther, IMoniker * ppmkPrefix ); + HRESULT RelativePathTo( IMoniker pmkOther, IMoniker * ppmkRelPath ); + HRESULT GetDisplayName( IBindCtx pbc, IMoniker pmkToLeft, LPOLESTR *ppszDisplayName ); + HRESULT ParseDisplayName( IBindCtx pbc, IMoniker pmkToLeft, LPOLESTR pszDisplayName, ULONG *pchEaten, IMoniker * ppmkOut ); + HRESULT IsSystemMoniker( DWORD * pdwMksys ); +} +alias IMoniker LPMONIKER; + +interface IROTData : IUnknown +{ + HRESULT GetComparisonData( byte * pbData, ULONG cbMax, ULONG *pcbData ); +} + +interface IEnumString : IUnknown +{ + HRESULT Next( ULONG celt, LPOLESTR *rgelt, ULONG *pceltFetched ); + HRESULT Skip( ULONG celt ); + HRESULT Reset(); + HRESULT Clone( IEnumString * ppenum ); +} +alias IEnumString LPENUMSTRING; + + +/**************************************************************************** + * Structured Storage Interfaces + ****************************************************************************/ + +interface ISequentialStream : IUnknown +{ + HRESULT Read( void *pv, ULONG cb, ULONG *pcbRead ); + HRESULT Write( void *pv, ULONG cb, ULONG *pcbWritten ); +} + + /* Storage stat buffer */ +struct STATSTG +{ + LPOLESTR pwcsName; + DWORD type; + ULARGE_INTEGER cbSize; + FILETIME mtime; + FILETIME ctime; + FILETIME atime; + DWORD grfMode; + DWORD grfLocksSupported; + CLSID clsid; + DWORD grfStateBits; + DWORD reserved; +} + + /* Storage element types */ +enum STGTY +{ + STGTY_STORAGE = 1, + STGTY_STREAM = 2, + STGTY_LOCKBYTES = 3, + STGTY_PROPERTY = 4 +} + +enum STREAM_SEEK +{ + STREAM_SEEK_SET = 0, + STREAM_SEEK_CUR = 1, + STREAM_SEEK_END = 2 +} + +enum LOCKTYPE +{ + LOCK_WRITE = 1, + LOCK_EXCLUSIVE = 2, + LOCK_ONLYONCE = 4 +} + +interface IStream : ISequentialStream +{ + HRESULT Seek( LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition ); + HRESULT SetSize( ULARGE_INTEGER libNewSize ); + HRESULT CopyTo( IStream pstm, ULARGE_INTEGER cb, ULARGE_INTEGER *pcbRead, ULARGE_INTEGER *pcbWritten); + HRESULT Commit( DWORD grfCommitFlags ); + HRESULT Revert(); + HRESULT LockRegion( ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType ); + HRESULT UnlockRegion( ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType ); + HRESULT Stat( STATSTG *pstatstg, DWORD grfStatFlag); + HRESULT Clone( IStream * ppstm ); +} +alias IStream LPSTREAM; + +interface IEnumSTATSTG : IUnknown +{ + HRESULT Next( ULONG celt, STATSTG *rgelt, ULONG *pceltFetched ); + HRESULT Skip( ULONG celt ); + HRESULT Reset(); + HRESULT Clone( IEnumSTATSTG * ppenum ); +} +alias IEnumSTATSTG LPENUMSTATSTG; + +struct RemSNB +{ + ULONG ulCntStr; + ULONG ulCntChar; + OLECHAR rgString[]; +} +alias RemSNB * wireSNB; +alias OLECHAR ** SNB; + +interface IStorage : IUnknown +{ + HRESULT CreateStream( OLECHAR *pwcsName, DWORD grfMode, DWORD reserved1, DWORD reserved2, IStream * ppstm); + HRESULT OpenStream( OLECHAR *pwcsName, void *reserved1, DWORD grfMode, DWORD reserved2, IStream * ppstm); + HRESULT CreateStorage( OLECHAR *pwcsName, DWORD grfMode, DWORD reserved1, DWORD reserved2, IStorage * ppstg); + HRESULT OpenStorage( OLECHAR *pwcsName, IStorage pstgPriority, DWORD grfMode, SNB snbExclude, DWORD reserved, IStorage * ppstg ); + HRESULT CopyTo( DWORD ciidExclude, IID *rgiidExclude, SNB snbExclude, IStorage pstgDest ); + HRESULT MoveElementTo( OLECHAR * pwcsName, IStorage pstgDest, OLECHAR *pwcsNewName, DWORD grfFlags ); + HRESULT Commit( DWORD grfCommitFlags ); + HRESULT Revert(); + HRESULT EnumElements( DWORD reserved1, void *reserved2, DWORD reserved3, IEnumSTATSTG * ppenum); + HRESULT DestroyElement( OLECHAR * pwcsName ); + HRESULT RenameElement( OLECHAR *pwcsOldName, OLECHAR *pwcsNewName ); + HRESULT SetElementTimes( OLECHAR * pwcsName, FILETIME * pctime, FILETIME *patime, FILETIME *pmtime ); + HRESULT SetClass( REFCLSID clsid ); + HRESULT SetStateBits( DWORD grfStateBits, DWORD grfMask ); + HRESULT Stat( STATSTG *pstatstg, DWORD grfStatFlag ); +} +alias IStorage LPSTORAGE; + +interface IPersistFile : IPersist +{ + HRESULT IsDirty(); + HRESULT Load(LPCOLESTR pszFileName,DWORD dwMode); + HRESULT Save(LPCOLESTR pszFileName,BOOL fRemember); + HRESULT SaveCompleted(LPCOLESTR pszFileName); + HRESULT GetCurFile(LPOLESTR *ppszFileName ); +} +alias IPersistFile LPPERSISTFILE; + +interface IPersistStorage : IPersist +{ + HRESULT IsDirty(); + HRESULT InitNew(IStorage pStg); + HRESULT Load(IStorage pStg); + HRESULT Save(IStorage pStgSave,BOOL fSameAsLoad); + HRESULT SaveCompleted(IStorage pStgNew); + HRESULT HandsOffStorage(); +} +alias IPersistStorage LPPERSISTSTORAGE; + +interface ILockBytes : IUnknown +{ + HRESULT ReadAt( +ULARGE_INTEGER ulOffset, +void *pv, +ULONG cb, +ULONG *pcbRead); + + HRESULT WriteAt( +ULARGE_INTEGER ulOffset, +void *pv, +ULONG cb, +ULONG *pcbWritten); + +HRESULT Flush(); + +HRESULT SetSize( +ULARGE_INTEGER cb); + + HRESULT LockRegion( +ULARGE_INTEGER libOffset, +ULARGE_INTEGER cb, +DWORD dwLockType); + + HRESULT UnlockRegion( +ULARGE_INTEGER libOffset, +ULARGE_INTEGER cb, +DWORD dwLockType); + + HRESULT Stat( +STATSTG *pstatstg, +DWORD grfStatFlag); +} +alias ILockBytes LPLOCKBYTES; + +struct DVTARGETDEVICE { + DWORD tdSize; + WORD tdDriverNameOffset; + WORD tdDeviceNameOffset; + WORD tdPortNameOffset; + WORD tdExtDevmodeOffset; +BYTE[1] tdData; +} + +typedef CLIPFORMAT LPCLIPFORMAT; + +struct FORMATETC { + CLIPFORMAT cfFormat; +DVTARGETDEVICE * ptd; + DWORD dwAspect; + LONG lindex; + DWORD tymed; +} +alias FORMATETC *LPFORMATETC; + +interface IEnumFORMATETC : IUnknown +{ + HRESULT Next( +ULONG celt, + FORMATETC *rgelt, +ULONG *pceltFetched); + + HRESULT Skip( +ULONG celt); + + HRESULT Reset(); + + HRESULT Clone( +IEnumFORMATETC * ppenum); +} +alias IEnumFORMATETC LPENUMFORMATETC; + + //Advise Flags +enum ADVF +{ + ADVF_NODATA = 1, + ADVF_PRIMEFIRST = 2, + ADVF_ONLYONCE = 4, + ADVF_DATAONSTOP = 64, + ADVFCACHE_NOHANDLER = 8, + ADVFCACHE_FORCEBUILTIN = 16, + ADVFCACHE_ONSAVE = 32 +} + + // Stats for data; used by several enumerations and by at least one + // implementation of IDataAdviseHolder; if a field is not used, it + // will be NULL. + +struct STATDATA +{ // field used by: + FORMATETC formatetc; // EnumAdvise, EnumData (cache), EnumFormats + DWORD advf; // EnumAdvise, EnumData (cache) + IAdviseSink pAdvSink; // EnumAdvise + DWORD dwConnection; // EnumAdvise +} +alias STATDATA * LPSTATDATA; + +interface IEnumSTATDATA : IUnknown +{ + HRESULT Next( +ULONG celt, + STATDATA *rgelt, +ULONG *pceltFetched); + + + HRESULT Skip( +ULONG celt); + + HRESULT Reset(); + + HRESULT Clone( +IEnumSTATDATA * ppenum); +} +alias IEnumSTATDATA LPENUMSTATDATA; + +interface IRootStorage : IUnknown +{ + HRESULT SwitchToFile( LPOLESTR pszFile ); +} +alias IRootStorage LPROOTSTORAGE; + + +/**************************************************************************** + * Notification Interfaces + ****************************************************************************/ + +enum TYMED { + TYMED_HGLOBAL = 1, + TYMED_FILE = 2, + TYMED_ISTREAM = 4, + TYMED_ISTORAGE = 8, + TYMED_GDI = 16, + TYMED_MFPICT = 32, + TYMED_ENHMF = 64, + TYMED_NULL = 0 +} + +struct RemSTGMEDIUM { + DWORD tymed; + DWORD dwHandleType; + ULONG pData; + ULONG pUnkForRelease; + ULONG cbData; + byte[1] data; +} + +union UNION_u { + HBITMAP hBitmap; + HMETAFILEPICT hMetaFilePict; + HENHMETAFILE hEnhMetaFile; + HGLOBAL hGlobal; + LPOLESTR lpszFileName; + IStream pstm; + IStorage pstg; +} +/* +struct uSTGMEDIUM { + DWORD tymed; + UNION_u u; + IUnknown pUnkForRelease; +} +*/ +// <Shawn Liu> modified +struct uSTGMEDIUM { + DWORD tymed; + void* unionField; + IUnknown pUnkForRelease; +} + + +enum { + OBJ_PEN =1, + OBJ_BRUSH =2, + OBJ_DC =3, + OBJ_METADC =4, + OBJ_PAL =5, + OBJ_FONT =6, + OBJ_BITMAP =7, + OBJ_REGION =8, + OBJ_METAFILE =9, + OBJ_MEMDC =10, + OBJ_EXTPEN =11, + OBJ_ENHMETADC =12, + OBJ_ENHMETAFILE =13 +} +union __MIDL_IAdviseSink_0002 +{ + wireHBITMAP hBitmap; + wireHPALETTE hPalette; + wireHGLOBAL hGeneric; +} + +struct GDI_OBJECT +{ + DWORD ObjectType; + __MIDL_IAdviseSink_0002 u; +} + +union __MIDL_IAdviseSink_0003 +{ + wireHMETAFILEPICT hMetaFilePict; + wireHENHMETAFILE hHEnhMetaFile; + GDI_OBJECT *hGdiHandle; + wireHGLOBAL hGlobal; + LPOLESTR lpszFileName; + BYTE_BLOB *pstm; + BYTE_BLOB *pstg; +} + +struct userSTGMEDIUM +{ + DWORD tymed; + __MIDL_IAdviseSink_0003 u; + IUnknown pUnkForRelease; +} + +alias userSTGMEDIUM *wireSTGMEDIUM; +alias uSTGMEDIUM STGMEDIUM; +alias userSTGMEDIUM *wireASYNC_STGMEDIUM; +alias STGMEDIUM ASYNC_STGMEDIUM; +alias STGMEDIUM *LPSTGMEDIUM; + +struct userFLAG_STGMEDIUM +{ + LONG ContextFlags; + LONG fPassOwnership; + userSTGMEDIUM Stgmed; +} + +alias userFLAG_STGMEDIUM *wireFLAG_STGMEDIUM; + +struct FLAG_STGMEDIUM +{ + LONG ContextFlags; + LONG fPassOwnership; + STGMEDIUM Stgmed; +} + + +interface IAdviseSink : IUnknown +{ + void OnDataChange(FORMATETC *pFormatetc,STGMEDIUM *pStgmed); + void OnViewChange(DWORD dwAspect,LONG lindex); + void OnRename(IMoniker pmk); + void OnSave(); + void OnClose(); +} +alias IAdviseSink LPADVISESINK; + +interface IAdviseSink2 : IAdviseSink +{ + void OnLinkSrcChange( IMoniker pmk ); +} +alias IAdviseSink2 LPADVISESINK2; + + +enum DATADIR +{ + DATADIR_GET = 1, + DATADIR_SET = 2 +} + +interface IDataObject : IUnknown +{ + + HRESULT GetData( FORMATETC *pformatetcIn, STGMEDIUM *pmedium); + + HRESULT GetDataHere( FORMATETC *pformatetc, STGMEDIUM *pmedium); + + HRESULT QueryGetData( FORMATETC *pformatetc); + + HRESULT GetCanonicalFormatEtc( + FORMATETC *pformatectIn, + FORMATETC *pformatetcOut); + + HRESULT SetData( + FORMATETC *pformatetc, + STGMEDIUM *pmedium, + BOOL fRelease); + + HRESULT EnumFormatEtc( + DWORD dwDirection, + IEnumFORMATETC * ppenumFormatEtc); + + HRESULT DAdvise( + FORMATETC *pformatetc, + DWORD advf, + IAdviseSink pAdvSink, + DWORD *pdwConnection); + + HRESULT DUnadvise(DWORD dwConnection); + + HRESULT EnumDAdvise(IEnumSTATDATA * ppenumAdvise); + +} +alias IDataObject LPDATAOBJECT; + +interface IDataAdviseHolder : IUnknown +{ + HRESULT Advise + ( + IDataObject pDataObject, + FORMATETC *pFetc, + DWORD advf, + IAdviseSink pAdvise, + DWORD *pdwConnection + ); + + HRESULT Unadvise + ( + DWORD dwConnection + ); + + HRESULT EnumAdvise + ( +IEnumSTATDATA * ppenumAdvise + ); + + HRESULT SendOnDataChange + ( + IDataObject pDataObject, + DWORD dwReserved, + DWORD advf + ); + +} +alias IDataAdviseHolder LPDATAADVISEHOLDER; + + +// call type used by IMessageFilter::HandleIncomingMessage +enum CALLTYPE +{ + CALLTYPE_TOPLEVEL = 1, // toplevel call - no outgoing call + CALLTYPE_NESTED = 2, // callback on behalf of previous outgoing call - should always handle + CALLTYPE_ASYNC = 3, // aysnchronous call - can NOT be rejected + CALLTYPE_TOPLEVEL_CALLPENDING = 4, // new toplevel call with new LID + CALLTYPE_ASYNC_CALLPENDING = 5 // async call - can NOT be rejected +} + +// status of server call - returned by IMessageFilter::HandleIncomingCall +// and passed to IMessageFilter::RetryRejectedCall +enum SERVERCALL +{ + SERVERCALL_ISHANDLED = 0, + SERVERCALL_REJECTED = 1, + SERVERCALL_RETRYLATER = 2 +} + +// Pending type indicates the level of nesting +enum PENDINGTYPE +{ + PENDINGTYPE_TOPLEVEL = 1, // toplevel call + PENDINGTYPE_NESTED = 2 // nested call +} + +// return values of MessagePending +enum PENDINGMSG +{ + PENDINGMSG_CANCELCALL = 0, // cancel the outgoing call + PENDINGMSG_WAITNOPROCESS = 1, // wait for the return and don't dispatch the message + PENDINGMSG_WAITDEFPROCESS = 2 // wait and dispatch the message + +} + +// additional interface information about the incoming call +struct INTERFACEINFO +{ + IUnknown pUnk; // the pointer to the object + IID iid; // interface id + WORD wMethod; // interface method +} +alias INTERFACEINFO *LPINTERFACEINFO; + + +interface IMessageFilter : IUnknown +{ + + DWORD HandleInComingCall + ( +DWORD dwCallType, +HTASK htaskCaller, +DWORD dwTickCount, +LPINTERFACEINFO lpInterfaceInfo + ); + + DWORD RetryRejectedCall + ( +HTASK htaskCallee, +DWORD dwTickCount, +DWORD dwRejectType + ); + + DWORD MessagePending + ( +HTASK htaskCallee, +DWORD dwTickCount, +DWORD dwPendingType + ); +} +alias IMessageFilter LPMESSAGEFILTER; + + + +/**************************************************************************** + * Object Remoting Interfaces + ****************************************************************************/ +/* +interface IRpcChannelBuffer : IUnknown +{ + + typedef unsigned long RPCOLEDATAREP; + + typedef struct tagRPCOLEMESSAGE + { + void *reserved1; + RPCOLEDATAREP dataRepresentation; + void *Buffer; + ULONG cbBuffer; + ULONG iMethod; + void *reserved2[5]; + ULONG rpcFlags; + } RPCOLEMESSAGE; + + typedef RPCOLEMESSAGE *PRPCOLEMESSAGE; + + HRESULT GetBuffer + ( + [in] RPCOLEMESSAGE *pMessage, + [in] REFIID riid + ); + + HRESULT SendReceive + ( + [in,out] RPCOLEMESSAGE *pMessage, + [out] ULONG *pStatus + ); + + HRESULT FreeBuffer + ( + [in] RPCOLEMESSAGE *pMessage + ); + + HRESULT GetDestCtx + ( + [out] DWORD *pdwDestContext, + [out] void **ppvDestContext + ); + + HRESULT IsConnected + ( + void + ); + +} + +[ + local, + object, + uuid(594f31d0-7f19-11d0-b194-00a0c90dc8bf) +] +interface IRpcChannelBuffer2 : IRpcChannelBuffer +{ + + HRESULT GetProtocolVersion + ( + [in,out] DWORD *pdwVersion + ); +} + +[ + local, + object, + uuid(25B15600-0115-11d0-BF0D-00AA00B8DFD2) +] +interface IRpcChannelBuffer3 : IRpcChannelBuffer2 +{ + + HRESULT Send + ( + [in,out] RPCOLEMESSAGE *pMsg, + [out] ULONG *pulStatus + ); + + HRESULT Receive + ( + [in,out] RPCOLEMESSAGE *pMsg, + [in] ULONG ulSize, + [out] ULONG *pulStatus + ); + + HRESULT Cancel + ( + [in] RPCOLEMESSAGE *pMsg + ); + + HRESULT GetCallContext + ( + [in] RPCOLEMESSAGE *pMsg, + [in] REFIID riid, + [out] void **pInterface + ); + + HRESULT GetDestCtxEx + ( + [in] RPCOLEMESSAGE *pMsg, + [out] DWORD *pdwDestContext, + [out] void **ppvDestContext + ); + + HRESULT GetState + ( + [in] RPCOLEMESSAGE *pMsg, + [out] DWORD *pState + ); + + HRESULT RegisterAsync + ( + [in] RPCOLEMESSAGE *pMsg, + [in] IAsyncManager *pAsyncMgr + ); + +} + + +[ + local, + object, + uuid(D5F56A34-593B-101A-B569-08002B2DBF7A) +] +interface IRpcProxyBuffer : IUnknown +{ + + HRESULT Connect + ( + [in, unique] IRpcChannelBuffer *pRpcChannelBuffer + ); + + void Disconnect + ( + void + ); + +} + +[ + local, + object, + uuid(D5F56AFC-593B-101A-B569-08002B2DBF7A) +] +interface IRpcStubBuffer : IUnknown +{ + + HRESULT Connect + ( + [in] IUnknown *pUnkServer + ); + + void Disconnect(); + + HRESULT Invoke + ( + [in] RPCOLEMESSAGE *_prpcmsg, + [in] IRpcChannelBuffer *_pRpcChannelBuffer + ); + + IRpcStubBuffer *IsIIDSupported + ( + [in] REFIID riid + ); + + ULONG CountRefs + ( + void + ); + + HRESULT DebugServerQueryInterface + ( + void **ppv + ); + + void DebugServerRelease + ( + void *pv + ); + +} + + + +[ + local, + object, + uuid(D5F569D0-593B-101A-B569-08002B2DBF7A) +] +interface IPSFactoryBuffer : IUnknown +{ + + HRESULT CreateProxy + ( + [in] IUnknown *pUnkOuter, + [in] REFIID riid, + [out] IRpcProxyBuffer **ppProxy, + [out] void **ppv + ); + + HRESULT CreateStub + ( + [in] REFIID riid, + [in, unique] IUnknown *pUnkServer, + [out] IRpcStubBuffer **ppStub + ); +} + +cpp_quote( "#if (_WIN32_WINNT >= 0x0400 ) || defined(_WIN32_DCOM) // DCOM" ) +cpp_quote( "// This interface is only valid on Windows NT 4.0" ) + +// This structure contains additional data for hooks. As a backward +// compatability hack, the entire structure is passed in place of the +// RIID parameter on all hook methods. Thus the IID must be the first +// parameter. As a forward compatability hack the second field is the +// current size of the structure. +typedef struct SChannelHookCallInfo +{ + IID iid; + DWORD cbSize; + GUID uCausality; + DWORD dwServerPid; + DWORD iMethod; + void *pObject; +} SChannelHookCallInfo; + +[ + local, + object, + uuid(1008c4a0-7613-11cf-9af1-0020af6e72f4) +] +interface IChannelHook : IUnknown +{ + void ClientGetSize( + [in] REFGUID uExtent, + [in] REFIID riid, + [out] ULONG *pDataSize ); + + void ClientFillBuffer( + [in] REFGUID uExtent, + [in] REFIID riid, + [in, out] ULONG *pDataSize, + [in] void *pDataBuffer ); + + void ClientNotify( + [in] REFGUID uExtent, + [in] REFIID riid, + [in] ULONG cbDataSize, + [in] void *pDataBuffer, + [in] DWORD lDataRep, + [in] HRESULT hrFault ); + + void ServerNotify( + [in] REFGUID uExtent, + [in] REFIID riid, + [in] ULONG cbDataSize, + [in] void *pDataBuffer, + [in] DWORD lDataRep ); + + void ServerGetSize( + [in] REFGUID uExtent, + [in] REFIID riid, + [in] HRESULT hrFault, + [out] ULONG *pDataSize ); + + void ServerFillBuffer( + [in] REFGUID uExtent, + [in] REFIID riid, + [in, out] ULONG *pDataSize, + [in] void *pDataBuffer, + [in] HRESULT hrFault ); +}; + +cpp_quote( "#endif //DCOM" ) +*/ + +/**************************************************************************** + * Property Storage Interfaces + ****************************************************************************/ + + /* +interface IPropertyStorage; +interface IEnumSTATPROPSTG; +interface IEnumSTATPROPSETSTG; + +[ + object, + uuid(00000138-0000-0000-C000-000000000046), + pointer_default(unique) +] + +interface IPropertyStorage : IUnknown +{ + + cpp_quote("") + cpp_quote("// Well-known Property Set Format IDs") + extern const FMTID FMTID_SummaryInformation; + extern const FMTID FMTID_DocSummaryInformation; + extern const FMTID FMTID_UserDefinedProperties; + + cpp_quote("") + cpp_quote("// Flags for IPropertySetStorage::Create") + const DWORD PROPSETFLAG_DEFAULT = 0; + const DWORD PROPSETFLAG_NONSIMPLE = 1; + const DWORD PROPSETFLAG_ANSI = 2; + cpp_quote("// This flag is only supported on StgCreatePropStg & StgOpenPropStg") + const DWORD PROPSETFLAG_UNBUFFERED = 4; + + typedef [unique] IPropertyStorage * LPPROPERTYSTORAGE; + + typedef struct tagPROPVARIANT PROPVARIANT; + + #define TYPEDEF_CA(type, name) \ + typedef struct tag##name\ + {\ + ULONG cElems;\ + [size_is( cElems )]\ + type * pElems;\ + } name + + TYPEDEF_CA(unsigned char, CAUB); + TYPEDEF_CA(short, CAI); + TYPEDEF_CA(USHORT, CAUI); + TYPEDEF_CA(long, CAL); + TYPEDEF_CA(ULONG, CAUL); + TYPEDEF_CA(float, CAFLT); + TYPEDEF_CA(double, CADBL); + TYPEDEF_CA(CY, CACY); + TYPEDEF_CA(DATE, CADATE); + TYPEDEF_CA(BSTR, CABSTR); + TYPEDEF_CA(BSTRBLOB, CABSTRBLOB); + TYPEDEF_CA(VARIANT_BOOL, CABOOL); + TYPEDEF_CA(SCODE, CASCODE); + TYPEDEF_CA(PROPVARIANT, CAPROPVARIANT); + TYPEDEF_CA(LARGE_INTEGER, CAH); + TYPEDEF_CA(ULARGE_INTEGER, CAUH); + TYPEDEF_CA(LPSTR, CALPSTR); + TYPEDEF_CA(LPWSTR, CALPWSTR); + TYPEDEF_CA(FILETIME, CAFILETIME); + TYPEDEF_CA(CLIPDATA, CACLIPDATA); + TYPEDEF_CA(CLSID, CACLSID); + +cpp_quote("// Disable the warning about the obsolete member named 'bool'") +cpp_quote("// 'bool', 'true', 'false', 'mutable', 'explicit', & 'typename'") +cpp_quote("// are reserved keywords") +cpp_quote("#pragma warning(disable:4237)") + + struct tagPROPVARIANT + { + VARTYPE vt; + WORD wReserved1; + WORD wReserved2; + WORD wReserved3; + [switch_is((unsigned short) (vt & 0x1fff))] union + { + [case(VT_EMPTY, VT_NULL)] + ; + [case(VT_UI1)] + UCHAR bVal; + [case(VT_I2)] + short iVal; + [case(VT_UI2)] + USHORT uiVal; + [case(VT_BOOL)] + VARIANT_BOOL boolVal; + [case(VT_ILLEGAL)] // obsolete field name; use boolVal + _VARIANT_BOOL bool; + [case(VT_I4)] + long lVal; + [case(VT_UI4)] + ULONG ulVal; + [case(VT_R4)] + float fltVal; + [case(VT_ERROR)] + SCODE scode; + [case(VT_I8)] + LARGE_INTEGER hVal; + [case(VT_UI8)] + ULARGE_INTEGER uhVal; + [case(VT_R8)] + double dblVal; + [case(VT_CY)] + CY cyVal; + [case(VT_DATE)] + DATE date; + [case(VT_FILETIME)] + FILETIME filetime; + [case(VT_CLSID)] + CLSID * puuid; + [case(VT_BLOB, VT_BLOB_OBJECT)] + BLOB blob; + [case(VT_CF)] + CLIPDATA *pclipdata; + [case(VT_STREAM, VT_STREAMED_OBJECT)] + IStream * pStream; + [case(VT_STORAGE, VT_STORED_OBJECT)] + IStorage * pStorage; + [case(VT_BSTR)] + BSTR bstrVal; + [case(VT_BSTR_BLOB)] // System use only + BSTRBLOB bstrblobVal; + [case(VT_LPSTR)] + LPSTR pszVal; + [case(VT_LPWSTR)] + LPWSTR pwszVal; + [case(VT_UI1|VT_VECTOR)] + CAUB caub; + [case(VT_I2|VT_VECTOR)] + CAI cai; + [case(VT_UI2|VT_VECTOR)] + CAUI caui; + [case(VT_BOOL|VT_VECTOR)] + CABOOL cabool; + [case(VT_I4|VT_VECTOR)] + CAL cal; + [case(VT_UI4|VT_VECTOR)] + CAUL caul; + [case(VT_R4|VT_VECTOR)] + CAFLT caflt; + [case(VT_ERROR|VT_VECTOR)] + CASCODE cascode; + [case(VT_I8|VT_VECTOR)] + CAH cah; + [case(VT_UI8|VT_VECTOR)] + CAUH cauh; + [case(VT_R8|VT_VECTOR)] + CADBL cadbl; + [case(VT_CY|VT_VECTOR)] + CACY cacy; + [case(VT_DATE|VT_VECTOR)] + CADATE cadate; + [case(VT_FILETIME|VT_VECTOR)] + CAFILETIME cafiletime; + [case(VT_CLSID|VT_VECTOR)] + CACLSID cauuid; + [case(VT_CF|VT_VECTOR)] + CACLIPDATA caclipdata; + [case(VT_BSTR|VT_VECTOR)] + CABSTR cabstr; + [case(VT_BSTR_BLOB|VT_VECTOR)] // System use only + CABSTRBLOB cabstrblob; + [case(VT_LPSTR|VT_VECTOR)] + CALPSTR calpstr; + [case(VT_LPWSTR|VT_VECTOR)] + CALPWSTR calpwstr; + [case(VT_VARIANT|VT_VECTOR)] + CAPROPVARIANT capropvar; + }; + }; + + typedef struct tagPROPVARIANT * LPPROPVARIANT; + + cpp_quote("// Reserved global Property IDs") + const PROPID PID_DICTIONARY = 0x00000000; + const PROPID PID_CODEPAGE = 0x00000001; + const PROPID PID_FIRST_USABLE = 0x00000002; + const PROPID PID_FIRST_NAME_DEFAULT = 0x00000fff; + const PROPID PID_LOCALE = 0x80000000; + const PROPID PID_MODIFY_TIME = 0x80000001; + const PROPID PID_SECURITY = 0x80000002; + const PROPID PID_ILLEGAL = 0xffffffff; + + + cpp_quote("// Property IDs for the SummaryInformation Property Set") + cpp_quote("") + cpp_quote("#define PIDSI_TITLE 0x00000002L // VT_LPSTR") + cpp_quote("#define PIDSI_SUBJECT 0x00000003L // VT_LPSTR") + cpp_quote("#define PIDSI_AUTHOR 0x00000004L // VT_LPSTR") + cpp_quote("#define PIDSI_KEYWORDS 0x00000005L // VT_LPSTR") + cpp_quote("#define PIDSI_COMMENTS 0x00000006L // VT_LPSTR") + cpp_quote("#define PIDSI_TEMPLATE 0x00000007L // VT_LPSTR") + cpp_quote("#define PIDSI_LASTAUTHOR 0x00000008L // VT_LPSTR") + cpp_quote("#define PIDSI_REVNUMBER 0x00000009L // VT_LPSTR") + cpp_quote("#define PIDSI_EDITTIME 0x0000000aL // VT_FILETIME (UTC)") + cpp_quote("#define PIDSI_LASTPRINTED 0x0000000bL // VT_FILETIME (UTC)") + cpp_quote("#define PIDSI_CREATE_DTM 0x0000000cL // VT_FILETIME (UTC)") + cpp_quote("#define PIDSI_LASTSAVE_DTM 0x0000000dL // VT_FILETIME (UTC)") + cpp_quote("#define PIDSI_PAGECOUNT 0x0000000eL // VT_I4") + cpp_quote("#define PIDSI_WORDCOUNT 0x0000000fL // VT_I4") + cpp_quote("#define PIDSI_CHARCOUNT 0x00000010L // VT_I4") + cpp_quote("#define PIDSI_THUMBNAIL 0x00000011L // VT_CF") + cpp_quote("#define PIDSI_APPNAME 0x00000012L // VT_LPSTR") + cpp_quote("#define PIDSI_DOC_SECURITY 0x00000013L // VT_I4") + + const ULONG PRSPEC_INVALID = 0xffffffff; + const ULONG PRSPEC_LPWSTR = 0; + const ULONG PRSPEC_PROPID = 1; + + typedef struct tagPROPSPEC + { + + ULONG ulKind; + [switch_is(ulKind)] union + { + [case(PRSPEC_PROPID)] + PROPID propid; + [case(PRSPEC_LPWSTR)] + LPOLESTR lpwstr; + [default] ; + } ; + + } PROPSPEC; + + typedef struct tagSTATPROPSTG + { + + LPOLESTR lpwstrName; + PROPID propid; + VARTYPE vt; + + } STATPROPSTG; + + cpp_quote("// Macros for parsing the OS Version of the Property Set Header") + cpp_quote("#define PROPSETHDR_OSVER_KIND(dwOSVer) HIWORD( (dwOSVer) )") + cpp_quote("#define PROPSETHDR_OSVER_MAJOR(dwOSVer) LOBYTE(LOWORD( (dwOSVer) ))") + cpp_quote("#define PROPSETHDR_OSVER_MINOR(dwOSVer) HIBYTE(LOWORD( (dwOSVer) ))") + cpp_quote("#define PROPSETHDR_OSVERSION_UNKNOWN 0xFFFFFFFF") + + + typedef struct tagSTATPROPSETSTG + { + + FMTID fmtid; + CLSID clsid; + DWORD grfFlags; + FILETIME mtime; + FILETIME ctime; + FILETIME atime; + DWORD dwOSVersion; + + } STATPROPSETSTG; + + + // When this IDL file is used for "IProp.dll" (the + // standalone property set DLL), we must have local + // and remotable routines (call_as routines are used + // to remove BSTRs, which are not remotable with some + // RPC run-times). + // + // For the remotable routines, we must use pointer + // parameters (e.g. "*rgspec" rather than "rgspec[]") + // so that the MIDL 2.0 compiler will generate an + // interpereted proxy/stub, rather than inline. + +#ifdef IPROPERTY_DLL + [local] +#endif + HRESULT ReadMultiple( + [in] ULONG cpspec, + [in, size_is(cpspec)] + const PROPSPEC rgpspec[], + [out, size_is(cpspec)] + PROPVARIANT rgpropvar[] + ); + +#ifdef IPROPERTY_DLL + [call_as(ReadMultiple)] + HRESULT RemoteReadMultiple( + [out] BOOL *pfBstrPresent, + [in] ULONG cpspec, + [in, size_is(cpspec)] + const PROPSPEC *rgpspec, + [out, size_is(cpspec)] + PROPVARIANT *rgpropvar + ); +#endif + +#ifdef IPROPERTY_DLL + [local] +#endif + HRESULT WriteMultiple( + [in] ULONG cpspec, + [in, size_is(cpspec)] + const PROPSPEC rgpspec[], + [in, size_is(cpspec)] + const PROPVARIANT rgpropvar[], + [in] PROPID propidNameFirst + ); + +#ifdef IPROPERTY_DLL + [call_as(WriteMultiple)] + HRESULT RemoteWriteMultiple( + [in] BOOL fBstrPresent, + [in] ULONG cpspec, + [in, size_is(cpspec)] + const PROPSPEC *rgpspec, + [in, size_is(cpspec)] + const PROPVARIANT *rgpropvar, + [in] PROPID propidNameFirst + ); +#endif + +#ifdef IPROPERTY_DLL + [local] +#endif + HRESULT DeleteMultiple( + [in] ULONG cpspec, + [in, size_is(cpspec)] + const PROPSPEC rgpspec[] + ); + +#ifdef IPROPERTY_DLL + [call_as(DeleteMultiple)] + HRESULT RemoteDeleteMultiple( + [in] ULONG cpspec, + [in, size_is(cpspec)] + const PROPSPEC *rgpspec + ); +#endif + + HRESULT ReadPropertyNames( + [in] ULONG cpropid, + [in, size_is(cpropid)] + const PROPID rgpropid[], + [out, size_is(cpropid)] + LPOLESTR rglpwstrName[] + ); + + HRESULT WritePropertyNames( + [in] ULONG cpropid, + [in, size_is(cpropid)] + const PROPID rgpropid[], + [in, size_is(cpropid)] + const LPOLESTR rglpwstrName[] + ); + + HRESULT DeletePropertyNames( + [in] ULONG cpropid, + [in, size_is(cpropid)] + const PROPID rgpropid[] + ); + + HRESULT Commit( + [in] DWORD grfCommitFlags + ); + + HRESULT Revert(); + + HRESULT Enum( + [out] IEnumSTATPROPSTG ** ppenum + ); + + HRESULT SetTimes( + [in] FILETIME const * pctime, + [in] FILETIME const * patime, + [in] FILETIME const * pmtime + ); + + HRESULT SetClass( + [in] REFCLSID clsid + ); + + HRESULT Stat( + [out] STATPROPSETSTG * pstatpsstg + ); +} + +[ + object, + uuid(0000013A-0000-0000-C000-000000000046), + pointer_default(unique) +] + +interface IPropertySetStorage : IUnknown +{ + + typedef [unique] IPropertySetStorage * LPPROPERTYSETSTORAGE; + + HRESULT Create( + [in] REFFMTID rfmtid, + [in, unique] + const CLSID * pclsid, + [in] DWORD grfFlags, + [in] DWORD grfMode, + [out] IPropertyStorage ** ppprstg + ); + + HRESULT Open( + [in] REFFMTID rfmtid, + [in] DWORD grfMode, + [out] IPropertyStorage ** ppprstg + ); + + HRESULT Delete( + [in] REFFMTID rfmtid + ); + + HRESULT Enum( + [out] IEnumSTATPROPSETSTG ** ppenum + ); + +} + + +[ + object, + uuid(00000139-0000-0000-C000-000000000046), + pointer_default(unique) +] + +interface IEnumSTATPROPSTG : IUnknown +{ + + typedef [unique] IEnumSTATPROPSTG * LPENUMSTATPROPSTG; + + [local] + HRESULT Next( + [in] ULONG celt, + [out, size_is(celt), length_is(*pceltFetched)] + STATPROPSTG * rgelt, + [out] ULONG * pceltFetched + ); + + [call_as(Next)] + HRESULT RemoteNext( + [in] ULONG celt, + [out, size_is(celt), length_is(*pceltFetched)] + STATPROPSTG * rgelt, + [out] ULONG * pceltFetched + ); + + HRESULT Skip( + [in] ULONG celt + ); + + HRESULT Reset(); + + HRESULT Clone( + [out] IEnumSTATPROPSTG ** ppenum + ); +} + + +[ + object, + uuid(0000013B-0000-0000-C000-000000000046), + pointer_default(unique) +] + +interface IEnumSTATPROPSETSTG : IUnknown +{ + + typedef [unique] IEnumSTATPROPSETSTG * LPENUMSTATPROPSETSTG; + + [local] + HRESULT Next( + [in] ULONG celt, + [out, size_is(celt), length_is(*pceltFetched)] + STATPROPSETSTG * rgelt, + [out] ULONG * pceltFetched + ); + + [call_as(Next)] + HRESULT RemoteNext( + [in] ULONG celt, + [out, size_is(celt), length_is(*pceltFetched)] + STATPROPSETSTG * rgelt, + [out] ULONG * pceltFetched + ); + + HRESULT Skip( + [in] ULONG celt + ); + + HRESULT Reset(); + + HRESULT Clone( + [out] IEnumSTATPROPSETSTG ** ppenum + ); +} + + +cpp_quote("WINOLEAPI PropVariantCopy ( PROPVARIANT * pvarDest, const PROPVARIANT * pvarSrc );") +cpp_quote("WINOLEAPI PropVariantClear ( PROPVARIANT * pvar );") +cpp_quote("WINOLEAPI FreePropVariantArray ( ULONG cVariants, PROPVARIANT * rgvars );") + +cpp_quote("") +cpp_quote("#define _PROPVARIANTINIT_DEFINED_") +cpp_quote("# ifdef __cplusplus") +cpp_quote("inline void PropVariantInit ( PROPVARIANT * pvar )") +cpp_quote("{") +cpp_quote(" memset ( pvar, 0, sizeof(PROPVARIANT) );") +cpp_quote("}") +cpp_quote("# else") +cpp_quote("# define PropVariantInit(pvar) memset ( pvar, 0, sizeof(PROPVARIANT) )") +cpp_quote("# endif") +cpp_quote("") + +cpp_quote("") +cpp_quote("#ifndef _STGCREATEPROPSTG_DEFINED_") +cpp_quote("WINOLEAPI StgCreatePropStg( IUnknown* pUnk, REFFMTID fmtid, const CLSID *pclsid, DWORD grfFlags, DWORD dwReserved, IPropertyStorage **ppPropStg );") +cpp_quote("WINOLEAPI StgOpenPropStg( IUnknown* pUnk, REFFMTID fmtid, DWORD grfFlags, DWORD dwReserved, IPropertyStorage **ppPropStg );") +cpp_quote("WINOLEAPI StgCreatePropSetStg( IStorage *pStorage, DWORD dwReserved, IPropertySetStorage **ppPropSetStg);") + +cpp_quote("") +cpp_quote("#define CCH_MAX_PROPSTG_NAME 31") +cpp_quote("WINOLEAPI FmtIdToPropStgName( const FMTID *pfmtid, LPOLESTR oszName );" ) +cpp_quote("WINOLEAPI PropStgNameToFmtId( const LPOLESTR oszName, FMTID *pfmtid );" ) +cpp_quote("#endif") + + */ + +/**************************************************************************** + * Connection Point Interfaces + ****************************************************************************/ + /* +#ifdef __INCLUDE_CPIFS +interface IConnectionPointContainer; +interface IConnectionPoint; +interface IEnumConnections; +interface IEnumConnectionPoints; + +[ + object, + uuid(B196B286-BAB4-101A-B69C-00AA00341D07), + pointer_default(unique) +] +interface IConnectionPoint : IUnknown +{ + typedef IConnectionPoint * PCONNECTIONPOINT; + typedef IConnectionPoint * LPCONNECTIONPOINT; + + HRESULT GetConnectionInterface + ( + [out] IID * piid + ); + + HRESULT GetConnectionPointContainer + ( + [out] IConnectionPointContainer ** ppCPC + ); + + HRESULT Advise + ( + [in] IUnknown * pUnkSink, + [out] DWORD * pdwCookie + ); + + HRESULT Unadvise + ( + [in] DWORD dwCookie + ); + + HRESULT EnumConnections + ( + [out] IEnumConnections ** ppEnum + ); +} + +[ + object, + uuid(B196B284-BAB4-101A-B69C-00AA00341D07), + pointer_default(unique) +] +interface IConnectionPointContainer : IUnknown +{ + typedef IConnectionPointContainer * PCONNECTIONPOINTCONTAINER; + typedef IConnectionPointContainer * LPCONNECTIONPOINTCONTAINER; + + HRESULT EnumConnectionPoints + ( + [out] IEnumConnectionPoints ** ppEnum + ); + + HRESULT FindConnectionPoint + ( + [in] REFIID riid, + [out] IConnectionPoint ** ppCP + ); +} + + +[ + object, + uuid(B196B287-BAB4-101A-B69C-00AA00341D07), + pointer_default(unique) +] +interface IEnumConnections : IUnknown +{ + typedef IEnumConnections * PENUMCONNECTIONS; + typedef IEnumConnections * LPENUMCONNECTIONS; + + typedef struct tagCONNECTDATA + { + IUnknown * pUnk; + DWORD dwCookie; + } CONNECTDATA; + + typedef struct tagCONNECTDATA * PCONNECTDATA; + typedef struct tagCONNECTDATA * LPCONNECTDATA; + + [local] + HRESULT Next( + [in] ULONG cConnections, + [out, + size_is(cConnections), + length_is(*lpcFetched)] CONNECTDATA * rgcd, + [out] ULONG * lpcFetched + ); + + [call_as(Next)] + HRESULT RemoteNext( + [in] ULONG cConnections, + [out, + size_is(cConnections), + length_is(*lpcFetched)] CONNECTDATA * rgcd, + [out] ULONG * lpcFetched + ); + + HRESULT Skip + ( + [in] ULONG cConnections + ); + + HRESULT Reset + ( + void + ); + + HRESULT Clone + ( + [out] IEnumConnections ** ppEnum + ); +} + + +[ + object, + uuid(B196B285-BAB4-101A-B69C-00AA00341D07), + pointer_default(unique) +] +interface IEnumConnectionPoints : IUnknown +{ + typedef IEnumConnectionPoints * PENUMCONNECTIONPOINTS; + typedef IEnumConnectionPoints * LPENUMCONNECTIONPOINTS; + + [local] + HRESULT Next( + [in] ULONG cConnections, + [out, + size_is(cConnections), + length_is(*lpcFetched)] IConnectionPoint ** rgpcn, + [out] ULONG * lpcFetched + ); + + [call_as(Next)] + HRESULT RemoteNext( + [in] ULONG cConnections, + [out, + size_is(cConnections), + length_is(*lpcFetched)] IConnectionPoint ** rgpcn, + [out] ULONG * lpcFetched + ); + + HRESULT Skip + ( + [in] ULONG cConnections + ); + + HRESULT Reset + ( + void + ); + + HRESULT Clone + ( + [out] IEnumConnectionPoints ** ppEnum + ); +} +#endif // __INCLUDE_CPIFS + + +cpp_quote( "#if (_WIN32_WINNT >= 0x0400 ) || defined(_WIN32_DCOM) // DCOM" ) +cpp_quote( "// This interface is only valid on Windows NT 4.0" ) + +[ + local, + object, + uuid(0000013D-0000-0000-C000-000000000046) +] +interface IClientSecurity : IUnknown +{ + + typedef struct tagSOLE_AUTHENTICATION_SERVICE + { + DWORD dwAuthnSvc; + DWORD dwAuthzSvc; + OLECHAR *pPrincipalName; + HRESULT hr; + } SOLE_AUTHENTICATION_SERVICE; + + typedef SOLE_AUTHENTICATION_SERVICE *PSOLE_AUTHENTICATION_SERVICE; + + typedef enum tagEOLE_AUTHENTICATION_CAPABILITIES + { + EOAC_NONE = 0x0, + EOAC_MUTUAL_AUTH = 0x1, + EOAC_CLOAKING = 0x10, + + // These are only valid for CoInitializeSecurity + EOAC_SECURE_REFS = 0x2, + EOAC_ACCESS_CONTROL = 0x4, + EOAC_APPID = 0x8 + } EOLE_AUTHENTICATION_CAPABILITIES; + + HRESULT QueryBlanket + ( + [in] IUnknown *pProxy, + [out] DWORD *pAuthnSvc, + [out] DWORD *pAuthzSvc, + [out] OLECHAR **pServerPrincName, + [out] DWORD *pAuthnLevel, + [out] DWORD *pImpLevel, + [out] void **pAuthInfo, + [out] DWORD *pCapabilites + ); + + HRESULT SetBlanket + ( + [in] IUnknown *pProxy, + [in] DWORD AuthnSvc, + [in] DWORD AuthzSvc, + [in] OLECHAR *pServerPrincName, + [in] DWORD AuthnLevel, + [in] DWORD ImpLevel, + [in] void *pAuthInfo, + [in] DWORD Capabilities + ); + + HRESULT CopyProxy + ( + [in] IUnknown *pProxy, + [out] IUnknown **ppCopy + ); +} + +[ + local, + object, + uuid(0000013E-0000-0000-C000-000000000046) +] +interface IServerSecurity : IUnknown +{ + HRESULT QueryBlanket + ( + [out] DWORD *pAuthnSvc, + [out] DWORD *pAuthzSvc, + [out] OLECHAR **pServerPrincName, + [out] DWORD *pAuthnLevel, + [out] DWORD *pImpLevel, + [out] void **pPrivs, + [out] DWORD *pCapabilities + ); + + HRESULT ImpersonateClient(); + + HRESULT RevertToSelf(); + + BOOL IsImpersonating(); +} + +[ + object, + uuid(00000140-0000-0000-C000-000000000046) +] + +interface IClassActivator : IUnknown +{ + HRESULT GetClassObject( + [in] REFCLSID rclsid, + [in] DWORD dwClassContext, + [in] LCID locale, + [in] REFIID riid, + [out, iid_is(riid)] void **ppv); +} + + +[ +object, +local, +uuid(00000144-0000-0000-C000-000000000046), +oleautomation +] +interface IRpcOptions : IUnknown +{ + HRESULT Set([in] IUnknown * pPrx, + [in] DWORD dwProperty, + [in] DWORD dwValue); + + HRESULT Query([in] IUnknown * pPrx, + [in] DWORD dwProperty, + [out] DWORD * pdwValue); + + HRESULT CopyProxy([in] IUnknown * punkProxy, + [out] IUnknown ** ppunkCopy); +} + +enum {COMBND_RPCSTRINGS = 0x01}; // flag indicating arBndInfo is the + // Rpc string bindings to be used. + +[ +object, +local, +uuid(00000148-0000-0000-C000-000000000046) +] +interface IComBinding : IUnknown +{ + HRESULT InitBinding([in] DWORD dwEndpointFlags, + [in] DWORD dwNICFlags, + [in] DWORD mbzReserved1, + [in] DWORD mbzReserved2, + [in] LPOLESTR pszBinding + ); + + HRESULT QueryBinding([out] LPDWORD pdwEndpointFlags, + [out] LPDWORD pdwNICFlags, + [out] LPDWORD mbzReserved1, + [out] LPDWORD mbzReserved2, + [out] LPOLESTR *ppszBinding + ); + + +} + + + + +cpp_quote( "#endif //DCOM" ) + + +[ + object, + uuid(99caf010-415e-11cf-8814-00aa00b569f5), + pointer_default(unique) +] + +interface IFillLockBytes: IUnknown +{ + [local] + HRESULT FillAppend + ( + [in, size_is(cb)] void const *pv, + [in] ULONG cb, + [out] ULONG *pcbWritten + ); + + [call_as(FillAppend)] + HRESULT _stdcall RemoteFillAppend( + [in, size_is(cb)] byte const *pv, + [in] ULONG cb, + [out] ULONG *pcbWritten); + + [local] + HRESULT FillAt + ( + [in] ULARGE_INTEGER ulOffset, + [in, size_is(cb)] void const *pv, + [in] ULONG cb, + [out] ULONG *pcbWritten + ); + + [call_as(FillAt)] + HRESULT _stdcall RemoteFillAt( + [in] ULARGE_INTEGER ulOffset, + [in, size_is(cb)] byte const *pv, + [in] ULONG cb, + [out] ULONG *pcbWritten); + + HRESULT SetFillSize + ( + [in] ULARGE_INTEGER ulSize + ); + + HRESULT Terminate + ( + [in] BOOL bCanceled + ); +} + + +[ + object, + uuid(a9d758a0-4617-11cf-95fc-00aa00680db4), + pointer_default(unique) +] + +interface IProgressNotify: IUnknown +{ + HRESULT OnProgress + ( + [in] DWORD dwProgressCurrent, + [in] DWORD dwProgressMaximum, + [in] BOOL fAccurate, + [in] BOOL fOwner + ); +} + + +[ + local, + object, + uuid(0e6d4d90-6738-11cf-9608-00aa00680db4), + pointer_default(unique) +] + +interface ILayoutStorage: IUnknown +{ + typedef struct tagStorageLayout + { + DWORD LayoutType; + OLECHAR *pwcsElementName; + LARGE_INTEGER cOffset; + LARGE_INTEGER cBytes; + } StorageLayout; + + HRESULT __stdcall LayoutScript + ( + [in] StorageLayout *pStorageLayout, + [in] DWORD nEntries, + [in] DWORD glfInterleavedFlag + ); + HRESULT __stdcall BeginMonitor(void); + + HRESULT __stdcall EndMonitor(void); + + HRESULT __stdcall ReLayoutDocfile + ( + [in] OLECHAR *pwcsNewDfName + ); + + HRESULT __stdcall ReLayoutDocfileOnILockBytes + ( + [in] ILockBytes *pILockBytes + ); + + +} + +[ + uuid(00000022-0000-0000-C000-000000000046), + version(1.0), + pointer_default(unique) + , object +] + +interface ISurrogate : IUnknown +{ + typedef [unique] ISurrogate* LPSURROGATE; + + HRESULT LoadDllServer( + [in] REFCLSID Clsid); + HRESULT FreeSurrogate(); +} + + +[ + local, + object, + uuid(00000146-0000-0000-C000-000000000046) +] +interface IGlobalInterfaceTable : IUnknown +{ + typedef [unique] IGlobalInterfaceTable *LPGLOBALINTERFACETABLE; + + HRESULT RegisterInterfaceInGlobal + ( + [in] IUnknown *pUnk, + [in] REFIID riid, + [out] DWORD *pdwCookie + ); + + HRESULT RevokeInterfaceFromGlobal + ( + [in] DWORD dwCookie + ); + + HRESULT GetInterfaceFromGlobal + ( + [in] DWORD dwCookie, + [in] REFIID riid, + [out, iid_is(riid)] void **ppv + ); +}; + + +[ + object, + uuid(0e6d4d92-6738-11cf-9608-00aa00680db4), + pointer_default(unique) +] + +interface IDirectWriterLock : IUnknown +{ + + HRESULT WaitForWriteAccess ([in] DWORD dwTimeout); + + HRESULT ReleaseWriteAccess (); + + HRESULT HaveWriteAccess (); + +} + +[ + object, + uuid(00000023-0000-0000-C000-000000000046) +] + +interface ISynchronize : IUnknown +{ + HRESULT Wait([in] DWORD dwMilliseconds); + HRESULT Signal(); + HRESULT Reset(); +} + +[ + local, + object, + uuid(00000025-0000-0000-C000-000000000046) +] +interface ISynchronizeMutex : ISynchronize +{ + HRESULT ReleaseMutex(); +} + +[ + local, + object, + uuid(00000024-0000-0000-C000-000000000046) +] +interface IAsyncSetup : IUnknown +{ + HRESULT GetAsyncManager( [in] REFIID riid, + [in] IUnknown *pOuter, + [in] DWORD dwFlags, + [out] IUnknown **ppInner, + [out] IAsyncManager **ppAsyncMgr ); +} + +[ + local, + object, + uuid(00000029-0000-0000-C000-000000000046) +] + +interface ICancelMethodCalls : IUnknown +{ + typedef [unique] ICancelMethodCalls *LPCANCELMETHODCALLS; + + HRESULT Cancel (void); + HRESULT TestCancel (void); + HRESULT SetCancelTimeout([in] ULONG ulSeconds); +} + +[ + local, + object, + uuid(0000002A-0000-0000-C000-000000000046) +] +interface IAsyncManager : IUnknown +{ + typedef enum tagDCOM_CALL_STATE + { + DCOM_NONE = 0x0, + DCOM_CALL_COMPLETE = 0x1, + DCOM_CALL_CANCELED = 0x2, + } DCOM_CALL_STATE; + + HRESULT CompleteCall ( [in] HRESULT Result ); + HRESULT GetCallContext( [in] REFIID riid, [out] void **pInterface ); + HRESULT GetState ( [out] ULONG *pulStateFlags); +} + +[ + local, + object, + uuid(0000002B-0000-0000-C000-000000000046) +] +interface IWaitMultiple : IUnknown +{ + HRESULT WaitMultiple ( [in] DWORD timeout, [out] ISynchronize **pSync ); + HRESULT AddSynchronize( [in] ISynchronize *pSync ); +} + +[ + local, + object, + uuid(0000002C-0000-0000-C000-000000000046) +] +interface ISynchronizeEvent : IUnknown +{ + HRESULT GetEvent( [out] HANDLE *pEvent ); +} + +[ + object, + uuid(00000026-0000-0000-C000-000000000046) +] +interface IUrlMon : IUnknown +{ + HRESULT AsyncGetClassBits( + [in] REFCLSID rclsid, + [in, unique] LPCWSTR pszTYPE, + [in, unique] LPCWSTR pszExt, + [in] DWORD dwFileVersionMS, + [in] DWORD dwFileVersionLS, + [in, unique] LPCWSTR pszCodeBase, + [in] IBindCtx * pbc, + [in] DWORD dwClassContext, + [in] REFIID riid, + [in] DWORD flags); +} + +//---------------------------------------------------------------------------- +// The Class Store Access Interface. +//---------------------------------------------------------------------------- +[ + object, + uuid(00000190-0000-0000-C000-000000000046) +] +interface IClassAccess : IUnknown +{ + +// This is the most common method to access the Class Container. +// It queries the Class Store for implementations for a specific +// Class Id. +// If a matching implementation is available for the object type, +// client architecture, locale and class context a pointer to the +// binary is returned along with other package info in the [out] parameter +// pPackageInfo. +// +// If the binary needs to be downloaded to the local machine, it is +// done as a part of this. +// + HRESULT GetClassInfo( + [in] REFCLSID clsid, // Class ID + [in] QUERYCONTEXT QryContext, // Query Attributes + [out] PACKAGEINFO * pPackageInfo + ); + +// +// GetClassSpecInfo is same as GetClassInfo except for it takes in +// any Class Specifier , CLSID or File Ext, or ProgID or MIME type. +// + HRESULT GetClassSpecInfo( + [in] uCLSSPEC * pClassSpec, // Class Spec (CLSID/Ext/MIME) + [in] QUERYCONTEXT QryContext, // Query Attributes + [out] PACKAGEINFO * pPackageInfo + ); + + +// +// GetInstallablePackages is used by CoGetPublishedAppInfo +// to provide list of published apps from the class store that are +// available for installation. +// + +typedef struct tagPUBLISHEDINFOLIST { + DWORD cPublApps; + [size_is(cPublApps), unique] PUBLISHEDAPPINFO *pPublAppInfo; +} PUBLISHEDINFOLIST; + + HRESULT GetInstallablePackages ( + [in] DWORD Count, + [out] PUBLISHEDINFOLIST *pInfoList + ); + +} + +[ + object, + uuid(00000192-0000-0000-C000-000000000046) +] +interface IClassRefresh : IUnknown +{ +// +// GetUpgrades is called to check if the Class Store has +// newer versions for any of a list of CLSIDs. The client calls this +// with a list of CLSIDs that were installed from the Class Container. +// + +typedef struct tagPACKAGEINFOLIST { + DWORD cPackInfo; + [size_is(cPackInfo), unique] PACKAGEINFO *pPackageInfo; +} PACKAGEINFOLIST; + + HRESULT GetUpgrades ( + [in] ULONG cClasses, + [in, size_is(cClasses)] CLSID *pClassList, // CLSIDs Installed + [in] CSPLATFORM Platform, + [in] LCID Locale, + [out] PACKAGEINFOLIST *pPackageInfoList); + +// +// CommitUpgrades is called to notify the Class Store that +// the newer versions were successfully installed and that the update sequence +// can be moved forward. +// + + HRESULT CommitUpgrades (); +} + + +//---------------------------------------------------------------------------- +// The Class Store Admin Interface. +//---------------------------------------------------------------------------- + +typedef struct tagCLASSDETAIL { + CLSID Clsid; + LPOLESTR pszDesc; + LPOLESTR pszIconPath; + CLSID TreatAsClsid; + CLSID AutoConvertClsid; + DWORD cFileExt; + [size_is(cFileExt)] LPOLESTR *prgFileExt; + LPOLESTR pMimeType; + LPOLESTR pDefaultProgId; + DWORD cOtherProgId; + [size_is(cOtherProgId)] LPOLESTR *prgOtherProgId; +} CLASSDETAIL; + +//+--------------------------------------------------------------------------- +// Contents: Enum Interfaces for Class Store +//---------------------------------------------------------------------------- +cpp_quote("#ifndef _LPCSADMNENUM_DEFINED") +cpp_quote("#define _LPCSADMNENUM_DEFINED") + +// +// IEnumPackage +// ============ +// + +[ + object, + uuid(00000193-0000-0000-C000-000000000046) +] +interface IEnumPackage : IUnknown +{ + +//---- Next() + + HRESULT Next( + [in] ULONG celt, + [out, size_is(celt), length_is(*pceltFetched)] PACKAGEDETAIL *rgelt, + [out] ULONG *pceltFetched); + +// +// celt number of elements to be fetched. +// rgelt array of PackageDetail structures. +// pceltFetched elements actually fetched. +// +// Returns: +// S_OK +// S_FALSE (Not enough elements to be fetched.) +// E_INVALIDARG +// E_FAIL +// CS_E_INVALID_VERSION (Class Container is corrupted +// OR is of a version that is no more supported) +// E_OUTOFMEMORY +// +// on errors +// *pceltFetched = 0 +// + + +//---- Skip() + + HRESULT Skip( + [in] ULONG celt); + +// +// celt number of elements to be skipped. +// +// Returns: +// S_OK +// S_FALSE (Not enough elements to be skipped.) +// E_FAIL +// E_ACCESSDENIED +// E_OUTOFMEMORY + + +//---- Reset() + + HRESULT Reset(); + +// +// Returns: +// S_OK +// + + +//---- Clone() + + HRESULT Clone( + [out] IEnumPackage **ppenum); + +// +// Returns: +// S_OK +// E_FAIL +// E_INVALIDARG +// E_ACCESSDENIED +// E_OUTOFMEMORY + + +} + + +// +// IEnumClass +// ========== +// + +[ + object, + uuid(00000194-0000-0000-C000-000000000046) +] + +interface IEnumClass : IUnknown +{ +//---- Next() + + HRESULT Next( + [in] ULONG celt, + [out, size_is(celt), length_is(*pceltFetched)] CLASSDETAIL *rgelt, + [out] ULONG *pceltFetched); + +// +// celt number of elements to be fetched. +// rgelt array of CLASSDETAIL structures. +// pceltFetched elements actually fetched. +// +// Returns: +// S_OK +// S_FALSE (Not enough elements to be fetched.) +// E_INVALIDARG +// E_FAIL +// CS_E_INVALID_VERSION (Class Container is corrupted +// OR is of a version that is no more supported) +// E_OUTOFMEMORY +// +// on errors +// *pceltFetched = 0 +// + +//---- Skip() + + HRESULT Skip( + [in] ULONG celt); + +// +// celt number of elements to be skipped. +// +// Returns: +// S_OK +// S_FALSE (Not enough elements to be skipped.) +// E_FAIL +// E_ACCESSDENIED +// E_OUTOFMEMORY + +//---- Reset() + + HRESULT Reset(); + +// +// Returns: +// S_OK +// + + +//---- Clone() + + HRESULT Clone( + [out] IEnumClass **ppenum); + +// +// Returns: +// S_OK +// E_FAIL +// E_INVALIDARG +// E_ACCESSDENIED +// E_OUTOFMEMORY + + + +} +cpp_quote("#endif") + +// +// IClassAdmin +// =========== +// + + +[ + object, + uuid(00000191-0000-0000-C000-000000000046) +] +interface IClassAdmin : IUnknown +{ + +// ::NewClass +// ----------- +// Stores a new Class Definition in the Class Store +// Corresponds to HKCR/{CLSID} in registry +// [In] - CLSID +// Class Name +// TreatAs CLSID (NULL GUID if no TreatAs) +// AutoConvert CLSID (NULL GUID if no AutoConvert) +// File Extension (NULL if no association) +// Mime Type (NULL if no association) +// Default ProgId (NULL if no association) +// Other ProgIds +// TypelibID +// Icon Path (NULL if none). +// +// Returns - S_OK +// E_ALREADY_EXISTS +// E_INVALIDARG +// + HRESULT NewClass ( + [in] CLASSDETAIL *pClassDetail + ); + +// ::DeleteClass +// ----------- +// Removes a Class Definition from the Class Store +// [In] - CLSID + + HRESULT DeleteClass ( + [in] REFCLSID guidClsId + ); + + +// ::NewInterface +// -------------- +// Stores a new Interface Definition in the Class Store +// Corresponds to HKCR/{IID} in registry +// [In] - IID +// Interface Name +// Proxy-Stub CLSID (NULL GUID if no ProxyStub) +// TypeLib GUID (NULL GUID if no TypeLib) +// +// Returns - S_OK +// E_ALREADY_EXISTS +// E_INVALID_ARG +// + HRESULT NewInterface ( + [in] REFIID iid, + [in, unique] LPOLESTR pszDesc, + [in] REFCLSID psclsid, + [in] REFCLSID typelibid + ); + +// ::DeleteInterface +// ----------- +// Removes an Interface Definition from the Class Store +// [In] - IID + + HRESULT DeleteInterface ( + [in] REFIID iid + ); + + +// ::NewPackage +// ------------ +// Stores a new application package in the Class Store +// May Correspond to HKCR/{CLSID}/LocalServer32 likes in registry +// +// Returns - S_OK +// E_ALREADY_EXISTS +// E_INVALIDARG +// + HRESULT NewPackage ( + [in] PACKAGEDETAIL *pPackageDetail + ); + + +// ::DeletePackage +// ----------- +// Removes a package from the Class Store +// [In] - PackageName + + HRESULT DeletePackage ( + [in] LPOLESTR pszPackageName + ); + +// ::GetClassesEnum() +// +// Returns the clsid enumerator +// for browsing classes defined in the class store. +// +// Returns: +// S_OK +// E_INVALIDARG +// E_FAIL +// E_ACCESSDENIED +// E_OUTOFMEMORY +// +// +// The value of the enumerator is NULL for all the error conditions. +// + + HRESULT GetClassesEnum( + [out] IEnumClass **ppIEnumClass + ); + + + +// ::GetPackagesEnum() +// +// Getting the Package enumerator from the classstore. +// +// guidClsid: All the apps that implements the clsid. +// ignored if NULLGUID. +// Vendor: All the apps provided by a given Vendor. +// ignored if NULL. +// +// ppIEnumPackage: NULL if there is any error. +// +// Returns: +// S_OK +// E_INVALIDARG +// E_FAIL +// E_ACCESSDENIED +// E_OUTOFMEMORY +// +// The value of the enumerator is NULL for all the error conditions. +// + + HRESULT GetPackagesEnum( + [in] REFCLSID guidClsid, + [in, unique] LPOLESTR pszVendor, + [in] CSPLATFORM Platform, + [in] DWORD dwContext, + [in] LCID Locale, + [out] IEnumPackage **ppIEnumPackage + ); + + +// ::GetClassDetails() +// +// Get all the class details given the clsid. +// +// [in] guidClsID class ID (guid) +// [out] CLASSDETAIL *pClassDetail +// +// Returns: +// S_OK +// E_INVALIDARG +// E_FAIL +// E_NOTFOUND (no such class) +// E_ACCESSDENIED +// E_OUTOFMEMORY +// +// + + + + HRESULT GetClassDetails ( + [in] REFCLSID guidClsId, + [out] CLASSDETAIL *pClassDetail + ); + + +// ::GetIidDetails() +// +// [IN] +// iid IID (guid) +// [OUT] +// pszDesc Description +// psClsid Proxy Stub Class ID +// pTypeLibId libid +// +// Returns: +// S_OK +// E_INVALIDARG +// E_FAIL +// E_NOTFOUND +// E_ACCESSDENIED +// E_OUTOFMEMORY +// +// + + HRESULT GetIidDetails ( + [in] REFIID iid, + [out] LPOLESTR *ppszDesc, + [out] CLSID *psClsid, + [out] CLSID *pTypeLibId + ); + +// ::GetPackageDetails() +// +// Get all the Package details given packagename. +// +// [IN] +// PackageName: Name of the package +// [OUT] +// pPackageDetail Package Detail +// +// Returns: +// S_OK +// E_INVALIDARG +// E_FAIL +// E_NOTFOUND (no such class) +// E_ACCESSDENIED +// E_OUTOFMEMORY +// +// + + + HRESULT GetPackageDetails ( + [in] LPOLESTR pszPackageName, + [out] PACKAGEDETAIL *pPackageDetail + ); +} + +cpp_quote("#if ( _MSC_VER >= 800 )") +cpp_quote("#pragma warning(default:4201)") +cpp_quote("#endif") + + */ + +} // extern (Windows)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/ole/win32/OLEIDL.d Fri Feb 08 19:49:32 2008 +0100 @@ -0,0 +1,479 @@ +module dwt.internal.ole.win32.OLEIDL; +//+------------------------------------------------------------------------- +// +// Microsoft Windows +// Copyright (C) Microsoft Corporation, 1992-1997. +// +// File: oadvhr.idl +// +//-------------------------------------------------------------------------- +private import dwt.internal.win32.WINTYPES; +private import dwt.internal.ole.win32.extras; +private import dwt.internal.ole.win32.OBJIDL; +//private import std.c.windows.windows; +//private import std.c.windows.com; + +extern( Windows ) { +//interface IOleInPlaceActiveObject; +//interface IEnumOLEVERB; + +interface IOleAdviseHolder : IUnknown +{ + HRESULT Advise( IAdviseSink pAdvise, DWORD * pdwConnection ); + HRESULT Unadvise( DWORD dwConnection ); + HRESULT EnumAdvise ( IEnumSTATDATA ppenumAdvise ); + HRESULT SendOnRename( IMoniker pmk ); + HRESULT SendOnSave(); + HRESULT SendOnClose(); +} +alias IOleAdviseHolder LPOLEADVISEHOLDER; + +interface IOleCache : IUnknown +{ + HRESULT Cache( FORMATETC *pformatetc, DWORD advf, DWORD * pdwConnection ); + HRESULT Uncache( DWORD dwConnection ); + HRESULT EnumCache( IEnumSTATDATA * ppenumSTATDATA ); + HRESULT InitCache( IDataObject pDataObject ); + HRESULT SetData( FORMATETC * pformatetc, STGMEDIUM * pmedium, BOOL fRelease ); +} +alias IOleCache LPOLECACHE; + +interface IOleCache2 : IOleCache +{ + // Cache update Flags +/* + const DWORD UPDFCACHE_NODATACACHE = 0x00000001; + const DWORD UPDFCACHE_ONSAVECACHE = 0x00000002; + const DWORD UPDFCACHE_ONSTOPCACHE = 0x00000004; + const DWORD UPDFCACHE_NORMALCACHE = 0x00000008; + const DWORD UPDFCACHE_IFBLANK = 0x00000010; + const DWORD UPDFCACHE_ONLYIFBLANK = 0x80000000; + + const DWORD UPDFCACHE_IFBLANKORONSAVECACHE = + (UPDFCACHE_IFBLANK | UPDFCACHE_ONSAVECACHE); + const DWORD UPDFCACHE_ALL = + ((DWORD)(~(UPDFCACHE_ONLYIFBLANK))); + const DWORD UPDFCACHE_ALLBUTNODATACACHE = + (UPDFCACHE_ALL & ((DWORD)(~UPDFCACHE_NODATACACHE))); + + + // IOleCache2::DiscardCache options + typedef [v1_enum] enum tagDISCARDCACHE + { + DISCARDCACHE_SAVEIFDIRTY = 0, // Save all dirty cache before discarding + DISCARDCACHE_NOSAVE = 1 // Don't save dirty caches before + // discarding + } DISCARDCACHE; +*/ + + HRESULT UpdateCache( LPDATAOBJECT pDataObject, DWORD grfUpdf, LPVOID pReserved ); + +// [call_as(UpdateCache)] +// HRESULT RemoteUpdateCache( LPDATAOBJECT pDataObject, DWORD grfUpdf, DWORD pReserved ); + HRESULT DiscardCache( DWORD dwDiscardOptions ); +} +alias IOleCache2 LPOLECACHE2; + +interface IOleCacheControl : IUnknown +{ + HRESULT OnRun( LPDATAOBJECT pDataObject ); + HRESULT OnStop(); +} +alias IOleCacheControl LPOLECACHECONTROL; + +interface IParseDisplayName : IUnknown +{ + HRESULT ParseDisplayName( IBindCtx pbc, LPOLESTR pszDisplayName, ULONG * pchEaten, IMoniker * ppmkOut ); +} +alias IParseDisplayName LPPARSEDISPLAYNAME; + +interface IOleContainer : IParseDisplayName +{ + HRESULT EnumObjects( DWORD grfFlags, IEnumUnknown * ppenum ); + HRESULT LockContainer( BOOL fLock ); +} +alias IOleContainer LPOLECONTAINER; + + +interface IOleClientSite : IUnknown +{ + HRESULT SaveObject(); + HRESULT GetMoniker( DWORD dwAssign, DWORD dwWhichMoniker, IMoniker * ppmk ); + HRESULT GetContainer( IOleContainer * ppContainer ); + HRESULT ShowObject(); + HRESULT OnShowWindow( BOOL fShow ); + HRESULT RequestNewObjectLayout(); +} +alias IOleClientSite LPOLECLIENTSITE; + +enum OLEGETMONIKER +{ + OLEGETMONIKER_ONLYIFTHERE = 1, + OLEGETMONIKER_FORCEASSIGN = 2, + OLEGETMONIKER_UNASSIGN = 3, + OLEGETMONIKER_TEMPFORUSER = 4 +} + +enum OLEWHICHMK +{ + OLEWHICHMK_CONTAINER = 1, + OLEWHICHMK_OBJREL = 2, + OLEWHICHMK_OBJFULL = 3 +} + +enum USERCLASSTYPE +{ + USERCLASSTYPE_FULL = 1, + USERCLASSTYPE_SHORT = 2, + USERCLASSTYPE_APPNAME = 3, +} + +enum OLEMISC +{ + OLEMISC_RECOMPOSEONRESIZE = 0x00000001, + OLEMISC_ONLYICONIC = 0x00000002, + OLEMISC_INSERTNOTREPLACE = 0x00000004, + OLEMISC_STATIC = 0x00000008, + OLEMISC_CANTLINKINSIDE = 0x00000010, + OLEMISC_CANLINKBYOLE1 = 0x00000020, + OLEMISC_ISLINKOBJECT = 0x00000040, + OLEMISC_INSIDEOUT = 0x00000080, + OLEMISC_ACTIVATEWHENVISIBLE = 0x00000100, + OLEMISC_RENDERINGISDEVICEINDEPENDENT= 0x00000200, + OLEMISC_INVISIBLEATRUNTIME = 0x00000400, + OLEMISC_ALWAYSRUN = 0x00000800, + OLEMISC_ACTSLIKEBUTTON = 0x00001000, + OLEMISC_ACTSLIKELABEL = 0x00002000, + OLEMISC_NOUIACTIVATE = 0x00004000, + OLEMISC_ALIGNABLE = 0x00008000, + OLEMISC_SIMPLEFRAME = 0x00010000, + OLEMISC_SETCLIENTSITEFIRST = 0x00020000, + OLEMISC_IMEMODE = 0x00040000, + OLEMISC_IGNOREACTIVATEWHENVISIBLE = 0x00080000, + OLEMISC_WANTSTOMENUMERGE = 0x00100000, + OLEMISC_SUPPORTSMULTILEVELUNDO = 0x00200000 +} + +enum OLECLOSE +{ + OLECLOSE_SAVEIFDIRTY = 0, + OLECLOSE_NOSAVE = 1, + OLECLOSE_PROMPTSAVE = 2, + SAVEIFDIRTY = 0, + NOSAVE = 1, + PROMPTSAVE = 2 +} + +interface IOleObject : IUnknown +{ + HRESULT SetClientSite( IOleClientSite pClientSite ); + HRESULT GetClientSite( IOleClientSite * ppClientSite ); + HRESULT SetHostNames( LPCOLESTR szContainerApp, LPCOLESTR szContainerObj ); + HRESULT Close( DWORD dwSaveOption ); + HRESULT SetMoniker( DWORD dwWhichMoniker, IMoniker pmk ); + HRESULT GetMoniker( DWORD dwAssign, DWORD dwWhichMoniker, IMoniker * ppmk ); + HRESULT InitFromData( IDataObject pDataObject, BOOL fCreation, DWORD dwReserved ); + HRESULT GetClipboardData( DWORD dwReserved, IDataObject * ppDataObject ); + HRESULT DoVerb( LONG iVerb, LPMSG lpmsg, IOleClientSite pActiveSite, LONG lindex, HWND hwndParent, LPCRECT lprcPosRect ); + HRESULT EnumVerbs( IEnumOLEVERB * ppEnumOleVerb ); + HRESULT Update(); + HRESULT IsUpToDate(); + HRESULT GetUserClassID( CLSID * pClsid ); + HRESULT GetUserType( DWORD dwFormOfType, LPOLESTR * pszUserType ); + HRESULT SetExtent( DWORD dwDrawAspect, SIZEL * psizel ); + HRESULT GetExtent( DWORD dwDrawAspect, SIZEL * psizel ); + HRESULT Advise( IAdviseSink pAdvSink, DWORD * pdwConnection ); + HRESULT Unadvise( DWORD dwConnection ); + HRESULT EnumAdvise( IEnumSTATDATA * ppenumAdvise ); + HRESULT GetMiscStatus( DWORD dwAspect, DWORD *pdwStatus ); + HRESULT SetColorScheme( LOGPALETTE *pLogpal ); +} +alias IOleObject LPOLEOBJECT; + +enum OLERENDER +{ + OLERENDER_NONE = 0, + OLERENDER_DRAW = 1, + OLERENDER_FORMAT = 2, + OLERENDER_ASIS = 3, + NONE = 0, + DRAW = 1, + FORMAT = 2, + ASIS = 3 +} +alias OLERENDER * LPOLERENDER; + +interface IOLETypes +{ +} + /****** OLE value types ***********************************************/ + /* rendering options */ + /****** Clipboard Data structures *****************************************/ + struct OBJECTDESCRIPTOR + { + ULONG cbSize; // Size of structure in bytes + CLSID clsid; // CLSID of data being transferred + DWORD dwDrawAspect; // Display aspect of the object + // normally DVASPECT_CONTENT or ICON. + // dwDrawAspect will be 0 (which is NOT + // DVASPECT_CONTENT) if the copier or + // dragsource didn't draw the object to + // begin with. + SIZEL sizel; // size of the object in HIMETRIC + // sizel is opt.: will be (0,0) for apps + // which don't draw the object being + // transferred + POINTL pointl; // Offset in HIMETRIC units from the + // upper-left corner of the obj where the + // mouse went down for the drag. + // NOTE: y coordinates increase downward. + // x coordinates increase to right + // pointl is opt.; it is only meaningful + // if object is transfered via drag/drop. + // (0, 0) if mouse position is unspecified + // (eg. when obj transfered via clipboard) + DWORD dwStatus; // Misc. status flags for object. Flags are + // defined by OLEMISC enum. these flags + // are as would be returned + // by IOleObject::GetMiscStatus. + DWORD dwFullUserTypeName; // Offset from beginning of structure to + // null-terminated string that specifies + // Full User Type Name of the object. + // 0 indicates string not present. + DWORD dwSrcOfCopy; // Offset from beginning of structure to + // null-terminated string that specifies + // source of the transfer. + // dwSrcOfCOpy is normally implemented as + // the display name of the temp-for-user + // moniker which identifies the source of + // the data. + // 0 indicates string not present. + // NOTE: moniker assignment is NOT forced. + // see IOleObject::GetMoniker( + // OLEGETMONIKER_TEMPFORUSER) + + /* variable sized string data may appear here */ + + } + alias OBJECTDESCRIPTOR LINKSRCDESCRIPTOR; + alias OBJECTDESCRIPTOR * POBJECTDESCRIPTOR; + alias OBJECTDESCRIPTOR * LPOBJECTDESCRIPTOR; + alias OBJECTDESCRIPTOR * PLINKSRCDESCRIPTOR; + alias OBJECTDESCRIPTOR * LPLINKSRCDESCRIPTOR; + + +interface IOleWindow : IUnknown +{ + HRESULT GetWindow( HWND * phwnd ); + HRESULT ContextSensitiveHelp( BOOL fEnterMode ); +} +alias IOleWindow LPOLEWINDOW; +enum OLEUPDATE +{ + OLEUPDATE_ALWAYS=1, + OLEUPDATE_ONCALL=3 +} +alias OLEUPDATE * LPOLEUPDATE; +alias OLEUPDATE * POLEUPDATE; + + // for IOleLink::BindToSource +enum OLELINKBIND +{ + OLELINKBIND_EVENIFCLASSDIFF = 1, +} + +interface IOleLink : IUnknown +{ + /* Link update options */ + HRESULT SetUpdateOptions( DWORD dwUpdateOpt ); + HRESULT GetUpdateOptions( DWORD * pdwUpdateOpt ); + HRESULT SetSourceMoniker( IMoniker pmk, REFCLSID rclsid ); + HRESULT GetSourceMoniker( IMoniker * ppmk ); + HRESULT SetSourceDisplayName( LPCOLESTR pszStatusText ); + HRESULT GetSourceDisplayName( LPOLESTR * ppszDisplayName ); + HRESULT BindToSource( DWORD bindflags, IBindCtx pbc ); + HRESULT BindIfRunning(); + HRESULT GetBoundSource( IUnknown * ppunk ); + HRESULT UnbindSource(); + HRESULT Update( IBindCtx pbc ); +} +alias IOleLink LPOLELINK; + +enum BINDSPEED +{ + BINDSPEED_INDEFINITE = 1, + BINDSPEED_MODERATE = 2, + BINDSPEED_IMMEDIATE = 3 +} + +enum OLECONTF +{ + OLECONTF_EMBEDDINGS = 1, + OLECONTF_LINKS = 2, + OLECONTF_OTHERS = 4, + OLECONTF_ONLYUSER = 8, + OLECONTF_ONLYIFRUNNING = 16 +} + +interface IOleItemContainer : IOleContainer +{ + HRESULT GetObject( LPOLESTR pszItem, DWORD dwSpeedNeeded, IBindCtx pbc, REFIID riid, void **ppvObject); + HRESULT GetObjectStorage( LPOLESTR pszItem, IBindCtx pbc, REFIID riid, void **ppvStorage); + HRESULT IsRunning(LPOLESTR pszItem); +} +alias IOleItemContainer LPOLEITEMCONTAINER; + +alias RECT BORDERWIDTHS; +alias LPRECT LPBORDERWIDTHS; +alias LPCRECT LPCBORDERWIDTHS; + +interface IOleInPlaceUIWindow : IOleWindow +{ + HRESULT GetBorder( LPRECT lprectBorder ); + HRESULT RequestBorderSpace( LPCBORDERWIDTHS pborderwidths ); + HRESULT SetBorderSpace( LPCBORDERWIDTHS pborderwidths ); + HRESULT SetActiveObject( LPOLEINPLACEACTIVEOBJECT pActiveObject, LPCOLESTR pszObjName ); +} +alias IOleInPlaceUIWindow LPOLEINPLACEUIWINDOW; + +interface IOleInPlaceActiveObject : IOleWindow +{ + HRESULT TranslateAccelerator( LPMSG lpmsg ); + HRESULT OnFrameWindowActivate( BOOL fActivate ); + HRESULT OnDocWindowActivate( BOOL fActivate ); + HRESULT ResizeBorder( LPCRECT prcBorder, IOleInPlaceUIWindow pUIWindow, BOOL fFrameWindow ); + HRESULT EnableModeless ( BOOL fEnable ); +} +alias IOleInPlaceActiveObject LPOLEINPLACEACTIVEOBJECT; + +struct OLEINPLACEFRAMEINFO // OleInPlaceFrameInfo +{ + UINT cb; + BOOL fMDIApp; + HWND hwndFrame; + HACCEL haccel; + UINT cAccelEntries; +} +alias OLEINPLACEFRAMEINFO * LPOLEINPLACEFRAMEINFO; + + +struct OLEMENUGROUPWIDTHS +{ + LONG width[6]; +} +alias OLEMENUGROUPWIDTHS * LPOLEMENUGROUPWIDTHS; + +alias HGLOBAL HOLEMENU; + +interface IOleInPlaceFrame : IOleInPlaceUIWindow +{ +HRESULT InsertMenus( HMENU hmenuShared, LPOLEMENUGROUPWIDTHS lpMenuWidths ); +HRESULT SetMenu( HMENU hmenuShared, HOLEMENU holemenu, HWND hwndActiveObject ); +HRESULT RemoveMenus( HMENU hmenuShared ); +HRESULT SetStatusText( LPCOLESTR pszStatusText ); +HRESULT EnableModeless( BOOL fEnable ); +HRESULT TranslateAccelerator( LPMSG lpmsg, WORD wID ); +} +alias IOleInPlaceFrame LPOLEINPLACEFRAME; + +interface IOleInPlaceObject : IOleWindow +{ + HRESULT InPlaceDeactivate(); + HRESULT UIDeactivate(); + HRESULT SetObjectRects( LPCRECT lprcPosRect, LPCRECT lprcClipRect ); + HRESULT ReactivateAndUndo(); +} +alias IOleInPlaceObject LPOLEINPLACEOBJECT; + +interface IOleInPlaceSite : IOleWindow +{ + HRESULT CanInPlaceActivate(); + HRESULT OnInPlaceActivate(); + HRESULT OnUIActivate(); + HRESULT GetWindowContext( IOleInPlaceFrame * ppFrame, IOleInPlaceUIWindow * ppDoc, LPRECT lprcPosRect, LPRECT lprcClipRect, LPOLEINPLACEFRAMEINFO lpFrameInfo ); + HRESULT Scroll( SIZE scrollExtant ); + HRESULT OnUIDeactivate( BOOL fUndoable ); + HRESULT OnInPlaceDeactivate(); + HRESULT DiscardUndoState(); + HRESULT DeactivateAndUndo(); + HRESULT OnPosRectChange( LPCRECT lprcPosRect ); +} +alias IOleInPlaceSite LPOLEINPLACESITE; + +interface IContinue : IUnknown +{ + HRESULT FContinue(); +} + +interface IViewObject : IUnknown +{ + HRESULT Draw( DWORD dwDrawAspect, LONG lindex, void * pvAspect, DVTARGETDEVICE *ptd, HDC hdcTargetDev, HDC hdcDraw, LPCRECTL lprcBounds, LPCRECTL lprcWBounds, BOOL (*pfnContinue)(DWORD dwContinue), DWORD dwContinue ); + HRESULT GetColorSet( DWORD dwDrawAspect, LONG lindex, void *pvAspect, DVTARGETDEVICE *ptd, HDC hicTargetDev, LOGPALETTE **ppColorSet ); + HRESULT Freeze( DWORD dwDrawAspect, LONG lindex, void *pvAspect, DWORD *pdwFreeze ); + HRESULT Unfreeze( DWORD dwFreeze ); + HRESULT SetAdvise( DWORD aspects, DWORD advf, IAdviseSink pAdvSink ); + HRESULT GetAdvise( DWORD * pAspects, DWORD * pAdvf, IAdviseSink * ppAdvSink ); +} +alias IViewObject LPVIEWOBJECT; + +interface IViewObject2 : IViewObject +{ + HRESULT GetExtent( DWORD dwDrawAspect, LONG lindex, DVTARGETDEVICE* ptd, LPSIZEL lpsizel ); +} +alias IViewObject2 LPVIEWOBJECT2; + +interface IDropSource : IUnknown +{ + HRESULT QueryContinueDrag( BOOL fEscapePressed, DWORD grfKeyState ); + HRESULT GiveFeedback( DWORD dwEffect ); +} +alias IDropSource LPDROPSOURCE; + +const DWORD MK_ALT = 0x0020; +const DWORD DROPEFFECT_NONE = 0; +const DWORD DROPEFFECT_COPY = 1; +const DWORD DROPEFFECT_MOVE = 2; +const DWORD DROPEFFECT_LINK = 4; +const DWORD DROPEFFECT_SCROLL = 0x80000000; +const DWORD DD_DEFSCROLLINSET = 11; +const DWORD DD_DEFSCROLLDELAY = 50; +const DWORD DD_DEFSCROLLINTERVAL = 50; +const DWORD DD_DEFDRAGDELAY = 200; +const DWORD DD_DEFDRAGMINDIST = 2; + +interface IDropTarget : IUnknown +{ + HRESULT DragEnter( IDataObject pDataObj, DWORD grfKeyState, POINTL pt, DWORD *pdwEffect ); + HRESULT DragOver( DWORD grfKeyState, POINTL pt, DWORD *pdwEffect ); + HRESULT DragLeave(); + HRESULT Drop(IDataObject pDataObj,DWORD grfKeyState,POINTL pt,DWORD *pdwEffect); +} +alias IDropTarget LPDROPTARGET; + +struct OLEVERB { + LONG lVerb; + LPOLESTR lpszVerbName; + DWORD fuFlags; + DWORD grfAttribs; +} +alias OLEVERB * LPOLEVERB; + +// Bitwise verb attributes used in OLEVERB.grfAttribs +enum OLEVERBATTRIB // bitwise +{ + OLEVERBATTRIB_NEVERDIRTIES = 1, + OLEVERBATTRIB_ONCONTAINERMENU = 2, + NEVERDIRTIES = 1, + ONCONTAINERMENU = 2 +} + +interface IEnumOLEVERB : IUnknown +{ + HRESULT Next( ULONG celt, LPOLEVERB rgelt, ULONG * pceltFetched ); + HRESULT Skip( ULONG celt ); + HRESULT Reset(); + HRESULT Clone( IEnumOLEVERB * ppenum ); +} +alias IEnumOLEVERB LPENUMOLEVERB; + +} /* extern(Windows) */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/ole/win32/extras.d Fri Feb 08 19:49:32 2008 +0100 @@ -0,0 +1,279 @@ +module dwt.internal.ole.win32.extras; + +// +// extra bits form here and there to bring the com alias inline with MS +// to ease the porting. +// + +//public import std.c.windows.com; +//public import std.c.windows.windows; +import dwt.internal.win32.WINTYPES; +// private import dwt.internal.ole.win32.comtypes; +alias WCHAR OLECHAR; +alias OLECHAR *LPOLESTR; +alias OLECHAR *LPCOLESTR; + +enum +{ + rmm = 23, // OLE 2 version number info + rup = 639, +} + +enum : int +{ + S_OK = 0, + S_FALSE = 0x00000001, + NOERROR = 0, + E_NOTIMPL = cast(int)0x80004001, + E_NOINTERFACE = cast(int)0x80004002, + E_POINTER = cast(int)0x80004003, + E_ABORT = cast(int)0x80004004, + E_FAIL = cast(int)0x80004005, + E_HANDLE = cast(int)0x80070006, + CLASS_E_NOAGGREGATION = cast(int)0x80040110, + E_OUTOFMEMORY = cast(int)0x8007000E, + E_INVALIDARG = cast(int)0x80070057, + E_UNEXPECTED = cast(int)0x8000FFFF, +} + +// in tango types.di +// struct GUID { // size is 16 +// align(1): +// DWORD Data1; +// WORD Data2; +// WORD Data3; +// BYTE Data4[8]; +// } + +enum +{ + 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_INPROC = (CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER), + CLSCTX_ALL = (CLSCTX_INPROC_SERVER| CLSCTX_INPROC_HANDLER| CLSCTX_LOCAL_SERVER), + CLSCTX_SERVER = (CLSCTX_INPROC_SERVER|CLSCTX_LOCAL_SERVER), +} + +alias GUID IID; +alias GUID CLSID; + +extern (C) +{ + extern IID IID_IUnknown; + extern IID IID_IClassFactory; + extern IID IID_IMarshal; + extern IID IID_IMallocSpy; + extern IID IID_IStdMarshalInfo; + extern IID IID_IExternalConnection; + extern IID IID_IMultiQI; + extern IID IID_IEnumUnknown; + extern IID IID_IBindCtx; + extern IID IID_IEnumMoniker; + extern IID IID_IRunnableObject; + extern IID IID_IRunningObjectTable; + extern IID IID_IPersist; + extern IID IID_IPersistStream; + extern IID IID_IMoniker; + extern IID IID_IROTData; + extern IID IID_IEnumString; + extern IID IID_ISequentialStream; + extern IID IID_IStream; + extern IID IID_IEnumSTATSTG; + extern IID IID_IStorage; + extern IID IID_IPersistFile; + extern IID IID_IPersistStorage; + extern IID IID_ILockBytes; + extern IID IID_IEnumFORMATETC; + extern IID IID_IEnumSTATDATA; + extern IID IID_IRootStorage; + extern IID IID_IAdviseSink; + extern IID IID_IAdviseSink2; + extern IID IID_IDataObject; + extern IID IID_IDataAdviseHolder; + extern IID IID_IMessageFilter; + extern IID IID_IRpcChannelBuffer; + extern IID IID_IRpcProxyBuffer; + extern IID IID_IRpcStubBuffer; + extern IID IID_IPSFactoryBuffer; + extern IID IID_IPropertyStorage; + extern IID IID_IPropertySetStorage; + extern IID IID_IEnumSTATPROPSTG; + extern IID IID_IEnumSTATPROPSETSTG; + extern IID IID_IFillLockBytes; + extern IID IID_IProgressNotify; + extern IID IID_ILayoutStorage; + extern IID GUID_NULL; + extern IID IID_IRpcChannel; + extern IID IID_IRpcStub; + extern IID IID_IStubManager; + extern IID IID_IRpcProxy; + extern IID IID_IProxyManager; + extern IID IID_IPSFactory; + extern IID IID_IInternalMoniker; + extern IID IID_IDfReserved1; + extern IID IID_IDfReserved2; + extern IID IID_IDfReserved3; + extern IID IID_IStub; + extern IID IID_IProxy; + extern IID IID_IEnumGeneric; + extern IID IID_IEnumHolder; + extern IID IID_IEnumCallback; + extern IID IID_IOleManager; + extern IID IID_IOlePresObj; + extern IID IID_IDebug; + extern IID IID_IDebugStream; + extern IID IID_StdOle; + extern IID IID_ICreateTypeInfo; + extern IID IID_ICreateTypeInfo2; + extern IID IID_ICreateTypeLib; + extern IID IID_ICreateTypeLib2; + extern IID IID_IDispatch; + extern IID IID_IEnumVARIANT; + extern IID IID_ITypeComp; + extern IID IID_ITypeInfo; + extern IID IID_ITypeInfo2; + extern IID IID_ITypeLib; + extern IID IID_ITypeLib2; + extern IID IID_ITypeChangeEvents; + extern IID IID_IErrorInfo; + extern IID IID_ICreateErrorInfo; + extern IID IID_ISupportErrorInfo; + extern IID IID_IOleAdviseHolder; + extern IID IID_IOleCache; + extern IID IID_IOleCache2; + extern IID IID_IOleCacheControl; + extern IID IID_IParseDisplayName; + extern IID IID_IOleContainer; + extern IID IID_IOleClientSite; + extern IID IID_IOleObject; + extern IID IID_IOleWindow; + extern IID IID_IOleLink; + extern IID IID_IOleItemContainer; + extern IID IID_IOleInPlaceUIWindow; + extern IID IID_IOleInPlaceActiveObject; + extern IID IID_IOleInPlaceFrame; + extern IID IID_IOleInPlaceObject; + extern IID IID_IOleInPlaceSite; + extern IID IID_IContinue; + extern IID IID_IViewObject; + extern IID IID_IViewObject2; + extern IID IID_IDropSource; + extern IID IID_IDropTarget; + extern IID IID_IEnumOLEVERB; +} + +extern (Windows) export { + DWORD CoBuildVersion(); + + int StringFromGUID2(GUID *rguid, LPOLESTR lpsz, int cbMax); + + /* init/uninit */ + + HRESULT CoInitialize(LPVOID pvReserved); + void CoUninitialize(); + DWORD CoGetCurrentProcess(); + + + HRESULT CoCreateInstance(CLSID *rclsid, IUnknown UnkOuter, + DWORD dwClsContext, IID* riid, void* ppv); + + //HINSTANCE CoLoadLibrary(LPOLESTR lpszLibName, BOOL bAutoFree); + void CoFreeLibrary(HINSTANCE hInst); + void CoFreeAllLibraries(); + void CoFreeUnusedLibraries(); + + interface IUnknown { + HRESULT QueryInterface(IID* riid, void** pvObject); + ULONG AddRef(); + ULONG Release(); + } + + interface IClassFactory : IUnknown { + HRESULT CreateInstance(IUnknown UnkOuter, IID* riid, void** pvObject); + HRESULT LockServer(BOOL fLock); + } + +} + + +alias IUnknown LPUNKNOWN; +alias IClassFactory LPCLASSFACTORY; + +//alias LPRECT LPCRECT; /* D has no consts */ +struct COAUTHINFO{} +//alias DWORD LCID; +alias PDWORD PLCID; +//typedef GUID CLSID; +//alias CLSID * LPCLSID; +alias GUID *REFGUID; + +alias IID *REFIID; + +alias CLSID *REFCLSID; + +//typedef FMTID *REFFMTID; +union __MIDL_IWinTypes_0001 +{ +DWORD dwValue; +wchar *pwszName; +} +struct userCLIPFORMAT +{ + long fContext; + __MIDL_IWinTypes_0001 u; +} + +alias userCLIPFORMAT *wireCLIPFORMAT; + +alias WORD CLIPFORMAT; + +alias void * HMETAFILEPICT; +// typeless hack +alias void * wireHGLOBAL; +alias void * wireHBITMAP; +alias void * wireHPALETTE; +alias void * wireHENHMETAFILE; +alias void * wireHMETAFILE; +alias void * wireHMETAFILEPICT; + +struct BYTE_BLOB { + ULONG clSize; + byte[1] abData; +} + +alias BYTE_BLOB *UP_BYTE_BLOB; + +struct WORD_BLOB +{ + ULONG clSize; + ushort[1] asData; +} + +alias WORD_BLOB *UP_WORD_BLOB; + +struct DWORD_BLOB +{ + ULONG clSize; + ULONG[1] alData; +} +alias DWORD_BLOB *UP_DWORD_BLOB; +alias ushort VARTYPE; +alias short VARIANT_BOOL; + +// all the st +enum READYSTATE + { READYSTATE_UNINITIALIZED = 0, + READYSTATE_LOADING = 1, + READYSTATE_LOADED = 2, + READYSTATE_INTERACTIVE = 3, + READYSTATE_COMPLETE = 4 +} + +alias HANDLE HTASK; \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/ole/win32/ifs.d Fri Feb 08 19:49:32 2008 +0100 @@ -0,0 +1,257 @@ +/* + * extra interface not define in any other modules, copied from MSDN 2003 + * don't import this module directly, import std.internal.ole.win32.com instead + * + * author : Shawn Liu + */ + +module dwt.internal.ole.win32.ifs; + +private import dwt.DWT; +private import dwt.internal.win32.WINTYPES; +private import dwt.internal.ole.win32.COM; +//private import std.c.windows.windows; +//private import std.c.windows.com; +private import dwt.internal.ole.win32.COMTYPES; +private import dwt.internal.ole.win32.OAIDL; +private import dwt.internal.ole.win32.OBJIDL; +private import dwt.internal.ole.win32.OLEIDL; +private import dwt.internal.ole.win32.DOCOBJ; +private import dwt.internal.ole.win32.EXDISP; +private import dwt.internal.ole.win32.MSHTMHST; +private import dwt.internal.ole.win32.extras; + + +interface IAccessible : IDispatch { +// int GetTypeInfoCount(int pctinfo); +// int GetTypeInfo(THIS_ UINT itinfo, LCID lcid, ITypeInfo FAR* FAR* pptinfo); +// int GetIDsOfNames - not implemented +// int Invoke - not implemented + HRESULT get_accParent(LPDISPATCH* ppdispParent); + HRESULT get_accChildCount(LONG* pcountChildren); + HRESULT get_accChild(VARIANT varChildID, LPDISPATCH* ppdispChild); + HRESULT get_accName(VARIANT varID, BSTR* pszName); + HRESULT get_accValue(VARIANT varID, BSTR* pszValue); + HRESULT get_accDescription(VARIANT varID,BSTR* pszDescription); + HRESULT get_accRole(VARIANT varID, VARIANT* pvarRole); + HRESULT get_accState(VARIANT varID, VARIANT* pvarState); + HRESULT get_accHelp(VARIANT varID, BSTR* pszHelp); + HRESULT get_accHelpTopic(BSTR* pszHelpFile, VARIANT varChild, LONG* pidTopic); + HRESULT get_accKeyboardShortcut(VARIANT varID, BSTR* pszKeyboardShortcut); + HRESULT get_accFocus(VARIANT* pvarID); + HRESULT get_accSelection(VARIANT* pvarChildren); + HRESULT get_accDefaultAction(VARIANT varID,BSTR* pszDefaultAction); + HRESULT accSelect(LONG flagsSelect, VARIANT varID); + HRESULT accLocation(LONG* pxLeft, LONG* pyTop, LONG* pcxWidth, LONG* pcyHeight, VARIANT varID); + HRESULT accNavigate(LONG navDir, VARIANT varStart, VARIANT* pvarEnd); + HRESULT accHitTest(LONG xLeft, LONG yTop, VARIANT* pvarID); + HRESULT accDoDefaultAction(VARIANT varID); + HRESULT put_accName(VARIANT varID, BSTR* szName); + HRESULT put_accValue(VARIANT varID, BSTR* szValue); +} +alias IAccessible LPACCESSIBLE; + +interface IClassFactory2 : IClassFactory +{ + HRESULT GetLicInfo(LICINFO * pLicInfo); + HRESULT RequestLicKey(DWORD dwReserved, BSTR * pbstrKey); + HRESULT CreateInstanceLic(LPUNKNOWN pUnkOuter, LPUNKNOWN pUnkReserved, REFIID riid, BSTR bstrKey, void ** ppvObject); +} +alias IClassFactory2 LPCLASSFACTORY2; + + +interface IConnectionPoint : IUnknown +{ + HRESULT GetConnectionInterface(IID * pIID); + HRESULT GetConnectionPointContainer(LPCONNECTIONPOINTCONTAINER * ppCPC); + HRESULT Advise(LPUNKNOWN pUnk, DWORD * pdwCookie); + HRESULT Unadvise(DWORD dwCookie); + HRESULT EnumConnections(LPENUMCONNECTIONS * ppEnum); +} +alias IConnectionPoint LPCONNECTIONPOINT; + + +interface IConnectionPointContainer : IUnknown +{ + HRESULT EnumConnectionPoints(LPENUMCONNECTIONPOINTS * ppEnum); + HRESULT FindConnectionPoint(REFIID riid, LPCONNECTIONPOINT * ppCP); +} +alias IConnectionPointContainer LPCONNECTIONPOINTCONTAINER; + +interface IEnumConnectionPoints : IUnknown +{ + HRESULT Next(ULONG celt, LPCONNECTIONPOINT * rgelt, ULONG * pceltFetched); + HRESULT Skip(ULONG celt); + HRESULT Reset(); + HRESULT Clone(LPENUMCONNECTIONPOINTS * ppenum); +} +alias IEnumConnectionPoints LPENUMCONNECTIONPOINTS; + +interface IEnumConnections : IUnknown { + HRESULT Next(ULONG cConnections, CONNECTDATA ** rgpcd, ULONG * pcFetched); + HRESULT Skip(ULONG cConnections); + HRESULT Reset(); + HRESULT Clone(LPENUMCONNECTIONS * ppEnum); +}alias IEnumConnections LPENUMCONNECTIONS; + +interface IEnumVARIANT : IUnknown { + HRESULT Next(ULONG celt, VARIANT *rgelt, ULONG *pceltFetched); + HRESULT Skip(ULONG celt); + HRESULT Reset(); + HRESULT Clone(LPENUMVARIANT * ppenum); +} +alias IEnumVARIANT LPENUMVARIANT; + + +interface IInternetSecurityManager : IUnknown { + HRESULT SetSecuritySite(LPINTERNETSECURITYMGRSITE pSite); + HRESULT GetSecuritySite(LPINTERNETSECURITYMGRSITE *ppSite); + HRESULT MapUrlToZone(LPCWSTR pwszUrl, DWORD *pdwZone, DWORD dwFlags); + HRESULT GetSecurityId(LPCWSTR pwszUrl, BYTE *pbSecurityId, DWORD *pcbSecurityId, DWORD_PTR dwReserved); + HRESULT ProcessUrlAction(LPCWSTR pwszUrl, DWORD dwAction, BYTE *pPolicy, DWORD cbPolicy, BYTE *pContext, DWORD cbContext, DWORD dwFlags, DWORD dwReserved); + HRESULT QueryCustomPolicy(LPCWSTR pwszUrl, REFGUID guidKey, BYTE **ppPolicy, DWORD *pcbPolicy, BYTE *pContext, DWORD cbContext, DWORD dwReserved); + HRESULT SetZoneMapping(DWORD dwZone, LPCWSTR lpszPattern, DWORD dwFlags); + HRESULT GetZoneMappings(DWORD dwZone, LPENUMSTRING * ppenumString, DWORD dwFlags); +} +interface IInternetSecurityMgrSite : IUnknown { + HRESULT EnableModeless(BOOL fEnable); + HRESULT GetWindow(HWND *phwnd); +} +alias IInternetSecurityMgrSite LPINTERNETSECURITYMGRSITE; + +interface IOleControl : IUnknown +{ + HRESULT GetControlInfo(CONTROLINFO* pCI); + HRESULT OnMnemonic(LPMSG pMsg); + HRESULT OnAmbientPropertyChange(DISPID dispID); + HRESULT FreezeEvents(BOOL bFreeze); +} +alias IOleControl LPOLECONTROL; + + +interface IOleControlSite : IUnknown { + HRESULT OnControlInfoChanged(); + HRESULT LockInPlaceActive( + BOOL fLock //Indicates whether to ensure the active state + ); + HRESULT GetExtendedControl( + LPDISPATCH* ppDisp //Address of output variable that receives the + // IDispatch interface pointer + ); + HRESULT TransformCoords( + POINTL* pPtlHimetric , //Address of POINTL structure + POINTF* pPtfContainer , //Address of POINTF structure + DWORD dwFlags //Flags indicating the exact conversion + ); + HRESULT TranslateAccelerator( + LPMSG pMsg , //Pointer to the structure + DWORD grfModifiers //Flags describing the state of the keys + ); + HRESULT OnFocus( + BOOL fGotFocus //Indicates whether the control gained focus + ); + HRESULT ShowPropertyFrame(); +} +alias IOleControlSite LPOLECONTROLSITE; + + +interface IPersistStreamInit : IPersist { + HRESULT IsDirty(); + HRESULT Load(LPSTREAM pStm); + HRESULT Save(LPSTREAM pStm, BOOL fClearDirty); + HRESULT GetSizeMax(ULARGE_INTEGER * pcbSize); + HRESULT InitNew(); +} + +interface IPropertyNotifySink : IUnknown { + HRESULT OnChanged(DISPID dispID); + HRESULT OnRequestEdit(DISPID dispID); +} +alias IPropertyNotifySink LPPROPERTYNOTIFYSINK; + +interface IProvideClassInfo : IUnknown +{ + HRESULT GetClassInfo(LPTYPEINFO * ppTI); +} +alias IProvideClassInfo LPPROVIDECLASSINFO; + +interface IProvideClassInfo2 : IProvideClassInfo +{ + HRESULT GetGUID(DWORD dwGuidKind, GUID * pGUID); +} +alias IProvideClassInfo2 LPPROVIDECLASSINFO2; + + +/* +interface IDocHostUIHandler : IUnknown +{ + int ShowContextMenu( int dwID, POINT* ppt, ComObj pcmdtReserved, ComObj pdispReserved); + int GetHostInfo( int pInfo ); + int ShowUI( int dwID, ComObj pActiveObject, ComObj pCommandTarget, ComObj pFrame, ComObj pDoc ); + int HideUI(); + int UpdateUI(); + int EnableModeless( int fEnable ); + int OnDocWindowActivate( int fActivate ); + int OnFrameWindowActivate( int fActivate ); + int ResizeBorder( RECT* prcBorder, ComObj pUIWindow, int fRameWindow ); + int TranslateAccelerator( int lpMsg, int pguidCmdGroup, int nCmdID ); + int GetOptionKeyPath( int pchKey, int dw ); + int GetDropTarget( ComObj pDropTarget, ComObj* ppDropTarget ); + int GetExternal( ComObj** ppDispatch ); + int TranslateUrl( int dwTranslate, int pchURLIn, int ppchURLOut ); + int FilterDataObject( ComObj pDO, ComObj* ppDORet ); +} + +interface IDocHostShowUI : IUnknown +{ + int ShowMessage( HWND hwnd, wchar* lpstrText, int lpstrCaption, int dwType, int lpstrHelpFile, int dwHelpContext, int plResult); + int ShowHelp( HWND hwnd, int pszHelpFile, int uCommand, int dwData, long ptMouse, ComObj pDispatchObjectHit ); +} +*/ +interface IServiceProvider : IUnknown { + HRESULT QueryService(REFGUID guidService, REFIID riid, void **ppv); +} +alias IServiceProvider LPSERVICEPROVIDER; + +interface ISpecifyPropertyPages : IUnknown { + HRESULT GetPages( + CAUUID *pPages //Pointer to structure + ); +} +alias ISpecifyPropertyPages LPSPECIFYPROPERTYPAGES; + + + + + + + +/* +interface IEnumFORMATETC : IEnumXXXX {} + + +interface IDataObject : IUnknown { + int GetData(int pFormatetc, int pmedium); + int GetDataHere(FORMATETC* pFormatetc, STGMEDIUM* pmedium); + int QueryGetData(FORMATETC* pFormatetc); + int GetCanonicalFormatEtc(int pFormatetcIn, int pFormatetcOut); + int SetData(int pFormatetc, int pmedium, int fRelease); + int EnumFormatEtc(int dwDirection, int ppenumFormatetc); + int DAdvise(int pFormatetc, int advf, int pAdvSink, int pdwConnection); + int DUnadvise(int dwConnection); + int EnumDAdvise(ComObj* ppenumAdvise); +} + +interface IDropSource : IUnknown { + int QueryContinueDrag(int fEscapePressed, int grfKeyState); + int GiveFeedback(int dwEffect); +} + +interface IDropTarget : IUnknown { + // NOTE : POINT* is splited to pt_x, pt_y + int DragEnter(ComObj pDataObject, int grfKeyState, int pt_x, int pt_y, int pdwEffect); + int DragOver(int grfKeyState, int pt_x, int pt_y, int pdwEffect); + int DragLeave(); + int Drop(ComObj pDataObject, int grfKeyState, int pt_x, int pt_y, int pdwEffect); +} +*/ \ No newline at end of file
--- a/dwt/internal/win32/OS.d Fri Feb 08 11:57:24 2008 +0100 +++ b/dwt/internal/win32/OS.d Fri Feb 08 19:49:32 2008 +0100 @@ -4014,6 +4014,7 @@ alias WINAPI.RegQueryValueExA RegQueryValueEx; alias WINAPI.RegisterClassA RegisterClass; alias WINAPI.RegisterClipboardFormatA RegisterClipboardFormat; + alias WINAPI.RegOpenKeyExA RegOpenKeyEx; alias WINAPI.RegisterWindowMessageA RegisterWindowMessage; alias STDWIN.RemovePropA RemoveProp; alias WINAPI.SHBrowseForFolderA SHBrowseForFolder; @@ -4112,6 +4113,7 @@ alias WINAPI.RegQueryValueExW RegQueryValueEx; alias WINAPI.RegisterClassW RegisterClass; alias WINAPI.RegisterClipboardFormatW RegisterClipboardFormat; + alias WINAPI.RegOpenKeyExW RegOpenKeyEx; alias WINAPI.RegisterWindowMessageW RegisterWindowMessage; alias STDWIN.RemovePropW RemoveProp; alias WINAPI.SHBrowseForFolderW SHBrowseForFolder;
--- a/dwt/internal/win32/WINTYPES.d Fri Feb 08 11:57:24 2008 +0100 +++ b/dwt/internal/win32/WINTYPES.d Fri Feb 08 19:49:32 2008 +0100 @@ -14,12 +14,11 @@ alias OPENFILENAME OPENFILENAMEA; alias WNDCLASS_T WNDCLASS; -alias TCLSID *REFCLSID; +//alias TCLSID *REFCLSID; -interface IUnknown{ -} +//interface IUnknown{} +//alias IUnknown LPUNKNOWN; -alias IUnknown LPUNKNOWN; struct SCRIPT_DIGITSUBSTITUTE { ushort NationalDigitLanguage;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/ole/win32/OLE.d Fri Feb 08 19:49:32 2008 +0100 @@ -0,0 +1,442 @@ +/******************************************************************************* + * Copyright (c) 2000, 2007 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +module dwt.ole.win32.OLE; + +import dwt.dwthelper.File; + +import dwt.DWT; +import dwt.DWTError; +import dwt.DWTException; +import dwt.internal.ole.win32.COM; +import dwt.internal.win32.OS; + +import dwt.dwthelper.utils; +import tango.util.Convert; +/** + * + * OLE contains all the constants used to create an ActiveX Control or an OLE Document. + * + * <p>Definitions for these constants can be found in MSDN. + * + */ +public class OLE : DWT { + + public static const int S_FALSE = 1; // Used for functions that semantically return a bool FALSE result to indicate that the function succeeded. + public static const int S_OK = 0; // Function succeeded. + public static const int E_FAIL = -2147467259; // Unspecified failure. + public static const int E_INVALIDARG = -2147024809; // Invalid argument + public static const int E_NOINTERFACE = -2147467262; // QueryInterface did not recognize the requested interface. + public static const int E_NOTIMPL = -2147467263; // Not implemented + + public static const char[] IID_IUNKNOWN = "{00000000-0000-0000-C000-000000000046}"; //$NON-NLS-1$ + public static const char[] IID_IDISPATCH = "{00020400-0000-0000-C000-000000000046}"; //$NON-NLS-1$ + + // Verbs that can be invoked on this client + public static const int OLEIVERB_DISCARDUNDOSTATE = -6; // close the OLE object and discard the undo state + public static const int OLEIVERB_HIDE = -3; // hide the OLE object + public static const int OLEIVERB_INPLACEACTIVATE = -5; // open the OLE for editing in-place + public static const int OLEIVERB_OPEN = -2; // open the OLE object for editing in a separate window + public static const int OLEIVERB_PRIMARY = 0; // opens the OLE object for editing + public static const int OLEIVERB_PROPERTIES = -7; // request the OLE object properties dialog + public static const int OLEIVERB_SHOW = -1; // show the OLE object + public static const int OLEIVERB_UIACTIVATE = -4; // activate the UI for the OLE object + + public static const int PROPERTY_CHANGING = 0; + public static const int PROPERTY_CHANGED = 1; + + /** + * Error code for OleError - No specific error information available + */ + public static const int HRESULT_UNSPECIFIED = 0; + /** + * Error code for OleError - Failed to create file + */ + public static const int ERROR_CANNOT_CREATE_FILE = 1000; + /** + * Error code for OleError - Failed to create Ole Client + */ + public static const int ERROR_CANNOT_CREATE_OBJECT = 1001; + /** + * Error code for OleError - File does not exist, is not accessible to user or does not have the correct format + */ + public static const int ERROR_CANNOT_OPEN_FILE = 1002; + /** + * Error code for OleError - Failed to find requested interface on OLE Object + */ + public static const int ERROR_INTERFACE_NOT_FOUND = 1003; + /** + * Error code for OleError - Class ID not found in registry + */ + public static const int ERROR_INVALID_CLASSID = 1004; + /** + * Error code for OleError - Failed to get the class factory for the specified classID + */ + public static const int ERROR_CANNOT_ACCESS_CLASSFACTORY = 1005; + /** + * Error code for OleError - Failed to create Licensed instance + */ + public static const int ERROR_CANNOT_CREATE_LICENSED_OBJECT = 1006; + /** + * Error code for OleError - Out of Memory + */ + public static const int ERROR_OUT_OF_MEMORY = 1007; + /** + * Error code for OleError - Failed to change Variant type + */ + public static const int ERROR_CANNOT_CHANGE_VARIANT_TYPE = 1010; + /** + * Error code for OleError - Invalid address received for Ole Interface + */ + public static const int ERROR_INVALID_INTERFACE_ADDRESS = 1011; + /** + * Error code for OleError - Unable to find Application + */ + public static const int ERROR_APPLICATION_NOT_FOUND = 1013; + /** + * Error code for OleError - Action can not be performed + */ + public static const int ERROR_ACTION_NOT_PERFORMED = 1014; + + public static const int OLECMDF_SUPPORTED = 1; + public static const int OLECMDF_ENABLED = 2; + public static const int OLECMDF_LATCHED = 4; + public static const int OLECMDF_NINCHED = 8; + + public static const int OLECMDTEXTF_NONE = 0; + public static const int OLECMDTEXTF_NAME = 1; + public static const int OLECMDTEXTF_STATUS = 2; + + public static const int OLECMDEXECOPT_DODEFAULT = 0; + public static const int OLECMDEXECOPT_PROMPTUSER = 1; + public static const int OLECMDEXECOPT_DONTPROMPTUSER = 2; + public static const int OLECMDEXECOPT_SHOWHELP = 3; + + public static const int OLECMDID_OPEN = 1; + public static const int OLECMDID_NEW = 2; + public static const int OLECMDID_SAVE = 3; + public static const int OLECMDID_SAVEAS = 4; + public static const int OLECMDID_SAVECOPYAS = 5; + public static const int OLECMDID_PRINT = 6; + public static const int OLECMDID_PRINTPREVIEW = 7; + public static const int OLECMDID_PAGESETUP = 8; + public static const int OLECMDID_SPELL = 9; + public static const int OLECMDID_PROPERTIES = 10; + public static const int OLECMDID_CUT = 11; + public static const int OLECMDID_COPY = 12; + public static const int OLECMDID_PASTE = 13; + public static const int OLECMDID_PASTESPECIAL = 14; + public static const int OLECMDID_UNDO = 15; + public static const int OLECMDID_REDO = 16; + public static const int OLECMDID_SELECTALL = 17; + public static const int OLECMDID_CLEARSELECTION = 18; + public static const int OLECMDID_ZOOM = 19; + public static const int OLECMDID_GETZOOMRANGE = 20; + public static const int OLECMDID_UPDATECOMMANDS = 21; + public static const int OLECMDID_REFRESH = 22; + public static const int OLECMDID_STOP = 23; + public static const int OLECMDID_HIDETOOLBARS = 24; + public static const int OLECMDID_SETPROGRESSMAX = 25; + public static const int OLECMDID_SETPROGRESSPOS = 26; + public static const int OLECMDID_SETPROGRESSTEXT = 27; + public static const int OLECMDID_SETTITLE = 28; + public static const int OLECMDID_SETDOWNLOADSTATE = 29; + public static const int OLECMDID_STOPDOWNLOAD = 30; + + /* Ole Property Description flags */ + public static int VARFLAG_FREADONLY = 0x1; + public static int VARFLAG_FSOURCE = 0x2; + public static int VARFLAG_FBINDABLE = 0x4; + public static int VARFLAG_FREQUESTEDIT = 0x8; + public static int VARFLAG_FDISPLAYBIND = 0x10; + public static int VARFLAG_FDEFAULTBIND = 0x20; + public static int VARFLAG_FHIDDEN = 0x40; + public static int VARFLAG_FRESTRICTED = 0x80; + public static int VARFLAG_FDEFAULTCOLLELEM = 0x100; + public static int VARFLAG_FUIDEFAULT = 0x200; + public static int VARFLAG_FNONBROWSABLE = 0x400; + public static int VARFLAG_FREPLACEABLE = 0x800; + public static int VARFLAG_FIMMEDIATEBIND = 0x1000; + + /* Ole Property Description kind */ + public static int VAR_PERINSTANCE = 0; + public static int VAR_STATIC = 1; + public static int VAR_CONST = 2; + public static int VAR_DISPATCH = 3; + + /* Ole Parameter Description flags */ + public static short IDLFLAG_NONE = 0; + public static short IDLFLAG_FIN = 1; + public static short IDLFLAG_FOUT = 2; + public static short IDLFLAG_FLCID = 4; + public static short IDLFLAG_FRETVAL = 8; + + /* Ole Description types */ + public static const short VT_BOOL = 11; // bool; True=-1, False=0. + public static const short VT_BSTR = 8; // Binary String. + public static const short VT_BYREF = 16384; // By reference - must be combined with one of the other VT values + public static const short VT_CY = 6; // Currency. + public static const short VT_DATE = 7; // Date. + public static const short VT_DISPATCH = 9; // IDispatch + public static const short VT_EMPTY = 0; // Not specified. + public static const short VT_ERROR = 10; // Scodes. + public static const short VT_I2 = 2; // 2-byte signed int. + public static const short VT_I4 = 3; // 4-byte signed int. + public static const short VT_NULL = 1; // Null. + public static const short VT_R4 = 4; // 4-byte real. + public static const short VT_R8 = 5; // 8-byte real. + public static const short VT_UI1 = 17; // Unsigned char. + public static const short VT_UI4 = 19; // Unsigned int. + public static const short VT_UNKNOWN = 13; // IUnknown FAR*. + public static const short VT_VARIANT = 12; // VARIANT FAR*. + public static const short VT_PTR = 26; + public static const short VT_USERDEFINED = 29; + public static const short VT_HRESULT = 25; + public static const short VT_DECIMAL = 14; + public static const short VT_I1 = 16; + public static const short VT_UI2 = 18; + public static const short VT_I8 = 20; + public static const short VT_UI8 = 21; + public static const short VT_INT = 22; + public static const short VT_UINT = 23; + public static const short VT_VOID = 24; + public static const short VT_SAFEARRAY = 27; + public static const short VT_CARRAY = 28; + public static const short VT_LPSTR = 30; + public static const short VT_LPWSTR = 31; + public static const short VT_RECORD = 36; + public static const short VT_FILETIME = 64; + public static const short VT_BLOB = 65; + public static const short VT_STREAM = 66; + public static const short VT_STORAGE = 67; + public static const short VT_STREAMED_OBJECT = 68; + public static const short VT_STORED_OBJECT = 69; + public static const short VT_BLOB_OBJECT = 70; + public static const short VT_CF = 71; + public static const short VT_CLSID = 72; + public static const short VT_VERSIONED_STREAM = 73; + public static const short VT_BSTR_BLOB = 0xfff; + public static const short VT_VECTOR = 0x1000; + public static const short VT_ARRAY = 0x2000; + + /* Ole Function Description Invoke Kind values */ + public static const int INVOKE_FUNC = 1; + public static const int INVOKE_PROPERTYGET = 2; + public static const int INVOKE_PROPERTYPUT = 4; + public static const int INVOKE_PROPERTYPUTREF = 8; + + /* Ole Function Description function kind */ + public static const int FUNC_VIRTUAL = 0; + public static const int FUNC_PUREVIRTUAL = 1; + public static const int FUNC_NONVIRTUAL = 2; + public static const int FUNC_STATIC = 3; + public static const int FUNC_DISPATCH = 4; + + /* Ole Function Description function flags */ + public static const short FUNCFLAG_FRESTRICTED = 1; + public static const short FUNCFLAG_FSOURCE = 0x2; + public static const short FUNCFLAG_FBINDABLE = 0x4; + public static const short FUNCFLAG_FREQUESTEDIT = 0x8; + public static const short FUNCFLAG_FDISPLAYBIND = 0x10; + public static const short FUNCFLAG_FDEFAULTBIND = 0x20; + public static const short FUNCFLAG_FHIDDEN = 0x40; + public static const short FUNCFLAG_FUSESGETLASTERROR = 0x80; + public static const short FUNCFLAG_FDEFAULTCOLLELEM = 0x100; + public static const short FUNCFLAG_FUIDEFAULT = 0x200; + public static const short FUNCFLAG_FNONBROWSABLE = 0x400; + public static const short FUNCFLAG_FREPLACEABLE = 0x800; + public static const short FUNCFLAG_FIMMEDIATEBIND = 0x1000; + + /* Ole Function Description calling convention */ + public static const int CC_FASTCALL = 0; + public static const int CC_CDECL = 1; + public static const int CC_MSCPASCAL = 2; + public static const int CC_PASCAL = 2; + public static const int CC_MACPASCAL = 3; + public static const int CC_STDCALL = 4; + public static const int CC_FPFASTCALL = 5; + public static const int CC_SYSCALL = 6; + public static const int CC_MPWCDECL = 7; + public static const int CC_MPWPASCAL = 8; + public static const int CC_MAX = 9; + + static const char[] ERROR_NOT_IMPLEMENTED_MSG = "Required functionality not currently supported.";//$NON-NLS-1$ + static const char[] ERROR_CANNOT_CREATE_FILE_MSG = "Failed to create file.";//$NON-NLS-1$ + static const char[] ERROR_CANNOT_CREATE_OBJECT_MSG = "Failed to create Ole Client.";//$NON-NLS-1$ + static const char[] ERROR_CANNOT_OPEN_FILE_MSG = "File does not exist, is not accessible to user or does not have the correct format.";//$NON-NLS-1$ + static const char[] ERROR_INTERFACE_NOT_FOUND_MSG = "Failed to find requested interface on OLE Object.";//$NON-NLS-1$ + static const char[] ERROR_INVALID_CLASSID_MSG = "Class ID not found in registry";//$NON-NLS-1$ + static const char[] ERROR_CANNOT_ACCESS_CLASSFACTORY_MSG = "Failed to get the class factory for the specified classID";//$NON-NLS-1$ + static const char[] ERROR_CANNOT_CREATE_LICENSED_OBJECT_MSG = "Failed to create Licensed instance";//$NON-NLS-1$ + static const char[] ERROR_OUT_OF_MEMORY_MSG = "Out of Memory";//$NON-NLS-1$ + static const char[] ERROR_CANNOT_CHANGE_VARIANT_TYPE_MSG = "Failed to change Variant type";//$NON-NLS-1$ + static const char[] ERROR_INVALID_INTERFACE_ADDRESS_MSG = "Invalid address received for Ole Interface.";//$NON-NLS-1$ + static const char[] ERROR_APPLICATION_NOT_FOUND_MSG = "Unable to find Application.";//$NON-NLS-1$ + static const char[] ERROR_ACTION_NOT_PERFORMED_MSG = "Action can not be performed.";//$NON-NLS-1$ + + +public static void error (int code) { + error (code, 0); +} +public static void error (int code, int hresult) { + + switch (code) { + /* Illegal Arguments (non-fatal) */ + case ERROR_INVALID_INTERFACE_ADDRESS :{ + throw new IllegalArgumentException (ERROR_INVALID_INTERFACE_ADDRESS_MSG); + } + + /* DWT Errors (non-fatal) */ + case ERROR_CANNOT_CREATE_FILE : { + char[] msg = ERROR_CANNOT_CREATE_FILE_MSG; + if (hresult !is 0) msg ~= " result = "~to!(char[])(hresult);//$NON-NLS-1$ + throw new DWTException (code, msg); + } + case ERROR_CANNOT_CREATE_OBJECT : { + char[] msg = ERROR_CANNOT_CREATE_OBJECT_MSG; + if (hresult !is 0) msg ~= " result = "~to!(char[])(hresult);//$NON-NLS-1$ + throw new DWTException (code, msg);//$NON-NLS-1$ + } + case ERROR_CANNOT_OPEN_FILE : { + char[] msg = ERROR_CANNOT_OPEN_FILE_MSG; + if (hresult !is 0) msg ~= " result = "~to!(char[])(hresult);//$NON-NLS-1$ + throw new DWTException (code, msg); + } + case ERROR_INTERFACE_NOT_FOUND : { + char[] msg = ERROR_INTERFACE_NOT_FOUND_MSG; + if (hresult !is 0) msg ~= " result = "~to!(char[])(hresult);//$NON-NLS-1$ + throw new DWTException (code, msg); + } + case ERROR_INVALID_CLASSID : { + char[] msg = ERROR_INVALID_CLASSID_MSG; + if (hresult !is 0) msg ~= " result = "~to!(char[])(hresult);//$NON-NLS-1$ + throw new DWTException (code, msg); + } + case ERROR_CANNOT_ACCESS_CLASSFACTORY : { + char[] msg = ERROR_CANNOT_ACCESS_CLASSFACTORY_MSG; + if (hresult !is 0) msg ~= " result = "~to!(char[])(hresult);//$NON-NLS-1$ + throw new DWTException (code, msg); + } + case ERROR_CANNOT_CREATE_LICENSED_OBJECT : { + char[] msg = ERROR_CANNOT_CREATE_LICENSED_OBJECT_MSG; + if (hresult !is 0) msg ~= " result = "~to!(char[])(hresult);//$NON-NLS-1$ + throw new DWTException (code, msg); + } + case ERROR_CANNOT_CHANGE_VARIANT_TYPE : { + char[] msg = ERROR_CANNOT_CHANGE_VARIANT_TYPE_MSG; + if (hresult !is 0) msg ~= " result = "~to!(char[])(hresult);//$NON-NLS-1$ + throw new DWTException (code, msg); + } + case ERROR_APPLICATION_NOT_FOUND : { + char[] msg = ERROR_APPLICATION_NOT_FOUND_MSG; + if (hresult !is 0) msg ~= " result = "~to!(char[])(hresult);//$NON-NLS-1$ + throw new DWTException (code, msg); + } + case ERROR_ACTION_NOT_PERFORMED : { + char[] msg = ERROR_ACTION_NOT_PERFORMED_MSG; + if (hresult !is 0) msg ~= " result = "~to!(char[])(hresult);//$NON-NLS-1$ + throw new DWTException (code, msg); + } + + /* OS Failure/Limit (fatal, may occur only on some platforms) */ + case ERROR_OUT_OF_MEMORY : { + char[] msg = ERROR_ACTION_NOT_PERFORMED_MSG; + if (hresult !is 0) msg ~= " result = "~to!(char[])(hresult); //$NON-NLS-1$ + throw new DWTError (code, msg); + } + } + + /* Unknown/Undefined Error */ + DWT.error(code); +} + +/* + * Finds the OLE program id that is associated with an extension. + * The extension may or may not begin with a '.'. On platforms + * that do not support OLE, an empty string is returned. + * + * @param extension the program extension + * @return a string that is the OLE program id or an empty string + * + * @exception IllegalArgumentException <ul> + * <li>ERROR_NULL_ARGUMENT when extension is null</li> + * </ul> + */ +public static char[] findProgramID (char[] extension) { + if (extension is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); + if (extension.length is 0) return ""; //$NON-NLS-1$ + + if (extension.charAt (0) !is '.') extension = "." ~ extension; //$NON-NLS-1$ + + /* Use the character encoding for the default locale */ + TCHAR[] extensionKey = StrToTCHARs(0, extension, true); + char[] result = getKeyValue(extensionKey); + if (result !is null) { + // look for "<programID>\NotInsertable" + TCHAR[] notInsertableKey = StrToTCHARs(0, result~"\\NotInsertable", true); //$NON-NLS-1$ + if (getKeyExists(notInsertableKey)) return ""; //$NON-NLS-1$ + // look for "<programID>\Insertable" + TCHAR[] insertableKey = StrToTCHARs(0, result~"\\Insertable", true); //$NON-NLS-1$ + if (getKeyExists(insertableKey)) return result; + // look for "<programID>\protocol\StdFileEditing\server" + TCHAR[] serverKey = StrToTCHARs(0, result~"\\protocol\\StdFileEditing\\server", true); //$NON-NLS-1$ + if (getKeyExists(serverKey)) return result; + } + + return ""; //$NON-NLS-1$ +} +static char[] getKeyValue (TCHAR[] key) { + void* [1] phkResult; + if (OS.RegOpenKeyEx (cast(void*)OS.HKEY_CLASSES_ROOT, key.ptr, 0, OS.KEY_READ, phkResult.ptr) !is 0) { + return null; + } + char[] result = null; + uint [1] lpcbData; + if (OS.RegQueryValueEx (phkResult [0], null, null, null, null, lpcbData.ptr) is 0) { + int length_ = lpcbData [0] / TCHAR.sizeof; + if (length_ is 0) { + result = ""; + } else { + /* Use the character encoding for the default locale */ + TCHAR[] lpData = NewTCHARs (0, length_); + if (OS.RegQueryValueEx (phkResult [0], null, null, null, cast(ubyte*)lpData.ptr, lpcbData.ptr) is 0) { + length_ = Math.max(0, lpData.length - 1); + result = TCHARsToStr( lpData[ 0 .. length_ ] ); + } + } + } + if (phkResult [0] !is null) OS.RegCloseKey (phkResult [0]); + return result; +} +private static bool getKeyExists (TCHAR[] key) { + void* [1] phkResult; + if (OS.RegOpenKeyEx (cast(void*)OS.HKEY_CLASSES_ROOT, key.ptr, 0, OS.KEY_READ, phkResult.ptr) !is 0) { + return false; + } + if (phkResult [0] !is null) OS.RegCloseKey (phkResult [0]); + return true; +} +/** + * Returns true if the specified file has an OLE Storage format. + * + * Note all empty files (regardless of extension) will return false. + * + * @param file the file to be checked + * + * @return true if this file has an OLE Storage format + */ +public static bool isOleFile(File file) { + if (file is null || !file.exists() || file.isDirectory()) + return false; + + return (COM.StgIsStorageFile( StrToTCHARz(file.getAbsolutePath()~"\0")) is COM.S_OK); +} + +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/ole/win32/OleAutomation.d Fri Feb 08 19:49:32 2008 +0100 @@ -0,0 +1,626 @@ +/******************************************************************************* + * Copyright (c) 2000, 2007 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +module dwt.ole.win32.OleAutomation; + + +import dwt.internal.ole.win32.COM; +import dwt.internal.ole.win32.COMTYPES; +import dwt.internal.ole.win32.OAIDL; +// import dwt.internal.ole.win32.DISPPARAMS; +// import dwt.internal.ole.win32.EXCEPINFO; +// import dwt.internal.ole.win32.FUNCDESC; +// import dwt.internal.ole.win32.GUID; +// import dwt.internal.ole.win32.IDispatch; +// import dwt.internal.ole.win32.ITypeInfo; +// import dwt.internal.ole.win32.TYPEATTR; +// import dwt.internal.ole.win32.VARDESC; +import dwt.internal.win32.OS; + +import dwt.ole.win32.OleClientSite; + + +//PORTING_TYPE +public final class OleAutomation { + this(IDispatch idispatch); + public this(OleClientSite clientSite) ; + IDispatch getAddress() ; +} + +/++ + +/** + * OleAutomation provides a generic mechanism for accessing functionality that is + * specific to a particular ActiveX Control or OLE Document. + * + * <p>The OLE Document or ActiveX Control must support the IDispatch interface in order to provide + * OleAutomation support. The additional functionality provided by the OLE Object is specified in + * its IDL file. The additional methods can either be to get property values (<code>getProperty</code>), + * to set property values (<code>setProperty</code>) or to invoke a method (<code>invoke</code> or + * <code>invokeNoReply</code>). Arguments are passed around in the form of <code>Variant</code> + * objects. + * + * <p>Here is a sample IDL fragment: + * + * <pre> + * interface IMyControl : IDispatch + * { + * [propget, id(0)] HRESULT maxFileCount([retval, out] int *c); + * [propput, id(0)] HRESULT maxFileCount([in] int c); + * [id(1)] HRESULT AddFile([in] BSTR fileName); + * }; + * </pre> + * + * <p>An example of how to interact with this extended functionality is shown below: + * + * <code><pre> + * OleAutomation automation = new OleAutomation(myControlSite); + * + * // Look up the ID of the maxFileCount parameter + * int[] rgdispid = automation.getIDsOfNames(new String[]{"maxFileCount"}); + * int maxFileCountID = rgdispid[0]; + * + * // Set the property maxFileCount to 100: + * if (automation.setProperty(maxFileCountID, new Variant(100))) { + * System.out.println("Max File Count was successfully set."); + * } + * + * // Get the new value of the maxFileCount parameter: + * Variant pVarResult = automation.getProperty(maxFileCountID); + * if (pVarResult !is null) { + * System.out.println("Max File Count is "+pVarResult.getInt()); + * } + * + * // Invoke the AddFile method + * // Look up the IDs of the AddFile method and its parameter + * rgdispid = automation.getIDsOfNames(new String[]{"AddFile", "fileName"}); + * int dispIdMember = rgdispid[0]; + * int[] rgdispidNamedArgs = new int[] {rgdispid[1]}; + * + * // Convert arguments to Variant objects + * Variant[] rgvarg = new Variant[1]; + * String fileName = "C:\\testfile"; + * rgvarg[0] = new Variant(fileName); + * + * // Call the method + * Variant pVarResult = automation.invoke(dispIdMember, rgvarg, rgdispidNamedArgs); + * + * // Check the return value + * if (pVarResult is null || pVarResult.getInt() !is OLE.S_OK){ + * System.out.println("Failed to add file "+fileName); + * } + * + * automation.dispose(); + * + * </pre></code> + */ +public final class OleAutomation { + private IDispatch objIDispatch; + private String exceptionDescription; + private ITypeInfo objITypeInfo; + +this(IDispatch idispatch) { + if (idispatch is null) OLE.error(OLE.ERROR_INVALID_INTERFACE_ADDRESS); + objIDispatch = idispatch; + objIDispatch.AddRef(); + + int[] ppv = new int[1]; + int result = objIDispatch.GetTypeInfo(0, COM.LOCALE_USER_DEFAULT, ppv); + if (result is OLE.S_OK) { + objITypeInfo = new ITypeInfo(ppv[0]); + objITypeInfo.AddRef(); + } +} +/** + * Creates an OleAutomation object for the specified client. + * + * @param clientSite the site for the OLE Document or ActiveX Control whose additional functionality + * you need to access + * + * @exception IllegalArgumentException <ul> + * <li>ERROR_INVALID_INTERFACE_ADDRESS when called with an invalid client site + * </ul> + */ + public this(OleClientSite clientSite) { + if (clientSite is null) OLE.error(OLE.ERROR_INVALID_INTERFACE_ADDRESS); + objIDispatch = clientSite.getAutomationObject(); + + int[] ppv = new int[1]; + int result = objIDispatch.GetTypeInfo(0, COM.LOCALE_USER_DEFAULT, ppv); + if (result is OLE.S_OK) { + objITypeInfo = new ITypeInfo(ppv[0]); + objITypeInfo.AddRef(); + } + } +/** + * Disposes the automation object. + * <p> + * This method releases the IDispatch interface on the OLE Document or ActiveX Control. + * Do not use the OleAutomation object after it has been disposed. + */ +public void dispose() { + + if (objIDispatch !is null){ + objIDispatch.Release(); + } + objIDispatch = null; + + if (objITypeInfo !is null){ + objITypeInfo.Release(); + } + objITypeInfo = null; + +} +int getAddress() { + return objIDispatch.getAddress(); +} +public String getHelpFile(int dispId) { + if (objITypeInfo is null) return null; + String[] file = new String[1]; + int rc = objITypeInfo.GetDocumentation(dispId, null, null, null, file ); + if (rc is OLE.S_OK) return file[0]; + return null; +} +public String getDocumentation(int dispId) { + if (objITypeInfo is null) return null; + String[] doc = new String[1]; + int rc = objITypeInfo.GetDocumentation(dispId, null, doc, null, null ); + if (rc is OLE.S_OK) return doc[0]; + return null; +} +public OlePropertyDescription getPropertyDescription(int index) { + if (objITypeInfo is null) return null; + int[] ppVarDesc = new int[1]; + int rc = objITypeInfo.GetVarDesc(index, ppVarDesc); + if (rc !is OLE.S_OK) return null; + VARDESC vardesc = new VARDESC(); + COM.MoveMemory(vardesc, ppVarDesc[0], VARDESC.sizeof); + + OlePropertyDescription data = new OlePropertyDescription(); + data.id = vardesc.memid; + data.name = getName(vardesc.memid); + data.type = vardesc.elemdescVar_tdesc_vt; + if (data.type is OLE.VT_PTR) { + short[] vt = new short[1]; + COM.MoveMemory(vt, vardesc.elemdescVar_tdesc_union + 4, 2); + data.type = vt[0]; + } + data.flags = vardesc.wVarFlags; + data.kind = vardesc.varkind; + data.description = getDocumentation(vardesc.memid); + data.helpFile = getHelpFile(vardesc.memid); + + objITypeInfo.ReleaseVarDesc(ppVarDesc[0]); + return data; +} +public OleFunctionDescription getFunctionDescription(int index) { + if (objITypeInfo is null) return null; + int[] ppFuncDesc = new int[1]; + int rc = objITypeInfo.GetFuncDesc(index, ppFuncDesc); + if (rc !is OLE.S_OK) return null; + FUNCDESC funcdesc = new FUNCDESC(); + COM.MoveMemory(funcdesc, ppFuncDesc[0], FUNCDESC.sizeof); + + OleFunctionDescription data = new OleFunctionDescription(); + + data.id = funcdesc.memid; + data.optionalArgCount = funcdesc.cParamsOpt; + data.invokeKind = funcdesc.invkind; + data.funcKind = funcdesc.funckind; + data.flags = funcdesc.wFuncFlags; + data.callingConvention = funcdesc.callconv; + data.documentation = getDocumentation(funcdesc.memid); + data.helpFile = getHelpFile(funcdesc.memid); + + String[] names = getNames(funcdesc.memid, funcdesc.cParams + 1); + if (names.length > 0) { + data.name = names[0]; + } + data.args = new OleParameterDescription[funcdesc.cParams]; + for (int i = 0; i < data.args.length; i++) { + data.args[i] = new OleParameterDescription(); + if (names.length > i + 1) { + data.args[i].name = names[i + 1]; + } + short[] vt = new short[1]; + COM.MoveMemory(vt, funcdesc.lprgelemdescParam + i * 16 + 4, 2); + if (vt[0] is OLE.VT_PTR) { + int[] pTypedesc = new int[1]; + COM.MoveMemory(pTypedesc, funcdesc.lprgelemdescParam + i * 16, 4); + short[] vt2 = new short[1]; + COM.MoveMemory(vt2, pTypedesc[0] + 4, 2); + vt[0] = (short)(vt2[0] | COM.VT_BYREF); + } + data.args[i].type = vt[0]; + short[] wParamFlags = new short[1]; + COM.MoveMemory(wParamFlags, funcdesc.lprgelemdescParam + i * 16 + 12, 2); + data.args[i].flags = wParamFlags[0]; + } + + data.returnType = funcdesc.elemdescFunc_tdesc_vt; + if (data.returnType is OLE.VT_PTR) { + short[] vt = new short[1]; + COM.MoveMemory(vt, funcdesc.elemdescFunc_tdesc_union + 4, 2); + data.returnType = vt[0]; + } + + objITypeInfo.ReleaseFuncDesc(ppFuncDesc[0]); + return data; +} +public TYPEATTR getTypeInfoAttributes() { + if (objITypeInfo is null) return null; + int[] ppTypeAttr = new int[1]; + int rc = objITypeInfo.GetTypeAttr(ppTypeAttr); + if (rc !is OLE.S_OK) return null; + TYPEATTR typeattr = new TYPEATTR(); + COM.MoveMemory(typeattr, ppTypeAttr[0], TYPEATTR.sizeof); + objITypeInfo.ReleaseTypeAttr(ppTypeAttr[0]); + return typeattr; +} +public String getName(int dispId) { + if (objITypeInfo is null) return null; + String[] name = new String[1]; + int rc = objITypeInfo.GetDocumentation(dispId, name, null, null, null ); + if (rc is OLE.S_OK) return name[0]; + return null; +} +public String[] getNames(int dispId, int maxSize) { + if (objITypeInfo is null) return new String[0]; + String[] names = new String[maxSize]; + int[] count = new int[1]; + int rc = objITypeInfo.GetNames(dispId, names, maxSize, count); + if (rc is OLE.S_OK) { + String[] newNames = new String[count[0]]; + System.arraycopy(names, 0, newNames, 0, count[0]); + return newNames; + } + return new String[0]; +} +/** + * Returns the positive integer values (IDs) that are associated with the specified names by the + * IDispatch implementor. If you are trying to get the names of the parameters in a method, the first + * String in the names array must be the name of the method followed by the names of the parameters. + * + * @param names an array of names for which you require the identifiers + * + * @return positive integer values that are associated with the specified names in the same + * order as the names where provided; or null if the names are unknown + */ +public int[] getIDsOfNames(String[] names) { + + int[] rgdispid = new int[names.length]; + int result = objIDispatch.GetIDsOfNames(new GUID(), names, names.length, COM.LOCALE_USER_DEFAULT, rgdispid); + if (result !is COM.S_OK) return null; + + return rgdispid; +} +/** + * Returns a description of the last error encountered. + * + * @return a description of the last error encountered + */ +public String getLastError() { + + return exceptionDescription; + +} +/** + * Returns the value of the property specified by the dispIdMember. + * + * @param dispIdMember the ID of the property as specified by the IDL of the ActiveX Control; the + * value for the ID can be obtained using OleAutomation.getIDsOfNames + * + * @return the value of the property specified by the dispIdMember or null + */ +public Variant getProperty(int dispIdMember) { + Variant pVarResult = new Variant(); + int result = invoke(dispIdMember, COM.DISPATCH_PROPERTYGET, null, null, pVarResult); + return (result is OLE.S_OK) ? pVarResult : null; +} +/** + * Returns the value of the property specified by the dispIdMember. + * + * @param dispIdMember the ID of the property as specified by the IDL of the ActiveX Control; the + * value for the ID can be obtained using OleAutomation.getIDsOfNames + * + * @param rgvarg an array of arguments for the method. All arguments are considered to be + * read only unless the Variant is a By Reference Variant type. + * + * @return the value of the property specified by the dispIdMember or null + * + * @since 2.0 + */ +public Variant getProperty(int dispIdMember, Variant[] rgvarg) { + Variant pVarResult = new Variant(); + int result = invoke(dispIdMember, COM.DISPATCH_PROPERTYGET, rgvarg, null, pVarResult); + return (result is OLE.S_OK) ? pVarResult : null; + +} +/** + * Returns the value of the property specified by the dispIdMember. + * + * @param dispIdMember the ID of the property as specified by the IDL of the ActiveX Control; the + * value for the ID can be obtained using OleAutomation.getIDsOfNames + * + * @param rgvarg an array of arguments for the method. All arguments are considered to be + * read only unless the Variant is a By Reference Variant type. + * + * @param rgdispidNamedArgs an array of identifiers for the arguments specified in rgvarg; the + * parameter IDs must be in the same order as their corresponding values; + * all arguments must have an identifier - identifiers can be obtained using + * OleAutomation.getIDsOfNames + * + * @return the value of the property specified by the dispIdMember or null + * + * @since 2.0 + */ +public Variant getProperty(int dispIdMember, Variant[] rgvarg, int[] rgdispidNamedArgs) { + Variant pVarResult = new Variant(); + int result = invoke(dispIdMember, COM.DISPATCH_PROPERTYGET, rgvarg, rgdispidNamedArgs, pVarResult); + return (result is OLE.S_OK) ? pVarResult : null; +} + +/** + * Invokes a method on the OLE Object; the method has no parameters. + * + * @param dispIdMember the ID of the method as specified by the IDL of the ActiveX Control; the + * value for the ID can be obtained using OleAutomation.getIDsOfNames + * + * @return the result of the method or null if the method failed to give result information + */ +public Variant invoke(int dispIdMember) { + Variant pVarResult = new Variant(); + int result = invoke(dispIdMember, COM.DISPATCH_METHOD, null, null, pVarResult); + return (result is COM.S_OK) ? pVarResult : null; +} +/** + * Invokes a method on the OLE Object; the method has no optional parameters. + * + * @param dispIdMember the ID of the method as specified by the IDL of the ActiveX Control; the + * value for the ID can be obtained using OleAutomation.getIDsOfNames + * + * @param rgvarg an array of arguments for the method. All arguments are considered to be + * read only unless the Variant is a By Reference Variant type. + * + * @return the result of the method or null if the method failed to give result information + */ +public Variant invoke(int dispIdMember, Variant[] rgvarg) { + Variant pVarResult = new Variant(); + int result = invoke(dispIdMember, COM.DISPATCH_METHOD, rgvarg, null, pVarResult); + return (result is COM.S_OK) ? pVarResult : null; +} +/** + * Invokes a method on the OLE Object; the method has optional parameters. It is not + * necessary to specify all the optional parameters, only include the parameters for which + * you are providing values. + * + * @param dispIdMember the ID of the method as specified by the IDL of the ActiveX Control; the + * value for the ID can be obtained using OleAutomation.getIDsOfNames + * + * @param rgvarg an array of arguments for the method. All arguments are considered to be + * read only unless the Variant is a By Reference Variant type. + * + * @param rgdispidNamedArgs an array of identifiers for the arguments specified in rgvarg; the + * parameter IDs must be in the same order as their corresponding values; + * all arguments must have an identifier - identifiers can be obtained using + * OleAutomation.getIDsOfNames + * + * @return the result of the method or null if the method failed to give result information + */ +public Variant invoke(int dispIdMember, Variant[] rgvarg, int[] rgdispidNamedArgs) { + Variant pVarResult = new Variant(); + int result = invoke(dispIdMember, COM.DISPATCH_METHOD, rgvarg, rgdispidNamedArgs, pVarResult); + return (result is COM.S_OK) ? pVarResult : null; +} +private int invoke(int dispIdMember, int wFlags, Variant[] rgvarg, int[] rgdispidNamedArgs, Variant pVarResult) { + + // get the IDispatch interface for the control + if (objIDispatch is null) return COM.E_FAIL; + + // create a DISPPARAMS structure for the input parameters + DISPPARAMS pDispParams = new DISPPARAMS(); + // store arguments in rgvarg + if (rgvarg !is null && rgvarg.length > 0) { + pDispParams.cArgs = rgvarg.length; + pDispParams.rgvarg = OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, Variant.sizeof * rgvarg.length); + int offset = 0; + for (int i = rgvarg.length - 1; i >= 0 ; i--) { + rgvarg[i].getData(pDispParams.rgvarg + offset); + offset += Variant.sizeof; + } + } + + // if arguments have ids, store the ids in rgdispidNamedArgs + if (rgdispidNamedArgs !is null && rgdispidNamedArgs.length > 0) { + pDispParams.cNamedArgs = rgdispidNamedArgs.length; + pDispParams.rgdispidNamedArgs = OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, 4 * rgdispidNamedArgs.length); + int offset = 0; + for (int i = rgdispidNamedArgs.length; i > 0; i--) { + COM.MoveMemory(pDispParams.rgdispidNamedArgs + offset, new int[] {rgdispidNamedArgs[i-1]}, 4); + offset += 4; + } + } + + // invoke the method + EXCEPINFO excepInfo = new EXCEPINFO(); + int[] pArgErr = new int[1]; + int pVarResultAddress = 0; + if (pVarResult !is null) pVarResultAddress = OS.GlobalAlloc(OS.GMEM_FIXED | OS.GMEM_ZEROINIT, Variant.sizeof); + int result = objIDispatch.Invoke(dispIdMember, new GUID(), COM.LOCALE_USER_DEFAULT, wFlags, pDispParams, pVarResultAddress, excepInfo, pArgErr); + + if (pVarResultAddress !is 0){ + pVarResult.setData(pVarResultAddress); + COM.VariantClear(pVarResultAddress); + OS.GlobalFree(pVarResultAddress); + } + + // free the Dispparams resources + if (pDispParams.rgdispidNamedArgs !is 0){ + OS.GlobalFree(pDispParams.rgdispidNamedArgs); + } + if (pDispParams.rgvarg !is 0) { + int offset = 0; + for (int i = 0, length = rgvarg.length; i < length; i++){ + COM.VariantClear(pDispParams.rgvarg + offset); + offset += Variant.sizeof; + } + OS.GlobalFree(pDispParams.rgvarg); + } + + // save error string and cleanup EXCEPINFO + manageExcepinfo(result, excepInfo); + + return result; +} +/** + * Invokes a method on the OLE Object; the method has no parameters. In the early days of OLE, + * the IDispatch interface was not well defined and some applications (mainly Word) did not support + * a return value. For these applications, call this method instead of calling + * <code>public void invoke(int dispIdMember)</code>. + * + * @param dispIdMember the ID of the method as specified by the IDL of the ActiveX Control; the + * value for the ID can be obtained using OleAutomation.getIDsOfNames + * + * @exception dwt.DWTException <ul> + * <li>ERROR_ACTION_NOT_PERFORMED when method invocation fails + * </ul> + */ +public void invokeNoReply(int dispIdMember) { + int result = invoke(dispIdMember, COM.DISPATCH_METHOD, null, null, null); + if (result !is COM.S_OK) + OLE.error(OLE.ERROR_ACTION_NOT_PERFORMED, result); +} +/** + * Invokes a method on the OLE Object; the method has no optional parameters. In the early days of OLE, + * the IDispatch interface was not well defined and some applications (mainly Word) did not support + * a return value. For these applications, call this method instead of calling + * <code>public void invoke(int dispIdMember, Variant[] rgvarg)</code>. + * + * @param dispIdMember the ID of the method as specified by the IDL of the ActiveX Control; the + * value for the ID can be obtained using OleAutomation.getIDsOfNames + * + * @param rgvarg an array of arguments for the method. All arguments are considered to be + * read only unless the Variant is a By Reference Variant type. + * + * @exception dwt.DWTException <ul> + * <li>ERROR_ACTION_NOT_PERFORMED when method invocation fails + * </ul> + */ +public void invokeNoReply(int dispIdMember, Variant[] rgvarg) { + int result = invoke(dispIdMember, COM.DISPATCH_METHOD, rgvarg, null, null); + if (result !is COM.S_OK) + OLE.error(OLE.ERROR_ACTION_NOT_PERFORMED, result); +} +/** + * Invokes a method on the OLE Object; the method has optional parameters. It is not + * necessary to specify all the optional parameters, only include the parameters for which + * you are providing values. In the early days of OLE, the IDispatch interface was not well + * defined and some applications (mainly Word) did not support a return value. For these + * applications, call this method instead of calling + * <code>public void invoke(int dispIdMember, Variant[] rgvarg, int[] rgdispidNamedArgs)</code>. + * + * @param dispIdMember the ID of the method as specified by the IDL of the ActiveX Control; the + * value for the ID can be obtained using OleAutomation.getIDsOfNames + * + * @param rgvarg an array of arguments for the method. All arguments are considered to be + * read only unless the Variant is a By Reference Variant type. + * + * @param rgdispidNamedArgs an array of identifiers for the arguments specified in rgvarg; the + * parameter IDs must be in the same order as their corresponding values; + * all arguments must have an identifier - identifiers can be obtained using + * OleAutomation.getIDsOfNames + * + * @exception dwt.DWTException <ul> + * <li>ERROR_ACTION_NOT_PERFORMED when method invocation fails + * </ul> + */ +public void invokeNoReply(int dispIdMember, Variant[] rgvarg, int[] rgdispidNamedArgs) { + int result = invoke(dispIdMember, COM.DISPATCH_METHOD, rgvarg, rgdispidNamedArgs, null); + if (result !is COM.S_OK) + OLE.error(OLE.ERROR_ACTION_NOT_PERFORMED, result); +} +private void manageExcepinfo(int hResult, EXCEPINFO excepInfo) { + + if (hResult is COM.S_OK){ + exceptionDescription = "No Error"; //$NON-NLS-1$ + return; + } + + // extract exception info + if (hResult is COM.DISP_E_EXCEPTION) { + if (excepInfo.bstrDescription !is 0){ + int size = COM.SysStringByteLen(excepInfo.bstrDescription); + char[] buffer = new char[(size + 1) /2]; + COM.MoveMemory(buffer, excepInfo.bstrDescription, size); + exceptionDescription = new String(buffer); + } else { + exceptionDescription = "OLE Automation Error Exception "; //$NON-NLS-1$ + if (excepInfo.wCode !is 0){ + exceptionDescription += "code = "+excepInfo.wCode; //$NON-NLS-1$ + } else if (excepInfo.scode !is 0){ + exceptionDescription += "code = "+excepInfo.scode; //$NON-NLS-1$ + } + } + } else { + exceptionDescription = "OLE Automation Error HResult : " + hResult; //$NON-NLS-1$ + } + + // cleanup EXCEPINFO struct + if (excepInfo.bstrDescription !is 0) + COM.SysFreeString(excepInfo.bstrDescription); + if (excepInfo.bstrHelpFile !is 0) + COM.SysFreeString(excepInfo.bstrHelpFile); + if (excepInfo.bstrSource !is 0) + COM.SysFreeString(excepInfo.bstrSource); +} +/** + * Sets the property specified by the dispIdMember to a new value. + * + * @param dispIdMember the ID of the property as specified by the IDL of the ActiveX Control; the + * value for the ID can be obtained using OleAutomation.getIDsOfNames + * @param rgvarg the new value of the property + * + * @return true if the operation was successful + */ +public bool setProperty(int dispIdMember, Variant rgvarg) { + Variant[] rgvarg2 = new Variant[] {rgvarg}; + int[] rgdispidNamedArgs = new int[] {COM.DISPID_PROPERTYPUT}; + int dwFlags = COM.DISPATCH_PROPERTYPUT; + if ((rgvarg.getType() & COM.VT_BYREF) is COM.VT_BYREF) + dwFlags = COM.DISPATCH_PROPERTYPUTREF; + Variant pVarResult = new Variant(); + int result = invoke(dispIdMember, dwFlags, rgvarg2, rgdispidNamedArgs, pVarResult); + return (result is COM.S_OK); +} +/** + * Sets the property specified by the dispIdMember to a new value. + * + * @param dispIdMember the ID of the property as specified by the IDL of the ActiveX Control; the + * value for the ID can be obtained using OleAutomation.getIDsOfNames + * @param rgvarg an array of arguments for the method. All arguments are considered to be + * read only unless the Variant is a By Reference Variant type. + * + * @return true if the operation was successful + * + * @since 2.0 + */ +public bool setProperty(int dispIdMember, Variant[] rgvarg) { + int[] rgdispidNamedArgs = new int[] {COM.DISPID_PROPERTYPUT}; + int dwFlags = COM.DISPATCH_PROPERTYPUT; + for (int i = 0; i < rgvarg.length; i++) { + if ((rgvarg[i].getType() & COM.VT_BYREF) is COM.VT_BYREF) + dwFlags = COM.DISPATCH_PROPERTYPUTREF; + } + Variant pVarResult = new Variant(); + int result = invoke(dispIdMember, dwFlags, rgvarg, rgdispidNamedArgs, pVarResult); + return (result is COM.S_OK); +} +} +++/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/ole/win32/OleClientSite.d Fri Feb 08 19:49:32 2008 +0100 @@ -0,0 +1,1398 @@ +/******************************************************************************* + * Copyright (c) 2000, 2007 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +module dwt.ole.win32.OleClientSite; + +import dwt.dwthelper.File; +import dwt.dwthelper.FileInputStream; +import dwt.dwthelper.FileOutputStream; +import dwt.dwthelper.utils; + +import dwt.DWT; +import dwt.DWTException; +import dwt.graphics.Point; +import dwt.graphics.Rectangle; +import dwt.internal.Compatibility; +// import dwt.internal.ole.win32.CAUUID; +// import dwt.internal.ole.win32.COM; +// import dwt.internal.ole.win32.COMObject; +// import dwt.internal.ole.win32.GUID; +// import dwt.internal.ole.win32.IDispatch; +// import dwt.internal.ole.win32.IMoniker; +// import dwt.internal.ole.win32.IOleCommandTarget; +// import dwt.internal.ole.win32.IOleDocument; +// import dwt.internal.ole.win32.IOleDocumentView; +// import dwt.internal.ole.win32.IOleInPlaceObject; +// import dwt.internal.ole.win32.IOleLink; +// import dwt.internal.ole.win32.IOleObject; +// import dwt.internal.ole.win32.IPersist; +// import dwt.internal.ole.win32.IPersistStorage; +// import dwt.internal.ole.win32.ISpecifyPropertyPages; +// import dwt.internal.ole.win32.IStorage; +// import dwt.internal.ole.win32.IStream; +// import dwt.internal.ole.win32.IUnknown; +// import dwt.internal.ole.win32.IViewObject2; +// import dwt.internal.ole.win32.OLECMD; +// import dwt.internal.ole.win32.OLEINPLACEFRAMEINFO; +import dwt.internal.win32.OS; + +import dwt.widgets.Composite; +import dwt.widgets.Event; +import dwt.widgets.Listener; +import dwt.widgets.Menu; +import dwt.widgets.Shell; + +//PORTING_TYPE +class OleClientSite : Composite { +} +/++ + +/** + * OleClientSite provides a site to manage an embedded OLE Document within a container. + * + * <p>The OleClientSite provides the following capabilities: + * <ul> + * <li>creates the in-place editor for a blank document or opening an existing OLE Document + * <li>lays the editor out + * <li>provides a mechanism for activating and deactivating the Document + * <li>provides a mechanism for saving changes made to the document + * </ul> + * + * <p>This object implements the OLE Interfaces IUnknown, IOleClientSite, IAdviseSink, + * IOleInPlaceSite + * + * <p>Note that although this class is a subclass of <code>Composite</code>, + * it does not make sense to add <code>Control</code> children to it, + * or set a layout on it. + * </p><p> + * <dl> + * <dt><b>Styles</b> <dd>BORDER + * <dt><b>Events</b> <dd>Dispose, Move, Resize + * </dl> + * + */ +public class OleClientSite : Composite { + + // Interfaces for this Ole Client Container + private COMObject iUnknown; + private COMObject iOleClientSite; + private COMObject iAdviseSink; + private COMObject iOleInPlaceSite; + private COMObject iOleDocumentSite; + + protected GUID appClsid; + private GUID objClsid; + private int refCount; + + // References to the associated Frame. + protected OleFrame frame; + + // Access to the embedded/linked Ole Object + protected IUnknown objIUnknown; + protected IOleObject objIOleObject; + protected IViewObject2 objIViewObject2; + protected IOleInPlaceObject objIOleInPlaceObject; + protected IOleCommandTarget objIOleCommandTarget; + protected IOleDocumentView objDocumentView; + + // Related storage information + protected IStorage tempStorage; // IStorage interface of the receiver + + // Internal state and style information + private int aspect; // the display aspect of the embedded object, e.g., DvaspectContent or DvaspectIcon + private int type; // Indicates the type of client that can be supported inside this container + private bool isStatic; // Indicates item's display is static, i.e., a bitmap, metafile, etc. + + private RECT borderWidths = new RECT(); + private RECT indent = new RECT(); + private bool inUpdate = false; + private bool inInit = true; + private bool inDispose = false; + + private static final String WORDPROGID = "Word.Document"; //$NON-NLS-1$ + + private Listener listener; + + static final int STATE_NONE = 0; + static final int STATE_RUNNING = 1; + static final int STATE_INPLACEACTIVE = 2; + static final int STATE_UIACTIVE = 3; + static final int STATE_ACTIVE = 4; + int state = STATE_NONE; + +protected OleClientSite(Composite parent, int style) { + /* + * NOTE: this constructor should never be used by itself because it does + * not create an Ole Object + */ + super(parent, style); + + createCOMInterfaces(); + + // install the Ole Frame for this Client Site + while (parent !is null) { + if (parent instanceof OleFrame){ + frame = (OleFrame)parent; + break; + } + parent = parent.getParent(); + } + if (frame is null) OLE.error(DWT.ERROR_INVALID_ARGUMENT); + frame.AddRef(); + + aspect = COM.DVASPECT_CONTENT; + type = COM.OLEEMBEDDED; + isStatic = false; + + listener = new Listener() { + public void handleEvent(Event e) { + switch (e.type) { + case DWT.Resize : + case DWT.Move : onResize(e); break; + case DWT.Dispose : onDispose(e); break; + case DWT.FocusIn: onFocusIn(e); break; + case DWT.FocusOut: onFocusOut(e); break; + case DWT.Paint: onPaint(e); break; + case DWT.Traverse: onTraverse(e); break; + case DWT.KeyDown: /* required for traversal */ break; + default : + OLE.error(DWT.ERROR_NOT_IMPLEMENTED); + } + } + }; + + frame.addListener(DWT.Resize, listener); + frame.addListener(DWT.Move, listener); + addListener(DWT.Dispose, listener); + addListener(DWT.FocusIn, listener); + addListener(DWT.FocusOut, listener); + addListener(DWT.Paint, listener); + addListener(DWT.Traverse, listener); + addListener(DWT.KeyDown, listener); +} +/** + * Create an OleClientSite child widget using the OLE Document type associated with the + * specified file. The OLE Document type is determined either through header information in the file + * or through a Registry entry for the file extension. Use style bits to select a particular look + * or set of properties. + * + * @param parent a composite widget; must be an OleFrame + * @param style the bitwise OR'ing of widget styles + * @param file the file that is to be opened in this OLE Document + * + * @exception IllegalArgumentException + * <ul><li>ERROR_NULL_ARGUMENT when the parent is null + * <li>ERROR_INVALID_ARGUMENT when the parent is not an OleFrame</ul> + * @exception DWTException + * <ul><li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread + * <li>ERROR_CANNOT_CREATE_OBJECT when failed to create OLE Object + * <li>ERROR_CANNOT_OPEN_FILE when failed to open file + * <li>ERROR_INTERFACE_NOT_FOUND when unable to create callbacks for OLE Interfaces + * <li>ERROR_INVALID_CLASSID + * </ul> + */ +public OleClientSite(Composite parent, int style, File file) { + this(parent, style); + try { + + if (file is null || file.isDirectory() || !file.exists()) + OLE.error(OLE.ERROR_INVALID_ARGUMENT); + + // Is there an associated CLSID? + appClsid = new GUID(); + char[] fileName = (file.getAbsolutePath()+"\0").toCharArray(); + int result = COM.GetClassFile(fileName, appClsid); + if (result !is COM.S_OK) + OLE.error(OLE.ERROR_INVALID_CLASSID, result); + // associated CLSID may not be installed on this machine + if (getProgramID() is null) + OLE.error(OLE.ERROR_INVALID_CLASSID, result); + + // Open a temporary storage object + tempStorage = createTempStorage(); + + // Create ole object with storage object + int[] address = new int[1]; + result = COM.OleCreateFromFile(appClsid, fileName, COM.IIDIUnknown, COM.OLERENDER_DRAW, null, 0, tempStorage.getAddress(), address); + if (result !is COM.S_OK) + OLE.error(OLE.ERROR_CANNOT_CREATE_OBJECT, result); + + objIUnknown = new IUnknown(address[0]); + + // Init sinks + addObjectReferences(); + + if (COM.OleRun(objIUnknown.getAddress()) is OLE.S_OK) state = STATE_RUNNING; + } catch (DWTException e) { + dispose(); + disposeCOMInterfaces(); + throw e; + } +} +/** + * Create an OleClientSite child widget to edit a blank document using the specified OLE Document + * application. Use style bits to select a particular look or set of properties. + * + * @param parent a composite widget; must be an OleFrame + * @param style the bitwise OR'ing of widget styles + * @param progId the unique program identifier of am OLE Document application; + * the value of the ProgID key or the value of the VersionIndependentProgID key specified + * in the registry for the desired OLE Document (for example, the VersionIndependentProgID + * for Word is Word.Document) + * + * @exception IllegalArgumentException + *<ul> + * <li>ERROR_NULL_ARGUMENT when the parent is null + * <li>ERROR_INVALID_ARGUMENT when the parent is not an OleFrame + *</ul> + * @exception DWTException + * <ul><li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread + * <li>ERROR_INVALID_CLASSID when the progId does not map to a registered CLSID + * <li>ERROR_CANNOT_CREATE_OBJECT when failed to create OLE Object + * </ul> + */ +public OleClientSite(Composite parent, int style, String progId) { + this(parent, style); + try { + appClsid = getClassID(progId); + if (appClsid is null) + OLE.error(OLE.ERROR_INVALID_CLASSID); + + // Open a temporary storage object + tempStorage = createTempStorage(); + + // Create ole object with storage object + int[] address = new int[1]; + int result = COM.OleCreate(appClsid, COM.IIDIUnknown, COM.OLERENDER_DRAW, null, 0, tempStorage.getAddress(), address); + if (result !is COM.S_OK) + OLE.error(OLE.ERROR_CANNOT_CREATE_OBJECT, result); + + objIUnknown = new IUnknown(address[0]); + + // Init sinks + addObjectReferences(); + + if (COM.OleRun(objIUnknown.getAddress()) is OLE.S_OK) state = STATE_RUNNING; + + } catch (DWTException e) { + dispose(); + disposeCOMInterfaces(); + throw e; + } +} +/** + * Create an OleClientSite child widget to edit the specified file using the specified OLE Document + * application. Use style bits to select a particular look or set of properties. + * <p> + * <b>IMPORTANT:</b> This method is <em>not</em> part of the public + * API for <code>OleClientSite</code>. It is marked public only so that it + * can be shared within the packages provided by DWT. It is not + * available on all platforms, and should never be called from + * application code. + * </p> + * @param parent a composite widget; must be an OleFrame + * @param style the bitwise OR'ing of widget styles + * @param progId the unique program identifier of am OLE Document application; + * the value of the ProgID key or the value of the VersionIndependentProgID key specified + * in the registry for the desired OLE Document (for example, the VersionIndependentProgID + * for Word is Word.Document) + * @param file the file that is to be opened in this OLE Document + * + * @exception IllegalArgumentException + * <ul><li>ERROR_NULL_ARGUMENT when the parent is null + * <li>ERROR_INVALID_ARGUMENT when the parent is not an OleFrame</ul> + * @exception DWTException + * <ul><li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread + * <li>ERROR_INVALID_CLASSID when the progId does not map to a registered CLSID + * <li>ERROR_CANNOT_CREATE_OBJECT when failed to create OLE Object + * <li>ERROR_CANNOT_OPEN_FILE when failed to open file + * </ul> + */ +public OleClientSite(Composite parent, int style, String progId, File file) { + this(parent, style); + try { + if (file is null || file.isDirectory() || !file.exists()) OLE.error(OLE.ERROR_INVALID_ARGUMENT); + appClsid = getClassID(progId); + if (appClsid is null) OLE.error(OLE.ERROR_INVALID_CLASSID); + + // Are we opening this file with the preferred OLE object? + char[] fileName = (file.getAbsolutePath()+"\0").toCharArray(); + GUID fileClsid = new GUID(); + COM.GetClassFile(fileName, fileClsid); + + if (COM.IsEqualGUID(appClsid, fileClsid)){ + // Using the same application that created file, therefore, use default mechanism. + tempStorage = createTempStorage(); + // Create ole object with storage object + int[] address = new int[1]; + int result = COM.OleCreateFromFile(appClsid, fileName, COM.IIDIUnknown, COM.OLERENDER_DRAW, null, 0, tempStorage.getAddress(), address); + if (result !is COM.S_OK) OLE.error(OLE.ERROR_CANNOT_CREATE_OBJECT, result); + objIUnknown = new IUnknown(address[0]); + } else { + // Not using the same application that created file, therefore, copy from original file to a new storage file + IStorage storage = null; + if (COM.StgIsStorageFile(fileName) is COM.S_OK) { + int[] address = new int[1]; + int mode = COM.STGM_READ | COM.STGM_TRANSACTED | COM.STGM_SHARE_EXCLUSIVE; + int result = COM.StgOpenStorage(fileName, 0, mode, 0, 0, address); //Does an AddRef if successful + if (result !is COM.S_OK) OLE.error(OLE.ERROR_CANNOT_OPEN_FILE, result); + storage = new IStorage(address[0]); + } else { + // Original file is not a Storage file so copy contents to a stream in a new storage file + int[] address = new int[1]; + int mode = COM.STGM_READWRITE | COM.STGM_DIRECT | COM.STGM_SHARE_EXCLUSIVE | COM.STGM_CREATE; + int result = COM.StgCreateDocfile(null, mode | COM.STGM_DELETEONRELEASE, 0, address); // Increments ref count if successful + if (result !is COM.S_OK) OLE.error(OLE.ERROR_CANNOT_OPEN_FILE, result); + storage = new IStorage(address[0]); + // Create a stream on the storage object. + // Word does not follow the standard and does not use "CONTENTS" as the name of + // its primary stream + String streamName = "CONTENTS"; //$NON-NLS-1$ + GUID wordGUID = getClassID(WORDPROGID); + if (wordGUID !is null && COM.IsEqualGUID(appClsid, wordGUID)) streamName = "WordDocument"; //$NON-NLS-1$ + address = new int[1]; + result = storage.CreateStream(streamName, mode, 0, 0, address); // Increments ref count if successful + if (result !is COM.S_OK) { + storage.Release(); + OLE.error(OLE.ERROR_CANNOT_OPEN_FILE, result); + } + IStream stream = new IStream(address[0]); + try { + // Copy over data in file to named stream + FileInputStream fileInput = new FileInputStream(file); + int increment = 1024*4; + byte[] buffer = new byte[increment]; + int count = 0; + while((count = fileInput.read(buffer)) > 0){ + int pv = COM.CoTaskMemAlloc(count); + OS.MoveMemory(pv, buffer, count); + result = stream.Write(pv, count, null) ; + COM.CoTaskMemFree(pv); + if (result !is COM.S_OK) { + fileInput.close(); + stream.Release(); + storage.Release(); + OLE.error(OLE.ERROR_CANNOT_OPEN_FILE, result); + } + } + fileInput.close(); + stream.Commit(COM.STGC_DEFAULT); + stream.Release(); + } catch (IOException err) { + stream.Release(); + storage.Release(); + OLE.error(OLE.ERROR_CANNOT_OPEN_FILE); + } + } + + // Open a temporary storage object + tempStorage = createTempStorage(); + // Copy over contents of file + int result = storage.CopyTo(0, null, null, tempStorage.getAddress()); + storage.Release(); + if (result !is COM.S_OK) OLE.error(OLE.ERROR_CANNOT_OPEN_FILE, result); + + // create ole client + int[] ppv = new int[1]; + result = COM.CoCreateInstance(appClsid, 0, COM.CLSCTX_INPROC_HANDLER | COM.CLSCTX_INPROC_SERVER, COM.IIDIUnknown, ppv); + if (result !is COM.S_OK) OLE.error(OLE.ERROR_CANNOT_CREATE_OBJECT, result); + objIUnknown = new IUnknown(ppv[0]); + // get the persistent storage of the ole client + ppv = new int[1]; + result = objIUnknown.QueryInterface(COM.IIDIPersistStorage, ppv); + if (result !is COM.S_OK) OLE.error(OLE.ERROR_CANNOT_CREATE_OBJECT, result); + IPersistStorage iPersistStorage = new IPersistStorage(ppv[0]); + // load the contents of the file into the ole client site + result = iPersistStorage.Load(tempStorage.getAddress()); + iPersistStorage.Release(); + if (result !is COM.S_OK)OLE.error(OLE.ERROR_CANNOT_CREATE_OBJECT, result); + } + + // Init sinks + addObjectReferences(); + + if (COM.OleRun(objIUnknown.getAddress()) is OLE.S_OK) state = STATE_RUNNING; + + } catch (DWTException e) { + dispose(); + disposeCOMInterfaces(); + throw e; + } +} +protected void addObjectReferences() { + // + int[] ppvObject = new int[1]; + if (objIUnknown.QueryInterface(COM.IIDIPersist, ppvObject) is COM.S_OK) { + IPersist objIPersist = new IPersist(ppvObject[0]); + GUID tempid = new GUID(); + if (objIPersist.GetClassID(tempid) is COM.S_OK) + objClsid = tempid; + objIPersist.Release(); + } + + // + ppvObject = new int[1]; + int result = objIUnknown.QueryInterface(COM.IIDIViewObject2, ppvObject); + if (result !is COM.S_OK) + OLE.error(OLE.ERROR_INTERFACE_NOT_FOUND, result); + objIViewObject2 = new IViewObject2(ppvObject[0]); + objIViewObject2.SetAdvise(aspect, 0, iAdviseSink.getAddress()); + + // + ppvObject = new int[1]; + result = objIUnknown.QueryInterface(COM.IIDIOleObject, ppvObject); + if (result !is COM.S_OK) + OLE.error(OLE.ERROR_INTERFACE_NOT_FOUND, result); + objIOleObject = new IOleObject(ppvObject[0]); + objIOleObject.SetClientSite(iOleClientSite.getAddress()); + int[] pdwConnection = new int[1]; + objIOleObject.Advise(iAdviseSink.getAddress(), pdwConnection); + objIOleObject.SetHostNames("main", "main"); //$NON-NLS-1$ //$NON-NLS-2$ + + // Notify the control object that it is embedded in an OLE container + COM.OleSetContainedObject(objIUnknown.getAddress(), true); + + // Is OLE object linked or embedded? + ppvObject = new int[1]; + if (objIUnknown.QueryInterface(COM.IIDIOleLink, ppvObject) is COM.S_OK) { + IOleLink objIOleLink = new IOleLink(ppvObject[0]); + int[] ppmk = new int[1]; + if (objIOleLink.GetSourceMoniker(ppmk) is COM.S_OK) { + IMoniker objIMoniker = new IMoniker(ppmk[0]); + objIMoniker.Release(); + type = COM.OLELINKED; + objIOleLink.BindIfRunning(); + } else { + isStatic = true; + } + objIOleLink.Release(); + } +} +protected int AddRef() { + refCount++; + return refCount; +} +private int CanInPlaceActivate() { + if (aspect is COM.DVASPECT_CONTENT && type is COM.OLEEMBEDDED) + return COM.S_OK; + + return COM.S_FALSE; +} +private int ContextSensitiveHelp(int fEnterMode) { + return COM.S_OK; +} +protected void createCOMInterfaces() { + + iUnknown = new COMObject(new int[]{2, 0, 0}){ + public int method0(int[] args) {return QueryInterface(args[0], args[1]);} + public int method1(int[] args) {return AddRef();} + public int method2(int[] args) {return Release();} + }; + + iOleClientSite = new COMObject(new int[]{2, 0, 0, 0, 3, 1, 0, 1, 0}){ + public int method0(int[] args) {return QueryInterface(args[0], args[1]);} + public int method1(int[] args) {return AddRef();} + public int method2(int[] args) {return Release();} + public int method3(int[] args) {return SaveObject();} + // method4 GetMoniker - not implemented + public int method5(int[] args) {return GetContainer(args[0]);} + public int method6(int[] args) {return ShowObject();} + public int method7(int[] args) {return OnShowWindow(args[0]);} + // method8 RequestNewObjectLayout - not implemented + }; + + iAdviseSink = new COMObject(new int[]{2, 0, 0, 2, 2, 1, 0, 0}){ + public int method0(int[] args) {return QueryInterface(args[0], args[1]);} + public int method1(int[] args) {return AddRef();} + public int method2(int[] args) {return Release();} + public int method3(int[] args) {return OnDataChange(args[0], args[1]);} + public int method4(int[] args) {return OnViewChange(args[0], args[1]);} + //method5 OnRename - not implemented + public int method6(int[] args) {OnSave();return 0;} + public int method7(int[] args) {return OnClose();} + }; + + iOleInPlaceSite = new COMObject(new int[]{2, 0, 0, 1, 1, 0, 0, 0, 5, 1, 1, 0, 0, 0, 1}){ + public int method0(int[] args) {return QueryInterface(args[0], args[1]);} + public int method1(int[] args) {return AddRef();} + public int method2(int[] args) {return Release();} + public int method3(int[] args) {return GetWindow(args[0]);} + public int method4(int[] args) {return ContextSensitiveHelp(args[0]);} + public int method5(int[] args) {return CanInPlaceActivate();} + public int method6(int[] args) {return OnInPlaceActivate();} + public int method7(int[] args) {return OnUIActivate();} + public int method8(int[] args) {return GetWindowContext(args[0], args[1], args[2], args[3], args[4]);} + public int method9(int[] args) {return Scroll(args[0]);} + public int method10(int[] args) {return OnUIDeactivate(args[0]);} + public int method11(int[] args) {return OnInPlaceDeactivate();} + // method12 DiscardUndoState - not implemented + // method13 DeactivateAndUndoChange - not implemented + public int method14(int[] args) {return OnPosRectChange(args[0]);} + }; + + iOleDocumentSite = new COMObject(new int[]{2, 0, 0, 1}){ + public int method0(int[] args) {return QueryInterface(args[0], args[1]);} + public int method1(int[] args) {return AddRef();} + public int method2(int[] args) {return Release();} + public int method3(int[] args) {return ActivateMe(args[0]);} + }; +} +protected IStorage createTempStorage() { + int[] tempStorage = new int[1]; + int grfMode = COM.STGM_READWRITE | COM.STGM_SHARE_EXCLUSIVE | COM.STGM_DELETEONRELEASE; + int result = COM.StgCreateDocfile(null, grfMode, 0, tempStorage); + if (result !is COM.S_OK) OLE.error(OLE.ERROR_CANNOT_CREATE_FILE, result); + return new IStorage(tempStorage[0]); +} +/** + * Deactivates an active in-place object and discards the object's undo state. + */ +public void deactivateInPlaceClient() { + if (objIOleInPlaceObject !is null) { + objIOleInPlaceObject.InPlaceDeactivate(); + } +} +private void deleteTempStorage() { + //Destroy this item's contents in the temp root IStorage. + if (tempStorage !is null){ + tempStorage.Release(); + } + tempStorage = null; +} +protected void disposeCOMInterfaces() { + if (iUnknown !is null) + iUnknown.dispose(); + iUnknown = null; + + if (iOleClientSite !is null) + iOleClientSite.dispose(); + iOleClientSite = null; + + if (iAdviseSink !is null) + iAdviseSink.dispose(); + iAdviseSink = null; + + if (iOleInPlaceSite !is null) + iOleInPlaceSite.dispose(); + iOleInPlaceSite = null; + + if (iOleDocumentSite !is null) + iOleDocumentSite.dispose(); + iOleDocumentSite = null; +} +/** + * Requests that the OLE Document or ActiveX Control perform an action; actions are almost always + * changes to the activation state. + * + * @param verb the operation that is requested. This is one of the OLE.OLEIVERB_ values + * + * @return an HRESULT value indicating the success of the operation request; OLE.S_OK indicates + * success + */ +public int doVerb(int verb) { + // Not all OLE clients (for example PowerPoint) can be set into the running state in the constructor. + // The fix is to ensure that the client is in the running state before invoking any verb on it. + if (state is STATE_NONE) { + if (COM.OleRun(objIUnknown.getAddress()) is OLE.S_OK) state = STATE_RUNNING; + } + if (state is STATE_NONE || isStatic) + return COM.E_FAIL; + + // See PR: 1FV9RZW + RECT rect = new RECT(); + OS.GetClientRect(handle, rect); + int result = objIOleObject.DoVerb(verb, null, iOleClientSite.getAddress(), 0, handle, rect); + + if (state !is STATE_RUNNING && inInit) { + updateStorage(); + inInit = false; + } + return result; +} +/** + * Asks the OLE Document or ActiveX Control to execute a command from a standard + * list of commands. The OLE Document or ActiveX Control must support the IOleCommandTarget + * interface. The OLE Document or ActiveX Control does not have to support all the commands + * in the standard list. To check if a command is supported, you can call queryStatus with + * the cmdID. + * + * @param cmdID the ID of a command; these are the OLE.OLECMDID_ values - a small set of common + * commands + * @param options the optional flags; these are the OLE.OLECMDEXECOPT_ values + * @param in the argument for the command + * @param out the return value of the command + * + * @return an HRESULT value; OLE.S_OK is returned if successful + * + */ +public int exec(int cmdID, int options, Variant in, Variant out) { + + if (objIOleCommandTarget is null) { + int[] address = new int[1]; + if (objIUnknown.QueryInterface(COM.IIDIOleCommandTarget, address) !is COM.S_OK) + return OLE.ERROR_INTERFACE_NOT_FOUND; + objIOleCommandTarget = new IOleCommandTarget(address[0]); + } + + int inAddress = 0; + if (in !is null){ + inAddress = OS.GlobalAlloc(OS.GMEM_FIXED | OS.GMEM_ZEROINIT, Variant.sizeof); + in.getData(inAddress); + } + int outAddress = 0; + if (out !is null){ + outAddress = OS.GlobalAlloc(OS.GMEM_FIXED | OS.GMEM_ZEROINIT, Variant.sizeof); + out.getData(outAddress); + } + + int result = objIOleCommandTarget.Exec(null, cmdID, options, inAddress, outAddress); + + if (inAddress !is 0){ + COM.VariantClear(inAddress); + OS.GlobalFree(inAddress); + } + if (outAddress !is 0) { + out.setData(outAddress); + COM.VariantClear(outAddress); + OS.GlobalFree(outAddress); + } + + return result; +} +IDispatch getAutomationObject() { + int[] ppvObject = new int[1]; + if (objIUnknown.QueryInterface(COM.IIDIDispatch, ppvObject) !is COM.S_OK) + return null; + return new IDispatch(ppvObject[0]); +} +protected GUID getClassID(String clientName) { + // create a GUID struct to hold the result + GUID guid = new GUID(); + + // create a null terminated array of char + char[] buffer = null; + if (clientName !is null) { + int count = clientName.length(); + buffer = new char[count + 1]; + clientName.getChars(0, count, buffer, 0); + } + if (COM.CLSIDFromProgID(buffer, guid) !is COM.S_OK){ + int result = COM.CLSIDFromString(buffer, guid); + if (result !is COM.S_OK) return null; + } + return guid; +} +private int GetContainer(int ppContainer) { + /* Simple containers that do not support links to their embedded + * objects probably do not need to implement this method. Instead, + * they can return E_NOINTERFACE and set ppContainer to NULL. + */ + if (ppContainer !is 0) + COM.MoveMemory(ppContainer, new int[]{0}, 4); + return COM.E_NOINTERFACE; +} +private SIZE getExtent() { + SIZE sizel = new SIZE(); + // get the current size of the embedded OLENatives object + if (objIOleObject !is null) { + if ( objIViewObject2 !is null && !COM.OleIsRunning(objIOleObject.getAddress())) { + objIViewObject2.GetExtent(aspect, -1, null, sizel); + } else { + objIOleObject.GetExtent(aspect, sizel); + } + } + return xFormHimetricToPixels(sizel); +} +public Rectangle getIndent() { + return new Rectangle(indent.left, indent.right, indent.top, indent.bottom); +} +/** + * Returns the program ID of the OLE Document or ActiveX Control. + * + * @return the program ID of the OLE Document or ActiveX Control + */ +public String getProgramID(){ + if (appClsid !is null){ + int[] lplpszProgID = new int[1]; + if (COM.ProgIDFromCLSID(appClsid, lplpszProgID) is COM.S_OK) { + int hMem = lplpszProgID[0]; + int length = OS.GlobalSize(hMem); + int ptr = OS.GlobalLock(hMem); + char[] buffer = new char[length]; + COM.MoveMemory(buffer, ptr, length); + OS.GlobalUnlock(hMem); + OS.GlobalFree(hMem); + + String result = new String(buffer); + // remove null terminator + int index = result.indexOf("\0"); + return result.substring(0, index); + } + } + return null; +} +int ActivateMe(int pViewToActivate) { + if (pViewToActivate is 0) { + int[] ppvObject = new int[1]; + if (objIUnknown.QueryInterface(COM.IIDIOleDocument, ppvObject) !is COM.S_OK) return COM.E_FAIL; + IOleDocument objOleDocument = new IOleDocument(ppvObject[0]); + if (objOleDocument.CreateView(iOleInPlaceSite.getAddress(), 0, 0, ppvObject) !is COM.S_OK) return COM.E_FAIL; + objOleDocument.Release(); + objDocumentView = new IOleDocumentView(ppvObject[0]); + } else { + objDocumentView = new IOleDocumentView(pViewToActivate); + objDocumentView.AddRef(); + objDocumentView.SetInPlaceSite(iOleInPlaceSite.getAddress()); + } + objDocumentView.UIActivate(1);//TRUE + RECT rect = getRect(); + objDocumentView.SetRect(rect); + objDocumentView.Show(1);//TRUE + return COM.S_OK; +} +protected int GetWindow(int phwnd) { + if (phwnd is 0) + return COM.E_INVALIDARG; + if (frame is null) { + COM.MoveMemory(phwnd, new int[] {0}, 4); + return COM.E_NOTIMPL; + } + + // Copy the Window's handle into the memory passed in + COM.MoveMemory(phwnd, new int[] {frame.handle}, 4); + return COM.S_OK; +} +RECT getRect() { + Point location = this.getLocation(); + Rectangle area = frame.getClientArea(); + RECT rect = new RECT(); + rect.left = location.x; + rect.top = location.y; + rect.right = location.x + area.width - borderWidths.left - borderWidths.right; + rect.bottom = location.y + area.height - borderWidths.top - borderWidths.bottom; + return rect; +} +private int GetWindowContext(int ppFrame, int ppDoc, int lprcPosRect, int lprcClipRect, int lpFrameInfo) { + if (frame is null || ppFrame is 0) + return COM.E_NOTIMPL; + + // fill in frame handle + int iOleInPlaceFrame = frame.getIOleInPlaceFrame(); + COM.MoveMemory(ppFrame, new int[] {iOleInPlaceFrame}, 4); + frame.AddRef(); + + // null out document handle + if (ppDoc !is 0) COM.MoveMemory(ppDoc, new int[] {0}, 4); + + // fill in position and clipping info + RECT rect = getRect(); + if (lprcPosRect !is 0) OS.MoveMemory(lprcPosRect, rect, RECT.sizeof); + if (lprcClipRect !is 0) OS.MoveMemory(lprcClipRect, rect, RECT.sizeof); + + // get frame info + OLEINPLACEFRAMEINFO frameInfo = new OLEINPLACEFRAMEINFO(); + frameInfo.cb = OLEINPLACEFRAMEINFO.sizeof; + frameInfo.fMDIApp = 0; + frameInfo.hwndFrame = frame.handle; + Shell shell = getShell(); + Menu menubar = shell.getMenuBar(); + if (menubar !is null && !menubar.isDisposed()) { + int hwnd = shell.handle; + int cAccel = OS.SendMessage(hwnd, OS.WM_APP, 0, 0); + if (cAccel !is 0) { + int hAccel = OS.SendMessage(hwnd, OS.WM_APP+1, 0, 0); + if (hAccel !is 0) { + frameInfo.cAccelEntries = cAccel; + frameInfo.haccel = hAccel; + } + } + } + COM.MoveMemory(lpFrameInfo, frameInfo, OLEINPLACEFRAMEINFO.sizeof); + + return COM.S_OK; +} +public bool isDirty() { + /* + * Note: this method must return true unless it is absolutely clear that the + * contents of the Ole Document do not differ from the contents in the file + * on the file system. + */ + + // Get access to the persistent storage mechanism + int[] address = new int[1]; + if (objIOleObject.QueryInterface(COM.IIDIPersistFile, address) !is COM.S_OK) + return true; + IPersistStorage permStorage = new IPersistStorage(address[0]); + // Are the contents of the permanent storage different from the file? + int result = permStorage.IsDirty(); + permStorage.Release(); + if (result is COM.S_FALSE) return false; + return true; +} +public bool isFocusControl () { + checkWidget (); + int focusHwnd = OS.GetFocus(); + if (objIOleInPlaceObject is null) return (handle is focusHwnd); + int[] phwnd = new int[1]; + objIOleInPlaceObject.GetWindow(phwnd); + while (focusHwnd !is 0) { + if (phwnd[0] is focusHwnd) return true; + focusHwnd = OS.GetParent(focusHwnd); + } + return false; +} +private int OnClose() { + return COM.S_OK; +} +private int OnDataChange(int pFormatetc, int pStgmed) { + return COM.S_OK; +} +private void onDispose(Event e) { + inDispose = true; + if (state !is STATE_NONE) + doVerb(OLE.OLEIVERB_DISCARDUNDOSTATE); + deactivateInPlaceClient(); + releaseObjectInterfaces(); // Note, must release object interfaces before releasing frame + deleteTempStorage(); + + // remove listeners + removeListener(DWT.Dispose, listener); + removeListener(DWT.FocusIn, listener); + removeListener(DWT.Paint, listener); + removeListener(DWT.Traverse, listener); + removeListener(DWT.KeyDown, listener); + frame.removeListener(DWT.Resize, listener); + frame.removeListener(DWT.Move, listener); + + frame.Release(); + frame = null; +} +void onFocusIn(Event e) { + if (inDispose) return; + if (state !is STATE_UIACTIVE) doVerb(OLE.OLEIVERB_SHOW); + if (objIOleInPlaceObject is null) return; + if (isFocusControl()) return; + int[] phwnd = new int[1]; + objIOleInPlaceObject.GetWindow(phwnd); + if (phwnd[0] is 0) return; + OS.SetFocus(phwnd[0]); +} +void onFocusOut(Event e) { +} +private int OnInPlaceActivate() { + state = STATE_INPLACEACTIVE; + frame.setCurrentDocument(this); + if (objIOleObject is null) + return COM.S_OK; + int[] ppvObject = new int[1]; + if (objIOleObject.QueryInterface(COM.IIDIOleInPlaceObject, ppvObject) is COM.S_OK) { + objIOleInPlaceObject = new IOleInPlaceObject(ppvObject[0]); + } + return COM.S_OK; +} +private int OnInPlaceDeactivate() { + if (objIOleInPlaceObject !is null) objIOleInPlaceObject.Release(); + objIOleInPlaceObject = null; + state = STATE_RUNNING; + redraw(); + Shell shell = getShell(); + if (isFocusControl() || frame.isFocusControl()) { + shell.traverse(DWT.TRAVERSE_TAB_NEXT); + } + return COM.S_OK; +} +private int OnPosRectChange(int lprcPosRect) { + Point size = getSize(); + setExtent(size.x, size.y); + return COM.S_OK; +} +private void onPaint(Event e) { + if (state is STATE_RUNNING || state is STATE_INPLACEACTIVE) { + SIZE size = getExtent(); + Rectangle area = getClientArea(); + RECT rect = new RECT(); + if (getProgramID().startsWith("Excel.Sheet")) { //$NON-NLS-1$ + rect.left = area.x; rect.right = area.x + (area.height * size.cx / size.cy); + rect.top = area.y; rect.bottom = area.y + area.height; + } else { + rect.left = area.x; rect.right = area.x + size.cx; + rect.top = area.y; rect.bottom = area.y + size.cy; + } + + int pArea = OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, RECT.sizeof); + OS.MoveMemory(pArea, rect, RECT.sizeof); + COM.OleDraw(objIUnknown.getAddress(), aspect, e.gc.handle, pArea); + OS.GlobalFree(pArea); + } +} +private void onResize(Event e) { + Rectangle area = frame.getClientArea(); + setBounds(borderWidths.left, + borderWidths.top, + area.width - borderWidths.left - borderWidths.right, + area.height - borderWidths.top - borderWidths.bottom); + + setObjectRects(); +} +private void OnSave() { +} +private int OnShowWindow(int fShow) { + return COM.S_OK; +} +private int OnUIActivate() { + if (objIOleInPlaceObject is null) return COM.E_FAIL; + state = STATE_UIACTIVE; + int[] phwnd = new int[1]; + if (objIOleInPlaceObject.GetWindow(phwnd) is COM.S_OK) { + OS.SetWindowPos(phwnd[0], OS.HWND_TOP, 0, 0, 0, 0, OS.SWP_NOSIZE | OS.SWP_NOMOVE); + } + return COM.S_OK; +} +private int OnUIDeactivate(int fUndoable) { + // currently, we are ignoring the fUndoable flag + if (frame is null || frame.isDisposed()) return COM.S_OK; + state = STATE_INPLACEACTIVE; + frame.SetActiveObject(0,0); + redraw(); + Shell shell = getShell(); + if (isFocusControl() || frame.isFocusControl()) { + shell.traverse(DWT.TRAVERSE_TAB_NEXT); + } + Menu menubar = shell.getMenuBar(); + if (menubar is null || menubar.isDisposed()) + return COM.S_OK; + + int shellHandle = shell.handle; + OS.SetMenu(shellHandle, menubar.handle); + return COM.OleSetMenuDescriptor(0, shellHandle, 0, 0, 0); +} +private void onTraverse(Event event) { + switch (event.detail) { + case DWT.TRAVERSE_ESCAPE: + case DWT.TRAVERSE_RETURN: + case DWT.TRAVERSE_TAB_NEXT: + case DWT.TRAVERSE_TAB_PREVIOUS: + case DWT.TRAVERSE_PAGE_NEXT: + case DWT.TRAVERSE_PAGE_PREVIOUS: + case DWT.TRAVERSE_MNEMONIC: + event.doit = true; + break; + } +} +private int OnViewChange(int dwAspect, int lindex) { + return COM.S_OK; +} +protected int QueryInterface(int riid, int ppvObject) { + + if (riid is 0 || ppvObject is 0) + return COM.E_NOINTERFACE; + GUID guid = new GUID(); + COM.MoveMemory(guid, riid, GUID.sizeof); + + if (COM.IsEqualGUID(guid, COM.IIDIUnknown)) { + COM.MoveMemory(ppvObject, new int[] {iUnknown.getAddress()}, 4); + AddRef(); + return COM.S_OK; + } + if (COM.IsEqualGUID(guid, COM.IIDIAdviseSink)) { + COM.MoveMemory(ppvObject, new int[] {iAdviseSink.getAddress()}, 4); + AddRef(); + return COM.S_OK; + } + if (COM.IsEqualGUID(guid, COM.IIDIOleClientSite)) { + COM.MoveMemory(ppvObject, new int[] {iOleClientSite.getAddress()}, 4); + AddRef(); + return COM.S_OK; + } + if (COM.IsEqualGUID(guid, COM.IIDIOleInPlaceSite)) { + COM.MoveMemory(ppvObject, new int[] {iOleInPlaceSite.getAddress()}, 4); + AddRef(); + return COM.S_OK; + } + if (COM.IsEqualGUID(guid, COM.IIDIOleDocumentSite )) { + String progID = getProgramID(); + if (!progID.startsWith("PowerPoint")) { //$NON-NLS-1$ + COM.MoveMemory(ppvObject, new int[] {iOleDocumentSite.getAddress()}, 4); + AddRef(); + return COM.S_OK; + } + } + COM.MoveMemory(ppvObject, new int[] {0}, 4); + return COM.E_NOINTERFACE; +} +/** + * Returns the status of the specified command. The status is any bitwise OR'd combination of + * SWTOLE.OLECMDF_SUPPORTED, SWTOLE.OLECMDF_ENABLED, SWTOLE.OLECMDF_LATCHED, SWTOLE.OLECMDF_NINCHED. + * You can query the status of a command before invoking it with OleClientSite.exec. The + * OLE Document or ActiveX Control must support the IOleCommandTarget to make use of this method. + * + * @param cmd the ID of a command; these are the OLE.OLECMDID_ values - a small set of common + * commands + * + * @return the status of the specified command or 0 if unable to query the OLE Object; these are the + * OLE.OLECMDF_ values + */ +public int queryStatus(int cmd) { + + if (objIOleCommandTarget is null) { + int[] address = new int[1]; + if (objIUnknown.QueryInterface(COM.IIDIOleCommandTarget, address) !is COM.S_OK) + return 0; + objIOleCommandTarget = new IOleCommandTarget(address[0]); + } + + OLECMD olecmd = new OLECMD(); + olecmd.cmdID = cmd; + + int result = objIOleCommandTarget.QueryStatus(null, 1, olecmd, null); + + if (result !is COM.S_OK) return 0; + + return olecmd.cmdf; +} +protected int Release() { + refCount--; + + if (refCount is 0) { + disposeCOMInterfaces(); + } + return refCount; +} +protected void releaseObjectInterfaces() { + + if (objIOleInPlaceObject!is null) + objIOleInPlaceObject.Release(); + objIOleInPlaceObject = null; + + if (objIOleObject !is null) { + objIOleObject.Close(COM.OLECLOSE_NOSAVE); + objIOleObject.Release(); + } + objIOleObject = null; + + if (objDocumentView !is null){ + objDocumentView.Release(); + } + objDocumentView = null; + + if (objIViewObject2 !is null) { + objIViewObject2.SetAdvise(aspect, 0, 0); + objIViewObject2.Release(); + } + objIViewObject2 = null; + + if (objIOleCommandTarget !is null) + objIOleCommandTarget.Release(); + objIOleCommandTarget = null; + + if (objIUnknown !is null){ + objIUnknown.Release(); + } + objIUnknown = null; + + COM.CoFreeUnusedLibraries(); +} +public bool save(File file, bool includeOleInfo) { + if (includeOleInfo) + return saveToStorageFile(file); + return saveToTraditionalFile(file); +} +private bool saveFromContents(int address, File file) { + + bool success = false; + + IStream tempContents = new IStream(address); + tempContents.AddRef(); + + try { + FileOutputStream writer = new FileOutputStream(file); + + int increment = 1024 * 4; + int pv = COM.CoTaskMemAlloc(increment); + int[] pcbWritten = new int[1]; + while (tempContents.Read(pv, increment, pcbWritten) is COM.S_OK && pcbWritten[0] > 0) { + byte[] buffer = new byte[ pcbWritten[0]]; + OS.MoveMemory(buffer, pv, pcbWritten[0]); + writer.write(buffer); // Note: if file does not exist, this will create the file the + // first time it is called + success = true; + } + COM.CoTaskMemFree(pv); + + writer.close(); + + } catch (IOException err) { + } + + tempContents.Release(); + + return success; +} +private bool saveFromOle10Native(int address, File file) { + + bool success = false; + + IStream tempContents = new IStream(address); + tempContents.AddRef(); + + // The "\1Ole10Native" stream contains a DWORD header whose value is the length + // of the native data that follows. + int pv = COM.CoTaskMemAlloc(4); + int[] size = new int[1]; + int rc = tempContents.Read(pv, 4, null); + OS.MoveMemory(size, pv, 4); + COM.CoTaskMemFree(pv); + if (rc is COM.S_OK && size[0] > 0) { + + // Read the data + byte[] buffer = new byte[size[0]]; + pv = COM.CoTaskMemAlloc(size[0]); + rc = tempContents.Read(pv, size[0], null); + OS.MoveMemory(buffer, pv, size[0]); + COM.CoTaskMemFree(pv); + + // open the file and write data into it + try { + FileOutputStream writer = new FileOutputStream(file); + writer.write(buffer); // Note: if file does not exist, this will create the file + writer.close(); + + success = true; + } catch (IOException err) { + } + } + tempContents.Release(); + + return success; +} +private int SaveObject() { + + updateStorage(); + + return COM.S_OK; +} +/** + * Saves the document to the specified file and includes OLE specific information. This method + * must <b>only</b> be used for files that have an OLE Storage format. For example, a word file + * edited with Word.Document should be saved using this method because there is formating information + * that should be stored in the OLE specific Storage format. + * + * @param file the file to which the changes are to be saved + * + * @return true if the save was successful + */ +private bool saveToStorageFile(File file) { + // The file will be saved using the formating of the current application - this + // may not be the format of the application that was originally used to create the file + // e.g. if an Excel file is opened in Word, the Word application will save the file in the + // Word format + // Note: if the file already exists, some applications will not overwrite the file + // In these cases, you should delete the file first (probably save the contents of the file in case the + // save fails) + if (file is null || file.isDirectory()) return false; + if (!updateStorage()) return false; + + // get access to the persistent storage mechanism + int[] address = new int[1]; + if (objIOleObject.QueryInterface(COM.IIDIPersistStorage, address) !is COM.S_OK) return false; + IPersistStorage permStorage = new IPersistStorage(address[0]); + try { + address = new int[1]; + char[] path = (file.getAbsolutePath()+"\0").toCharArray(); + int mode = COM.STGM_TRANSACTED | COM.STGM_READWRITE | COM.STGM_SHARE_EXCLUSIVE | COM.STGM_CREATE; + int result = COM.StgCreateDocfile(path, mode, 0, address); //Does an AddRef if successful + if (result !is COM.S_OK) return false; + IStorage storage = new IStorage(address[0]); + try { + if (COM.OleSave(permStorage.getAddress(), storage.getAddress(), false) is COM.S_OK) { + if (storage.Commit(COM.STGC_DEFAULT) is COM.S_OK) { + return true; + } + } + } finally { + storage.Release(); + } + } finally { + permStorage.Release(); + } + return false; +} +/** + * Saves the document to the specified file. This method must be used for + * files that do not have an OLE Storage format. For example, a bitmap file edited with MSPaint + * should be saved using this method because bitmap is a standard format that does not include any + * OLE specific data. + * + * @param file the file to which the changes are to be saved + * + * @return true if the save was successful + */ +private bool saveToTraditionalFile(File file) { + // Note: if the file already exists, some applications will not overwrite the file + // In these cases, you should delete the file first (probably save the contents of the file in case the + // save fails) + if (file is null || file.isDirectory()) + return false; + if (!updateStorage()) + return false; + + int[] address = new int[1]; + // Look for a CONTENTS stream + if (tempStorage.OpenStream("CONTENTS", 0, COM.STGM_DIRECT | COM.STGM_READ | COM.STGM_SHARE_EXCLUSIVE, 0, address) is COM.S_OK) //$NON-NLS-1$ + return saveFromContents(address[0], file); + + // Look for Ole 1.0 object stream + if (tempStorage.OpenStream("\1Ole10Native", 0, COM.STGM_DIRECT | COM.STGM_READ | COM.STGM_SHARE_EXCLUSIVE, 0, address) is COM.S_OK) //$NON-NLS-1$ + return saveFromOle10Native(address[0], file); + + return false; +} +private int Scroll(int scrollExtant) { + return COM.S_OK; +} +void setBorderSpace(RECT newBorderwidth) { + borderWidths = newBorderwidth; + // readjust size and location of client site + Rectangle area = frame.getClientArea(); + setBounds(borderWidths.left, borderWidths.top, + area.width - borderWidths.left - borderWidths.right, + area.height - borderWidths.top - borderWidths.bottom); + setObjectRects(); +} +private void setExtent(int width, int height){ + // Resize the width and height of the embedded/linked OLENatives object + // to the specified values. + + if (objIOleObject is null || isStatic || inUpdate) return; + SIZE currentExtent = getExtent(); + if (width is currentExtent.cx && height is currentExtent.cy) return; + + SIZE newExtent = new SIZE(); + newExtent.cx = width; newExtent.cy = height; + newExtent = xFormPixelsToHimetric(newExtent); + + // Get the server running first, then do a SetExtent, then show it + bool alreadyRunning = COM.OleIsRunning(objIOleObject.getAddress()); + if (!alreadyRunning) + COM.OleRun(objIOleObject.getAddress()); + + if (objIOleObject.SetExtent(aspect, newExtent) is COM.S_OK){ + inUpdate = true; + objIOleObject.Update(); + inUpdate = false; + if (!alreadyRunning) + // Close server if it wasn't already running upon entering this method. + objIOleObject.Close(COM.OLECLOSE_SAVEIFDIRTY); + } +} +public void setIndent(Rectangle newIndent) { + indent = new RECT(); + indent.left = newIndent.x; + indent.right = newIndent.width; + indent.top = newIndent.y; + indent.bottom = newIndent.height; +} +private void setObjectRects() { + if (objIOleInPlaceObject is null) return; + // size the object to fill the available space + // leave a border + RECT rect = getRect(); + objIOleInPlaceObject.SetObjectRects(rect, rect); +} + +private int ShowObject() { + /* Tells the container to position the object so it is visible to + * the user. This method ensures that the container itself is + * visible and not minimized. + */ + return COM.S_OK; +} +/** + * Displays a dialog with the property information for this OLE Object. The OLE Document or + * ActiveX Control must support the ISpecifyPropertyPages interface. + * + * @param title the name that will appear in the titlebar of the dialog + */ +public void showProperties(String title) { + + // Get the Property Page information from the OLE Object + int[] ppvObject = new int[1]; + if (objIUnknown.QueryInterface(COM.IIDISpecifyPropertyPages, ppvObject) !is COM.S_OK) return; + ISpecifyPropertyPages objISPP = new ISpecifyPropertyPages(ppvObject[0]); + CAUUID caGUID = new CAUUID(); + int result = objISPP.GetPages(caGUID); + objISPP.Release(); + if (result !is COM.S_OK) return; + + // create a frame in which to display the pages + char[] chTitle = null; + if (title !is null) { + chTitle = new char[title.length()]; + title.getChars(0, title.length(), chTitle, 0); + } + result = COM.OleCreatePropertyFrame(frame.handle, 10, 10, chTitle, 1, new int[] {objIUnknown.getAddress()}, caGUID.cElems, caGUID.pElems, COM.LOCALE_USER_DEFAULT, 0, 0); + + // free the property page information + COM.CoTaskMemFree(caGUID.pElems); +} +private bool updateStorage() { + + if (tempStorage is null) return false; + + int[] ppv = new int[1]; + if (objIUnknown.QueryInterface(COM.IIDIPersistStorage, ppv) !is COM.S_OK) return false; + IPersistStorage iPersistStorage = new IPersistStorage(ppv[0]); + + int result = COM.OleSave(iPersistStorage.getAddress(), tempStorage.getAddress(), true); + + if (result !is COM.S_OK){ + // OleSave will fail for static objects, so do what OleSave does. + COM.WriteClassStg(tempStorage.getAddress(), objClsid); + result = iPersistStorage.Save(tempStorage.getAddress(), true); + } + + tempStorage.Commit(COM.STGC_DEFAULT); + result = iPersistStorage.SaveCompleted(0); + iPersistStorage.Release(); + + return true; +} +private SIZE xFormHimetricToPixels(SIZE aSize) { + // Return a new Size which is the pixel transformation of a + // size in HIMETRIC units. + + int hDC = OS.GetDC(0); + int xppi = OS.GetDeviceCaps(hDC, 88); // logical pixels/inch in x + int yppi = OS.GetDeviceCaps(hDC, 90); // logical pixels/inch in y + OS.ReleaseDC(0, hDC); + int cx = Compatibility.round(aSize.cx * xppi, 2540); // 2540 HIMETRIC units per inch + int cy = Compatibility.round(aSize.cy * yppi, 2540); + SIZE size = new SIZE(); + size.cx = cx; + size.cy = cy; + return size; +} +private SIZE xFormPixelsToHimetric(SIZE aSize) { + // Return a new size which is the HIMETRIC transformation of a + // size in pixel units. + + int hDC = OS.GetDC(0); + int xppi = OS.GetDeviceCaps(hDC, 88); // logical pixels/inch in x + int yppi = OS.GetDeviceCaps(hDC, 90); // logical pixels/inch in y + OS.ReleaseDC(0, hDC); + int cx = Compatibility.round(aSize.cx * 2540, xppi); // 2540 HIMETRIC units per inch + int cy = Compatibility.round(aSize.cy * 2540, yppi); + SIZE size = new SIZE(); + size.cx = cx; + size.cy = cy; + return size; +} +} +++/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/ole/win32/OleControlSite.d Fri Feb 08 19:49:32 2008 +0100 @@ -0,0 +1,893 @@ +/******************************************************************************* + * Copyright (c) 2000, 2007 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +module dwt.ole.win32.OleControlSite; + +import dwt.DWT; +import dwt.DWTError; +import dwt.DWTException; +import dwt.graphics.Color; +import dwt.graphics.Font; +import dwt.graphics.FontData; +import dwt.internal.ole.win32.COM; +import dwt.internal.win32.OS; +import dwt.widgets.Composite; +import dwt.widgets.Event; + +import dwt.ole.win32.OleClientSite; + +class OleControlSite : OleClientSite { +} +/++ +/** + * OleControlSite provides a site to manage an embedded ActiveX Control within a container. + * + * <p>In addition to the behaviour provided by OleClientSite, this object provides the following: + * <ul> + * <li>events from the ActiveX control + * <li>notification of property changes from the ActiveX control + * <li>simplified access to well known properties of the ActiveX Control (e.g. font, background color) + * <li>expose ambient properties of the container to the ActiveX Control + * </ul> + * + * <p>This object implements the OLE Interfaces IOleControlSite, IDispatch, and IPropertyNotifySink. + * + * <p>Note that although this class is a subclass of <code>Composite</code>, + * it does not make sense to add <code>Control</code> children to it, + * or set a layout on it. + * </p><p> + * <dl> + * <dt><b>Styles</b> <dd>BORDER + * <dt><b>Events</b> <dd>Dispose, Move, Resize + * </dl> + * + */ +public class OleControlSite extends OleClientSite +{ + // interfaces for this container + private COMObject iOleControlSite; + private COMObject iDispatch; + + // supporting Property Change attributes + private OlePropertyChangeSink olePropertyChangeSink; + + // supporting Event Sink attributes + private OleEventSink[] oleEventSink = new OleEventSink[0]; + private GUID[] oleEventSinkGUID = new GUID[0]; + private int[] oleEventSinkIUnknown = new int[0]; + + // supporting information for the Control COM object + private CONTROLINFO currentControlInfo; + private int[] sitePropertyIds = new int[0]; + private Variant[] sitePropertyValues = new Variant[0]; + + // work around for IE destroying the caret + static int SWT_RESTORECARET; + +/** + * Create an OleControlSite child widget using style bits + * to select a particular look or set of properties. + * + * @param parent a composite widget; must be an OleFrame + * @param style the bitwise OR'ing of widget styles + * @param progId the unique program identifier which has been registered for this ActiveX Control; + * the value of the ProgID key or the value of the VersionIndependentProgID key specified + * in the registry for this Control (for example, the VersionIndependentProgID for + * Internet Explorer is Shell.Explorer) + * + *@exception IllegalArgumentException <ul> + * <li>ERROR_NULL_ARGUMENT when the parent is null + *</ul> + * @exception DWTException <ul> + * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread + * <li>ERROR_INVALID_CLASSID when the progId does not map to a registered CLSID + * <li>ERROR_CANNOT_CREATE_OBJECT when failed to create OLE Object + * <li>ERROR_CANNOT_ACCESS_CLASSFACTORY when Class Factory could not be found + * <li>ERROR_CANNOT_CREATE_LICENSED_OBJECT when failed to create a licensed OLE Object + * </ul> + */ +public OleControlSite(Composite parent, int style, String progId) { + super(parent, style); + try { + + // check for licensing + appClsid = getClassID(progId); + if (appClsid is null) OLE.error(OLE.ERROR_INVALID_CLASSID); + + int licinfo = getLicenseInfo(appClsid); + if (licinfo is 0) { + + // Open a storage object + tempStorage = createTempStorage(); + + // Create ole object with storage object + int[] address = new int[1]; + int result = COM.OleCreate(appClsid, COM.IIDIUnknown, COM.OLERENDER_DRAW, null, 0, tempStorage.getAddress(), address); + if (result !is COM.S_OK) + OLE.error(OLE.ERROR_CANNOT_CREATE_OBJECT, result); + + objIUnknown = new IUnknown(address[0]); + + } else { + // Prepare the ClassFactory + int[] ppvObject = new int[1]; + try { + int result = COM.CoGetClassObject(appClsid, COM.CLSCTX_INPROC_HANDLER | COM.CLSCTX_INPROC_SERVER, 0, COM.IIDIClassFactory2, ppvObject); + if (result !is COM.S_OK) { + OLE.error(OLE.ERROR_CANNOT_ACCESS_CLASSFACTORY, result); + } + IClassFactory2 classFactory = new IClassFactory2(ppvObject[0]); + // Create Com Object + ppvObject = new int[1]; + result = classFactory.CreateInstanceLic(0, 0, COM.IIDIUnknown, licinfo, ppvObject); + classFactory.Release(); + if (result !is COM.S_OK) + OLE.error(OLE.ERROR_CANNOT_CREATE_LICENSED_OBJECT, result); + } finally { + COM.SysFreeString(licinfo); + } + + objIUnknown = new IUnknown(ppvObject[0]); + + // Prepare a storage medium + ppvObject = new int[1]; + if (objIUnknown.QueryInterface(COM.IIDIPersistStorage, ppvObject) is COM.S_OK) { + IPersistStorage persist = new IPersistStorage(ppvObject[0]); + tempStorage = createTempStorage(); + persist.InitNew(tempStorage.getAddress()); + persist.Release(); + } + } + + // Init sinks + addObjectReferences(); + + // Init site properties + setSiteProperty(COM.DISPID_AMBIENT_USERMODE, new Variant(true)); + setSiteProperty(COM.DISPID_AMBIENT_UIDEAD, new Variant(false)); + + if (COM.OleRun(objIUnknown.getAddress()) is OLE.S_OK) state= STATE_RUNNING; + + } catch (DWTError e) { + dispose(); + disposeCOMInterfaces(); + throw e; + } +} +/** + * Adds the listener to receive events. + * + * @param eventID the id of the event + * + * @param listener the listener + * + * @exception IllegalArgumentException <ul> + * <li>ERROR_NULL_ARGUMENT when listener is null</li> + * </ul> + */ +public void addEventListener(int eventID, OleListener listener) { + if (listener is null) OLE.error (DWT.ERROR_NULL_ARGUMENT); + GUID riid = getDefaultEventSinkGUID(objIUnknown); + if (riid !is null) { + addEventListener(objIUnknown.getAddress(), riid, eventID, listener); + } + +} +static GUID getDefaultEventSinkGUID(IUnknown unknown) { + // get Event Sink I/F from IProvideClassInfo2 + int[] ppvObject = new int[1]; + if (unknown.QueryInterface(COM.IIDIProvideClassInfo2, ppvObject) is COM.S_OK) { + IProvideClassInfo2 pci2 = new IProvideClassInfo2(ppvObject[0]); + GUID riid = new GUID(); + int result = pci2.GetGUID(COM.GUIDKIND_DEFAULT_SOURCE_DISP_IID, riid); + pci2.Release(); + if (result is COM.S_OK) return riid; + } + + // get Event Sink I/F from IProvideClassInfo + if (unknown.QueryInterface(COM.IIDIProvideClassInfo, ppvObject) is COM.S_OK) { + IProvideClassInfo pci = new IProvideClassInfo(ppvObject[0]); + int[] ppTI = new int[1]; + int[] ppEI = new int[1]; + int result = pci.GetClassInfo(ppTI); + pci.Release(); + + if (result is COM.S_OK && ppTI[0] !is 0) { + ITypeInfo classInfo = new ITypeInfo(ppTI[0]); + int[] ppTypeAttr = new int[1]; + result = classInfo.GetTypeAttr(ppTypeAttr); + if (result is COM.S_OK && ppTypeAttr[0] !is 0) { + TYPEATTR typeAttribute = new TYPEATTR(); + COM.MoveMemory(typeAttribute, ppTypeAttr[0], TYPEATTR.sizeof); + classInfo.ReleaseTypeAttr(ppTypeAttr[0]); + int implMask = COM.IMPLTYPEFLAG_FDEFAULT | COM.IMPLTYPEFLAG_FSOURCE | COM.IMPLTYPEFLAG_FRESTRICTED; + int implBits = COM.IMPLTYPEFLAG_FDEFAULT | COM.IMPLTYPEFLAG_FSOURCE; + + for (int i = 0; i < typeAttribute.cImplTypes; i++) { + int[] pImplTypeFlags = new int[1]; + if (classInfo.GetImplTypeFlags(i, pImplTypeFlags) is COM.S_OK) { + if ((pImplTypeFlags[0] & implMask) is implBits) { + int[] pRefType = new int[1]; + if (classInfo.GetRefTypeOfImplType(i, pRefType) is COM.S_OK) { + classInfo.GetRefTypeInfo(pRefType[0], ppEI); + } + } + } + } + } + classInfo.Release(); + + if (ppEI[0] !is 0) { + ITypeInfo eventInfo = new ITypeInfo(ppEI[0]); + ppTypeAttr = new int[1]; + result = eventInfo.GetTypeAttr(ppTypeAttr); + GUID riid = null; + if (result is COM.S_OK && ppTypeAttr[0] !is 0) { + riid = new GUID(); + COM.MoveMemory(riid, ppTypeAttr[0], GUID.sizeof); + eventInfo.ReleaseTypeAttr(ppTypeAttr[0]); + } + eventInfo.Release(); + return riid; + } + } + } + return null; +} + +/** + * Adds the listener to receive events. + * + * @since 2.0 + * + * @param automation the automation object that provides the event notification + * @param eventID the id of the event + * @param listener the listener + * + * @exception IllegalArgumentException <ul> + * <li>ERROR_NULL_ARGUMENT when listener is null</li> + * </ul> + */ +public void addEventListener(OleAutomation automation, int eventID, OleListener listener) { + if (listener is null || automation is null) OLE.error (DWT.ERROR_NULL_ARGUMENT); + int address = automation.getAddress(); + IUnknown unknown = new IUnknown(address); + GUID riid = getDefaultEventSinkGUID(unknown); + if (riid !is null) { + addEventListener(address, riid, eventID, listener); + } + +} +/** + * Adds the listener to receive events. + * + * @since 3.2 + * + * @param automation the automation object that provides the event notification + * @param eventSinkId the GUID of the event sink + * @param eventID the id of the event + * @param listener the listener + * + * @exception IllegalArgumentException <ul> + * <li>ERROR_NULL_ARGUMENT when listener is null</li> + * </ul> + */ +public void addEventListener(OleAutomation automation, String eventSinkId, int eventID, OleListener listener) { + if (listener is null || automation is null || eventSinkId is null) OLE.error (DWT.ERROR_NULL_ARGUMENT); + int address = automation.getAddress(); + if (address is 0) return; + char[] buffer = (eventSinkId +"\0").toCharArray(); + GUID guid = new GUID(); + if (COM.IIDFromString(buffer, guid) !is COM.S_OK) return; + addEventListener(address, guid, eventID, listener); +} + +void addEventListener(int iunknown, GUID guid, int eventID, OleListener listener) { + if (listener is null || iunknown is 0 || guid is null) OLE.error (DWT.ERROR_NULL_ARGUMENT); + // have we connected to this kind of event sink before? + int index = -1; + for (int i = 0; i < oleEventSinkGUID.length; i++) { + if (COM.IsEqualGUID(oleEventSinkGUID[i], guid)) { + if (iunknown is oleEventSinkIUnknown[i]) { + index = i; + break; + } + } + } + if (index !is -1) { + oleEventSink[index].addListener(eventID, listener); + } else { + int oldLength = oleEventSink.length; + OleEventSink[] newOleEventSink = new OleEventSink[oldLength + 1]; + GUID[] newOleEventSinkGUID = new GUID[oldLength + 1]; + int[] newOleEventSinkIUnknown = new int[oldLength + 1]; + System.arraycopy(oleEventSink, 0, newOleEventSink, 0, oldLength); + System.arraycopy(oleEventSinkGUID, 0, newOleEventSinkGUID, 0, oldLength); + System.arraycopy(oleEventSinkIUnknown, 0, newOleEventSinkIUnknown, 0, oldLength); + oleEventSink = newOleEventSink; + oleEventSinkGUID = newOleEventSinkGUID; + oleEventSinkIUnknown = newOleEventSinkIUnknown; + + oleEventSink[oldLength] = new OleEventSink(this, iunknown, guid); + oleEventSinkGUID[oldLength] = guid; + oleEventSinkIUnknown[oldLength] = iunknown; + oleEventSink[oldLength].AddRef(); + oleEventSink[oldLength].connect(); + oleEventSink[oldLength].addListener(eventID, listener); + + } +} +protected void addObjectReferences() { + + super.addObjectReferences(); + + // Get property change notification from control + connectPropertyChangeSink(); + + // Get access to the Control object + int[] ppvObject = new int[1]; + if (objIUnknown.QueryInterface(COM.IIDIOleControl, ppvObject) is COM.S_OK) { + IOleControl objIOleControl = new IOleControl(ppvObject[0]); + // ask the control for its info in case users + // need to act on it + currentControlInfo = new CONTROLINFO(); + objIOleControl.GetControlInfo(currentControlInfo); + objIOleControl.Release(); + } +} +/** + * Adds the listener to receive events. + * + * @param propertyID the identifier of the property + * @param listener the listener + * + * @exception IllegalArgumentException <ul> + * <li>ERROR_NULL_ARGUMENT when listener is null</li> + * </ul> + */ +public void addPropertyListener(int propertyID, OleListener listener) { + if (listener is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); + olePropertyChangeSink.addListener(propertyID, listener); +} + +private void connectPropertyChangeSink() { + olePropertyChangeSink = new OlePropertyChangeSink(this); + olePropertyChangeSink.AddRef(); + olePropertyChangeSink.connect(objIUnknown); +} +protected void createCOMInterfaces () { + super.createCOMInterfaces(); + + // register each of the interfaces that this object implements + iOleControlSite = new COMObject(new int[]{2, 0, 0, 0, 1, 1, 3, 2, 1, 0}){ + public int method0(int[] args) {return QueryInterface(args[0], args[1]);} + public int method1(int[] args) {return AddRef();} + public int method2(int[] args) {return Release();} + public int method3(int[] args) {return OnControlInfoChanged();} + // method4 LockInPlaceActive - not implemented + // method5 GetExtendedControl - not implemented + // method6 TransformCoords - not implemented + // method7 Translate Accelerator - not implemented + public int method8(int[] args) {return OnFocus(args[0]);} + // method9 ShowPropertyFrame - not implemented + }; + + iDispatch = new COMObject(new int[]{2, 0, 0, 1, 3, 5, 8}){ + public int method0(int[] args) {return QueryInterface(args[0], args[1]);} + public int method1(int[] args) {return AddRef();} + public int method2(int[] args) {return Release();} + // method3 GetTypeInfoCount - not implemented + // method4 GetTypeInfo - not implemented + // method5 GetIDsOfNames - not implemented + public int method6(int[] args) {return Invoke(args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7]);} + }; +} +private void disconnectEventSinks() { + + for (int i = 0; i < oleEventSink.length; i++) { + OleEventSink sink = oleEventSink[i]; + sink.disconnect(); + sink.Release(); + } + oleEventSink = new OleEventSink[0]; + oleEventSinkGUID = new GUID[0]; + oleEventSinkIUnknown = new int[0]; +} +private void disconnectPropertyChangeSink() { + + if (olePropertyChangeSink !is null) { + olePropertyChangeSink.disconnect(objIUnknown); + olePropertyChangeSink.Release(); + } + olePropertyChangeSink = null; +} +protected void disposeCOMInterfaces() { + super.disposeCOMInterfaces(); + + if (iOleControlSite !is null) + iOleControlSite.dispose(); + iOleControlSite = null; + + if (iDispatch !is null) + iDispatch.dispose(); + iDispatch = null; +} +public Color getBackground () { + + if (objIUnknown !is null) { + // !! We are getting the OLE_COLOR - should we change this to the COLORREF value? + OleAutomation oleObject= new OleAutomation(this); + Variant varBackColor = oleObject.getProperty(COM.DISPID_BACKCOLOR); + oleObject.dispose(); + + if (varBackColor !is null){ + int[] colorRef = new int[1]; + if (COM.OleTranslateColor(varBackColor.getInt(), getDisplay().hPalette, colorRef) is COM.S_OK) + return Color.win32_new(getDisplay(), colorRef[0]); + } + } + + return super.getBackground(); +} +public Font getFont () { + + if (objIUnknown !is null) { + OleAutomation oleObject= new OleAutomation(this); + Variant varDispFont = oleObject.getProperty(COM.DISPID_FONT); + oleObject.dispose(); + + if (varDispFont !is null){ + OleAutomation iDispFont = varDispFont.getAutomation(); + Variant lfFaceName = iDispFont.getProperty(COM.DISPID_FONT_NAME); + Variant lfHeight = iDispFont.getProperty(COM.DISPID_FONT_SIZE); + Variant lfItalic = iDispFont.getProperty(COM.DISPID_FONT_ITALIC); + //Variant lfCharSet = iDispFont.getProperty(COM.DISPID_FONT_CHARSET); + Variant lfBold = iDispFont.getProperty(COM.DISPID_FONT_BOLD); + iDispFont.dispose(); + + if (lfFaceName !is null && + lfHeight !is null && + lfItalic !is null && + lfBold !is null){ + int style = 3 * lfBold.getInt() + 2 * lfItalic.getInt(); + Font font = new Font(getShell().getDisplay(), lfFaceName.getString(), lfHeight.getInt(), style); + return font; + } + } + } + + return super.getFont(); +} +public Color getForeground () { + + if (objIUnknown !is null) { + // !! We are getting the OLE_COLOR - should we change this to the COLORREF value? + OleAutomation oleObject= new OleAutomation(this); + Variant varForeColor = oleObject.getProperty(COM.DISPID_FORECOLOR); + oleObject.dispose(); + + if (varForeColor !is null){ + int[] colorRef = new int[1]; + if (COM.OleTranslateColor(varForeColor.getInt(), getDisplay().hPalette, colorRef) is COM.S_OK) + return Color.win32_new(getDisplay(), colorRef[0]); + } + } + + return super.getForeground(); +} +protected int getLicenseInfo(GUID clsid) { + int[] ppvObject = new int[1]; + + if (COM.CoGetClassObject(clsid, COM.CLSCTX_INPROC_HANDLER | COM.CLSCTX_INPROC_SERVER, 0, COM.IIDIClassFactory2, ppvObject) !is COM.S_OK) { + return 0; + } + IClassFactory2 classFactory = new IClassFactory2(ppvObject[0]); + LICINFO licinfo = new LICINFO(); + if (classFactory.GetLicInfo(licinfo) !is COM.S_OK) { + classFactory.Release(); + return 0; + } + int[] pBstrKey = new int[1]; + if (licinfo !is null && licinfo.fRuntimeKeyAvail) { + if (classFactory.RequestLicKey(0, pBstrKey) is COM.S_OK) { + classFactory.Release(); + return pBstrKey[0]; + } + } + classFactory.Release(); + return 0; +} +/** + * + * Get the control site property specified by the dispIdMember. + * + * @since 2.1 + * + */ +public Variant getSiteProperty(int dispId){ + for (int i = 0; i < sitePropertyIds.length; i++) { + if (sitePropertyIds[i] is dispId) { + return sitePropertyValues[i]; + } + } + return null; +} +protected int GetWindow(int phwnd) { + + if (phwnd is 0) + return COM.E_INVALIDARG; + if (frame is null) { + COM.MoveMemory(phwnd, new int[] {0}, 4); + return COM.E_NOTIMPL; + } + + // Copy the Window's handle into the memory passed in + COM.MoveMemory(phwnd, new int[] {handle}, 4); + return COM.S_OK; +} +private int Invoke(int dispIdMember, int riid, int lcid, int dwFlags, int pDispParams, int pVarResult, int pExcepInfo, int pArgErr) { + if (pVarResult is 0 || dwFlags !is COM.DISPATCH_PROPERTYGET) { + if (pExcepInfo !is 0) COM.MoveMemory(pExcepInfo, new int[] {0}, 4); + if (pArgErr !is 0) COM.MoveMemory(pArgErr, new int[] {0}, 4); + return COM.DISP_E_MEMBERNOTFOUND; + } + Variant result = getSiteProperty(dispIdMember); + if (result !is null) { + if (pVarResult !is 0) result.getData(pVarResult); + return COM.S_OK; + } + switch (dispIdMember) { + // indicate a false result + case COM.DISPID_AMBIENT_SUPPORTSMNEMONICS : + case COM.DISPID_AMBIENT_SHOWGRABHANDLES : + case COM.DISPID_AMBIENT_SHOWHATCHING : + if (pVarResult !is 0) COM.MoveMemory(pVarResult, new int[] {0}, 4); + if (pExcepInfo !is 0) COM.MoveMemory(pExcepInfo, new int[] {0}, 4); + if (pArgErr !is 0) COM.MoveMemory(pArgErr, new int[] {0}, 4); + return COM.S_FALSE; + + // not implemented + case COM.DISPID_AMBIENT_OFFLINEIFNOTCONNECTED : + case COM.DISPID_AMBIENT_BACKCOLOR : + case COM.DISPID_AMBIENT_FORECOLOR : + case COM.DISPID_AMBIENT_FONT : + case COM.DISPID_AMBIENT_LOCALEID : + case COM.DISPID_AMBIENT_SILENT : + case COM.DISPID_AMBIENT_MESSAGEREFLECT : + if (pVarResult !is 0) COM.MoveMemory(pVarResult, new int[] {0}, 4); + if (pExcepInfo !is 0) COM.MoveMemory(pExcepInfo, new int[] {0}, 4); + if (pArgErr !is 0) COM.MoveMemory(pArgErr, new int[] {0}, 4); + return COM.E_NOTIMPL; + + default : + if (pVarResult !is 0) COM.MoveMemory(pVarResult, new int[] {0}, 4); + if (pExcepInfo !is 0) COM.MoveMemory(pExcepInfo, new int[] {0}, 4); + if (pArgErr !is 0) COM.MoveMemory(pArgErr, new int[] {0}, 4); + return COM.DISP_E_MEMBERNOTFOUND; + } +} +private int OnControlInfoChanged() { + int[] ppvObject = new int[1]; + if (objIUnknown.QueryInterface(COM.IIDIOleControl, ppvObject) is COM.S_OK) { + IOleControl objIOleControl = new IOleControl(ppvObject[0]); + // ask the control for its info in case users + // need to act on it + currentControlInfo = new CONTROLINFO(); + objIOleControl.GetControlInfo(currentControlInfo); + objIOleControl.Release(); + } + return COM.S_OK; +} +void onFocusIn(Event e) { + if (objIOleInPlaceObject is null) return; + doVerb(OLE.OLEIVERB_UIACTIVATE); + if (isFocusControl()) return; + int[] phwnd = new int[1]; + objIOleInPlaceObject.GetWindow(phwnd); + if (phwnd[0] is 0) return; + OS.SetFocus(phwnd[0]); +} +void onFocusOut(Event e) { + if (objIOleInPlaceObject !is null) { + /* + * Bug in Windows. When IE7 loses focus and UIDeactivate() + * is called, IE destroys the caret even though it is + * no longer owned by IE. If focus has moved to a control + * that shows a caret then the caret disappears. The fix + * is to detect this case and restore the caret. + */ + int threadId = OS.GetCurrentThreadId(); + GUITHREADINFO lpgui1 = new GUITHREADINFO(); + lpgui1.cbSize = GUITHREADINFO.sizeof; + OS.GetGUIThreadInfo(threadId, lpgui1); + objIOleInPlaceObject.UIDeactivate(); + if (lpgui1.hwndCaret !is 0) { + GUITHREADINFO lpgui2 = new GUITHREADINFO(); + lpgui2.cbSize = GUITHREADINFO.sizeof; + OS.GetGUIThreadInfo(threadId, lpgui2); + if (lpgui2.hwndCaret is 0 && lpgui1.hwndCaret is OS.GetFocus()) { + if (SWT_RESTORECARET is 0) { + SWT_RESTORECARET = OS.RegisterWindowMessage (new TCHAR (0, "SWT_RESTORECARET", true)); + } + /* + * If the caret was not restored by DWT, put it back using + * the information from GUITHREADINFO. Note that this will + * not be correct when the caret has a bitmap. There is no + * API to query the bitmap that the caret is using. + */ + if (OS.SendMessage (lpgui1.hwndCaret, SWT_RESTORECARET, 0, 0) is 0) { + int width = lpgui1.right - lpgui1.left; + int height = lpgui1.bottom - lpgui1.top; + OS.CreateCaret (lpgui1.hwndCaret, 0, width, height); + OS.SetCaretPos (lpgui1.left, lpgui1.top); + OS.ShowCaret (lpgui1.hwndCaret); + } + } + } + } +} +private int OnFocus(int fGotFocus) { + return COM.S_OK; +} +protected int OnUIDeactivate(int fUndoable) { + // controls don't need to do anything for + // border space or menubars + state = STATE_INPLACEACTIVE; + return COM.S_OK; +} +protected int QueryInterface(int riid, int ppvObject) { + int result = super.QueryInterface(riid, ppvObject); + if (result is COM.S_OK) + return result; + if (riid is 0 || ppvObject is 0) + return COM.E_INVALIDARG; + GUID guid = new GUID(); + COM.MoveMemory(guid, riid, GUID.sizeof); + if (COM.IsEqualGUID(guid, COM.IIDIOleControlSite)) { + COM.MoveMemory(ppvObject, new int[] {iOleControlSite.getAddress()}, 4); + AddRef(); + return COM.S_OK; + } + if (COM.IsEqualGUID(guid, COM.IIDIDispatch)) { + COM.MoveMemory(ppvObject, new int[] {iDispatch.getAddress()}, 4); + AddRef(); + return COM.S_OK; + } + COM.MoveMemory(ppvObject, new int[] {0}, 4); + return COM.E_NOINTERFACE; +} +protected int Release() { + int result = super.Release(); + if (result is 0) { + for (int i = 0; i < sitePropertyIds.length; i++) { + sitePropertyValues[i].dispose(); + } + sitePropertyIds = new int[0]; + sitePropertyValues = new Variant[0]; + } + return result; +} +protected void releaseObjectInterfaces() { + + disconnectEventSinks(); + + disconnectPropertyChangeSink(); + + super.releaseObjectInterfaces(); +} +/** + * Removes the listener. + * + * @param eventID the event identifier + * + * @param listener the listener + * + * @exception IllegalArgumentException <ul> + * <li>ERROR_NULL_ARGUMENT when listener is null</li> + * </ul> + */ +public void removeEventListener(int eventID, OleListener listener) { + checkWidget(); + if (listener is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); + + GUID riid = getDefaultEventSinkGUID(objIUnknown); + if (riid !is null) { + removeEventListener(objIUnknown.getAddress(), riid, eventID, listener); + } +} +/** + * Removes the listener. + * + * @since 2.0 + * @deprecated - use OleControlSite.removeEventListener(OleAutomation, int, OleListener) + * + * @param automation the automation object that provides the event notification + * + * @param guid the identifier of the events COM interface + * + * @param eventID the event identifier + * + * @param listener the listener + * + * @exception IllegalArgumentException <ul> + * <li>ERROR_NULL_ARGUMENT when listener is null</li> + * </ul> + */ +public void removeEventListener(OleAutomation automation, GUID guid, int eventID, OleListener listener) { + checkWidget(); + if (automation is null || listener is null || guid is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); + removeEventListener(automation.getAddress(), guid, eventID, listener); +} +/** + * Removes the listener. + * + * @since 2.0 + * + * @param automation the automation object that provides the event notification + * + * @param eventID the event identifier + * + * @param listener the listener + * + * @exception IllegalArgumentException <ul> + * <li>ERROR_NULL_ARGUMENT when listener is null</li> + * </ul> + */ +public void removeEventListener(OleAutomation automation, int eventID, OleListener listener) { + checkWidget(); + if (automation is null || listener is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); + int address = automation.getAddress(); + IUnknown unknown = new IUnknown(address); + GUID riid = getDefaultEventSinkGUID(unknown); + if (riid !is null) { + removeEventListener(address, riid, eventID, listener); + } +} +void removeEventListener(int iunknown, GUID guid, int eventID, OleListener listener) { + if (listener is null || guid is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); + for (int i = 0; i < oleEventSink.length; i++) { + if (COM.IsEqualGUID(oleEventSinkGUID[i], guid)) { + if (iunknown is oleEventSinkIUnknown[i]) { + oleEventSink[i].removeListener(eventID, listener); + if (!oleEventSink[i].hasListeners()) { + //free resources associated with event sink + oleEventSink[i].disconnect(); + oleEventSink[i].Release(); + int oldLength = oleEventSink.length; + if (oldLength is 1) { + oleEventSink = new OleEventSink[0]; + oleEventSinkGUID = new GUID[0]; + oleEventSinkIUnknown = new int[0]; + } else { + OleEventSink[] newOleEventSink = new OleEventSink[oldLength - 1]; + System.arraycopy(oleEventSink, 0, newOleEventSink, 0, i); + System.arraycopy(oleEventSink, i + 1, newOleEventSink, i, oldLength - i - 1); + oleEventSink = newOleEventSink; + + GUID[] newOleEventSinkGUID = new GUID[oldLength - 1]; + System.arraycopy(oleEventSinkGUID, 0, newOleEventSinkGUID, 0, i); + System.arraycopy(oleEventSinkGUID, i + 1, newOleEventSinkGUID, i, oldLength - i - 1); + oleEventSinkGUID = newOleEventSinkGUID; + + int[] newOleEventSinkIUnknown = new int[oldLength - 1]; + System.arraycopy(oleEventSinkIUnknown, 0, newOleEventSinkIUnknown, 0, i); + System.arraycopy(oleEventSinkIUnknown, i + 1, newOleEventSinkIUnknown, i, oldLength - i - 1); + oleEventSinkIUnknown = newOleEventSinkIUnknown; + } + } + return; + } + } + } +} +/** + * Removes the listener. + * + * @param listener the listener + * + * @exception IllegalArgumentException <ul> + * <li>ERROR_NULL_ARGUMENT when listener is null</li> + * </ul> + */ +public void removePropertyListener(int propertyID, OleListener listener) { + if (listener is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); + olePropertyChangeSink.removeListener(propertyID, listener); +} +public void setBackground (Color color) { + + super.setBackground(color); + + //set the background of the ActiveX Control + if (objIUnknown !is null) { + OleAutomation oleObject= new OleAutomation(this); + oleObject.setProperty(COM.DISPID_BACKCOLOR, new Variant(color.handle)); + oleObject.dispose(); + } +} +public void setFont (Font font) { + + super.setFont(font); + + //set the font of the ActiveX Control + if (objIUnknown !is null) { + + OleAutomation oleObject= new OleAutomation(this); + Variant varDispFont = oleObject.getProperty(COM.DISPID_FONT); + oleObject.dispose(); + + if (varDispFont !is null){ + OleAutomation iDispFont = varDispFont.getAutomation(); + FontData[] fdata = font.getFontData(); + iDispFont.setProperty(COM.DISPID_FONT_NAME, new Variant(fdata[0].getName())); + iDispFont.setProperty(COM.DISPID_FONT_SIZE, new Variant(fdata[0].getHeight())); + iDispFont.setProperty(COM.DISPID_FONT_ITALIC, new Variant(fdata[0].getStyle() & DWT.ITALIC)); + //iDispFont.setProperty(COM.DISPID_FONT_CHARSET, new Variant(fdata[0].getCharset)); + iDispFont.setProperty(COM.DISPID_FONT_BOLD, new Variant((fdata[0].getStyle() & DWT.BOLD))); + iDispFont.dispose(); + } + } + + return; +} +public void setForeground (Color color) { + + super.setForeground(color); + + //set the foreground of the ActiveX Control + if (objIUnknown !is null) { + OleAutomation oleObject= new OleAutomation(this); + oleObject.setProperty(COM.DISPID_FORECOLOR, new Variant(color.handle)); + oleObject.dispose(); + } +} +/** + * Sets the control site property specified by the dispIdMember to a new value. + * The value will be disposed by the control site when it is no longer required + * using Variant.dispose. Passing a value of null will clear the dispId value. + * + * @param dispId the ID of the property as specified by the IDL of the ActiveX Control + * @param value The new value for the property as expressed in a Variant. + * + * @since 2.1 + */ +public void setSiteProperty(int dispId, Variant value){ + for (int i = 0; i < sitePropertyIds.length; i++) { + if (sitePropertyIds[i] is dispId) { + if (sitePropertyValues[i] !is null) { + sitePropertyValues[i].dispose(); + } + if (value !is null) { + sitePropertyValues[i] = value; + } else { + int oldLength = sitePropertyIds.length; + int[] newSitePropertyIds = new int[oldLength - 1]; + Variant[] newSitePropertyValues = new Variant[oldLength - 1]; + System.arraycopy(sitePropertyIds, 0, newSitePropertyIds, 0, i); + System.arraycopy(sitePropertyIds, i + 1, newSitePropertyIds, i, oldLength - i - 1); + System.arraycopy(sitePropertyValues, 0, newSitePropertyValues, 0, i); + System.arraycopy(sitePropertyValues, i + 1, newSitePropertyValues, i, oldLength - i - 1); + sitePropertyIds = newSitePropertyIds; + sitePropertyValues = newSitePropertyValues; + } + return; + } + } + int oldLength = sitePropertyIds.length; + int[] newSitePropertyIds = new int[oldLength + 1]; + Variant[] newSitePropertyValues = new Variant[oldLength + 1]; + System.arraycopy(sitePropertyIds, 0, newSitePropertyIds, 0, oldLength); + System.arraycopy(sitePropertyValues, 0, newSitePropertyValues, 0, oldLength); + newSitePropertyIds[oldLength] = dispId; + newSitePropertyValues[oldLength] = value; + sitePropertyIds = newSitePropertyIds; + sitePropertyValues = newSitePropertyValues; +} +} +++/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/ole/win32/Variant.d Fri Feb 08 19:49:32 2008 +0100 @@ -0,0 +1,1082 @@ +/******************************************************************************* + * Copyright (c) 2000, 2006 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +module dwt.ole.win32.Variant; + +import dwt.DWT; +import dwt.DWTException; +import dwt.internal.ole.win32.extras; +import dwt.internal.ole.win32.COM; +import dwt.internal.ole.win32.COMTYPES; +import dwt.internal.ole.win32.OAIDL; +import dwt.internal.win32.OS; + +import dwt.ole.win32.OleAutomation; +import dwt.ole.win32.OLE; + +import tango.util.Convert; +import tango.text.convert.Format; + +/** + * + * A Variant is a generic OLE mechanism for passing data of different types via a common interface. + * + * <p>It is used within the OleAutomation object for getting a property, setting a property or invoking + * a method on an OLE Control or OLE Document. + * + */ +public final class Variant +{ + /** + * A variant always takes up 16 bytes, no matter what you + * store in it. Objects, strings, and arrays are not physically + * stored in the Variant; in these cases, four bytes of the + * Variant are used to hold either an object reference, or a + * pointer to the string or array. The actual data are stored elsewhere. + */ + //public static final int sizeof = 16; + private short type; // OLE.VT_* type + + private bool booleanData; + private byte byteData; + private short shortData; + private char charData; + private int intData; + private long longData; + private float floatData; + private double doubleData; + private char[] stringData; + private void* byRefPtr; + private IDispatch dispatchData; + private IUnknown unknownData; + +/** + * Invokes platform specific functionality to copy a variant + * into operating system memory. + * <p> + * <b>IMPORTANT:</b> This method is <em>not</em> part of the public + * API for <code>Variant</code>. It is marked public only so that it + * can be shared within the packages provided by DWT. It is not + * available on all platforms, and should never be called from + * application code. + * </p> + * + * @param pVarDest destination pointer to a variant + * @param varSrc source <code>Variant</code> + * + * @since 3.3 + */ +public static void win32_copy (VARIANT* pVarDest, Variant varSrc) { + varSrc.getData (pVarDest); +} + +/** + * Invokes platform specific functionality to wrap a variant + * that was allocated in operating system memory. + * <p> + * <b>IMPORTANT:</b> This method is <em>not</em> part of the public + * API for <code>Variant</code>. It is marked public only so that it + * can be shared within the packages provided by DWT. It is not + * available on all platforms, and should never be called from + * application code. + * </p> + * + * @param pVariant pointer to a variant + * + * @return a new <code>Variant</code> + * + * @since 3.3 + */ +public static Variant win32_new (VARIANT* pVariant) { + Variant variant = new Variant (); + variant.setData (pVariant); + return variant; +} + +/** + * Create an empty Variant object with type VT_EMPTY. + * + * @since 2.0 + */ +public this(){ + type = COM.VT_EMPTY; +} +/** + * Create a Variant object which represents a Java float as a VT_R4. + * + * @param val the Java float value that this Variant represents + * + */ +public this(float val) { + type = COM.VT_R4; + floatData = val; + +} +/** + * Create a Variant object which represents a Java double as a VT_R8. + * + * @param val the Java double value that this Variant represents + * + * @since 3.2 + */ +public this(double val) { + type = COM.VT_R8; + doubleData = val; +} +/** + * Create a Variant object which represents a Java int as a VT_I4. + * + * @param val the Java int value that this Variant represents + * + */ +public this(int val) { + type = COM.VT_I4; + intData = val; +} +public this(uint val) { + type = COM.VT_I4; + intData = val; +} +/** + * Create a Variant object which contains a reference to the data being transferred. + * + * <p>When creating a VT_BYREF Variant, you must give the full Variant type + * including VT_BYREF such as + * + * <pre><code>short byRefType = OLE.VT_BSTR | OLE.VT_BYREF</code></pre>. + * + * @param ptr a pointer to the data being transferred. + * @param byRefType the type of the data being transferred such as OLE.VT_BSTR | OLE.VT_BYREF + * + */ +public this(void* ptr, ushort byRefType) { + type = byRefType; + byRefPtr = ptr; +} +/** + * Create a Variant object which represents an IDispatch interface as a VT_Dispatch. + * + * @param automation the OleAutomation object that this Variant represents + * + */ +public this(OleAutomation automation) { + type = COM.VT_DISPATCH; + dispatchData = automation.getAddress(); +} +/** + * Create a Variant object which represents an IDispatch interface as a VT_Dispatch. + * <p>The caller is expected to have appropriately invoked unknown.AddRef() before creating + * this Variant. + * + * @since 2.0 + * + * @param idispatch the IDispatch object that this Variant represents + * + */ +public this(IDispatch idispatch) { + type = COM.VT_DISPATCH; + dispatchData = idispatch; +} +/** + * Create a Variant object which represents an IUnknown interface as a VT_UNKNOWN. + * + * <p>The caller is expected to have appropriately invoked unknown.AddRef() before creating + * this Variant. + * + * @param unknown the IUnknown object that this Variant represents + * + */ +public this(IUnknown unknown) { + type = COM.VT_UNKNOWN; + unknownData = unknown; +} +/** + * Create a Variant object which represents a Java long as a VT_I8. + * + * @param val the Java long value that this Variant represents + * + *@since 3.2 + */ + public this(long val) { + type = COM.VT_I8; + longData = val; +} +/** + * Create a Variant object which represents a Java String as a VT_BSTR. + * + * @param string the Java String value that this Variant represents + * + */ +public this(char[] string) { + type = COM.VT_BSTR; + stringData = string; +} +/** + * Create a Variant object which represents a Java short as a VT_I2. + * + * @param val the Java short value that this Variant represents + * + */ +public this(short val) { + type = COM.VT_I2; + shortData = val; +} +/** + * Create a Variant object which represents a Java bool as a VT_BOOL. + * + * @param val the Java bool value that this Variant represents + * + */ +public this(bool val) { + type = COM.VT_BOOL; + booleanData = val; +} + +/** + * Calling dispose will release resources associated with this Variant. + * If the resource is an IDispatch or IUnknown interface, Release will be called. + * If the resource is a ByRef pointer, nothing is released. + * + * @since 2.1 + */ +public void dispose() { + if ((type & COM.VT_BYREF) is COM.VT_BYREF) { + return; + } + + switch (type) { + case COM.VT_DISPATCH : + dispatchData.Release(); + break; + case COM.VT_UNKNOWN : + unknownData.Release(); + break; + default: + } + +} +/** + * Returns the OleAutomation object represented by this Variant. + * + * <p>If this Variant does not contain an OleAutomation object, an attempt is made to + * coerce the Variant type into an OleAutomation object. If this fails, an error is + * thrown. Note that OleAutomation objects must be disposed when no longer + * needed. + * + * @return the OleAutomation object represented by this Variant + * + * @exception DWTException <ul> + * <li>ERROR_CANNOT_CHANGE_VARIANT_TYPE when type of Variant can not be coerced into an OleAutomation object</li> + * </ul> + */ +public OleAutomation getAutomation() { + if (type is COM.VT_EMPTY) { + OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE, -1); + } + if (type is COM.VT_DISPATCH) { + return new OleAutomation(dispatchData); + } + // try to coerce the value to the desired type + auto oldPtr = cast(VARIANT*) OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, VARIANT.sizeof); + auto newPtr = cast(VARIANT*) OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, VARIANT.sizeof); + try { + getData(oldPtr); + HRESULT result = COM.VariantChangeType(newPtr, oldPtr, 0, COM.VT_DISPATCH); + if (result !is COM.S_OK) + OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE, result); + Variant autoVar = new Variant(); + autoVar.setData(newPtr); + return autoVar.getAutomation(); + } finally { + COM.VariantClear(oldPtr); + OS.GlobalFree(oldPtr); + COM.VariantClear(newPtr); // Note: This must absolutely be done AFTER the + // OleAutomation object is created as Variant Clear + // will result in a Release being performed on the + // Dispatch object + OS.GlobalFree(newPtr); + } +} +/** + * Returns the IDispatch object represented by this Variant. + * + * <p>If this Variant does not contain an IDispatch object, an attempt is made to + * coerce the Variant type into an IDIspatch object. If this fails, an error is + * thrown. + * + * @since 2.0 + * + * @return the IDispatch object represented by this Variant + * + * @exception DWTException <ul> + * <li>ERROR_CANNOT_CHANGE_VARIANT_TYPE when type of Variant can not be coerced into an IDispatch object</li> + * </ul> + */ +public IDispatch getDispatch() { + if (type is COM.VT_EMPTY) { + OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE, -1); + } + if (type is COM.VT_DISPATCH) { + return dispatchData; + } + // try to coerce the value to the desired type + auto oldPtr = cast(VARIANT*) OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, VARIANT.sizeof); + auto newPtr = cast(VARIANT*) OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, VARIANT.sizeof); + try { + getData(oldPtr); + int result = COM.VariantChangeType(newPtr, oldPtr, 0, COM.VT_DISPATCH); + if (result !is COM.S_OK) + OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE, result); + Variant autoVar = new Variant(); + autoVar.setData(newPtr); + return autoVar.getDispatch(); + } finally { + COM.VariantClear(oldPtr); + OS.GlobalFree(oldPtr); + COM.VariantClear(newPtr); // Note: This must absolutely be done AFTER the + // OleAutomation object is created as Variant Clear + // will result in a Release being performed on the + // Dispatch object + OS.GlobalFree(newPtr); + } +} +/** + * Returns the Java bool represented by this Variant. + * + * <p>If this Variant does not contain a Java bool, an attempt is made to + * coerce the Variant type into a Java bool. If this fails, an error is thrown. + * + * @return the Java bool represented by this Variant + * + * @exception DWTException <ul> + * <li>ERROR_CANNOT_CHANGE_VARIANT_TYPE when type of Variant can not be coerced into a bool</li> + * </ul> + * + */ +public bool getBoolean() { + if (type is COM.VT_EMPTY) { + OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE, -1); + } + if (type is COM.VT_BOOL) { + return booleanData; + } + + // try to coerce the value to the desired type + auto oldPtr = cast(VARIANT*) OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, VARIANT.sizeof); + auto newPtr = cast(VARIANT*) OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, VARIANT.sizeof); + try { + getData(oldPtr); + int result = COM.VariantChangeType(newPtr, oldPtr, 0, COM.VT_BOOL); + if (result !is COM.S_OK) + OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE, result); + Variant boolVar = new Variant(); + boolVar.setData(newPtr); + return boolVar.getBoolean(); + } finally { + COM.VariantClear(oldPtr); + OS.GlobalFree(oldPtr); + COM.VariantClear(newPtr); + OS.GlobalFree(newPtr); + } +} +/** + * Returns a pointer to the referenced data represented by this Variant. + * + * <p>If this Variant does not contain a reference to data, zero is returned. + * + * @return a pointer to the referenced data represented by this Variant or 0 + * + */ +public void* getByRef() { + if (type is COM.VT_EMPTY) { + OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE, -1); + } + if ((type & COM.VT_BYREF)is COM.VT_BYREF) { + return byRefPtr; + } + + return null; +} +/** + * Returns the Java byte represented by this Variant. + * + * <p>If this Variant does not contain a Java byte, an attempt is made to + * coerce the Variant type into a Java byte. If this fails, an error is thrown. + * + * @return the Java byte represented by this Variant + * + * @exception DWTException <ul> + * <li>ERROR_CANNOT_CHANGE_VARIANT_TYPE when type of Variant can not be coerced into a byte</li> + * </ul> + * + * @since 3.3 + */ +public byte getByte() { + if (type is COM.VT_EMPTY) { + OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE, -1); + } + if (type is COM.VT_I1) { + return byteData; + } + + // try to coerce the value to the desired type + auto oldPtr = cast(VARIANT*) OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, VARIANT.sizeof); + auto newPtr = cast(VARIANT*) OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, VARIANT.sizeof); + try { + getData(oldPtr); + int result = COM.VariantChangeType(newPtr, oldPtr, 0, COM.VT_I1); + if (result !is COM.S_OK) + OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE, result); + Variant byteVar = new Variant(); + byteVar.setData(newPtr); + return byteVar.getByte(); + } finally { + COM.VariantClear(oldPtr); + OS.GlobalFree(oldPtr); + COM.VariantClear(newPtr); + OS.GlobalFree(newPtr); + } +} +/** + * Returns the Java char represented by this Variant. + * + * <p>If this Variant does not contain a Java char, an attempt is made to + * coerce the Variant type into a Java char. If this fails, an error is thrown. + * + * @return the Java char represented by this Variant + * + * @exception DWTException <ul> + * <li>ERROR_CANNOT_CHANGE_VARIANT_TYPE when type of Variant can not be coerced into a char</li> + * </ul> + * + * @since 3.3 + */ +public char getChar() { + if (type is COM.VT_EMPTY) { + OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE, -1); + } + if (type is COM.VT_UI2) { + return charData; + } + + // try to coerce the value to the desired type + auto oldPtr = cast(VARIANT*) OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, VARIANT.sizeof); + auto newPtr = cast(VARIANT*) OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, VARIANT.sizeof); + try { + getData(oldPtr); + int result = COM.VariantChangeType(newPtr, oldPtr, 0, COM.VT_UI2); + if (result !is COM.S_OK) + OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE, result); + Variant charVar = new Variant(); + charVar.setData(newPtr); + return charVar.getChar(); + } finally { + COM.VariantClear(oldPtr); + OS.GlobalFree(oldPtr); + COM.VariantClear(newPtr); + OS.GlobalFree(newPtr); + } +} +void getData(VARIANT* pData){ + if (pData is null) OLE.error(OLE.ERROR_OUT_OF_MEMORY); + + COM.VariantInit(pData); + + // set type + pData.vt = type; + if ((type & COM.VT_BYREF) is COM.VT_BYREF) { + COM.MoveMemory(pData, &type, 2); + COM.MoveMemory(pData + 8, &byRefPtr, 4); + return; + } + + switch (type) { + case COM.VT_EMPTY : + case COM.VT_NULL : + COM.MoveMemory(pData, &type, 2); + break; + case COM.VT_BOOL : + COM.MoveMemory(pData, &type, 2); + auto v = booleanData ? COM.VARIANT_TRUE : COM.VARIANT_FALSE; + COM.MoveMemory(pData + 8, &v, 2); + break; + case COM.VT_I1 : + COM.MoveMemory(pData, &type, 2); + COM.MoveMemory(pData + 8, &byteData, 1); + break; + case COM.VT_I2 : + COM.MoveMemory(pData, &type, 2); + COM.MoveMemory(pData + 8, &shortData, 2); + break; + case COM.VT_UI2 : + COM.MoveMemory(pData, &type, 2); + COM.MoveMemory(pData + 8, &charData, 2); + break; + case COM.VT_I4 : + COM.MoveMemory(pData, &type, 2); + COM.MoveMemory(pData + 8, &intData, 4); + break; + case COM.VT_I8 : + COM.MoveMemory(pData, &type, 2); + COM.MoveMemory(pData + 8, &longData, 8); + break; + case COM.VT_R4 : + COM.MoveMemory(pData, &type, 2); + COM.MoveMemory(pData + 8, &floatData, 4); + break; + case COM.VT_R8 : + COM.MoveMemory(pData, &type, 2); + COM.MoveMemory(pData + 8, &doubleData, 8); + break; + case COM.VT_DISPATCH : + dispatchData.AddRef(); + COM.MoveMemory(pData, &type, 2); + auto v = cast(void*)dispatchData; + COM.MoveMemory(pData + 8, &v, 4); + break; + case COM.VT_UNKNOWN : + unknownData.AddRef(); + COM.MoveMemory(pData, &type, 2); + auto v = cast(void*)dispatchData; + COM.MoveMemory(pData + 8, &v, 4); + break; + case COM.VT_BSTR : + COM.MoveMemory(pData, &type, 2); + wchar[] data = StrToWCHARs(stringData); + auto ptr = COM.SysAllocString(data.ptr); + COM.MoveMemory(pData + 8, &ptr, 4); + break; + + default : + OLE.error(DWT.ERROR_NOT_IMPLEMENTED); + } +} +/** + * Returns the Java double represented by this Variant. + * + * <p>If this Variant does not contain a Java double, an attempt is made to + * coerce the Variant type into a Java double. If this fails, an error is thrown. + * + * @return the Java double represented by this Variant + * + * @exception DWTException <ul> + * <li>ERROR_CANNOT_CHANGE_VARIANT_TYPE when type of Variant can not be coerced into a double</li> + * </ul> + * + * @since 3.2 + */ +public double getDouble() { + if (type is COM.VT_EMPTY) { + OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE, -1); + } + if (type is COM.VT_R8) { + return doubleData; + } + + // try to coerce the value to the desired type + auto oldPtr = cast(VARIANT*) OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, VARIANT.sizeof); + auto newPtr = cast(VARIANT*) OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, VARIANT.sizeof); + try { + getData(oldPtr); + int result = COM.VariantChangeType(newPtr, oldPtr, 0, COM.VT_R8); + if (result !is COM.S_OK) + OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE, result); + Variant doubleVar = new Variant(); + doubleVar.setData(newPtr); + return doubleVar.getDouble(); + } finally { + COM.VariantClear(oldPtr); + OS.GlobalFree(oldPtr); + COM.VariantClear(newPtr); + OS.GlobalFree(newPtr); + } +} + +/** + * Returns the Java float represented by this Variant. + * + * <p>If this Variant does not contain a Java float, an attempt is made to + * coerce the Variant type into a Java float. If this fails, an error is thrown. + * + * @return the Java float represented by this Variant + * + * @exception DWTException <ul> + * <li>ERROR_CANNOT_CHANGE_VARIANT_TYPE when type of Variant can not be coerced into a float</li> + * </ul> + */ +public float getFloat() { + if (type is COM.VT_EMPTY) { + OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE, -1); + } + if (type is COM.VT_R4) { + return floatData; + } + + // try to coerce the value to the desired type + auto oldPtr = cast(VARIANT*) OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, VARIANT.sizeof); + auto newPtr = cast(VARIANT*) OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, VARIANT.sizeof); + try { + getData(oldPtr); + int result = COM.VariantChangeType(newPtr, oldPtr, 0, COM.VT_R4); + if (result !is COM.S_OK) + OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE, result); + Variant floatVar = new Variant(); + floatVar.setData(newPtr); + return floatVar.getFloat(); + } finally { + COM.VariantClear(oldPtr); + OS.GlobalFree(oldPtr); + COM.VariantClear(newPtr); + OS.GlobalFree(newPtr); + } + +} +/** + * Returns the Java int represented by this Variant. + * + * <p>If this Variant does not contain a Java int, an attempt is made to + * coerce the Variant type into a Java int. If this fails, an error is thrown. + * + * @return the Java int represented by this Variant + * + * @exception DWTException <ul> + * <li>ERROR_CANNOT_CHANGE_VARIANT_TYPE when type of Variant can not be coerced into a int</li> + * </ul> + */ +public int getInt() { + if (type is COM.VT_EMPTY) { + OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE, -1); + } + if (type is COM.VT_I4) { + return intData; + } + + // try to coerce the value to the desired type + auto oldPtr = cast(VARIANT*) OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, VARIANT.sizeof); + auto newPtr = cast(VARIANT*) OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, VARIANT.sizeof); + try { + getData(oldPtr); + int result = COM.VariantChangeType(newPtr, oldPtr, 0, COM.VT_I4); + if (result !is COM.S_OK) + OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE, result); + Variant intVar = new Variant(); + intVar.setData(newPtr); + return intVar.getInt(); + } finally { + COM.VariantClear(oldPtr); + OS.GlobalFree(oldPtr); + COM.VariantClear(newPtr); + OS.GlobalFree(newPtr); + } +} +/** + * Returns the Java long represented by this Variant. + * + * <p>If this Variant does not contain a Java long, an attempt is made to + * coerce the Variant type into a Java long. If this fails, an error is thrown. + * + * @return the Java long represented by this Variant + * + * @exception DWTException <ul> + * <li>ERROR_CANNOT_CHANGE_VARIANT_TYPE when type of Variant can not be coerced into a long</li> + * </ul> + * + * @since 3.2 + */ +public long getLong() { + if (type is COM.VT_EMPTY) { + OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE, -1); + } + if (type is COM.VT_I8) { + return longData; + } + + // try to coerce the value to the desired type + auto oldPtr = cast(VARIANT*) OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, VARIANT.sizeof); + auto newPtr = cast(VARIANT*) OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, VARIANT.sizeof); + try { + getData(oldPtr); + int result = COM.VariantChangeType(newPtr, oldPtr, 0, COM.VT_I8); + if (result !is COM.S_OK) + OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE, result); + Variant longVar = new Variant(); + longVar.setData(newPtr); + return longVar.getLong(); + } finally { + COM.VariantClear(oldPtr); + OS.GlobalFree(oldPtr); + COM.VariantClear(newPtr); + OS.GlobalFree(newPtr); + } +} +/** + * Returns the Java short represented by this Variant. + * + * <p>If this Variant does not contain a Java short, an attempt is made to + * coerce the Variant type into a Java short. If this fails, an error is thrown. + * + * @return the Java short represented by this Variant + * + * @exception DWTException <ul> + * <li>ERROR_CANNOT_CHANGE_VARIANT_TYPE when type of Variant can not be coerced into a short</li> + * </ul> + */ +public short getShort() { + if (type is COM.VT_EMPTY) { + OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE, -1); + } + if (type is COM.VT_I2) { + return shortData; + } + + // try to coerce the value to the desired type + auto oldPtr = cast(VARIANT*) OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, VARIANT.sizeof); + auto newPtr = cast(VARIANT*) OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, VARIANT.sizeof); + try { + getData(oldPtr); + int result = COM.VariantChangeType(newPtr, oldPtr, 0, COM.VT_I2); + if (result !is COM.S_OK) + OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE, result); + Variant shortVar = new Variant(); + shortVar.setData(newPtr); + return shortVar.getShort(); + } finally { + COM.VariantClear(oldPtr); + OS.GlobalFree(oldPtr); + COM.VariantClear(newPtr); + OS.GlobalFree(newPtr); + } + +} +/** + * Returns the Java String represented by this Variant. + * + * <p>If this Variant does not contain a Java String, an attempt is made to + * coerce the Variant type into a Java String. If this fails, an error is thrown. + * + * @return the Java String represented by this Variant + * + * @exception DWTException <ul> + * <li>ERROR_CANNOT_CHANGE_VARIANT_TYPE when type of Variant can not be coerced into a String</li> + * </ul> + */ +public char[] getString() { + if (type is COM.VT_EMPTY) { + OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE, -1); + } + if (type is COM.VT_BSTR) { + return stringData; + } + + // try to coerce the value to the desired type + auto oldPtr = cast(VARIANT*) OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, VARIANT.sizeof); + auto newPtr = cast(VARIANT*) OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, VARIANT.sizeof); + try { + getData(oldPtr); + int result = COM.VariantChangeType(newPtr, oldPtr, 0, COM.VT_BSTR); + if (result !is COM.S_OK) + OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE, result); + + Variant stringVar = new Variant(); + stringVar.setData(newPtr); + return stringVar.getString(); + + } finally { + COM.VariantClear(oldPtr); + OS.GlobalFree(oldPtr); + COM.VariantClear(newPtr); + OS.GlobalFree(newPtr); + } +} +/** + * Returns the type of the variant type. This will be an OLE.VT_* value or + * a bitwise combination of OLE.VT_* values as in the case of + * OLE.VT_BSTR | OLE.VT_BYREF. + * + * @return the type of the variant data + * + * @since 2.0 + */ +public short getType() { + return type; +} +/** + * Returns the IUnknown object represented by this Variant. + * + * <p>If this Variant does not contain an IUnknown object, an attempt is made to + * coerce the Variant type into an IUnknown object. If this fails, an error is + * thrown. + * + * @return the IUnknown object represented by this Variant + * + * @exception DWTException <ul> + * <li>ERROR_CANNOT_CHANGE_VARIANT_TYPE when type of Variant can not be coerced into + * an IUnknown object</li> + * </ul> + */ +public IUnknown getUnknown() { + if (type is COM.VT_EMPTY) { + OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE, -1); + } + if (type is COM.VT_UNKNOWN) { + return unknownData; + } + + // try to coerce the value to the desired type + auto oldPtr = cast(VARIANT*) OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, VARIANT.sizeof); + auto newPtr = cast(VARIANT*) OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, VARIANT.sizeof); + try { + getData(oldPtr); + int result = COM.VariantChangeType(newPtr, oldPtr, 0, COM.VT_UNKNOWN); + if (result !is COM.S_OK) + OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE, result); + Variant unknownVar = new Variant(); + unknownVar.setData(newPtr); + return unknownVar.getUnknown(); + } finally { + COM.VariantClear(oldPtr); + OS.GlobalFree(oldPtr); + COM.VariantClear(newPtr); // Note: This must absolutely be done AFTER the + // IUnknown object is created as Variant Clear + // will result in a Release being performed on the + // Dispatch object + OS.GlobalFree(newPtr); + } +} +/** + * Update the by reference value of this variant with a new bool value. + * + * @param val the new bool value + * + * @exception DWTException <ul> + * <li>ERROR_CANNOT_CHANGE_VARIANT_TYPE when type of Variant is not + * a (VT_BYREF | VT_BOOL) object</li> + * </ul> + * + * @since 2.1 + */ +public void setByRef(bool val) { + if ((type & COM.VT_BYREF) is 0 || (type & COM.VT_BOOL) is 0) { + OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE); + } + auto v = val ? COM.VARIANT_TRUE : COM.VARIANT_FALSE; + COM.MoveMemory(byRefPtr, &v, 2); +} +/** + * Update the by reference value of this variant with a new float value. + * + * @param val the new float value + * + * @exception DWTException <ul> + * <li>ERROR_CANNOT_CHANGE_VARIANT_TYPE when type of Variant is not + * a (VT_BYREF | VT_R4) object</li> + * </ul> + * + * @since 2.1 + */ +public void setByRef(float val) { + if ((type & COM.VT_BYREF) is 0 || (type & COM.VT_R4) is 0) { + OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE); + } + COM.MoveMemory(byRefPtr, &val, 4); +} +/** + * Update the by reference value of this variant with a new integer value. + * + * @param val the new integer value + * + * @exception DWTException <ul> + * <li>ERROR_CANNOT_CHANGE_VARIANT_TYPE when type of Variant is not a (VT_BYREF | VT_I4) object</li> + * </ul> + * + * @since 2.1 + */ +public void setByRef(int val) { + if ((type & COM.VT_BYREF) is 0 || (type & COM.VT_I4) is 0) { + OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE); + } + COM.MoveMemory(byRefPtr, &val, 4); +} +/** + * Update the by reference value of this variant with a new short value. + * + * @param val the new short value + * + * @exception DWTException <ul> + * <li>ERROR_CANNOT_CHANGE_VARIANT_TYPE when type of Variant is not a (VT_BYREF | VT_I2) object + * </ul> + * + * @since 2.1 + */ +public void setByRef(short val) { + if ((type & COM.VT_BYREF) is 0 || (type & COM.VT_I2) is 0) { + OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE); + } + COM.MoveMemory(byRefPtr, &val, 2); +} + +void setData(VARIANT* pData){ + if (pData is null) OLE.error(OLE.ERROR_INVALID_ARGUMENT); + + short[1] dataType ; + COM.MoveMemory(dataType.ptr, pData, 2); + type = dataType[0]; + + if ((type & COM.VT_BYREF) is COM.VT_BYREF) { + void*[1] newByRefPtr; + OS.MoveMemory(newByRefPtr.ptr, pData + 8, 4); + byRefPtr = newByRefPtr[0]; + return; + } + + switch (type) { + case COM.VT_EMPTY : + case COM.VT_NULL : + break; + case COM.VT_BOOL : + short[1] newBooleanData; + COM.MoveMemory(newBooleanData.ptr, pData + 8, 2); + booleanData = (newBooleanData[0] !is COM.VARIANT_FALSE); + break; + case COM.VT_I1 : + byte[1] newByteData; + COM.MoveMemory(newByteData.ptr, pData + 8, 1); + byteData = newByteData[0]; + break; + case COM.VT_I2 : + short[1] newShortData; + COM.MoveMemory(newShortData.ptr, pData + 8, 2); + shortData = newShortData[0]; + break; + case COM.VT_UI2 : + char[1] newCharData; + COM.MoveMemory(newCharData.ptr, pData + 8, 2); + charData = newCharData[0]; + break; + case COM.VT_I4 : + int[1] newIntData; + OS.MoveMemory(newIntData.ptr, pData + 8, 4); + intData = newIntData[0]; + break; + case COM.VT_I8 : + long[1] newLongData; + OS.MoveMemory(newLongData.ptr, pData + 8, 8); + longData = newLongData[0]; + break; + case COM.VT_R4 : + float[1] newFloatData; + COM.MoveMemory(newFloatData.ptr, pData + 8, 4); + floatData = newFloatData[0]; + break; + case COM.VT_R8 : + double[1] newDoubleData; + COM.MoveMemory(newDoubleData.ptr, pData + 8, 8); + doubleData = newDoubleData[0]; + break; + case COM.VT_DISPATCH : { + IDispatch[1] ppvObject; + OS.MoveMemory(ppvObject.ptr, pData + 8, 4); + if (ppvObject[0] is null) { + type = COM.VT_EMPTY; + break; + } + dispatchData = ppvObject[0]; + dispatchData.AddRef(); + break; + } + case COM.VT_UNKNOWN : { + IUnknown[1] ppvObject; + OS.MoveMemory(ppvObject.ptr, pData + 8, 4); + if (ppvObject[0] is null) { + type = COM.VT_EMPTY; + break; + } + unknownData = ppvObject[0]; + unknownData.AddRef(); + break; + } + case COM.VT_BSTR : + // get the address of the memory in which the string resides + wchar*[1] hMem; + OS.MoveMemory(hMem.ptr, pData + 8, 4); + if (hMem[0] is null) { + type = COM.VT_EMPTY; + break; + } + // Get the size of the string from the OS - the size is expressed in number + // of bytes - each unicode character is 2 bytes. + int size = COM.SysStringByteLen(hMem[0]); + if (size > 0){ + // get the unicode character array from the global memory and create a String + wchar[] buffer = new wchar[(size + 1) /2]; // add one to avoid rounding errors + COM.MoveMemory(buffer.ptr, hMem[0], size); + stringData = WCHARsToStr( buffer ); + } else { + stringData = ""; //$NON-NLS-1$ + } + break; + + default : + // try coercing it into one of the known forms + auto newPData = cast(VARIANT*) OS.GlobalAlloc(OS.GMEM_FIXED | OS.GMEM_ZEROINIT, VARIANT.sizeof); + if (COM.VariantChangeType(newPData, pData, 0, COM.VT_R4) is COM.S_OK) { + setData(newPData); + } else if (COM.VariantChangeType(newPData, pData, 0, COM.VT_I4) is COM.S_OK) { + setData(newPData); + } else if (COM.VariantChangeType(newPData, pData, 0, COM.VT_BSTR) is COM.S_OK) { + setData(newPData); + } + COM.VariantClear(newPData); + OS.GlobalFree(newPData); + break; + } +} + +/** + * Returns a string containing a concise, human-readable + * description of the receiver. + * + * @return a string representation of the Variant + */ +public char[] toString () { + switch (type) { + case COM.VT_BOOL : + return "VT_BOOL{"~to!(char[])(booleanData)~"}"; + case COM.VT_I1 : + return "VT_I1{"~to!(char[])(byteData)~"}"; + case COM.VT_I2 : + return "VT_I2{"~to!(char[])(shortData)~"}"; + case COM.VT_UI2 : + return "VT_UI2{"~charData~"}"; + case COM.VT_I4 : + return "VT_I4{"~to!(char[])(intData)~"}"; + case COM.VT_I8 : + return "VT_I8{"~to!(char[])(longData)~"}"; + case COM.VT_R4 : + return "VT_R4{"~to!(char[])(floatData)~"}"; + case COM.VT_R8 : + return "VT_R8{"~to!(char[])(doubleData)~"}"; + case COM.VT_BSTR : + return "VT_BSTR{"~stringData~"}"; + case COM.VT_DISPATCH : + return Format("VT_DISPATCH{{0x{:X}}", cast(void*) (dispatchData is null ? null : dispatchData)); + case COM.VT_UNKNOWN : + return Format("VT_UNKNOWN{{0x{:X}}", cast(void*) (unknownData is null ? null : unknownData)); + case COM.VT_EMPTY : + return "VT_EMPTY"; + case COM.VT_NULL : + return "VT_NULL"; + } + if ((type & COM.VT_BYREF) !is 0) { + return Format("VT_BYREF|{}{{{}}",(type & ~COM.VT_BYREF), byRefPtr ); + } + return "Unsupported Type "~to!(char[])(type); +} +}