Hi,
I am currently trying to use Managed C++ to create a ,.Net wrapper for some unmanaged C++ code. I'm nearly there, but I have a really annoying issue. My code is as follows:
public : void Play(System::Byte buffer[]) { char buffer2[88200]; // Fill the unmanaged buffer pSidplay2->play(buffer2, 88200); //buffer = buffer2*;
// Copy the unmanaged data into the managed buffer for (int a = 0; a < 88200; a++) { buffer[ a ] = buffer2[ a ]; } }
The code simply accepts a managed Byte array from C# and fills it using my unmanaged routine. The code as it stands is fine. However, I would like to limit the amount of data to the size of the buffer received from c#. As you can see I have currently fixed it at 88200 bytes. The problem I am having is I do not know how to access the length property of the input bute array from my C++ function. There is no length property so I have no idea how I can obtain the length of the array. Furthermore, I am unable to initialise the char array with a non fixed value, the compiler complains that a constant must be used to initialise an array.
I really want something like the following:
public : void Play(System::Byte buffer[]) { char buffer2[buffer->Length]; // Fill the unmanaged buffer pSidplay2->play(buffer2, buffer->Length); //buffer = buffer2*;
// Copy the unmanaged data into the managed buffer for (int a = 0; a < buffer->Length; a++) { buffer[ a ] = buffer2[ a ]; } }
How do I achieve this Its been driving me nuts as there seems to be no way of doing what I need to do.
Any ideas anyone
Thanks,
Damien,
Visual C++7
|