Win32 API 日本語リファレンス
ホームStorage.FileSystem › SetTapeParameters

SetTapeParameters

関数
テープドライブやメディアのパラメータを設定する。
DLLKERNEL32.dll呼出規約winapi対応OSWindows XP 以降

シグネチャ

// KERNEL32.dll
#include <windows.h>

DWORD SetTapeParameters(
    HANDLE hDevice,
    TAPE_INFORMATION_TYPE dwOperation,
    void* lpTapeInformation
);

パラメーター

名前方向説明
hDeviceHANDLEin構成情報を設定する対象のデバイスへのハンドル。このハンドルは CreateFile 関数を使用して作成します。
dwOperationTAPE_INFORMATION_TYPEin

設定する情報の種類。このパラメーターは次のいずれかの値である必要があります。

意味
SET_TAPE_DRIVE_INFORMATION
1L
lpTapeInformation で指定されたデバイス固有の情報を設定します。
SET_TAPE_MEDIA_INFORMATION
0L
lpTapeInformation パラメーターで指定されたテープ固有の情報を設定します。
lpTapeInformationvoid*in

設定する情報を含む構造体へのポインター。dwOperation パラメーターが SET_TAPE_MEDIA_INFORMATION の場合、lpTapeInformationTAPE_SET_MEDIA_PARAMETERS 構造体を指します。

dwOperationSET_TAPE_DRIVE_INFORMATION の場合、lpTapeInformationTAPE_SET_DRIVE_PARAMETERS 構造体を指します。

戻り値の型: DWORD

公式ドキュメント

テープのブロックサイズを指定するか、テープデバイスを構成します。

戻り値

関数が成功した場合、戻り値は NO_ERROR です。

関数が失敗した場合は、次のいずれかのエラーコードを返すことがあります。

エラー 説明
ERROR_BEGINNING_OF_MEDIA
1102L
メディアの先頭マーカーより前のデータにアクセスしようとして失敗しました。
ERROR_BUS_RESET
1111L
バス上でリセット状態が検出されました。
ERROR_DEVICE_NOT_PARTITIONED
1107L
テープのロード中にパーティション情報が見つかりませんでした。
ERROR_END_OF_MEDIA
1100L
操作中にテープの終端マーカーに達しました。
ERROR_FILEMARK_DETECTED
1101L
操作中にファイルマークに達しました。
ERROR_INVALID_BLOCK_LENGTH
1106L
マルチボリュームパーティション内の新しいテープでブロックサイズが正しくありません。
ERROR_MEDIA_CHANGED
1110L
ドライブ内にあったテープが交換または取り出されました。
ERROR_NO_DATA_DETECTED
1104L
操作中にデータの終端マーカーに達しました。
ERROR_NO_MEDIA_IN_DRIVE
1112L
ドライブにメディアがありません。
ERROR_NOT_SUPPORTED
50L
テープドライバーが要求された機能をサポートしていません。
ERROR_PARTITION_FAILURE
1105L
テープをパーティション分割できませんでした。
ERROR_SETMARK_DETECTED
1103L
操作中にセットマークに達しました。
ERROR_UNABLE_TO_LOCK_MEDIA
1108L
取り出し機構をロックしようとして失敗しました。
ERROR_UNABLE_TO_UNLOAD_MEDIA
1109L
テープをアンロードしようとして失敗しました。
ERROR_WRITE_PROTECT
19L
メディアが書き込み禁止になっています。
出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)

各言語での呼び出し定義

// KERNEL32.dll
#include <windows.h>

DWORD SetTapeParameters(
    HANDLE hDevice,
    TAPE_INFORMATION_TYPE dwOperation,
    void* lpTapeInformation
);
[DllImport("KERNEL32.dll", ExactSpelling = true)]
static extern uint SetTapeParameters(
    IntPtr hDevice,   // HANDLE
    uint dwOperation,   // TAPE_INFORMATION_TYPE
    IntPtr lpTapeInformation   // void*
);
<DllImport("KERNEL32.dll", ExactSpelling:=True)>
Public Shared Function SetTapeParameters(
    hDevice As IntPtr,   ' HANDLE
    dwOperation As UInteger,   ' TAPE_INFORMATION_TYPE
    lpTapeInformation As IntPtr   ' void*
) As UInteger
End Function
' hDevice : HANDLE
' dwOperation : TAPE_INFORMATION_TYPE
' lpTapeInformation : void*
Declare PtrSafe Function SetTapeParameters Lib "kernel32" ( _
    ByVal hDevice As LongPtr, _
    ByVal dwOperation As Long, _
    ByVal lpTapeInformation As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

SetTapeParameters = ctypes.windll.kernel32.SetTapeParameters
SetTapeParameters.restype = wintypes.DWORD
SetTapeParameters.argtypes = [
    wintypes.HANDLE,  # hDevice : HANDLE
    wintypes.DWORD,  # dwOperation : TAPE_INFORMATION_TYPE
    ctypes.POINTER(None),  # lpTapeInformation : void*
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('KERNEL32.dll')
SetTapeParameters = Fiddle::Function.new(
  lib['SetTapeParameters'],
  [
    Fiddle::TYPE_VOIDP,  # hDevice : HANDLE
    -Fiddle::TYPE_INT,  # dwOperation : TAPE_INFORMATION_TYPE
    Fiddle::TYPE_VOIDP,  # lpTapeInformation : void*
  ],
  -Fiddle::TYPE_INT)
#[link(name = "kernel32")]
extern "system" {
    fn SetTapeParameters(
        hDevice: *mut core::ffi::c_void,  // HANDLE
        dwOperation: u32,  // TAPE_INFORMATION_TYPE
        lpTapeInformation: *mut ()  // void*
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("KERNEL32.dll")]
public static extern uint SetTapeParameters(IntPtr hDevice, uint dwOperation, IntPtr lpTapeInformation);
"@
$api = Add-Type -MemberDefinition $sig -Name 'KERNEL32_SetTapeParameters' -Namespace Win32 -PassThru
# $api::SetTapeParameters(hDevice, dwOperation, lpTapeInformation)
#uselib "KERNEL32.dll"
#func global SetTapeParameters "SetTapeParameters" sptr, sptr, sptr
; SetTapeParameters hDevice, dwOperation, lpTapeInformation   ; 戻り値は stat
; hDevice : HANDLE -> "sptr"
; dwOperation : TAPE_INFORMATION_TYPE -> "sptr"
; lpTapeInformation : void* -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "KERNEL32.dll"
#cfunc global SetTapeParameters "SetTapeParameters" sptr, int, sptr
; res = SetTapeParameters(hDevice, dwOperation, lpTapeInformation)
; hDevice : HANDLE -> "sptr"
; dwOperation : TAPE_INFORMATION_TYPE -> "int"
; lpTapeInformation : void* -> "sptr"
; DWORD SetTapeParameters(HANDLE hDevice, TAPE_INFORMATION_TYPE dwOperation, void* lpTapeInformation)
#uselib "KERNEL32.dll"
#cfunc global SetTapeParameters "SetTapeParameters" intptr, int, intptr
; res = SetTapeParameters(hDevice, dwOperation, lpTapeInformation)
; hDevice : HANDLE -> "intptr"
; dwOperation : TAPE_INFORMATION_TYPE -> "int"
; lpTapeInformation : void* -> "intptr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	kernel32 = windows.NewLazySystemDLL("KERNEL32.dll")
	procSetTapeParameters = kernel32.NewProc("SetTapeParameters")
)

// hDevice (HANDLE), dwOperation (TAPE_INFORMATION_TYPE), lpTapeInformation (void*)
r1, _, err := procSetTapeParameters.Call(
	uintptr(hDevice),
	uintptr(dwOperation),
	uintptr(lpTapeInformation),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function SetTapeParameters(
  hDevice: THandle;   // HANDLE
  dwOperation: DWORD;   // TAPE_INFORMATION_TYPE
  lpTapeInformation: Pointer   // void*
): DWORD; stdcall;
  external 'KERNEL32.dll' name 'SetTapeParameters';
result := DllCall("KERNEL32\SetTapeParameters"
    , "Ptr", hDevice   ; HANDLE
    , "UInt", dwOperation   ; TAPE_INFORMATION_TYPE
    , "Ptr", lpTapeInformation   ; void*
    , "UInt")   ; return: DWORD
●SetTapeParameters(hDevice, dwOperation, lpTapeInformation) = DLL("KERNEL32.dll", "dword SetTapeParameters(void*, dword, void*)")
# 呼び出し: SetTapeParameters(hDevice, dwOperation, lpTapeInformation)
# hDevice : HANDLE -> "void*"
# dwOperation : TAPE_INFORMATION_TYPE -> "dword"
# lpTapeInformation : void* -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

extern "kernel32" fn SetTapeParameters(
    hDevice: ?*anyopaque, // HANDLE
    dwOperation: u32, // TAPE_INFORMATION_TYPE
    lpTapeInformation: ?*anyopaque // void*
) callconv(std.os.windows.WINAPI) u32;
proc SetTapeParameters(
    hDevice: pointer,  # HANDLE
    dwOperation: uint32,  # TAPE_INFORMATION_TYPE
    lpTapeInformation: pointer  # void*
): uint32 {.importc: "SetTapeParameters", stdcall, dynlib: "KERNEL32.dll".}
pragma(lib, "kernel32");
extern(Windows)
uint SetTapeParameters(
    void* hDevice,   // HANDLE
    uint dwOperation,   // TAPE_INFORMATION_TYPE
    void* lpTapeInformation   // void*
);
ccall((:SetTapeParameters, "KERNEL32.dll"), stdcall, UInt32,
      (Ptr{Cvoid}, UInt32, Ptr{Cvoid}),
      hDevice, dwOperation, lpTapeInformation)
# hDevice : HANDLE -> Ptr{Cvoid}
# dwOperation : TAPE_INFORMATION_TYPE -> UInt32
# lpTapeInformation : void* -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
uint32_t SetTapeParameters(
    void* hDevice,
    uint32_t dwOperation,
    void* lpTapeInformation);
]]
local kernel32 = ffi.load("kernel32")
-- kernel32.SetTapeParameters(hDevice, dwOperation, lpTapeInformation)
-- hDevice : HANDLE
-- dwOperation : TAPE_INFORMATION_TYPE
-- lpTapeInformation : void*
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('KERNEL32.dll');
const SetTapeParameters = lib.func('__stdcall', 'SetTapeParameters', 'uint32_t', ['void *', 'uint32_t', 'void *']);
// SetTapeParameters(hDevice, dwOperation, lpTapeInformation)
// hDevice : HANDLE -> 'void *'
// dwOperation : TAPE_INFORMATION_TYPE -> 'uint32_t'
// lpTapeInformation : void* -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("KERNEL32.dll", {
  SetTapeParameters: { parameters: ["pointer", "u32", "pointer"], result: "u32" },
});
// lib.symbols.SetTapeParameters(hDevice, dwOperation, lpTapeInformation)
// hDevice : HANDLE -> "pointer"
// dwOperation : TAPE_INFORMATION_TYPE -> "u32"
// lpTapeInformation : void* -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
uint32_t SetTapeParameters(
    void* hDevice,
    uint32_t dwOperation,
    void* lpTapeInformation);
C, "KERNEL32.dll");
// $ffi->SetTapeParameters(hDevice, dwOperation, lpTapeInformation);
// hDevice : HANDLE
// dwOperation : TAPE_INFORMATION_TYPE
// lpTapeInformation : void*
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。
import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;

public interface Kernel32 extends StdCallLibrary {
    Kernel32 INSTANCE = Native.load("kernel32", Kernel32.class);
    int SetTapeParameters(
        Pointer hDevice,   // HANDLE
        int dwOperation,   // TAPE_INFORMATION_TYPE
        Pointer lpTapeInformation   // void*
    );
}
@[Link("kernel32")]
lib LibKERNEL32
  fun SetTapeParameters = SetTapeParameters(
    hDevice : Void*,   # HANDLE
    dwOperation : UInt32,   # TAPE_INFORMATION_TYPE
    lpTapeInformation : Void*   # void*
  ) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef SetTapeParametersNative = Uint32 Function(Pointer<Void>, Uint32, Pointer<Void>);
typedef SetTapeParametersDart = int Function(Pointer<Void>, int, Pointer<Void>);
final SetTapeParameters = DynamicLibrary.open('KERNEL32.dll')
    .lookupFunction<SetTapeParametersNative, SetTapeParametersDart>('SetTapeParameters');
// hDevice : HANDLE -> Pointer<Void>
// dwOperation : TAPE_INFORMATION_TYPE -> Uint32
// lpTapeInformation : void* -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function SetTapeParameters(
  hDevice: THandle;   // HANDLE
  dwOperation: DWORD;   // TAPE_INFORMATION_TYPE
  lpTapeInformation: Pointer   // void*
): DWORD; stdcall;
  external 'KERNEL32.dll' name 'SetTapeParameters';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "SetTapeParameters"
  c_SetTapeParameters :: Ptr () -> Word32 -> Ptr () -> IO Word32
-- hDevice : HANDLE -> Ptr ()
-- dwOperation : TAPE_INFORMATION_TYPE -> Word32
-- lpTapeInformation : void* -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let settapeparameters =
  foreign "SetTapeParameters"
    ((ptr void) @-> uint32_t @-> (ptr void) @-> returning uint32_t)
(* hDevice : HANDLE -> (ptr void) *)
(* dwOperation : TAPE_INFORMATION_TYPE -> uint32_t *)
(* lpTapeInformation : void* -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library kernel32 (t "KERNEL32.dll"))
(cffi:use-foreign-library kernel32)

(cffi:defcfun ("SetTapeParameters" set-tape-parameters :convention :stdcall) :uint32
  (h-device :pointer)   ; HANDLE
  (dw-operation :uint32)   ; TAPE_INFORMATION_TYPE
  (lp-tape-information :pointer))   ; void*
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $SetTapeParameters = Win32::API::More->new('KERNEL32',
    'DWORD SetTapeParameters(HANDLE hDevice, DWORD dwOperation, LPVOID lpTapeInformation)');
# my $ret = $SetTapeParameters->Call($hDevice, $dwOperation, $lpTapeInformation);
# hDevice : HANDLE -> HANDLE
# dwOperation : TAPE_INFORMATION_TYPE -> DWORD
# lpTapeInformation : void* -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

公式の関連項目
使用する型