예제 #1
0
파일: Native.cs 프로젝트: ywscr/busdog
        public DeviceIOCTL(string devicePath, bool async)
        {
            this.async = async;
            FileOptions fileOps = FileOptions.None;

            if (async)
            {
                overlapped = new DeviceIoOverlapped();
                hEvent     = new ManualResetEvent(false);
                fileOps    = FileOptions.Asynchronous;
            }
            hDevice = new SafeFileHandle(
                CreateFile(
                    devicePath,
                    FileAccess.ReadWrite,
                    FileShare.ReadWrite,
                    0,
                    FileMode.Open,
                    fileOps,
                    IntPtr.Zero),
                true);
        }
예제 #2
0
 public DeviceIOCTL(string devicePath, bool async)
 {
     this.async = async;
     FileOptions fileOps = FileOptions.None;
     if (async)
     {
         overlapped = new DeviceIoOverlapped();
         hEvent = new ManualResetEvent(false);
         fileOps = FileOptions.Asynchronous;
     }
     hDevice = new SafeFileHandle(
         CreateFile(
             devicePath,
             FileAccess.ReadWrite,
             FileShare.ReadWrite,
             0,
             FileMode.Open,
             fileOps,
             IntPtr.Zero),
         true);
 }