I'm currently working on a C++ command line application in Visual Studio. But at the moment I get stuck at some point:
I have an array of bytes, containing 3 elements:
byte arr [3] = {0x0A, 0xFF, 0xBF}
Now I want to give this array to a function. But while building I get the following error:
"Conversion from byte[3] into VARIANT is not possible."
So can anyone provide a simple example who this can be done in C++ using Visual Studio.
Thanks for your help.
There are C++ types, and type byte is missing in this list
https://en.cppreference.com/w/cpp/language/types
There is a link on how to use arrays in COM
https://www.codeguru.com/cpp/com-tech/activex/com/article.php/c2577/Using-COM-to-Pass-Arrays.htm
Note, the byte is not a C++ type and not a COM type. The C++ type for byte is char or unsigned char. Probably the most suitable for byte is the COM type is VT_UI1. Also check the type VT_ARRAY. You should use SafeArray* functions to work with COM arrays.
Some info on working with COM types you can find here: http://www.roblocher.com/whitepapers/oletypes.html
And here
Return Array of object from ATL ActiveX Control
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.