0

My MFC code has a function:

SelectItems(CDWordArray & awTop);

I invoke this thorugh another CPP project, as:

array< unsigned int >^ selectedItems;  
DWORD cnt = m_handle->SelectItems(selectedItems);

But i get error

can not convert parameter 1 from 'cli::array<Type>^' to 'CDWordArray &'
Deduplicator
  • 44,692
  • 7
  • 66
  • 118
Jaqen H'ghar
  • 1,839
  • 7
  • 37
  • 66

1 Answers1

3

A CDWordArray isn't likely to be compatible with a managed array, the CObject base class makes it murky. You'll have to create a new instance of it and copy the array elements. That's expensive, consider restructuring the code so you can use the pin_ptr<> class. The MSDN HowTo article is here. Don't cast the pointer you get from pin_ptr<>, that's not likely to work.

Matteo Italia
  • 123,740
  • 17
  • 206
  • 299
Hans Passant
  • 922,412
  • 146
  • 1,693
  • 2,536