2016년 8월 23일 화요일

C# Pointer


http://hbesthee.tistory.com/1163


Ex :

public byte[] DataTransFromBuffer(SapBuffer buff)
{
try
{
byte[] output = new byte[buff.Width * buff.Height];
GCHandle pinnedArray = GCHandle.Alloc(output, GCHandleType.Pinned); // make
IntPtr pointer = pinnedArray.AddrOfPinnedObject();
buff.ReadRect(0, 0, buff.Width, buff.Height, pointer);
Marshal.Copy(pointer, output, 0, output.Length);
pinnedArray.Free();
return output;
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
return null;
}
}

댓글 없음:

댓글 쓰기