5
Answers

Passing an array of bytes from C++ to C#

jmales

jmales

20y
8.1k
1
Hi All, I am trying to write a C# program to call a routine in managed C++. In the routine, the C# program passes a delegate to the managed C++. The delegate looks like this in c++: public __delegate void FoundPidDelegate ( unsigned char pData __gc[], ); My C# routine looks like this: static private void MyFoundPidFunction (byte []pData) The C++ program should call the delegate and pass it an array of bytes (or at least the address of an array of bytes). In C++ I am allocating the memory like this: unsigned char arrManaged __gc [] = new unsigned char __gc[iDataLen]; Then I call the C# delegate routine like this: m_pFoundFunc(arrManaged); When I arrive back in my C# program, the pData array only has ONE element (a correct one) and if I try to look at pData[1], I get an error. What am I doing wrong? Thanks! Josh
Answers (5)
0
joe

joe

NA 3 3.1k 11y
Hm, it seems, that a lot of USB-Devices doesnt have a Friendly Name. So I'm searching for the  Model-Name (like in the Picture). Sadly, I can't figure it out how.
0
Suthish Nair

Suthish Nair

NA 31.7k 4.6m 11y

http://stackoverflow.com/questions/7314257/what-usb-devices-friendly-name-are-currently-connected-to-pc

http://stackoverflow.com/questions/2208722/how-to-get-friendly-device-name-from-dev-broadcast-deviceinterface-and-device-in