Home > Net >  How managed code data turn unmanaged data? Array <Byte> how to unsigned char *
How managed code data turn unmanaged data? Array <Byte> how to unsigned char *

Time:11-06

How managed code data type unmanaged data types? Array ^ how to unsigned char *?

Look up to the net is a kind of approach:
 
#include
Using the namespace System;
Using the namespace System: : Runtime: : InteropServices;
# pragma comment (lib, "User32. Lib")
Int main (array{
Array & lt; Byte> ^ arr=gcnew array (128);
for(int i=0; i<26. I++)
Arr [I]='a' + I;
IntPtr p=Marshal: : UnsafeAddrOfPinnedArrayElement (arr, 0);
: : MessageBoxA (0, (unsigned char *) p.T oPointer (), 0, 0).
return 0;
}


I find nothing can, print out,

CodePudding user response:

Reference:

How managed code data turn unmanaged data? Array How to a char *

CodePudding user response:

 
Array ^ bs;
STD: : vector VecBinData (bs - & gt; Length);
For (int I=0; I & lt; Bs - & gt; Length; I++)
{
VecBinData [I]=bs [I];
}
Unsigned char * pszValue=https://bbs.csdn.net/topics/(unsigned char *) & vecBinData [0].

CodePudding user response:

There is no length attribute array in c + +, so when passing arrays are usually in pairs, is to take the array length. So you're in exporting c + + functions, parameters should have two. The parameter types reference can refer to the table on the net, such as:
https://www.cnblogs.com/yiki/archive/2008/10/29/1321848.html
Is actually puts some data memory, object encapsulation, c #. Net internal increased the information such as the length, so can directly obtain the length, and passed to the c + +, c + + only know c # the first byte of the data in an array of addresses, actually can see debugging data at this time, but only one address, you can't determine where data is to end. Like a line segment, only the starting point, it is no good ending.

CodePudding user response:

This I understand, so the question is how to get out, CLR c + + object address

CodePudding user response:

Code is no problem,,,,,,,,
  •  Tags:  
  • C#
  • Related