C#-托管变量变为非托管变量

 托管变量变为非托管变量

string a="";
string b;
int str_size = Marshal.SizeOf(a);
IntPtr buffer = Marshal.AllocHGlobal(str_size);  // 从进程的非托管内存中给DevBroadcastDeviceinterface分配内存
Marshal.StructureToPtr(b, buffer, true);        // 将数据从托管对象封送到非托管内存块(dbi->buffer,删除旧的数据)
posted @ 2022-11-17 11:09  ꧁执笔小白꧂  阅读(64)  评论(0)    收藏  举报