■ DeviceIoControl 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 41 42 43 44 45 46 47 48 |
using System; using System.Runtime.InteropServices; #region 장치 IO 제어하기 - DeviceIoControl(deviceHandle, ioControlCode, inBuffer, inBufferSize, outBuffer, outBufferSize, byteCountReturned, overlappedHandle) /// <summary> /// 장치 IO 제어하기 /// </summary> /// <param name="deviceHandle">디바이스 핸들</param> /// <param name="ioControlCode">IO 제어 코드</param> /// <param name="inBuffer">입력 버퍼</param> /// <param name="inBufferSize">입력 버퍼 크기</param> /// <param name="outBuffer">출력 버퍼</param> /// <param name="outBufferSize">출력 버퍼 크기</param> /// <param name="byteCountReturned">반환 바이트 수</param> /// <param name="overlappedHandle">중첩 핸들</param> /// <returns>처리 결과</returns> [DllImport("kernel32")] public static extern bool DeviceIoControl ( IntPtr deviceHandle, uint ioControlCode, ref short inBuffer, uint inBufferSize, IntPtr outBuffer, uint outBufferSize, ref uint byteCountReturned, IntPtr overlappedHandle ); #endregion /// <summary> /// FSCTL_SET_COMPRESSION /// </summary> private const uint FSCTL_SET_COMPRESSION = 0x0009C040; /// <summary> /// COMPRESSION_FORMAT_NONE /// </summary> private const short COMPRESSION_FORMAT_NONE = 0; /// <summary> /// COMPRESSION_FORMAT_DEFAULT /// </summary> private const short COMPRESSION_FORMAT_DEFAULT = 1; |