托管代码数据如何转非托管数据?
array<Byte>^ 怎样转为 char *?
------解决方案--------------------------------------------------------
up
------解决方案--------------------------------------------------------
- C/C++ code
#include<windows.h>using namespace System;using namespace System::Runtime::InteropServices;#pragma comment( lib , "User32.lib" )int main(array<System::String ^> ^args){ array <Byte>^ arr = gcnew array<Byte>(128); for(int i=0;i<26;i++) arr[i]='a'+i; IntPtr p = Marshal::UnsafeAddrOfPinnedArrayElement( arr , 0 ); ::MessageBoxA( 0 , (char*)p.ToPointer() , 0 , 0 ); return 0;}