ホーム › Storage.FileSystem › GetTapeParameters
GetTapeParameters
関数テープドライブやメディアのパラメータ情報を取得する。
シグネチャ
// KERNEL32.dll
#include <windows.h>
DWORD GetTapeParameters(
HANDLE hDevice,
GET_TAPE_DRIVE_PARAMETERS_OPERATION dwOperation,
DWORD* lpdwSize,
void* lpTapeInformation
);パラメーター
| 名前 | 型 | 方向 | 説明 | ||||||
|---|---|---|---|---|---|---|---|---|---|
| hDevice | HANDLE | in | 情報を取得する対象デバイスのハンドル。このハンドルは CreateFile 関数を使用して作成します。 | ||||||
| dwOperation | GET_TAPE_DRIVE_PARAMETERS_OPERATION | in | 要求する情報の種類。このパラメーターは次のいずれかの値である必要があります。
| ||||||
| lpdwSize | DWORD* | inout | lpTapeInformation パラメーターで指定されたバッファーのサイズ(バイト単位)を受け取る変数へのポインター。バッファーが小さすぎる場合、このパラメーターは必要なサイズを受け取ります。 | ||||||
| lpTapeInformation | void* | out | 要求された情報を格納する構造体へのポインター。dwOperation パラメーターが GET_TAPE_MEDIA_INFORMATION の場合、lpTapeInformation は TAPE_GET_MEDIA_PARAMETERS 構造体を指します。 dwOperation が GET_TAPE_DRIVE_INFORMATION の場合、lpTapeInformation は TAPE_GET_DRIVE_PARAMETERS 構造体を指します。 |
戻り値の型: DWORD
公式ドキュメント
テープまたはテープドライブを記述する情報を取得します。
戻り値
関数が成功した場合、戻り値は NO_ERROR です。
関数が失敗した場合、次のいずれかのエラーコードを返すことがあります。
| エラーコード | 説明 |
|---|---|
|
メディアの先頭マーカーより前のデータにアクセスしようとして失敗しました。 |
|
バス上でリセット状態が検出されました。 |
| テープのロード中にパーティション情報が見つかりませんでした。 | |
|
操作中にテープの終端マーカーに到達しました。 |
|
操作中にファイルマークに到達しました。 |
| マルチボリュームパーティション内の新しいテープでブロックサイズが正しくありません。 | |
|
ドライブ内にあったテープが交換または取り外されました。 |
|
操作中にデータの終端マーカーに到達しました。 |
|
ドライブにメディアがありません。 |
| テープドライバーが、要求された機能をサポートしていません。 | |
|
テープをパーティション分割できませんでした。 |
|
操作中にセットマークに到達しました。 |
| 取り出し機構をロックしようとして失敗しました。 | |
| テープをアンロードしようとして失敗しました。 | |
| メディアが書き込み禁止です。 |
解説(Remarks)
dwOperation パラメーターに GET_TAPE_DRIVE_INFORMATION 値を指定して GetTapeParameters 関数を呼び出したときに返されるブロックサイズの範囲値(最大値および最小値)は、ドライブの制限ではなくシステムの制限を示します。ただし、実際のブロックサイズの制限を決定するのは、テープドライブデバイスおよびドライブ内に存在するメディアです。したがって、アプリケーションは、dwOperation に GET_TAPE_DRIVE_INFORMATION を指定して取得した範囲に含まれるすべてのブロックサイズを設定できるとは限りません。
出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// KERNEL32.dll
#include <windows.h>
DWORD GetTapeParameters(
HANDLE hDevice,
GET_TAPE_DRIVE_PARAMETERS_OPERATION dwOperation,
DWORD* lpdwSize,
void* lpTapeInformation
);[DllImport("KERNEL32.dll", ExactSpelling = true)]
static extern uint GetTapeParameters(
IntPtr hDevice, // HANDLE
uint dwOperation, // GET_TAPE_DRIVE_PARAMETERS_OPERATION
ref uint lpdwSize, // DWORD* in/out
IntPtr lpTapeInformation // void* out
);<DllImport("KERNEL32.dll", ExactSpelling:=True)>
Public Shared Function GetTapeParameters(
hDevice As IntPtr, ' HANDLE
dwOperation As UInteger, ' GET_TAPE_DRIVE_PARAMETERS_OPERATION
ByRef lpdwSize As UInteger, ' DWORD* in/out
lpTapeInformation As IntPtr ' void* out
) As UInteger
End Function' hDevice : HANDLE
' dwOperation : GET_TAPE_DRIVE_PARAMETERS_OPERATION
' lpdwSize : DWORD* in/out
' lpTapeInformation : void* out
Declare PtrSafe Function GetTapeParameters Lib "kernel32" ( _
ByVal hDevice As LongPtr, _
ByVal dwOperation As Long, _
ByRef lpdwSize 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
GetTapeParameters = ctypes.windll.kernel32.GetTapeParameters
GetTapeParameters.restype = wintypes.DWORD
GetTapeParameters.argtypes = [
wintypes.HANDLE, # hDevice : HANDLE
wintypes.DWORD, # dwOperation : GET_TAPE_DRIVE_PARAMETERS_OPERATION
ctypes.POINTER(wintypes.DWORD), # lpdwSize : DWORD* in/out
ctypes.POINTER(None), # lpTapeInformation : void* out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('KERNEL32.dll')
GetTapeParameters = Fiddle::Function.new(
lib['GetTapeParameters'],
[
Fiddle::TYPE_VOIDP, # hDevice : HANDLE
-Fiddle::TYPE_INT, # dwOperation : GET_TAPE_DRIVE_PARAMETERS_OPERATION
Fiddle::TYPE_VOIDP, # lpdwSize : DWORD* in/out
Fiddle::TYPE_VOIDP, # lpTapeInformation : void* out
],
-Fiddle::TYPE_INT)#[link(name = "kernel32")]
extern "system" {
fn GetTapeParameters(
hDevice: *mut core::ffi::c_void, // HANDLE
dwOperation: u32, // GET_TAPE_DRIVE_PARAMETERS_OPERATION
lpdwSize: *mut u32, // DWORD* in/out
lpTapeInformation: *mut () // void* out
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("KERNEL32.dll")]
public static extern uint GetTapeParameters(IntPtr hDevice, uint dwOperation, ref uint lpdwSize, IntPtr lpTapeInformation);
"@
$api = Add-Type -MemberDefinition $sig -Name 'KERNEL32_GetTapeParameters' -Namespace Win32 -PassThru
# $api::GetTapeParameters(hDevice, dwOperation, lpdwSize, lpTapeInformation)#uselib "KERNEL32.dll"
#func global GetTapeParameters "GetTapeParameters" sptr, sptr, sptr, sptr
; GetTapeParameters hDevice, dwOperation, varptr(lpdwSize), lpTapeInformation ; 戻り値は stat
; hDevice : HANDLE -> "sptr"
; dwOperation : GET_TAPE_DRIVE_PARAMETERS_OPERATION -> "sptr"
; lpdwSize : DWORD* in/out -> "sptr"
; lpTapeInformation : void* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "KERNEL32.dll" #cfunc global GetTapeParameters "GetTapeParameters" sptr, int, var, sptr ; res = GetTapeParameters(hDevice, dwOperation, lpdwSize, lpTapeInformation) ; hDevice : HANDLE -> "sptr" ; dwOperation : GET_TAPE_DRIVE_PARAMETERS_OPERATION -> "int" ; lpdwSize : DWORD* in/out -> "var" ; lpTapeInformation : void* out -> "sptr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "KERNEL32.dll" #cfunc global GetTapeParameters "GetTapeParameters" sptr, int, sptr, sptr ; res = GetTapeParameters(hDevice, dwOperation, varptr(lpdwSize), lpTapeInformation) ; hDevice : HANDLE -> "sptr" ; dwOperation : GET_TAPE_DRIVE_PARAMETERS_OPERATION -> "int" ; lpdwSize : DWORD* in/out -> "sptr" ; lpTapeInformation : void* out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; DWORD GetTapeParameters(HANDLE hDevice, GET_TAPE_DRIVE_PARAMETERS_OPERATION dwOperation, DWORD* lpdwSize, void* lpTapeInformation) #uselib "KERNEL32.dll" #cfunc global GetTapeParameters "GetTapeParameters" intptr, int, var, intptr ; res = GetTapeParameters(hDevice, dwOperation, lpdwSize, lpTapeInformation) ; hDevice : HANDLE -> "intptr" ; dwOperation : GET_TAPE_DRIVE_PARAMETERS_OPERATION -> "int" ; lpdwSize : DWORD* in/out -> "var" ; lpTapeInformation : void* out -> "intptr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; DWORD GetTapeParameters(HANDLE hDevice, GET_TAPE_DRIVE_PARAMETERS_OPERATION dwOperation, DWORD* lpdwSize, void* lpTapeInformation) #uselib "KERNEL32.dll" #cfunc global GetTapeParameters "GetTapeParameters" intptr, int, intptr, intptr ; res = GetTapeParameters(hDevice, dwOperation, varptr(lpdwSize), lpTapeInformation) ; hDevice : HANDLE -> "intptr" ; dwOperation : GET_TAPE_DRIVE_PARAMETERS_OPERATION -> "int" ; lpdwSize : DWORD* in/out -> "intptr" ; lpTapeInformation : void* out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
kernel32 = windows.NewLazySystemDLL("KERNEL32.dll")
procGetTapeParameters = kernel32.NewProc("GetTapeParameters")
)
// hDevice (HANDLE), dwOperation (GET_TAPE_DRIVE_PARAMETERS_OPERATION), lpdwSize (DWORD* in/out), lpTapeInformation (void* out)
r1, _, err := procGetTapeParameters.Call(
uintptr(hDevice),
uintptr(dwOperation),
uintptr(lpdwSize),
uintptr(lpTapeInformation),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction GetTapeParameters(
hDevice: THandle; // HANDLE
dwOperation: DWORD; // GET_TAPE_DRIVE_PARAMETERS_OPERATION
lpdwSize: Pointer; // DWORD* in/out
lpTapeInformation: Pointer // void* out
): DWORD; stdcall;
external 'KERNEL32.dll' name 'GetTapeParameters';result := DllCall("KERNEL32\GetTapeParameters"
, "Ptr", hDevice ; HANDLE
, "UInt", dwOperation ; GET_TAPE_DRIVE_PARAMETERS_OPERATION
, "Ptr", lpdwSize ; DWORD* in/out
, "Ptr", lpTapeInformation ; void* out
, "UInt") ; return: DWORD●GetTapeParameters(hDevice, dwOperation, lpdwSize, lpTapeInformation) = DLL("KERNEL32.dll", "dword GetTapeParameters(void*, dword, void*, void*)")
# 呼び出し: GetTapeParameters(hDevice, dwOperation, lpdwSize, lpTapeInformation)
# hDevice : HANDLE -> "void*"
# dwOperation : GET_TAPE_DRIVE_PARAMETERS_OPERATION -> "dword"
# lpdwSize : DWORD* in/out -> "void*"
# lpTapeInformation : void* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "kernel32" fn GetTapeParameters(
hDevice: ?*anyopaque, // HANDLE
dwOperation: u32, // GET_TAPE_DRIVE_PARAMETERS_OPERATION
lpdwSize: [*c]u32, // DWORD* in/out
lpTapeInformation: ?*anyopaque // void* out
) callconv(std.os.windows.WINAPI) u32;proc GetTapeParameters(
hDevice: pointer, # HANDLE
dwOperation: uint32, # GET_TAPE_DRIVE_PARAMETERS_OPERATION
lpdwSize: ptr uint32, # DWORD* in/out
lpTapeInformation: pointer # void* out
): uint32 {.importc: "GetTapeParameters", stdcall, dynlib: "KERNEL32.dll".}pragma(lib, "kernel32");
extern(Windows)
uint GetTapeParameters(
void* hDevice, // HANDLE
uint dwOperation, // GET_TAPE_DRIVE_PARAMETERS_OPERATION
uint* lpdwSize, // DWORD* in/out
void* lpTapeInformation // void* out
);ccall((:GetTapeParameters, "KERNEL32.dll"), stdcall, UInt32,
(Ptr{Cvoid}, UInt32, Ptr{UInt32}, Ptr{Cvoid}),
hDevice, dwOperation, lpdwSize, lpTapeInformation)
# hDevice : HANDLE -> Ptr{Cvoid}
# dwOperation : GET_TAPE_DRIVE_PARAMETERS_OPERATION -> UInt32
# lpdwSize : DWORD* in/out -> Ptr{UInt32}
# lpTapeInformation : void* out -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
uint32_t GetTapeParameters(
void* hDevice,
uint32_t dwOperation,
uint32_t* lpdwSize,
void* lpTapeInformation);
]]
local kernel32 = ffi.load("kernel32")
-- kernel32.GetTapeParameters(hDevice, dwOperation, lpdwSize, lpTapeInformation)
-- hDevice : HANDLE
-- dwOperation : GET_TAPE_DRIVE_PARAMETERS_OPERATION
-- lpdwSize : DWORD* in/out
-- lpTapeInformation : void* out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('KERNEL32.dll');
const GetTapeParameters = lib.func('__stdcall', 'GetTapeParameters', 'uint32_t', ['void *', 'uint32_t', 'uint32_t *', 'void *']);
// GetTapeParameters(hDevice, dwOperation, lpdwSize, lpTapeInformation)
// hDevice : HANDLE -> 'void *'
// dwOperation : GET_TAPE_DRIVE_PARAMETERS_OPERATION -> 'uint32_t'
// lpdwSize : DWORD* in/out -> 'uint32_t *'
// lpTapeInformation : void* out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("KERNEL32.dll", {
GetTapeParameters: { parameters: ["pointer", "u32", "pointer", "pointer"], result: "u32" },
});
// lib.symbols.GetTapeParameters(hDevice, dwOperation, lpdwSize, lpTapeInformation)
// hDevice : HANDLE -> "pointer"
// dwOperation : GET_TAPE_DRIVE_PARAMETERS_OPERATION -> "u32"
// lpdwSize : DWORD* in/out -> "pointer"
// lpTapeInformation : void* out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
uint32_t GetTapeParameters(
void* hDevice,
uint32_t dwOperation,
uint32_t* lpdwSize,
void* lpTapeInformation);
C, "KERNEL32.dll");
// $ffi->GetTapeParameters(hDevice, dwOperation, lpdwSize, lpTapeInformation);
// hDevice : HANDLE
// dwOperation : GET_TAPE_DRIVE_PARAMETERS_OPERATION
// lpdwSize : DWORD* in/out
// lpTapeInformation : void* out
// 構造体/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 GetTapeParameters(
Pointer hDevice, // HANDLE
int dwOperation, // GET_TAPE_DRIVE_PARAMETERS_OPERATION
IntByReference lpdwSize, // DWORD* in/out
Pointer lpTapeInformation // void* out
);
}@[Link("kernel32")]
lib LibKERNEL32
fun GetTapeParameters = GetTapeParameters(
hDevice : Void*, # HANDLE
dwOperation : UInt32, # GET_TAPE_DRIVE_PARAMETERS_OPERATION
lpdwSize : UInt32*, # DWORD* in/out
lpTapeInformation : Void* # void* out
) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef GetTapeParametersNative = Uint32 Function(Pointer<Void>, Uint32, Pointer<Uint32>, Pointer<Void>);
typedef GetTapeParametersDart = int Function(Pointer<Void>, int, Pointer<Uint32>, Pointer<Void>);
final GetTapeParameters = DynamicLibrary.open('KERNEL32.dll')
.lookupFunction<GetTapeParametersNative, GetTapeParametersDart>('GetTapeParameters');
// hDevice : HANDLE -> Pointer<Void>
// dwOperation : GET_TAPE_DRIVE_PARAMETERS_OPERATION -> Uint32
// lpdwSize : DWORD* in/out -> Pointer<Uint32>
// lpTapeInformation : void* out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function GetTapeParameters(
hDevice: THandle; // HANDLE
dwOperation: DWORD; // GET_TAPE_DRIVE_PARAMETERS_OPERATION
lpdwSize: Pointer; // DWORD* in/out
lpTapeInformation: Pointer // void* out
): DWORD; stdcall;
external 'KERNEL32.dll' name 'GetTapeParameters';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "GetTapeParameters"
c_GetTapeParameters :: Ptr () -> Word32 -> Ptr Word32 -> Ptr () -> IO Word32
-- hDevice : HANDLE -> Ptr ()
-- dwOperation : GET_TAPE_DRIVE_PARAMETERS_OPERATION -> Word32
-- lpdwSize : DWORD* in/out -> Ptr Word32
-- lpTapeInformation : void* out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let gettapeparameters =
foreign "GetTapeParameters"
((ptr void) @-> uint32_t @-> (ptr uint32_t) @-> (ptr void) @-> returning uint32_t)
(* hDevice : HANDLE -> (ptr void) *)
(* dwOperation : GET_TAPE_DRIVE_PARAMETERS_OPERATION -> uint32_t *)
(* lpdwSize : DWORD* in/out -> (ptr uint32_t) *)
(* lpTapeInformation : void* out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library kernel32 (t "KERNEL32.dll"))
(cffi:use-foreign-library kernel32)
(cffi:defcfun ("GetTapeParameters" get-tape-parameters :convention :stdcall) :uint32
(h-device :pointer) ; HANDLE
(dw-operation :uint32) ; GET_TAPE_DRIVE_PARAMETERS_OPERATION
(lpdw-size :pointer) ; DWORD* in/out
(lp-tape-information :pointer)) ; void* out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $GetTapeParameters = Win32::API::More->new('KERNEL32',
'DWORD GetTapeParameters(HANDLE hDevice, DWORD dwOperation, LPVOID lpdwSize, LPVOID lpTapeInformation)');
# my $ret = $GetTapeParameters->Call($hDevice, $dwOperation, $lpdwSize, $lpTapeInformation);
# hDevice : HANDLE -> HANDLE
# dwOperation : GET_TAPE_DRIVE_PARAMETERS_OPERATION -> DWORD
# lpdwSize : DWORD* in/out -> LPVOID
# lpTapeInformation : void* out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
公式の関連項目
- f CreateFileW — ファイルやデバイスを作成または開いてハンドルを返す。
- f SetTapeParameters — テープドライブやメディアのパラメータを設定する。
- s TAPE_GET_DRIVE_PARAMETERS
- s TAPE_GET_MEDIA_PARAMETERS