Main > Software Forum
What is Mame's "generic output support system" capable of?
<< < (2/5) > >>
Howard_Casto:
yeah, amoung others....  the problem is that he is using a variable type not supported in visual basic.  There isn't any way to convert it because the proper data never gets sent in the first place due to having to stick it in a different variable type. 
headkaze:
What variable type are you referring to? Have you tried something like this...


--- Code: ---Private Type COPYDATASTRUCT
    dwData As Long
    cbData As Long
    lpData As Long
End Type

Private Type copydata_id_string
    id As Long
    sString(0 To 255) As Byte
End Type

Sub handle_copydata(lParam As Long)
Dim sString  As String
Dim copydata As COPYDATASTRUCT
Dim data As copydata_id_string

Call CopyMemory(copydata, ByVal lParam, Len(copydata))
Call CopyMemory(data, ByVal copydata.lpData, copydata.cbData)

sString = StrConv(data.sString, vbUnicode)
sString = Left$(sString, InStr(0, sString, Chr$(0)) - 1)

frmReceive.lblString = sString
End Sub
--- End code ---
Howard_Casto:
I appreciate your help, but that won't work. 


It's gonna crash on this line:

Call CopyMemory(buf(0), ByVal data.sString(0), copydata.cbData-4) ' minus the 4 bytes for id


You see you are assuming that just because you setup the id string structure into two seperate variables that it'll actually split them up when it recieves the data.  It can't, because vb doesn't support the two variable types that are being sent. 

UINT32 cannot be converted to long, period, end of story.  At least not in a data structure it can't.  Aaron argued me this point as well at nauseum.  I agree with you both that on paper it should convert, but when you run it, vb craps all over itself, half of the time just disappearing... no error message no nothing. 

The only way I could get any kind of data without it crashing was to ditch the structure entirely and setup a big byte array.  Unfortunately all the data I got back, even if I trimmed 4 bytes off,1 was gibberish.

I'm up for ideas, I just don't know how to get it working and I can assure you that all of the usual techniques (read modified example code swiped from websites) don't work. 
headkaze:
I must have just changed my last post while you did yours. I changed it a bit to simplify. Thats really strange that a UINT32 can't convert to a Long since they are both 4 bytes in length.

Perhaps you can try changing the struct to


--- Code: ---Private Type copydata_id_string
    id(0 To 3) As Byte
    sString(0 To 255) As Byte
End Type
--- End code ---

I have no idea! *shrugs*
Howard_Casto:
That's how I have it setup in my app right now... it doesn't crash, but it doesn't work either. 

I get back a ampersand for the game name when i try to call it, and a q when led0 sends data. 

I'm beginning to wonder if the memory addresses copy memory is sending are compatable. 
Navigation
Message Index
Next page
Previous page

Go to full version