github.com/ContinuumLLC/godep-go-ole-go-ole@v1.2.0/ole.go (about)

     1  package ole
     2  
     3  import (
     4  	"fmt"
     5  	"strings"
     6  )
     7  
     8  // DISPPARAMS are the arguments that passed to methods or property.
     9  type DISPPARAMS struct {
    10  	rgvarg            uintptr
    11  	rgdispidNamedArgs uintptr
    12  	cArgs             uint32
    13  	cNamedArgs        uint32
    14  }
    15  
    16  // EXCEPINFO defines exception info.
    17  type EXCEPINFO struct {
    18  	wCode             uint16
    19  	wReserved         uint16
    20  	bstrSource        *uint16
    21  	bstrDescription   *uint16
    22  	bstrHelpFile      *uint16
    23  	dwHelpContext     uint32
    24  	pvReserved        uintptr
    25  	pfnDeferredFillIn uintptr
    26  	scode             uint32
    27  }
    28  
    29  // String convert EXCEPINFO to string.
    30  func (e EXCEPINFO) String() string {
    31  	var src, desc, hlp string
    32  	if e.bstrSource == nil {
    33  		src = "<nil>"
    34  	} else {
    35  		src = BstrToString(e.bstrSource)
    36  	}
    37  
    38  	if e.bstrDescription == nil {
    39  		desc = "<nil>"
    40  	} else {
    41  		desc = BstrToString(e.bstrDescription)
    42  	}
    43  
    44  	if e.bstrHelpFile == nil {
    45  		hlp = "<nil>"
    46  	} else {
    47  		hlp = BstrToString(e.bstrHelpFile)
    48  	}
    49  
    50  	return fmt.Sprintf(
    51  		"wCode: %#x, bstrSource: %v, bstrDescription: %v, bstrHelpFile: %v, dwHelpContext: %#x, scode: %#x",
    52  		e.wCode, src, desc, hlp, e.dwHelpContext, e.scode,
    53  	)
    54  }
    55  
    56  // Error implements error interface and returns error string.
    57  func (e EXCEPINFO) Error() string {
    58  	if e.bstrDescription != nil {
    59  		return strings.TrimSpace(BstrToString(e.bstrDescription))
    60  	}
    61  
    62  	src := "Unknown"
    63  	if e.bstrSource != nil {
    64  		src = BstrToString(e.bstrSource)
    65  	}
    66  
    67  	code := e.scode
    68  	if e.wCode != 0 {
    69  		code = uint32(e.wCode)
    70  	}
    71  
    72  	return fmt.Sprintf("%v: %#x", src, code)
    73  }
    74  
    75  // PARAMDATA defines parameter data type.
    76  type PARAMDATA struct {
    77  	Name *int16
    78  	Vt   uint16
    79  }
    80  
    81  // METHODDATA defines method info.
    82  type METHODDATA struct {
    83  	Name     *uint16
    84  	Data     *PARAMDATA
    85  	Dispid   int32
    86  	Meth     uint32
    87  	CC       int32
    88  	CArgs    uint32
    89  	Flags    uint16
    90  	VtReturn uint32
    91  }
    92  
    93  // INTERFACEDATA defines interface info.
    94  type INTERFACEDATA struct {
    95  	MethodData *METHODDATA
    96  	CMembers   uint32
    97  }
    98  
    99  // Point is 2D vector type.
   100  type Point struct {
   101  	X int32
   102  	Y int32
   103  }
   104  
   105  // Msg is message between processes.
   106  type Msg struct {
   107  	Hwnd    uint32
   108  	Message uint32
   109  	Wparam  int32
   110  	Lparam  int32
   111  	Time    uint32
   112  	Pt      Point
   113  }
   114  
   115  // TYPEDESC defines data type.
   116  type TYPEDESC struct {
   117  	Hreftype uint32
   118  	VT       uint16
   119  }
   120  
   121  // IDLDESC defines IDL info.
   122  type IDLDESC struct {
   123  	DwReserved uint32
   124  	WIDLFlags  uint16
   125  }
   126  
   127  // TYPEATTR defines type info.
   128  type TYPEATTR struct {
   129  	Guid             GUID
   130  	Lcid             uint32
   131  	dwReserved       uint32
   132  	MemidConstructor int32
   133  	MemidDestructor  int32
   134  	LpstrSchema      *uint16
   135  	CbSizeInstance   uint32
   136  	Typekind         int32
   137  	CFuncs           uint16
   138  	CVars            uint16
   139  	CImplTypes       uint16
   140  	CbSizeVft        uint16
   141  	CbAlignment      uint16
   142  	WTypeFlags       uint16
   143  	WMajorVerNum     uint16
   144  	WMinorVerNum     uint16
   145  	TdescAlias       TYPEDESC
   146  	IdldescType      IDLDESC
   147  }