I have a safe array I need to pass from vb.net to unmanaged c++ code. How do I pass a safe array with a subtype of VT_UI1? I have only cause the code to crash my program when it gets to passing the safe array. I know the safe array works from directly unmanaged c++ or vbscript but I think that the program gets an unexpected type and so it crashs.
Heres what I have so far:
<MarshalAsAttribute(UnmanagedType.BStr)> Dim InputReport1(4) As Object '...... other code in-between here. '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 InputReport1(0) = CByte(0) InputReport1(1) = CByte(x(usernum)) InputReport1(2) = CByte(y(usernum)) InputReport1(3) = CByte(0) InputReport1(4) = CByte(0) End If GenericHIDDev(usernum).QueueInputReport(InputReport1, 10) GenericHIDDev(usernum).StartProcessing()
The first statement is how Iam defining my variable. It crashs when it gets to QueueInputReport because the data is invalid because if I dim it as byte it returns invalid type error.
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