how to declare an safe array in vb.net?

  • Thread starter Thread starter The Thinker
  • Start date Start date
T

The Thinker

Guest
I need to declare a safearray but I have tried everything I can to pass a safe array to unmanaged code. I know the safe array is of type variant. But I can see that my vbscript code works but not my vb.net code which is similar. Heres what I know about how the safe array contents are being passed to com from vb.net:

1. The safe array array has the variant type

2. Its not fixed size (got using fFeatures from the safearray structure in the c++ code)

3. It not static (got using fFeatures from the safearray structure in the c++ code).

Everything is opposite for the 3 features listed above for my vbscript code.

Heres my vb.net code:



Dim InputReport1() As Object = New Object(4) {CByte(0), CByte(100), CByte(100), CByte(0), CByte(0)}
.........other code and functions here.

Public Function sendinputreport(xcoord As Integer, ycoord As Integer, leftclick As Boolean, rightclick As Boolean) As Boolean
device report to send to computer (x,y coordinates, left or right clicks, and scrolling).
file contents:
number of devices
x for dev1
y for dev1
left click for dev1
x for dev2
y for dev2
left click for dev2

Dim x(40), y(40) As Integer
x(usernum) = xcoord
y(usernum) = ycoord
MsgBox(x(usernum))

If x(usernum) <= 255 And y(usernum) <= 255 Then

GenericHIDDev(usernum).QueueInputReport(InputReport1, 10)
MsgBox("start processing")
GenericHIDDev(usernum).StartProcessing()
End If

sendinputreport = True
End Function


The code sends input to my fake emulated device but the unmanaged c++ code requires a safearray thats defined as
SAFEARRAY* psaInputReport. Anyone know how I could be passing it wrong?





Once you eliminate the impossible, whatever remains, no matter how improbable, must be the truth. - "Sherlock holmes" "speak softly and carry a big stick" - theodore roosevelt. Fear leads to anger, anger leads to hate, hate leads to suffering - Yoda. Blog - http://www.computerprofessions.co.nr

Continue reading...
 
Back
Top