Frage

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 &'
War es hilfreich?

Lösung

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.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top