How to receive a BYTE[] from C# -
there 2 questions:
- i try make program need use com component(ocx) created mfc. assume component name myocx. myocx has function "readuserdata (byte* buf)".(i can see function spec has become readuserdata(ref byte buf) in c#.) buf byte[30]. content string: 100.
here partial of code:
byte buf = new byte(); if (myocx.readuserdata(ref buf)) { (int = 0; < 30; i++) { myocx.readuserdata(ref buf); textbox3.text += (char)buf; } }
there no error during running, textbox3.text content "111111111111111111111111111111", think because "100" first letter '1' 30 times.
i ask how write code make can "100" original byte[30];
- another question not has readuserdata(byte* buf), has writeuserdata(byte* buf). write "200" buf. please tell me how this.
thank you.
not knowing how myoxc.readuserdata works, try this:
byte[] buf = new byte[30]; if (myocx.readuserdata(ref buf)) (int = 0; < byte.length; i++) textbox3.text += (char)buf[i];
in code looks first read succeeds, and, because supplied single byte write data returned first character '1'. subsequent calls fail, why buf never changed, keep on printing out original value.
Comments
Post a Comment