첨부 실행 코드는 나눔고딕코딩 폰트를 사용합니다.
728x90
반응형
728x170

■ GCHandle 클래스의 AddrOfPinnedObject 메소드를 사용해 고정된 객체 데이터의 핸들을 구하는 방법을 보여준다.

 

▶ 예제 코드 (C#)

using System.Runtime.InteropServices;
using System.Text;

byte[] sourceByteArray = Encoding.UTF8.GetBytes("안녕하세요");

GCHandle targetGCHandle = GCHandle.Alloc(sourceByteArray, GCHandleType.Pinned);

IntPtr targetHandle = targetGCHandle.AddrOfPinnedObject();

string target = Marshal.PtrToStringUTF8(targetHandle);

Console.WriteLine(target);

targetGCHandle.Free();
728x90
반응형
그리드형(광고전용)
Posted by icodebroker

댓글을 달아 주세요