-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathaxhelper.bi
164 lines (136 loc) · 4.68 KB
/
axhelper.bi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
#Include once"win/ocidl.bi"
'covert string to bstr
'please follow with sysfreestring(bstr) after use to avoid memory leak
Function StringToBSTR(cnv_string As String) As BSTR
Dim sb As BSTR
Dim As Integer n
n = (MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, cnv_string, -1, NULL, 0))-1
sb=SysAllocStringLen(sb,n)
MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, cnv_string, -1, sb, n)
Return sb
End Function
'return numeric value from variant
Function Variantv(ByRef v As variant)As Double
Dim vvar As variant
VariantChangeTypeEx(@vvar,@v,NULL,VARIANT_NOVALUEPROP,VT_R8)
Return vvar.dblval
End Function
'return string value from variant
Function Variants(ByRef v As variant)As String
Dim vvar As variant
VariantChangeTypeEx(@vvar,@v,NULL,VARIANT_NOVALUEPROP,VT_BSTR)
Function=*Cast(wstring Ptr,vvar.bstrval)
End Function
'return bstr value from variant
Function Variantb(ByRef v As variant)As bstr
Dim vvar As variant
VariantChangeTypeEx(@vvar,@v,NULL,VARIANT_NOVALUEPROP,VT_BSTR)
Function=vvar.bstrval
End Function
'assign variant with value
Declare sub vlet OverLoad(v As variant,x As variant)
Declare sub vlet OverLoad(v As variant,x As string)
Declare sub vlet OverLoad(v As variant,x As Longint)
Declare sub vlet OverLoad(v As variant,x As Ulongint)
Declare sub vlet OverLoad(v As variant,x As Double)
sub vlet(v As variant,x As variant)
v.vt=vt_variant:v.pvarval=@x
End sub
sub vlet(v As variant,x As string)
v.vt=vt_bstr:v.bstrval=stringtobstr(x)
End sub
sub vlet(v As variant,x As LongInt)
v.vt=vt_i8:v.llval=x
End Sub
sub vlet(v As variant,x As ULongInt)
v.vt=vt_ui8:v.ullval=x
End Sub
sub vlet(v As variant,x As single)
v.vt=vt_r4:v.fltval=x
End Sub
Sub vlet(v As variant,x As double)
v.vt=vt_r8:v.dblval=x
End Sub
'assign value to variant ptr
Declare function vptr OverLoad(x As variant)As Variant Ptr
Declare Function vptr OverLoad(x As string)As Variant Ptr
Declare Function vptr OverLoad(x As Longint)As Variant Ptr
Declare Function vptr OverLoad(x As Ulongint)As Variant Ptr
Declare Function vptr OverLoad(x As Double)As Variant Ptr
Function vptr(x As variant)As Variant Ptr
static v As variant
v.vt=vt_variant:v.pvarval=@x
Return @v
End Function
Function vptr(x As string)As Variant Ptr
Static v As variant
v.vt=vt_bstr:v.bstrval=stringtobstr(x)
Return @v
End Function
Function vptr(x As LongInt)As Variant Ptr
Static v As variant
v.vt=vt_i8:v.llval=x
Return @v
End Function
Function vptr(x As ULongInt)As Variant Ptr
Static v As variant
v.vt=vt_ui8:v.ullval=x
Return @v
End Function
Function vptr(x As double)As Variant Ptr
Static v As variant
v.vt=vt_r8:v.dblval=x
Return @v
End Function
'assign variant as pointer to a variable
Declare sub vplet OverLoad(byref v As variant,Byref x As variant)
Declare sub vplet OverLoad(byref v As variant,Byref x As bstr)
Declare sub vplet OverLoad(ByRef v As variant,Byref x As byte)
Declare sub vplet OverLoad(ByRef v As variant,Byref x As ubyte)
Declare sub vplet OverLoad(ByRef v As variant,Byref x As short)
Declare sub vplet OverLoad(ByRef v As variant,Byref x As ushort)
Declare sub vplet OverLoad(ByRef v As variant,Byref x As Integer)
Declare sub vplet OverLoad(ByRef v As variant,Byref x As Uinteger)
'Declare sub vplet OverLoad(ByRef v As variant,Byref x As Longint)
'Declare sub vplet OverLoad(ByRef v As variant,Byref x As Ulongint)
Declare sub vplet OverLoad(ByRef v As variant,Byref x As single)
Declare sub vplet OverLoad(ByRef v As variant,Byref x As Double)
sub vplet(ByRef v As variant,Byref x As variant)
v.vt=vt_byref Or vt_variant
v.pvarval=@x
End sub
sub vplet(ByRef v As variant,Byref x As bstr)
v.vt=vt_byref Or vt_bstr:v.pbstrval=@x
End sub
sub vplet(ByRef v As variant,ByRef x As Byte)
v.vt=vt_byref Or vt_i1:v.pbval=@x
End Sub
sub vplet(ByRef v As variant,ByRef x As UByte)
v.vt=vt_byref Or vt_ui1:v.pbval=@x
End Sub
sub vplet(ByRef v As variant,ByRef x As Short)
v.vt=vt_byref Or vt_i2:v.pival=@x
End Sub
sub vplet(ByRef v As variant,ByRef x As UShort)
v.vt=vt_byref Or vt_ui2:v.puival=@x
End Sub
sub vplet(ByRef v As variant,Byref x As Integer)
v.vt=vt_byref Or vt_i4:v.plval=@x
End Sub
sub vplet(ByRef v As variant,Byref x As UInteger)
v.vt=vt_byref Or vt_ui4:v.pulval=@x
End Sub
/'
sub vplet(ByRef v As variant,Byref x As LongInt)
v.vt=vt_byref Or vt_i8:v.pllval=@x
End Sub
sub vplet(ByRef v As variant,Byref x As ULongInt)
v.vt=vt_byref Or vt_ui8:v.pullval=@x
End Sub
'/
sub vplet(ByRef v As variant,Byref x As single)
v.vt=vt_byref Or vt_r4:v.pfltval=@x
End Sub
Sub vplet(ByRef v As variant,Byref x As double)
v.vt=vt_byref Or vt_r8:v.pdblval=@x
End Sub