コード例 #1
0
        //////////////////////////////////////////////

        /// <summary>
        /// Constructs a tape drive with the given integer ID.
        /// All tape drives under windows have an ID, starting at 0.
        /// </summary>
        /// <param name="tapeID">ID of tape</param>
        public TapeDrive(int tapeID)
        {
            // check OS version first
            if (Environment.OSVersion.Platform != PlatformID.Win32NT)
            {
                throw(new PlatformNotSupportedException("Tape drive access requires WindowsNT 4 or higher"));
            }

            tapeHandle = TapeDriveFunctions.CreateFile(@"\\.\TAPE" + tapeID,
                                                       0x80000000 | 0x40000000, // (GENERIC_READ | GENERIC_WRITE) read/write access
                                                       0,                       // not used
                                                       null,                    // not used
                                                       3,                       // (OPEN_EXISTING) required for tape devices
                                                       0,                       // not used
                                                       0);                      // not used

            if (tapeHandle == 0)
            {
                throw(new TapeDriveNotFoundException());
            }

            info = TapeDriveFunctions.GetTapeDriveParameters(this);

            setInfo.Compression        = info.Compression;
            setInfo.DataPadding        = info.DataPadding;
            setInfo.ECC                = info.ECC;
            setInfo.EOTWarningZoneSize = info.EOTWarningZoneSize;
            setInfo.ReportSetmarks     = info.ReportSetmarks;

            tapeStream = new TapeStream(this);
        }
コード例 #2
0
        //////////////////////////////////////////////
        /// <summary>
        /// Constructs a tape drive with the given integer ID.
        /// All tape drives under windows have an ID, starting at 0.
        /// </summary>
        /// <param name="tapeID">ID of tape</param>
        public TapeDrive(int tapeID)
        {
            // check OS version first
            if (Environment.OSVersion.Platform != PlatformID.Win32NT)
                throw(new PlatformNotSupportedException("Tape drive access requires WindowsNT 4 or higher"));

            tapeHandle = TapeDriveFunctions.CreateFile(@"\\.\TAPE" + tapeID,
                0x80000000 | 0x40000000,			// (GENERIC_READ | GENERIC_WRITE) read/write access
                0,                            // not used
                null,                         // not used
                3,														// (OPEN_EXISTING) required for tape devices
                0,                            // not used
                0);														// not used

            if (tapeHandle == 0)
                throw(new TapeDriveNotFoundException());

            info = TapeDriveFunctions.GetTapeDriveParameters(this);

            setInfo.Compression = info.Compression;
            setInfo.DataPadding = info.DataPadding;
            setInfo.ECC = info.ECC;
            setInfo.EOTWarningZoneSize = info.EOTWarningZoneSize;
            setInfo.ReportSetmarks = info.ReportSetmarks;

            tapeStream = new TapeStream(this);
        }