Here I have a C # metro application with a C ++ WinRT component. I need to do something in WinRT, for example, assign a name / path to a photo and get a thumbnail of photos.
First, I write the value structure and extract the struct array function in WinRT C ++, as shown below.
public value struct Item { String^ strName; String^ strPath; }; public ref class CTestWinRT sealed { public: CTestWinRT(); void TestOutStructArray(Platform::WriteOnlyArray<Item>^ intOutArray) { intOutArray->Data[0].strName = ref new String(L"test1.jpg"); intOutArray->Data[0].strPath = ref new String(L"c:\\temp"); intOutArray->Data[1].strName = ref new String(L"test2.jpg"); intOutArray->Data[1].strPath = ref new String(L"c:\\temp"); } };
Then I use the TestOutStructArray function in the C # button, as shown below.
CTestWinRT myNative = new CTestWinRT(); private void btnTestClick(object sender, RoutedEventArgs e) { Item[] items = new Item[2]; myNative.TestOutStructArray(items); }
The function works fine, and the array of elements can see that the values ββare correct in the debug window.
Now I want to add an array of bytes to the struct value, as shown below.
public value struct Item { String^ strName; String^ strPath; uint8 byteThumbnail[8096]; };
This will result in a compiler error:
error C3987: 'byteThumbnail': public member signature contains native type 'unsigned char [8096]'
error C3992: 'byteThumbnail': public member signature contains invalid type 'unsigned char [8096]'
I look at MSDN about the value of struct, he said that the value of struct cannot have the class ref or struct as a member, so I think I can not write code as indicated above.
http://msdn.microsoft.com/en-us/library/windows/apps/hh699861.aspx
Does anyone know how to use another way to replace value struct? I need the array to have a "byte array" inside.