public void SetTaskNumber(string path, byte taskNumber) { SafeFileHandle asyncWriteHandle = CreateFile(path, Win32HardwareIOSupport.GENERIC_WRITE, Win32HardwareIOSupport.FILE_SHARE_WRITE | Win32HardwareIOSupport.FILE_SHARE_READ, IntPtr.Zero, Win32HardwareIOSupport.OPEN_EXISTING, 0, IntPtr.Zero); if (asyncWriteHandle.IsInvalid) { Marshal.ThrowExceptionForHR(Marshal.GetHRForLastWin32Error()); } uint wrBytes; if (!WriteFile(asyncWriteHandle, UnlockConfigReq.getCommandPacket(taskNumber), 65, out wrBytes, IntPtr.Zero)) { Marshal.ThrowExceptionForHR(Marshal.GetHRForLastWin32Error()); } asyncWriteHandle.Close(); }
public void SetTaskNumber(FileStream hardwareFileStream, byte taskNumber) { hardwareFileStream.Write(UnlockConfigReq.getCommandPacket(taskNumber), 0, 65); }