Вот пример на PB
- Код: Выделить всё
#Compile Exe
#Dim All
#Include "win32api.inc"
' ========================================================================================
' VARIANTDATA UNION
' ========================================================================================
Union VARIANTDATAUNION
bVal As Byte ' VT_UI1
iVal As Integer ' VT_I2
lVal As Long ' VT_I4
fltVal As Single ' VT_R4
dblVal As Double ' VT_R8
boolVal As Integer ' VT_BOOL
scode As Long ' VT_ERROR
cyVal As Long ' VT_CY
date As Double ' VT_DATE
bstrVal As Long ' VT_BSTR
punkVal As Dword ' VT_UNKNOWN
pdispVal As Dword ' VT_DISPATCH
tblob As BLOB ' VT_BLOB
parray As Dword ' VT_ARRAY|*
pbVal As Byte Ptr ' VT_BYREF|VT_UI1
piVal As Integer Ptr ' VT_BYREF|VT_I2
plVal As Long Ptr ' VT_BYREF|VT_I4
pfltVal As Single Ptr ' VT_BYREF|VT_R4
pdblVal As Double Ptr ' VT_BYREF|VT_R8
pboolVal As Integer Ptr ' VT_BYREF|VT_BOOL
pscode As Long Ptr ' VT_BYREF|VT_ERROR
pcyVal As Long Ptr ' VT_BYREF|VT_CY
pdate As Double Ptr ' VT_BYREF|VT_DATE
pbstrVal As Long Ptr ' VT_BYREF|VT_BSTR
ppunkVal As Dword Ptr ' VT_BYREF|VT_UNKNOWN
ppdispVal As Dword Ptr ' VT_BYREF|VT_DISPATCH
psArray As Dword Ptr ' VT_ARRAY|*
pVariant As Dword Ptr ' VT_BYREF|VT_VARIANT
pByRef As Dword ' Generic ByRef
End Union
' ========================================================================================
' ========================================================================================
' VARIANTAPI structure
' ========================================================================================
Type VARIANTAPITYPE
vt As Word 'VARTYPE
wReserved1 As Word
wReserved2 As Word
wReserved3 As Word
vd As VARIANTDATAUNION
End Type
' ===
Function GetLong(ByVal lpv As VARIANTAPITYPE Ptr) As Long
Function=@lpv.vd.lVal
End Function
Sub SetLong(ByVal lpv As VARIANTAPITYPE Ptr, ByVal lng As Long)
@lpv.vd.lVal=lng
End Sub
Function PBMain () As Long
Local vLong As Variant
Local lng As Long
vLong=123%
lng=GetLong(VarPtr(vLong))
Incr lng
SetLong VarPtr(vLong), lng
MsgBox Str$(Variant#(vLong))
End Function