Type Cast from cli::array<unsigned char=""> to unsigned char*</unsigned>
-
Hello! I am about 2 hours into looking at Managed Code, so I'm completely new to this. The problem I'm running into is casting a managed type to an unmanaged type. I need to cast a cli array of unsigned char into unsigned char *. Is there a Marshal:: function that can do this for me? Here's what's going on... MyFunction accepts (unsigned char *) MyFunction((unsigned char*)&pStructure->pCliArrayOfUChar) This obviously doesn't work because you can't cast from managed to unmanaged. (I just learned this!) Thanks for your help!!
-
Hello! I am about 2 hours into looking at Managed Code, so I'm completely new to this. The problem I'm running into is casting a managed type to an unmanaged type. I need to cast a cli array of unsigned char into unsigned char *. Is there a Marshal:: function that can do this for me? Here's what's going on... MyFunction accepts (unsigned char *) MyFunction((unsigned char*)&pStructure->pCliArrayOfUChar) This obviously doesn't work because you can't cast from managed to unmanaged. (I just learned this!) Thanks for your help!!
-
Hello! I am about 2 hours into looking at Managed Code, so I'm completely new to this. The problem I'm running into is casting a managed type to an unmanaged type. I need to cast a cli array of unsigned char into unsigned char *. Is there a Marshal:: function that can do this for me? Here's what's going on... MyFunction accepts (unsigned char *) MyFunction((unsigned char*)&pStructure->pCliArrayOfUChar) This obviously doesn't work because you can't cast from managed to unmanaged. (I just learned this!) Thanks for your help!!
ChemmieBro wrote:
need to cast a cli array of unsigned char into unsigned char *
Right. You don't cast, you marshal data from managed to unmanaged. Marshal::Copy Method[^] You can also pin a pointer to the first element of the array Direct manipulation of CLI arrays using native pointers[^] Mark
Mark Salsbery Microsoft MVP - Visual C++ :java: