using System; using System.Runtime.InteropServices; using Vanara.InteropServices; namespace Vanara.PInvoke { public static partial class Kernel32 { /// Erasing technique. public enum TAPE_ERASE_TYPE { /// Erases the tape from the current position to the end of the current partition. TAPE_ERASE_LONG = 1, /// Writes an erase gap or end-of-data marker at the current position. TAPE_ERASE_SHORT = 0, } /// High-order bits of the device features flag. [Flags] public enum TAPE_FEATURES_HIGH : uint { /// The device moves the tape to a device-specific block address and returns as soon as the move begins. TAPE_DRIVE_ABS_BLK_IMMED = 0x80002000, /// The device moves the tape to a device specific block address. TAPE_DRIVE_ABSOLUTE_BLK = 0x80001000, /// The device moves the tape to the end-of-data marker in a partition. TAPE_DRIVE_END_OF_DATA = 0x80010000, /// The device moves the tape forward (or backward) a specified number of filemarks. TAPE_DRIVE_FILEMARKS = 0x80040000, /// The device enables and disables the device for further operations. TAPE_DRIVE_LOAD_UNLOAD = 0x80000001, /// The device supports immediate load and unload operations. TAPE_DRIVE_LOAD_UNLD_IMMED = 0x80000020, /// The device enables and disables the tape ejection mechanism. TAPE_DRIVE_LOCK_UNLOCK = 0x80000004, /// The device supports immediate lock and unlock operations. TAPE_DRIVE_LOCK_UNLK_IMMED = 0x80000080, /// The device moves the tape to a logical block address in a partition and returns as soon as the move begins. TAPE_DRIVE_LOG_BLK_IMMED = 0x80008000, /// The device moves the tape to a logical block address in a partition. TAPE_DRIVE_LOGICAL_BLK = 0x80004000, /// The device moves the tape forward (or backward) a specified number of blocks. TAPE_DRIVE_RELATIVE_BLKS = 0x80020000, /// The device moves the tape backward over blocks, filemarks, or setmarks. TAPE_DRIVE_REVERSE_POSITION = 0x80400000, /// The device supports immediate rewind operation. TAPE_DRIVE_REWIND_IMMEDIATE = 0x80000008, /// /// The device moves the tape forward (or backward) to the first occurrence of a specified number of consecutive filemarks. /// TAPE_DRIVE_SEQUENTIAL_FMKS = 0x80080000, /// /// The device moves the tape forward (or backward) to the first occurrence of a specified number of consecutive setmarks. /// TAPE_DRIVE_SEQUENTIAL_SMKS = 0x80200000, /// The device supports setting the size of a fixed-length logical block or setting the variable-length block mode. TAPE_DRIVE_SET_BLOCK_SIZE = 0x80000010, /// The device enables and disables hardware data compression. TAPE_DRIVE_SET_COMPRESSION = 0x80000200, /// The device enables and disables hardware error correction. TAPE_DRIVE_SET_ECC = 0x80000100, /// The device enables and disables data padding. TAPE_DRIVE_SET_PADDING = 0x80000400, /// The device enables and disables the reporting of setmarks. TAPE_DRIVE_SET_REPORT_SMKS = 0x80000800, /// The device moves the tape forward (or reverse) a specified number of setmarks. TAPE_DRIVE_SETMARKS = 0x80100000, /// The device supports immediate spacing. TAPE_DRIVE_SPACE_IMMEDIATE = 0x80800000, /// The device supports tape tensioning. TAPE_DRIVE_TENSION = 0x80000002, /// The device supports immediate tape tensioning. TAPE_DRIVE_TENSION_IMMED = 0x80000040, /// The device writes filemarks. TAPE_DRIVE_WRITE_FILEMARKS = 0x82000000, /// The device writes long filemarks. TAPE_DRIVE_WRITE_LONG_FMKS = 0x88000000, /// The device supports immediate writing of short and long filemarks. TAPE_DRIVE_WRITE_MARK_IMMED = 0x90000000, /// The device writes setmarks. TAPE_DRIVE_WRITE_SETMARKS = 0x81000000, /// The device writes short filemarks. TAPE_DRIVE_WRITE_SHORT_FMKS = 0x84000000, } /// Low-order bits of the device features flag. [Flags] public enum TAPE_FEATURES_LOW : uint { /// The device supports hardware data compression. TAPE_DRIVE_COMPRESSION = 0x00020000, /// The device can report if cleaning is required. TAPE_DRIVE_CLEAN_REQUESTS = 0x02000000, /// The device supports hardware error correction. TAPE_DRIVE_ECC = 0x00010000, /// The device physically ejects the tape on a software eject. TAPE_DRIVE_EJECT_MEDIA = 0x01000000, /// The device performs the erase operation from the beginning-of-partition marker only. TAPE_DRIVE_ERASE_BOP_ONLY = 0x00000040, /// The device performs a long erase operation. TAPE_DRIVE_ERASE_LONG = 0x00000020, /// The device performs an immediate erase operation — that is, it returns when the erase operation begins. TAPE_DRIVE_ERASE_IMMEDIATE = 0x00000080, /// The device performs a short erase operation. TAPE_DRIVE_ERASE_SHORT = 0x00000010, /// The device creates fixed data partitions. TAPE_DRIVE_FIXED = 0x00000001, /// The device supports fixed-length block mode. TAPE_DRIVE_FIXED_BLOCK = 0x00000400, /// The device provides the current device-specific block address. TAPE_DRIVE_GET_ABSOLUTE_BLK = 0x00100000, /// The device provides the current logical block address (and logical tape partition). TAPE_DRIVE_GET_LOGICAL_BLK = 0x00200000, /// The device creates initiator-defined partitions. TAPE_DRIVE_INITIATOR = 0x00000004, /// The device supports data padding. TAPE_DRIVE_PADDING = 0x00040000, /// The device supports setmark reporting. TAPE_DRIVE_REPORT_SMKS = 0x00080000, /// The device creates select data partitions. TAPE_DRIVE_SELECT = 0x00000002, /// The device must be at the beginning of a partition before it can set compression on. TAPE_DRIVE_SET_CMP_BOP_ONLY = 0x04000000, /// The device supports setting the end-of-medium warning size. TAPE_DRIVE_SET_EOT_WZ_SIZE = 0x00400000, /// The device returns the maximum capacity of the tape. TAPE_DRIVE_TAPE_CAPACITY = 0x00000100, /// The device returns the remaining capacity of the tape. TAPE_DRIVE_TAPE_REMAINING = 0x00000200, /// The device supports variable-length block mode. TAPE_DRIVE_VARIABLE_BLOCK = 0x00000800, /// The device returns an error if the tape is write-enabled or write-protected. TAPE_DRIVE_WRITE_PROTECT = 0x00001000, } /// Type of information requested. public enum TAPE_PARAM_OP { /// Retrieves information about the tape in the tape device. [CorrespondingType(typeof(TAPE_GET_MEDIA_PARAMETERS))] GET_TAPE_MEDIA_INFORMATION = 0, /// Retrieves information about the tape device. [CorrespondingType(typeof(TAPE_GET_DRIVE_PARAMETERS))] GET_TAPE_DRIVE_INFORMATION = 1, /// Sets the tape-specific information specified by the lpTapeInformation parameter. [CorrespondingType(typeof(TAPE_GET_MEDIA_PARAMETERS))] SET_TAPE_MEDIA_INFORMATION = 0, /// Sets the device-specific information specified by lpTapeInformation. [CorrespondingType(typeof(TAPE_GET_DRIVE_PARAMETERS))] SET_TAPE_DRIVE_INFORMATION = 1 } /// Type of partition to create. public enum TAPE_PARTITION_METHOD { /// /// Partitions the tape based on the device's default definition of partitions. The dwCount and dwSize parameters are ignored. /// TAPE_FIXED_PARTITIONS = 0, /// /// Partitions the tape into the number and size of partitions specified by dwCount and dwSize, respectively, except for the last /// partition. The size of the last partition is the remainder of the tape. /// TAPE_INITIATOR_PARTITIONS = 2, /// /// Partitions the tape into the number of partitions specified by dwCount. The dwSize parameter is ignored. The size of the /// partitions is determined by the device's default partition size. For more specific information, see the documentation for /// your tape device. /// TAPE_SELECT_PARTITIONS = 1 } /// Type of positioning to perform. public enum TAPE_POS_METHOD { /// /// Moves the tape to the device-specific block address specified by the dwOffsetLow and dwOffsetHigh parameters. The dwPartition /// parameter is ignored. /// TAPE_ABSOLUTE_BLOCK = 1, /// /// Moves the tape to the block address specified by dwOffsetLow and dwOffsetHigh in the partition specified by dwPartition. /// TAPE_LOGICAL_BLOCK = 2, /// /// Moves the tape to the beginning of the current partition. The dwPartition, dwOffsetLow, and dwOffsetHigh parameters are ignored. /// TAPE_REWIND = 0, /// Moves the tape to the end of the data on the partition specified by dwPartition. TAPE_SPACE_END_OF_DATA = 4, /// /// Moves the tape forward (or backward) the number of filemarks specified by dwOffsetLow and dwOffsetHigh in the current /// partition. The dwPartition parameter is ignored. /// TAPE_SPACE_FILEMARKS = 6, /// /// Moves the tape forward (or backward) the number of blocks specified by dwOffsetLow and dwOffsetHigh in the current partition. /// The dwPartition parameter is ignored. /// TAPE_SPACE_RELATIVE_BLOCKS = 5, /// /// Moves the tape forward (or backward) to the first occurrence of n filemarks in the current partition, where n is the number /// specified by dwOffsetLow and dwOffsetHigh. The dwPartition parameter is ignored. /// TAPE_SPACE_SEQUENTIAL_FMKS = 7, /// /// Moves the tape forward (or backward) to the first occurrence of n setmarks in the current partition, where n is the number /// specified by dwOffsetLow and dwOffsetHigh. The dwPartition parameter is ignored. /// TAPE_SPACE_SEQUENTIAL_SMKS = 9, /// /// Moves the tape forward (or backward) the number of setmarks specified by dwOffsetLow and dwOffsetHigh in the current /// partition. The dwPartition parameter is ignored. /// TAPE_SPACE_SETMARKS = 8, } /// Type of address to obtain. public enum TAPE_POS_TYPE { /// /// The lpdwOffsetLow and lpdwOffsetHigh parameters receive the device-specific block address. The dwPartition parameter receives zero. /// TAPE_ABSOLUTE_POSITION = 0, /// /// The lpdwOffsetLow and lpdwOffsetHigh parameters receive the logical block address. The dwPartition parameter receives the /// logical tape partition. /// TAPE_LOGICAL_POSITION = 1 } /// Tape device preparation. public enum TAPE_PREP_OP { /// Performs a low-level format of the tape. Currently, only the QIC117 device supports this feature. TAPE_FORMAT = 5, /// Loads the tape and moves the tape to the beginning. TAPE_LOAD = 0, /// Locks the tape ejection mechanism so that the tape is not ejected accidentally. TAPE_LOCK = 3, /// /// Adjusts the tension by moving the tape to the end of the tape and back to the beginning. This option is not supported by all /// devices. This value is ignored if it is not supported. /// TAPE_TENSION = 2, /// /// Moves the tape to the beginning for removal from the device. After a successful unload operation, the device returns errors /// to applications that attempt to access the tape, until the tape is loaded again. /// TAPE_UNLOAD = 1, /// Unlocks the tape ejection mechanism. TAPE_UNLOCK = 4, } /// Type of tapemarks to write. public enum TAPEMARK_TYPE { /// Writes the number of filemarks specified by the dwTapemarkCount parameter. TAPE_FILEMARKS = 1, /// Writes the number of long filemarks specified by dwTapemarkCount. TAPE_LONG_FILEMARKS = 3, /// Writes the number of setmarks specified by dwTapemarkCount. TAPE_SETMARKS = 0, /// Writes the number of short filemarks specified by dwTapemarkCount. TAPE_SHORT_FILEMARKS = 2, } /// /// The BackupRead function can be used to back up a file or directory, including the security information. The function reads /// data associated with a specified file or directory into a buffer, which can then be written to the backup medium using the /// WriteFile function. /// /// /// /// Handle to the file or directory to be backed up. To obtain the handle, call the CreateFile function. The SACLs are not /// read unless the file handle was created with the ACCESS_SYSTEM_SECURITY access right. For more information, see File /// Security and Access Rights. /// /// /// The handle must be synchronous (nonoverlapped). This means that the FILE_FLAG_OVERLAPPED flag must not be set when /// CreateFile is called. This function does not validate that the handle it receives is synchronous, so it does not return an /// error code for a synchronous handle, but calling it with an asynchronous (overlapped) handle can result in subtle errors that are /// very difficult to debug. /// /// /// The BackupRead function may fail if CreateFile was called with the flag FILE_FLAG_NO_BUFFERING. In this /// case, the GetLastError function returns the value ERROR_INVALID_PARAMETER. /// /// /// Pointer to a buffer that receives the data. /// /// Length of the buffer, in bytes. The buffer size must be greater than the size of a WIN32_STREAM_ID structure. /// /// /// Pointer to a variable that receives the number of bytes read. /// /// If the function returns a nonzero value, and the variable pointed to by lpNumberOfBytesRead is zero, then all the data associated /// with the file handle has been read. /// /// /// /// Indicates whether you have finished using BackupRead on the handle. While you are backing up the file, specify this /// parameter as FALSE. Once you are done using BackupRead, you must call BackupRead one more time specifying /// TRUE for this parameter and passing the appropriate lpContext. lpContext must be passed when bAbort is TRUE; all /// other parameters are ignored. /// /// /// Indicates whether the function will restore the access-control list (ACL) data for the file or directory. /// If bProcessSecurity is TRUE, the ACL data will be backed up. /// /// /// /// Pointer to a variable that receives a pointer to an internal data structure used by BackupRead to maintain context /// information during a backup operation. /// /// /// You must set the variable pointed to by lpContext to NULL before the first call to BackupRead for the specified /// file or directory. The function allocates memory for the data structure, and then sets the variable to point to that structure. /// You must not change lpContext or the variable that it points to between calls to BackupRead. /// /// /// To release the memory used by the data structure, call BackupRead with the bAbort parameter set to TRUE when the /// backup operation is complete. /// /// /// /// If the function succeeds, the return value is nonzero. /// /// If the function fails, the return value is zero, indicating that an I/O error occurred. To get extended error information, call GetLastError. /// /// // BOOL BackupRead( _In_ HANDLE hFile, _Out_ LPBYTE lpBuffer, _In_ DWORD nNumberOfBytesToRead, _Out_ LPDWORD lpNumberOfBytesRead, // _In_ BOOL bAbort, _In_ BOOL bProcessSecurity, _Out_ LPVOID *lpContext); https://msdn.microsoft.com/en-us/library/windows/desktop/aa362509(v=vs.85).aspx [DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true)] [PInvokeData("Winbase.h", MSDNShortId = "aa362509")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool BackupRead([In] HFILE hFile, IntPtr lpBuffer, uint nNumberOfBytesToRead, out uint lpNumberOfBytesRead, [MarshalAs(UnmanagedType.Bool)] bool bAbort, [MarshalAs(UnmanagedType.Bool)] bool bProcessSecurity, out IntPtr lpContext); /// /// The BackupSeek function seeks forward in a data stream initially accessed by using the BackupRead or /// BackupWrite function. /// /// /// Handle to the file or directory. This handle is created by using the CreateFile function. /// /// The handle must be synchronous (nonoverlapped). This means that the FILE_FLAG_OVERLAPPED flag must not be set when /// CreateFile is called. This function does not validate that the handle it receives is synchronous, so it does not return an /// error code for a synchronous handle, but calling it with an asynchronous (overlapped) handle can result in subtle errors that are /// very difficult to debug. /// /// /// Low-order part of the number of bytes to seek. /// High-order part of the number of bytes to seek. /// /// Pointer to a variable that receives the low-order bits of the number of bytes the function actually seeks. /// /// /// Pointer to a variable that receives the high-order bits of the number of bytes the function actually seeks. /// /// /// Pointer to an internal data structure used by the function. This structure must be the same structure that was initialized by the /// BackupRead or BackupWrite function. An application must not touch the contents of this structure. /// /// /// If the function could seek the requested amount, the function returns a nonzero value. /// /// If the function could not seek the requested amount, the function returns zero. To get extended error information, call GetLastError. /// /// // BOOL BackupSeek( _In_ HANDLE hFile, _In_ DWORD dwLowBytesToSeek, _In_ DWORD dwHighBytesToSeek, _Out_ LPDWORD lpdwLowByteSeeked, // _Out_ LPDWORD lpdwHighByteSeeked, _In_ LPVOID *lpContext); https://msdn.microsoft.com/en-us/library/windows/desktop/aa362510(v=vs.85).aspx [DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true)] [PInvokeData("Winbase.h", MSDNShortId = "aa362510")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool BackupSeek([In] HFILE hFile, uint dwLowBytesToSeek, uint dwHighBytesToSeek, out uint lpdwLowByteSeeked, out uint lpdwHighByteSeeked, ref IntPtr lpContext); /// /// The BackupWrite function can be used to restore a file or directory that was backed up using BackupRead. Use the /// ReadFile function to get a stream of data from the backup medium, then use BackupWrite to write the data to the /// specified file or directory. /// /// /// /// Handle to the file or directory to be restored. To obtain the handle, call the CreateFile function. The SACLs are not /// restored unless the file handle was created with the ACCESS_SYSTEM_SECURITY access right. To ensure that the integrity /// ACEs are restored correctly, the file handle must also have been created with the WRITE_OWNER access right. For more information, /// see File Security and Access Rights. /// /// Windows Server 2003 and Windows XP: The WRITE_OWNER access right is not required. /// /// The handle must be synchronous (nonoverlapped). This means that the FILE_FLAG_OVERLAPPED flag must not be set when /// CreateFile is called. This function does not validate that the handle it receives is synchronous, so it does not return an /// error code for a synchronous handle, but calling it with an asynchronous (overlapped) handle can result in subtle errors that are /// very difficult to debug. /// /// /// The BackupWrite function may fail if CreateFile was called with the flag FILE_FLAG_NO_BUFFERING. In this /// case, the GetLastError function returns the value ERROR_INVALID_PARAMETER. /// /// /// Pointer to a buffer that the function writes data from. /// /// Size of the buffer, in bytes. The buffer size must be greater than the size of a WIN32_STREAM_ID structure. /// /// Pointer to a variable that receives the number of bytes written. /// /// Indicates whether you have finished using BackupWrite on the handle. While you are restoring the file, specify this /// parameter as FALSE. After you are done using BackupWrite, you must call BackupWrite one more time specifying /// TRUE for this parameter and passing the appropriate lpContext. lpContext must be passed when bAbort is TRUE; all /// other parameters are ignored. /// /// /// Specifies whether the function will restore the access-control list (ACL) data for the file or directory. /// /// If bProcessSecurity is TRUE, you need to specify WRITE_OWNER and WRITE_DAC access when opening the file or /// directory handle. If the handle does not have those access rights, the operating system denies access to the ACL data, and ACL /// data restoration will not occur. /// /// /// /// /// Pointer to a variable that receives a pointer to an internal data structure used by BackupWrite to maintain context /// information during a restore operation. /// /// /// You must set the variable pointed to by lpContext to NULL before the first call to BackupWrite for the specified /// file or directory. The function allocates memory for the data structure, and then sets the variable to point to that structure. /// You must not change lpContext or the variable that it points to between calls to BackupWrite. /// /// /// To release the memory used by the data structure, call BackupWrite with the bAbort parameter set to TRUE when the /// restore operation is complete. /// /// /// /// If the function succeeds, the return value is nonzero. /// /// If the function fails, the return value is zero, indicating that an I/O error occurred. To get extended error information, call GetLastError. /// /// // BOOL BackupWrite( _In_ HANDLE hFile, _In_ LPBYTE lpBuffer, _In_ DWORD nNumberOfBytesToWrite, _Out_ LPDWORD lpNumberOfBytesWritten, // _In_ BOOL bAbort, _In_ BOOL bProcessSecurity, _Out_ LPVOID *lpContext); https://msdn.microsoft.com/en-us/library/windows/desktop/aa362511(v=vs.85).aspx [DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true)] [PInvokeData("Winbase.h", MSDNShortId = "aa362511")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool BackupWrite([In] HFILE hFile, [In] IntPtr lpBuffer, uint nNumberOfBytesToWrite, out uint lpNumberOfBytesWritten, [MarshalAs(UnmanagedType.Bool)] bool bAbort, [MarshalAs(UnmanagedType.Bool)] bool bProcessSecurity, out IntPtr lpContext); /// The CreateTapePartition function reformats a tape. /// /// Handle to the device where the new partition is to be created. This handle is created by using the CreateFile function. /// /// /// /// Type of partition to create. To determine what type of partitions your device supports, see the documentation for your hardware. /// This parameter can have one of the following values. /// /// /// /// /// Value /// Meaning /// /// /// TAPE_FIXED_PARTITIONS0L /// Partitions the tape based on the device's default definition of partitions. The dwCount and dwSize parameters are ignored. /// /// /// TAPE_INITIATOR_PARTITIONS2L /// /// Partitions the tape into the number and size of partitions specified by dwCount and dwSize, respectively, except for the last /// partition. The size of the last partition is the remainder of the tape. /// /// /// /// TAPE_SELECT_PARTITIONS1L /// /// Partitions the tape into the number of partitions specified by dwCount. The dwSize parameter is ignored. The size of the /// partitions is determined by the device's default partition size. For more specific information, see the documentation for your /// tape device. /// /// /// /// /// /// /// Number of partitions to create. The GetTapeParameters function provides the maximum number of partitions a tape can support. /// /// Size of each partition, in megabytes. This value is ignored if the dwPartitionMethod parameter is TAPE_SELECT_PARTITIONS. /// /// If the function succeeds, the return value is NO_ERROR. /// If the function fails, it can return one of the following error codes. /// /// /// /// Error /// Description /// /// /// ERROR_BEGINNING_OF_MEDIA1102L /// An attempt to access data before the beginning-of-medium marker failed. /// /// /// ERROR_BUS_RESET1111L /// A reset condition was detected on the bus. /// /// /// ERROR_END_OF_MEDIA1100L /// The end-of-tape marker was reached during an operation. /// /// /// ERROR_FILEMARK_DETECTED1101L /// A filemark was reached during an operation. /// /// /// ERROR_SETMARK_DETECTED1103L /// A setmark was reached during an operation. /// /// /// ERROR_NO_DATA_DETECTED1104L /// The end-of-data marker was reached during an operation. /// /// /// ERROR_PARTITION_FAILURE1105L /// The tape could not be partitioned. /// /// /// ERROR_INVALID_BLOCK_LENGTH1106L /// The block size is incorrect on a new tape in a multivolume partition. /// /// /// ERROR_DEVICE_NOT_PARTITIONED1107L /// The partition information could not be found when a tape was being loaded. /// /// /// ERROR_MEDIA_CHANGED1110L /// The tape that was in the drive has been replaced or removed. /// /// /// ERROR_NO_MEDIA_IN_DRIVE1112L /// There is no media in the drive. /// /// /// ERROR_NOT_SUPPORTED50L /// The tape driver does not support a requested function. /// /// /// ERROR_UNABLE_TO_LOCK_MEDIA1108L /// An attempt to lock the ejection mechanism failed. /// /// /// ERROR_UNABLE_TO_UNLOAD_MEDIA1109L /// An attempt to unload the tape failed. /// /// /// ERROR_WRITE_PROTECT19L /// The media is write protected. /// /// /// /// // DWORD CreateTapePartition( _In_ HANDLE hDevice, _In_ DWORD dwPartitionMethod, _In_ DWORD dwCount, _In_ DWORD dwSize); https://msdn.microsoft.com/en-us/library/windows/desktop/aa362519(v=vs.85).aspx [DllImport(Lib.Kernel32, SetLastError = false, ExactSpelling = true)] [PInvokeData("Winbase.h", MSDNShortId = "aa362519")] public static extern Win32Error CreateTapePartition([In] HFILE hDevice, TAPE_PARTITION_METHOD dwPartitionMethod, uint dwCount, uint dwSize); /// The EraseTape function erases all or part of a tape. /// Handle to the device where the tape is to be erased. This handle is created by using the CreateFile function. /// /// Erasing technique. This parameter can be one of the following values. /// /// /// Value /// Meaning /// /// /// TAPE_ERASE_LONG 1L /// Erases the tape from the current position to the end of the current partition. /// /// /// TAPE_ERASE_SHORT 0L /// Writes an erase gap or end-of-data marker at the current position. /// /// /// /// /// If this parameter is TRUE, the function returns immediately; if it is FALSE, the function does not return until /// the erase operation has been completed. /// /// /// If the function succeeds, the return value is NO_ERROR. /// If the function fails, it can return one of the following error codes. /// /// /// Error code /// Description /// /// /// ERROR_BEGINNING_OF_MEDIA 1102L /// An attempt to access data before the beginning-of-medium marker failed. /// /// /// ERROR_BUS_RESET 1111L /// A reset condition was detected on the bus. /// /// /// ERROR_DEVICE_NOT_PARTITIONED 1107L /// The partition information could not be found when a tape was being loaded. /// /// /// ERROR_END_OF_MEDIA 1100L /// The end-of-tape marker was reached during an operation. /// /// /// ERROR_FILEMARK_DETECTED 1101L /// A filemark was reached during an operation. /// /// /// ERROR_INVALID_BLOCK_LENGTH 1106L /// The block size is incorrect on a new tape in a multivolume partition. /// /// /// ERROR_MEDIA_CHANGED 1110L /// The tape that was in the drive has been replaced or removed. /// /// /// ERROR_NO_DATA_DETECTED 1104L /// The end-of-data marker was reached during an operation. /// /// /// ERROR_NO_MEDIA_IN_DRIVE 1112L /// There is no media in the drive. /// /// /// ERROR_NOT_SUPPORTED 50L /// The tape driver does not support a requested function. /// /// /// ERROR_PARTITION_FAILURE 1105L /// The tape could not be partitioned. /// /// /// ERROR_SETMARK_DETECTED 1103L /// A setmark was reached during an operation. /// /// /// ERROR_UNABLE_TO_LOCK_MEDIA 1108L /// An attempt to lock the ejection mechanism failed. /// /// /// ERROR_UNABLE_TO_UNLOAD_MEDIA 1109L /// An attempt to unload the tape failed. /// /// /// ERROR_WRITE_PROTECT 19L /// The media is write protected. /// /// /// /// /// Some tape devices do not support certain tape operations. To determine your tape device's capabilities, see your tape device /// documentation and use the GetTapeParameters function. /// // https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-erasetape // DWORD EraseTape( HANDLE hDevice, DWORD dwEraseType, BOOL bImmediate ); [DllImport(Lib.Kernel32, SetLastError = false, ExactSpelling = true)] [PInvokeData("winbase.h", MSDNShortId = "af262e79-ebdb-4ec5-9b59-ed6725a48bdf")] public static extern Win32Error EraseTape([In] HFILE hDevice, TAPE_ERASE_TYPE dwEraseType, [MarshalAs(UnmanagedType.Bool)] bool bImmediate); /// The GetTapeParameters function retrieves information that describes the tape or the tape drive. /// /// Handle to the device about which information is sought. This handle is created by using the CreateFile function. /// /// /// Type of information requested. This parameter must be one of the following values. /// /// /// /// Value /// Meaning /// /// /// GET_TAPE_DRIVE_INFORMATION1 /// Retrieves information about the tape device. /// /// /// GET_TAPE_MEDIA_INFORMATION0 /// Retrieves information about the tape in the tape device. /// /// /// /// /// /// Pointer to a variable that receives the size, in bytes, of the buffer specified by the lpTapeInformation parameter. If the buffer /// is too small, this parameter receives the required size. /// /// /// /// Pointer to a structure that contains the requested information. If the dwOperation parameter is GET_TAPE_MEDIA_INFORMATION, /// lpTapeInformation points to a TAPE_GET_MEDIA_PARAMETERS structure. /// /// If dwOperation is GET_TAPE_DRIVE_INFORMATION, lpTapeInformation points to a TAPE_GET_DRIVE_PARAMETERS structure. /// /// /// If the function succeeds, the return value is NO_ERROR. /// If the function fails, it can return one of the following error codes. /// /// /// /// Error code /// Description /// /// /// ERROR_BEGINNING_OF_MEDIA1102L /// An attempt to access data before the beginning-of-medium marker failed. /// /// /// ERROR_BUS_RESET1111L /// A reset condition was detected on the bus. /// /// /// ERROR_DEVICE_NOT_PARTITIONED1107L /// The partition information could not be found when a tape was being loaded. /// /// /// ERROR_END_OF_MEDIA1100L /// The end-of-tape marker was reached during an operation. /// /// /// ERROR_FILEMARK_DETECTED1101L /// A filemark was reached during an operation. /// /// /// ERROR_INVALID_BLOCK_LENGTH1106L /// The block size is incorrect on a new tape in a multivolume partition. /// /// /// ERROR_MEDIA_CHANGED1110L /// The tape that was in the drive has been replaced or removed. /// /// /// ERROR_NO_DATA_DETECTED1104L /// The end-of-data marker was reached during an operation. /// /// /// ERROR_NO_MEDIA_IN_DRIVE1112L /// There is no media in the drive. /// /// /// ERROR_NOT_SUPPORTED50L /// The tape driver does not support a requested function. /// /// /// ERROR_PARTITION_FAILURE1105L /// The tape could not be partitioned. /// /// /// ERROR_SETMARK_DETECTED1103L /// A setmark was reached during an operation. /// /// /// ERROR_UNABLE_TO_LOCK_MEDIA1108L /// An attempt to lock the ejection mechanism failed. /// /// /// ERROR_UNABLE_TO_UNLOAD_MEDIA1109L /// An attempt to unload the tape failed. /// /// /// ERROR_WRITE_PROTECT19L /// The media is write protected. /// /// /// /// // DWORD GetTapeParameters( _In_ HANDLE hDevice, _In_ DWORD dwOperation, _Out_ LPDWORD lpdwSize, _Out_ LPVOID lpTapeInformation); https://msdn.microsoft.com/en-us/library/windows/desktop/aa362526(v=vs.85).aspx [DllImport(Lib.Kernel32, SetLastError = false, ExactSpelling = true)] [PInvokeData("Winbase.h", MSDNShortId = "aa362526")] public static extern Win32Error GetTapeParameters([In] HFILE hDevice, TAPE_PARAM_OP dwOperation, ref uint lpdwSize, IntPtr lpTapeInformation); /// The GetTapePosition function retrieves the current address of the tape, in logical or absolute blocks. /// Handle to the device on which to get the tape position. This handle is created by using CreateFile. /// /// Type of address to obtain. This parameter can be one of the following values. /// /// /// /// Value /// Meaning /// /// /// TAPE_ABSOLUTE_POSITION0L /// /// The lpdwOffsetLow and lpdwOffsetHigh parameters receive the device-specific block address. The dwPartition parameter receives zero. /// /// /// /// TAPE_LOGICAL_POSITION1L /// /// The lpdwOffsetLow and lpdwOffsetHigh parameters receive the logical block address. The dwPartition parameter receives the logical /// tape partition. /// /// /// /// /// /// /// Pointer to a variable that receives the number of the current tape partition. Partitions are numbered logically from 1 through n, /// where 1 is the first partition on the tape and n is the last. When a device-specific block address is retrieved, or if the device /// supports only one partition, this parameter receives zero. /// /// Pointer to a variable that receives the low-order bits of the current tape position. /// /// Pointer to a variable that receives the high-order bits of the current tape position. This parameter can be NULL if the /// high-order bits are not required. /// /// /// If the function succeeds, the return value is NO_ERROR. /// If the function fails, it can return one of the following error codes. /// /// /// /// Error code /// Description /// /// /// ERROR_BEGINNING_OF_MEDIA1102L /// An attempt to access data before the beginning-of-medium marker failed. /// /// /// ERROR_BUS_RESET1111L /// A reset condition was detected on the bus. /// /// /// ERROR_DEVICE_NOT_PARTITIONED1107L /// The partition information could not be found when a tape was being loaded. /// /// /// ERROR_END_OF_MEDIA1100L /// The end-of-tape marker was reached during an operation. /// /// /// ERROR_FILEMARK_DETECTED1101L /// A filemark was reached during an operation. /// /// /// ERROR_INVALID_BLOCK_LENGTH1106L /// The block size is incorrect on a new tape in a multivolume partition. /// /// /// ERROR_MEDIA_CHANGED1110L /// The tape that was in the drive has been replaced or removed. /// /// /// ERROR_NO_DATA_DETECTED1104L /// The end-of-data marker was reached during an operation. /// /// /// ERROR_NO_MEDIA_IN_DRIVE1112L /// There is no media in the drive. /// /// /// ERROR_NOT_SUPPORTED50L /// The tape driver does not support a requested function. /// /// /// ERROR_PARTITION_FAILURE1105L /// The tape could not be partitioned. /// /// /// ERROR_SETMARK_DETECTED1103L /// A setmark was reached during an operation. /// /// /// ERROR_UNABLE_TO_LOCK_MEDIA1108L /// An attempt to lock the ejection mechanism failed. /// /// /// ERROR_UNABLE_TO_UNLOAD_MEDIA1109L /// An attempt to unload the tape failed. /// /// /// ERROR_WRITE_PROTECT19L /// The media is write protected. /// /// /// /// // DWORD GetTapePosition( _In_ HANDLE hDevice, _In_ DWORD dwPositionType, _Out_ LPDWORD lpdwPartition, _Out_ LPDWORD lpdwOffsetLow, // _Out_ LPDWORD lpdwOffsetHigh); https://msdn.microsoft.com/en-us/library/windows/desktop/aa362528(v=vs.85).aspx [DllImport(Lib.Kernel32, SetLastError = false, ExactSpelling = true)] [PInvokeData("Winbase.h", MSDNShortId = "aa362528")] public static extern Win32Error GetTapePosition([In] HFILE hDevice, TAPE_POS_TYPE dwPositionType, out uint lpdwPartition, out uint lpdwOffsetLow, out uint lpdwOffsetHigh); /// The GetTapeStatus function determines whether the tape device is ready to process tape commands. /// /// Handle to the device for which to get the device status. This handle is created by using the CreateFile function. /// /// /// If the tape device is ready to accept appropriate tape-access commands without returning errors, the return value is NO_ERROR. /// If the function fails, it can return one of the following error codes. /// /// /// /// Error code /// Description /// /// /// ERROR_BEGINNING_OF_MEDIA1102L /// An attempt to access data before the beginning-of-medium marker failed. /// /// /// ERROR_BUS_RESET1111L /// A reset condition was detected on the bus. /// /// /// ERROR_DEVICE_NOT_PARTITIONED1107L /// The partition information could not be found when a tape was being loaded. /// /// /// ERROR_DEVICE_REQUIRES_CLEANING1165L /// The tape drive is capable of reporting that it requires cleaning, and reports that it does require cleaning. /// /// /// ERROR_END_OF_MEDIA1100L /// The end-of-tape marker was reached during an operation. /// /// /// ERROR_FILEMARK_DETECTED1101L /// A filemark was reached during an operation. /// /// /// ERROR_INVALID_BLOCK_LENGTH1106L /// The block size is incorrect on a new tape in a multivolume partition. /// /// /// ERROR_MEDIA_CHANGED1110L /// The tape that was in the drive has been replaced or removed. /// /// /// ERROR_NO_DATA_DETECTED1104L /// The end-of-data marker was reached during an operation. /// /// /// ERROR_NO_MEDIA_IN_DRIVE1112L /// There is no media in the drive. /// /// /// ERROR_NOT_SUPPORTED50L /// The tape driver does not support a requested function. /// /// /// ERROR_PARTITION_FAILURE1105L /// The tape could not be partitioned. /// /// /// ERROR_SETMARK_DETECTED1103L /// A setmark was reached during an operation. /// /// /// ERROR_UNABLE_TO_LOCK_MEDIA1108L /// An attempt to lock the ejection mechanism failed. /// /// /// ERROR_UNABLE_TO_UNLOAD_MEDIA1109L /// An attempt to unload the tape failed. /// /// /// ERROR_WRITE_PROTECT19L /// The media is write protected. /// /// /// /// // DWORD GetTapeStatus( _In_ HANDLE hDevice); https://msdn.microsoft.com/en-us/library/windows/desktop/aa362530(v=vs.85).aspx [DllImport(Lib.Kernel32, SetLastError = false, ExactSpelling = true)] [PInvokeData("Winbase.h", MSDNShortId = "aa362530")] public static extern Win32Error GetTapeStatus([In] HFILE hDevice); /// The PrepareTape function prepares the tape to be accessed or removed. /// Handle to the device preparing the tape. This handle is created by using the CreateFile function. /// /// Tape device preparation. This parameter can be one of the following values. /// /// /// /// Value /// Meaning /// /// /// TAPE_FORMAT5L /// Performs a low-level format of the tape. Currently, only the QIC117 device supports this feature. /// /// /// TAPE_LOAD0L /// Loads the tape and moves the tape to the beginning. /// /// /// TAPE_LOCK3L /// Locks the tape ejection mechanism so that the tape is not ejected accidentally. /// /// /// TAPE_TENSION2L /// /// Adjusts the tension by moving the tape to the end of the tape and back to the beginning. This option is not supported by all /// devices. This value is ignored if it is not supported. /// /// /// /// TAPE_UNLOAD1L /// /// Moves the tape to the beginning for removal from the device. After a successful unload operation, the device returns errors to /// applications that attempt to access the tape, until the tape is loaded again. /// /// /// /// TAPE_UNLOCK4L /// Unlocks the tape ejection mechanism. /// /// /// /// /// /// If this parameter is TRUE, the function returns immediately. If it is FALSE, the function does not return until the /// operation has been completed. /// /// /// If the function succeeds, the return value is NO_ERROR. /// If the function fails, it can return one of the following error codes. /// /// /// /// Error /// Description /// /// /// ERROR_BEGINNING_OF_MEDIA1102L /// An attempt to access data before the beginning-of-medium marker failed. /// /// /// ERROR_BUS_RESET1111L /// A reset condition was detected on the bus. /// /// /// ERROR_DEVICE_NOT_PARTITIONED1107L /// The partition information could not be found when a tape was being loaded. /// /// /// ERROR_END_OF_MEDIA1100L /// The end-of-tape marker was reached during an operation. /// /// /// ERROR_FILEMARK_DETECTED1101L /// A filemark was reached during an operation. /// /// /// ERROR_INVALID_BLOCK_LENGTH1106L /// The block size is incorrect on a new tape in a multivolume partition. /// /// /// ERROR_MEDIA_CHANGED1110L /// The tape that was in the drive has been replaced or removed. /// /// /// ERROR_NO_DATA_DETECTED1104L /// The end-of-data marker was reached during an operation. /// /// /// ERROR_NO_MEDIA_IN_DRIVE1112L /// There is no media in the drive. /// /// /// ERROR_NOT_SUPPORTED50L /// The tape driver does not support a requested function. /// /// /// ERROR_PARTITION_FAILURE1105L /// The tape could not be partitioned. /// /// /// ERROR_SETMARK_DETECTED1103L /// A setmark was reached during an operation. /// /// /// ERROR_UNABLE_TO_LOCK_MEDIA1108L /// An attempt to lock the ejection mechanism failed. /// /// /// ERROR_UNABLE_TO_UNLOAD_MEDIA1109L /// An attempt to unload the tape failed. /// /// /// ERROR_WRITE_PROTECT19L /// The media is write protected. /// /// /// /// // DWORD PrepareTape( _In_ HANDLE hDevice, _In_ DWORD dwOperation, _In_ BOOL bImmediate); https://msdn.microsoft.com/en-us/library/windows/desktop/aa362532(v=vs.85).aspx [DllImport(Lib.Kernel32, SetLastError = false, ExactSpelling = true)] [PInvokeData("Winbase.h", MSDNShortId = "aa362532")] public static extern Win32Error PrepareTape([In] HFILE hDevice, TAPE_PREP_OP dwOperation, [MarshalAs(UnmanagedType.Bool)] bool bImmediate); /// The SetTapeParameters function either specifies the block size of a tape or configures the tape device. /// /// Handle to the device for which to set configuration information. This handle is created by using the CreateFile function. /// /// /// Type of information to set. This parameter must be one of the following values. /// /// /// /// Value /// Meaning /// /// /// SET_TAPE_DRIVE_INFORMATION1L /// Sets the device-specific information specified by lpTapeInformation. /// /// /// SET_TAPE_MEDIA_INFORMATION0L /// Sets the tape-specific information specified by the lpTapeInformation parameter. /// /// /// /// /// /// /// Pointer to a structure that contains the information to set. If the dwOperation parameter is SET_TAPE_MEDIA_INFORMATION, /// lpTapeInformation points to a TAPE_SET_MEDIA_PARAMETERS structure. /// /// If dwOperation is SET_TAPE_DRIVE_INFORMATION, lpTapeInformation points to a TAPE_SET_DRIVE_PARAMETERS structure. /// /// /// If the function succeeds, the return value is NO_ERROR. /// If the function fails, it can return one of the following error codes. /// /// /// /// Error /// Description /// /// /// ERROR_BEGINNING_OF_MEDIA1102L /// An attempt to access data before the beginning-of-medium marker failed. /// /// /// ERROR_BUS_RESET1111L /// A reset condition was detected on the bus. /// /// /// ERROR_DEVICE_NOT_PARTITIONED1107L /// The partition information could not be found when a tape was being loaded. /// /// /// ERROR_END_OF_MEDIA1100L /// The end-of-tape marker was reached during an operation. /// /// /// ERROR_FILEMARK_DETECTED1101L /// A filemark was reached during an operation. /// /// /// ERROR_INVALID_BLOCK_LENGTH1106L /// The block size is incorrect on a new tape in a multivolume partition. /// /// /// ERROR_MEDIA_CHANGED1110L /// The tape that was in the drive has been replaced or removed. /// /// /// ERROR_NO_DATA_DETECTED1104L /// The end-of-data marker was reached during an operation. /// /// /// ERROR_NO_MEDIA_IN_DRIVE1112L /// There is no media in the drive. /// /// /// ERROR_NOT_SUPPORTED50L /// The tape driver does not support a requested function. /// /// /// ERROR_PARTITION_FAILURE1105L /// The tape could not be partitioned. /// /// /// ERROR_SETMARK_DETECTED1103L /// A setmark was reached during an operation. /// /// /// ERROR_UNABLE_TO_LOCK_MEDIA1108L /// An attempt to lock the ejection mechanism failed. /// /// /// ERROR_UNABLE_TO_UNLOAD_MEDIA1109L /// An attempt to unload the tape failed. /// /// /// ERROR_WRITE_PROTECT19L /// The media is write protected. /// /// /// /// // DWORD SetTapeParameters( _In_ HANDLE hDevice, _In_ DWORD dwOperation, _In_ LPVOID lpTapeInformation); https://msdn.microsoft.com/en-us/library/windows/desktop/aa362534(v=vs.85).aspx [DllImport(Lib.Kernel32, SetLastError = false, ExactSpelling = true)] [PInvokeData("Winbase.h", MSDNShortId = "aa362534")] public static extern Win32Error SetTapeParameters([In] HFILE hDevice, TAPE_PARAM_OP dwOperation, [In] IntPtr lpTapeInformation); /// The SetTapePosition function sets the tape position on the specified device. /// /// Handle to the device on which to set the tape position. This handle is created by using the CreateFile function. /// /// /// Type of positioning to perform. This parameter must be one of the following values. /// /// /// /// Value /// Meaning /// /// /// TAPE_ABSOLUTE_BLOCK1L /// /// Moves the tape to the device-specific block address specified by the dwOffsetLow and dwOffsetHigh parameters. The dwPartition /// parameter is ignored. /// /// /// /// TAPE_LOGICAL_BLOCK2L /// Moves the tape to the block address specified by dwOffsetLow and dwOffsetHigh in the partition specified by dwPartition. /// /// /// TAPE_REWIND0L /// /// Moves the tape to the beginning of the current partition. The dwPartition, dwOffsetLow, and dwOffsetHigh parameters are ignored. /// /// /// /// TAPE_SPACE_END_OF_DATA4L /// Moves the tape to the end of the data on the partition specified by dwPartition. /// /// /// TAPE_SPACE_FILEMARKS6L /// /// Moves the tape forward (or backward) the number of filemarks specified by dwOffsetLow and dwOffsetHigh in the current partition. /// The dwPartition parameter is ignored. /// /// /// /// TAPE_SPACE_RELATIVE_BLOCKS5L /// /// Moves the tape forward (or backward) the number of blocks specified by dwOffsetLow and dwOffsetHigh in the current partition. The /// dwPartition parameter is ignored. /// /// /// /// TAPE_SPACE_SEQUENTIAL_FMKS7L /// /// Moves the tape forward (or backward) to the first occurrence of n filemarks in the current partition, where n is the number /// specified by dwOffsetLow and dwOffsetHigh. The dwPartition parameter is ignored. /// /// /// /// TAPE_SPACE_SEQUENTIAL_SMKS9L /// /// Moves the tape forward (or backward) to the first occurrence of n setmarks in the current partition, where n is the number /// specified by dwOffsetLow and dwOffsetHigh. The dwPartition parameter is ignored. /// /// /// /// TAPE_SPACE_SETMARKS8L /// /// Moves the tape forward (or backward) the number of setmarks specified by dwOffsetLow and dwOffsetHigh in the current partition. /// The dwPartition parameter is ignored. /// /// /// /// /// /// /// Partition to position within. If dwPartition is zero, the current partition is used. Partitions are numbered logically from 1 /// through n, where 1 is the first partition on the tape and n is the last. /// /// /// Low-order bits of the block address or count for the position operation specified by the dwPositionMethod parameter. /// /// /// High-order bits of the block address or count for the position operation specified by the dwPositionMethod parameter. If the /// high-order bits are not required, this parameter should be zero. /// /// /// Indicates whether to return as soon as the move operation begins. If this parameter is TRUE, the function returns /// immediately; if FALSE, the function does not return until the move operation has been completed. /// /// /// If the function succeeds, the return value is NO_ERROR. /// If the function fails, it can return one of the following error codes. /// /// /// /// Error /// Description /// /// /// ERROR_BEGINNING_OF_MEDIA1102L /// An attempt to access data before the beginning-of-medium marker failed. /// /// /// ERROR_BUS_RESET1111L /// A reset condition was detected on the bus. /// /// /// ERROR_DEVICE_NOT_PARTITIONED1107L /// The partition information could not be found when a tape was being loaded. /// /// /// ERROR_END_OF_MEDIA1100L /// The end-of-tape marker was reached during an operation. /// /// /// ERROR_FILEMARK_DETECTED1101L /// A filemark was reached during an operation. /// /// /// ERROR_INVALID_BLOCK_LENGTH1106L /// The block size is incorrect on a new tape in a multivolume partition. /// /// /// ERROR_MEDIA_CHANGED1110L /// The tape that was in the drive has been replaced or removed. /// /// /// ERROR_NO_DATA_DETECTED1104L /// The end-of-data marker was reached during an operation. /// /// /// ERROR_NO_MEDIA_IN_DRIVE1112L /// There is no media in the drive. /// /// /// ERROR_NOT_SUPPORTED50L /// The tape driver does not support a requested function. /// /// /// ERROR_PARTITION_FAILURE1105L /// The tape could not be partitioned. /// /// /// ERROR_SETMARK_DETECTED1103L /// A setmark was reached during an operation. /// /// /// ERROR_UNABLE_TO_LOCK_MEDIA1108L /// An attempt to lock the ejection mechanism failed. /// /// /// ERROR_UNABLE_TO_UNLOAD_MEDIA1109L /// An attempt to unload the tape failed. /// /// /// ERROR_WRITE_PROTECT19L /// The media is write protected. /// /// /// /// // DWORD SetTapePosition( _In_ HANDLE hDevice, _In_ DWORD dwPositionMethod, _In_ DWORD dwPartition, _In_ DWORD dwOffsetLow, _In_ // DWORD dwOffsetHigh, _In_ BOOL bImmediate); https://msdn.microsoft.com/en-us/library/windows/desktop/aa362536(v=vs.85).aspx [DllImport(Lib.Kernel32, SetLastError = false, ExactSpelling = true)] [PInvokeData("Winbase.h", MSDNShortId = "aa362536")] public static extern Win32Error SetTapePosition([In] HFILE hDevice, TAPE_POS_METHOD dwPositionMethod, uint dwPartition, uint dwOffsetLow, uint dwOffsetHigh, [MarshalAs(UnmanagedType.Bool)] bool bImmediate); /// /// The WriteTapemark function writes a specified number of filemarks, setmarks, short filemarks, or long filemarks to a tape /// device. These tapemarks divide a tape partition into smaller areas. /// /// /// Handle to the device on which to write tapemarks. This handle is created by using the CreateFile function. /// /// /// Type of tapemarks to write. This parameter can be one of the following values. /// /// /// /// Value /// Meaning /// /// /// TAPE_FILEMARKS1L /// Writes the number of filemarks specified by the dwTapemarkCount parameter. /// /// /// TAPE_LONG_FILEMARKS3L /// Writes the number of long filemarks specified by dwTapemarkCount. /// /// /// TAPE_SETMARKS0L /// Writes the number of setmarks specified by dwTapemarkCount. /// /// /// TAPE_SHORT_FILEMARKS2L /// Writes the number of short filemarks specified by dwTapemarkCount. /// /// /// /// /// Number of tapemarks to write. /// /// If this parameter is TRUE, the function returns immediately; if it is FALSE, the function does not return until the /// operation has been completed. /// /// /// If the function succeeds, the return value is NO_ERROR. /// If the function fails, it can return one of the following error codes. /// /// /// /// Error /// Description /// /// /// ERROR_BEGINNING_OF_MEDIA1102L /// An attempt to access data before the beginning-of-medium marker failed. /// /// /// ERROR_BUS_RESET1111L /// A reset condition was detected on the bus. /// /// /// ERROR_DEVICE_NOT_PARTITIONED1107L /// The partition information could not be found when a tape was being loaded. /// /// /// ERROR_END_OF_MEDIA1100L /// The end-of-tape marker was reached during an operation. /// /// /// ERROR_FILEMARK_DETECTED1101L /// A filemark was reached during an operation. /// /// /// ERROR_INVALID_BLOCK_LENGTH1106L /// The block size is incorrect on a new tape in a multivolume partition. /// /// /// ERROR_MEDIA_CHANGED1110L /// The tape that was in the drive has been replaced or removed. /// /// /// ERROR_NO_DATA_DETECTED1104L /// The end-of-data marker was reached during an operation. /// /// /// ERROR_NO_MEDIA_IN_DRIVE1112L /// There is no media in the drive. /// /// /// ERROR_NOT_SUPPORTED50L /// The tape driver does not support a requested function. /// /// /// ERROR_PARTITION_FAILURE1105L /// The tape could not be partitioned. /// /// /// ERROR_SETMARK_DETECTED1103L /// A setmark was reached during an operation. /// /// /// ERROR_UNABLE_TO_LOCK_MEDIA1108L /// An attempt to lock the ejection mechanism failed. /// /// /// ERROR_UNABLE_TO_UNLOAD_MEDIA1109L /// An attempt to unload the tape failed. /// /// /// ERROR_WRITE_PROTECT19L /// The media is write protected. /// /// /// /// // DWORD WriteTapemark( _In_ HANDLE hDevice, _In_ DWORD dwTapemarkType, _In_ DWORD dwTapemarkCount, _In_ BOOL bImmediate); https://msdn.microsoft.com/en-us/library/windows/desktop/aa362668(v=vs.85).aspx [DllImport(Lib.Kernel32, SetLastError = false, ExactSpelling = true)] [PInvokeData("Winbase.h", MSDNShortId = "aa362668")] public static extern Win32Error WriteTapemark([In] HFILE hDevice, TAPEMARK_TYPE dwTapemarkType, uint dwTapemarkCount, [MarshalAs(UnmanagedType.Bool)] bool bImmediate); /// The TAPE_GET_DRIVE_PARAMETERS structure describes the tape drive. It is used by the GetTapeParameters function. // https://msdn.microsoft.com/en-us/library/windows/desktop/aa362562(v=vs.85).aspx [PInvokeData("Winnt.h", MSDNShortId = "aa362562")] [StructLayout(LayoutKind.Sequential, Pack = 1)] public struct TAPE_GET_DRIVE_PARAMETERS { /// If this member is TRUE, the device supports hardware error correction. Otherwise, it does not. [MarshalAs(UnmanagedType.U1)] public bool ECC; /// If this member is TRUE, hardware data compression is enabled. Otherwise, it is disabled. [MarshalAs(UnmanagedType.U1)] public bool Compression; /// /// If this member is TRUE, data padding is enabled. Otherwise, it is disabled. Data padding keeps the tape streaming at a /// constant speed. /// [MarshalAs(UnmanagedType.U1)] public bool DataPadding; /// If this member is TRUE, setmark reporting is enabled. Otherwise, it is disabled. [MarshalAs(UnmanagedType.U1)] public bool ReportSetmarks; /// Device's default fixed block size, in bytes. public uint DefaultBlockSize; /// Device's maximum block size, in bytes. public uint MaximumBlockSize; /// Device's minimum block size, in bytes. public uint MinimumBlockSize; /// Maximum number of partitions that can be created on the device. public uint MaximumPartitionCount; /// Low-order bits of the device features flag. public TAPE_FEATURES_LOW FeaturesLow; /// High-order bits of the device features flag. public TAPE_FEATURES_HIGH FeaturesHigh; /// Indicates the number of bytes between the end-of-tape warning and the physical end of the tape. public uint EOTWarningZoneSize; } /// /// The TAPE_GET_MEDIA_PARAMETERS structure describes the tape in the tape drive. It is used by the GetTapeParameters function. /// // https://msdn.microsoft.com/en-us/library/windows/desktop/aa362564(v=vs.85).aspx [PInvokeData("Winnt.h", MSDNShortId = "aa362564")] [StructLayout(LayoutKind.Sequential, Pack = 4)] public struct TAPE_GET_MEDIA_PARAMETERS { /// Total number of bytes on the current tape partition. public long Capacity; /// Number of bytes between the current position and the end of the current tape partition. public long Remaining; /// Number of bytes per block. public uint BlockSize; /// Number of partitions on the tape. public uint PartitionCount; /// If this member is TRUE, the tape is write-protected. Otherwise, it is not. [MarshalAs(UnmanagedType.U1)] public bool WriteProtected; } } }