■ SetHandleInformation API 함수를 선언하는 방법을 보여준다.
▶ 예제 코드 (C#)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
using System; using System.Runtime.InteropServices; #region 핸들 정보 설정하기 - SetHandleInformation(objectHandle, mask, flag) /// <summary> /// 핸들 정보 설정하기 /// </summary> /// <param name="objectHandle">객체 핸들</param> /// <param name="mask">마스크</param> /// <param name="flag">플래그</param> /// <returns>처리 결과</returns> [DllImport("kernel32", SetLastError = true)] private static extern bool SetHandleInformation(IntPtr objectHandle, HANDLE_FLAG mask, HANDLE_FLAG flag); #endregion /// <summary> /// 핸들 플래그 /// </summary> [Flags] public enum HANDLE_FLAG : uint { /// <summary> /// NONE /// </summary> NONE = 0, /// <summary> /// INHERIT /// </summary> INHERIT = 1, /// <summary> /// PROTECT_FROM_CLOSE /// </summary> PROTECT_FROM_CLOSE = 2 } |