BinaryOleType

Specifies how a binary buffer will be used by COM/OLE functions.

Syntax:

BinaryOleType( handle, type, reserved-1, reserved-2, reserved-3 )

Parameters:

(i) handle: handle of buffer.

(i) type: specifies what type of parameter the buffer will represent, see below.

(i) reserved-1: reserved for future use, specify as 0.

(i) reserved-2: reserved for future use, specify as 0.

(i) reserved-3: reserved for future use, specify as 0.

Returns:

(i) @TRUE if successful.

 

BinaryOleType defines the attributes of the binary buffer specified by "handle", which determines what happens when you use the binary buffer handle as a parameter to a COM/OLE object (i.e., one created with the "ObjectCreate" function).

When a binary buffer is created with BinaryAlloc, it has a "type" of 0 (undefined). You must use BinaryOleType to set the buffer's type before using it as a parameter to a COM/OLE object. This function does not modify any data in the binary buffer itself.

When a COM/OLE object is called, and one of the parameters is a binary buffer handle, the following actions are automatically taken:

  1. An internal COM/OLE buffer is created which is (at least) as large as the binary buffer.

  2. If the binary buffer is defined as an input (or input/output) parameter (see "type" below), any data in the binary buffer (up to the binary EOD) is converted as necessary to the specified format and copied to the COM/OLE buffer.

  3. The COM/OLE buffer is passed to the COM/OLE object.

    When the COM/OLE object returns:

  4. If the binary buffer is defined as an output (or input/output) parameter (see "type" below), then any data in the COM/OLE buffer is copied back to the binary buffer. If it is possible to determine how much data was returned in the COM/OLE buffer, then the binary EOD is set to the end of the data; otherwise, the binary EOD is set to the end of the binary buffer.

  5. The COM/OLE buffer is freed.

TYPE

"type" specifies what type of parameter the buffer will represent, and whether it will be used as an input or output parameter (or both). It consists of one entry from each of the following groups, added together:

 

data type:

0  undefined

1  BSTR (VT_BSTR)

2  BSTR* (VT_BSTR | VT_BYREF)

3  byte array (VT_UI1 | VT_ARRAY)

4  I1 pointer (VT_I1 | VT_BYREF)

5  I2 pointer (VT_I2 | VT_BYREF)

6  I4 pointer (VT_I4 | VT_BYREF)

7  UI1 pointer (VT_UI1 | VT_BYREF)

8  UI2 pointer (VT_UI2 | VT_BYREF)

9  UI4 pointer (VT_UI4 | VT_BYREF)

10  R4 pointer (VT_R4 | VT_BYREF)

11  R8 pointer (VT_R8 | VT_BYREF)

 

direction:

100  input parameter

200  output parameter

300  input/output parameter

 

Example:


;Wake on LAN example
#DefineFunction Hex2Dec(hex)
str="0123456789ABCDEF"
hex=StrTrim(StrUpper(hex))
hexlen=StrLen(hex)
dec=0
For x=1 To hexlen
   dec=(dec*16) + StrIndex(str,StrSub(hex,x,1),0,@FWDSCAN) -1
Next
Return(dec)
#EndFunction
BCastAddr="10.10.10.255" ; Set network broacast address here
MacAddress="11:22:33:44:55:66" ; Set MAC address of machine to wake up here
bbpacket=BinaryAlloc( (6*33) + 6)
BinaryOleType(bbpacket,103,0,0,0)
BinaryPoke(bbpacket,0,255)
BinaryPoke(bbpacket,1,255)
BinaryPoke(bbpacket,2,255)
BinaryPoke(bbpacket,3,255)
BinaryPoke(bbpacket,4,255)
BinaryPoke(bbpacket,5,255)
For yy=0 To 15
   For xx=1 To 6
      mm=ItemExtract(xx,MacAddress,":")
      mm=Hex2Dec(mm)
      BinaryPoke(bbpacket,5+xx+(yy*6),mm)
   Next
Next
;The WinSock OCX has a distribution problem in that
;it sometimes is not installed properly. This is
;reported to fix it...
If RegExistKey(@REGCLASSES,"Licenses\2c49f800-c2dd-11cf-9ad6-0080c7e7b78d") == @FALSE
   ErrorMode(@OFF)
   flag=RegSetValue(@REGCLASSES,"Licenses\2c49f800-c2dd-11cf-9ad6-0080c7e7b78d","mlrljgrlhltlngjlthrligklpkrhllglqlrk")
   ErrorMode(@CANCEL)
   If flag==0
      Message("Error","Admin access required to set registry key.")
      Exit
   EndIf
EndIf
objSocket = ObjectOpen("MSWinsock.Winsock")
objSocket.Protocol = 1 ;UDP
objSocket.RemoteHost = BCastAddr
objSocket.SendData(bbpacket)
ObjectClose(objSocket)
BinaryFree(bbpacket)
Message("All","Doned")
Exit
See Also:

Binary Operations, BinaryAlloc, BinaryCopy, BinaryFree, BinaryRead, BinaryReadEx, DllCall