ホーム › Storage.IscsiDisc › GetIScsiTargetInformationA
GetIScsiTargetInformationA
関数指定iSCSIターゲットの情報を取得する(ANSI版)。
シグネチャ
// ISCSIDSC.dll (ANSI / -A)
#include <windows.h>
DWORD GetIScsiTargetInformationA(
LPSTR TargetName,
LPSTR DiscoveryMechanism, // optional
TARGET_INFORMATION_CLASS InfoClass,
DWORD* BufferSize,
void* Buffer
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| TargetName | LPSTR | in | 情報を取得する対象iSCSIターゲットの名前を指す。 |
| DiscoveryMechanism | LPSTR | inoptional | ターゲットが発見された探索メカニズム名を指す。NULL可。 |
| InfoClass | TARGET_INFORMATION_CLASS | in | 取得する情報種別を指定するTARGET_INFORMATION_CLASS列挙値。 |
| BufferSize | DWORD* | inout | 入力でBufferのサイズ、出力で必要サイズを受け取るDWORDへのポインタ。 |
| Buffer | void* | inout | 取得した情報を受け取るバッファへのポインタ。 |
戻り値の型: DWORD
各言語での呼び出し定義
// ISCSIDSC.dll (ANSI / -A)
#include <windows.h>
DWORD GetIScsiTargetInformationA(
LPSTR TargetName,
LPSTR DiscoveryMechanism, // optional
TARGET_INFORMATION_CLASS InfoClass,
DWORD* BufferSize,
void* Buffer
);[DllImport("ISCSIDSC.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern uint GetIScsiTargetInformationA(
[MarshalAs(UnmanagedType.LPStr)] string TargetName, // LPSTR
[MarshalAs(UnmanagedType.LPStr)] string DiscoveryMechanism, // LPSTR optional
int InfoClass, // TARGET_INFORMATION_CLASS
ref uint BufferSize, // DWORD* in/out
IntPtr Buffer // void* in/out
);<DllImport("ISCSIDSC.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Function GetIScsiTargetInformationA(
<MarshalAs(UnmanagedType.LPStr)> TargetName As String, ' LPSTR
<MarshalAs(UnmanagedType.LPStr)> DiscoveryMechanism As String, ' LPSTR optional
InfoClass As Integer, ' TARGET_INFORMATION_CLASS
ByRef BufferSize As UInteger, ' DWORD* in/out
Buffer As IntPtr ' void* in/out
) As UInteger
End Function' TargetName : LPSTR
' DiscoveryMechanism : LPSTR optional
' InfoClass : TARGET_INFORMATION_CLASS
' BufferSize : DWORD* in/out
' Buffer : void* in/out
Declare PtrSafe Function GetIScsiTargetInformationA Lib "iscsidsc" ( _
ByVal TargetName As String, _
ByVal DiscoveryMechanism As String, _
ByVal InfoClass As Long, _
ByRef BufferSize As Long, _
ByVal Buffer As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
GetIScsiTargetInformationA = ctypes.windll.iscsidsc.GetIScsiTargetInformationA
GetIScsiTargetInformationA.restype = wintypes.DWORD
GetIScsiTargetInformationA.argtypes = [
wintypes.LPCSTR, # TargetName : LPSTR
wintypes.LPCSTR, # DiscoveryMechanism : LPSTR optional
ctypes.c_int, # InfoClass : TARGET_INFORMATION_CLASS
ctypes.POINTER(wintypes.DWORD), # BufferSize : DWORD* in/out
ctypes.POINTER(None), # Buffer : void* in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('ISCSIDSC.dll')
GetIScsiTargetInformationA = Fiddle::Function.new(
lib['GetIScsiTargetInformationA'],
[
Fiddle::TYPE_VOIDP, # TargetName : LPSTR
Fiddle::TYPE_VOIDP, # DiscoveryMechanism : LPSTR optional
Fiddle::TYPE_INT, # InfoClass : TARGET_INFORMATION_CLASS
Fiddle::TYPE_VOIDP, # BufferSize : DWORD* in/out
Fiddle::TYPE_VOIDP, # Buffer : void* in/out
],
-Fiddle::TYPE_INT)#[link(name = "iscsidsc")]
extern "system" {
fn GetIScsiTargetInformationA(
TargetName: *mut u8, // LPSTR
DiscoveryMechanism: *mut u8, // LPSTR optional
InfoClass: i32, // TARGET_INFORMATION_CLASS
BufferSize: *mut u32, // DWORD* in/out
Buffer: *mut () // void* in/out
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("ISCSIDSC.dll", CharSet = CharSet.Ansi)]
public static extern uint GetIScsiTargetInformationA([MarshalAs(UnmanagedType.LPStr)] string TargetName, [MarshalAs(UnmanagedType.LPStr)] string DiscoveryMechanism, int InfoClass, ref uint BufferSize, IntPtr Buffer);
"@
$api = Add-Type -MemberDefinition $sig -Name 'ISCSIDSC_GetIScsiTargetInformationA' -Namespace Win32 -PassThru
# $api::GetIScsiTargetInformationA(TargetName, DiscoveryMechanism, InfoClass, BufferSize, Buffer)#uselib "ISCSIDSC.dll"
#func global GetIScsiTargetInformationA "GetIScsiTargetInformationA" sptr, sptr, sptr, sptr, sptr
; GetIScsiTargetInformationA TargetName, DiscoveryMechanism, InfoClass, varptr(BufferSize), Buffer ; 戻り値は stat
; TargetName : LPSTR -> "sptr"
; DiscoveryMechanism : LPSTR optional -> "sptr"
; InfoClass : TARGET_INFORMATION_CLASS -> "sptr"
; BufferSize : DWORD* in/out -> "sptr"
; Buffer : void* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "ISCSIDSC.dll" #cfunc global GetIScsiTargetInformationA "GetIScsiTargetInformationA" str, str, int, var, sptr ; res = GetIScsiTargetInformationA(TargetName, DiscoveryMechanism, InfoClass, BufferSize, Buffer) ; TargetName : LPSTR -> "str" ; DiscoveryMechanism : LPSTR optional -> "str" ; InfoClass : TARGET_INFORMATION_CLASS -> "int" ; BufferSize : DWORD* in/out -> "var" ; Buffer : void* in/out -> "sptr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "ISCSIDSC.dll" #cfunc global GetIScsiTargetInformationA "GetIScsiTargetInformationA" str, str, int, sptr, sptr ; res = GetIScsiTargetInformationA(TargetName, DiscoveryMechanism, InfoClass, varptr(BufferSize), Buffer) ; TargetName : LPSTR -> "str" ; DiscoveryMechanism : LPSTR optional -> "str" ; InfoClass : TARGET_INFORMATION_CLASS -> "int" ; BufferSize : DWORD* in/out -> "sptr" ; Buffer : void* in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; DWORD GetIScsiTargetInformationA(LPSTR TargetName, LPSTR DiscoveryMechanism, TARGET_INFORMATION_CLASS InfoClass, DWORD* BufferSize, void* Buffer) #uselib "ISCSIDSC.dll" #cfunc global GetIScsiTargetInformationA "GetIScsiTargetInformationA" str, str, int, var, intptr ; res = GetIScsiTargetInformationA(TargetName, DiscoveryMechanism, InfoClass, BufferSize, Buffer) ; TargetName : LPSTR -> "str" ; DiscoveryMechanism : LPSTR optional -> "str" ; InfoClass : TARGET_INFORMATION_CLASS -> "int" ; BufferSize : DWORD* in/out -> "var" ; Buffer : void* in/out -> "intptr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; DWORD GetIScsiTargetInformationA(LPSTR TargetName, LPSTR DiscoveryMechanism, TARGET_INFORMATION_CLASS InfoClass, DWORD* BufferSize, void* Buffer) #uselib "ISCSIDSC.dll" #cfunc global GetIScsiTargetInformationA "GetIScsiTargetInformationA" str, str, int, intptr, intptr ; res = GetIScsiTargetInformationA(TargetName, DiscoveryMechanism, InfoClass, varptr(BufferSize), Buffer) ; TargetName : LPSTR -> "str" ; DiscoveryMechanism : LPSTR optional -> "str" ; InfoClass : TARGET_INFORMATION_CLASS -> "int" ; BufferSize : DWORD* in/out -> "intptr" ; Buffer : void* in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
iscsidsc = windows.NewLazySystemDLL("ISCSIDSC.dll")
procGetIScsiTargetInformationA = iscsidsc.NewProc("GetIScsiTargetInformationA")
)
// TargetName (LPSTR), DiscoveryMechanism (LPSTR optional), InfoClass (TARGET_INFORMATION_CLASS), BufferSize (DWORD* in/out), Buffer (void* in/out)
r1, _, err := procGetIScsiTargetInformationA.Call(
uintptr(unsafe.Pointer(windows.BytePtrFromString(TargetName))),
uintptr(unsafe.Pointer(windows.BytePtrFromString(DiscoveryMechanism))),
uintptr(InfoClass),
uintptr(BufferSize),
uintptr(Buffer),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction GetIScsiTargetInformationA(
TargetName: PAnsiChar; // LPSTR
DiscoveryMechanism: PAnsiChar; // LPSTR optional
InfoClass: Integer; // TARGET_INFORMATION_CLASS
BufferSize: Pointer; // DWORD* in/out
Buffer: Pointer // void* in/out
): DWORD; stdcall;
external 'ISCSIDSC.dll' name 'GetIScsiTargetInformationA';result := DllCall("ISCSIDSC\GetIScsiTargetInformationA"
, "AStr", TargetName ; LPSTR
, "AStr", DiscoveryMechanism ; LPSTR optional
, "Int", InfoClass ; TARGET_INFORMATION_CLASS
, "Ptr", BufferSize ; DWORD* in/out
, "Ptr", Buffer ; void* in/out
, "UInt") ; return: DWORD●GetIScsiTargetInformationA(TargetName, DiscoveryMechanism, InfoClass, BufferSize, Buffer) = DLL("ISCSIDSC.dll", "dword GetIScsiTargetInformationA(char*, char*, int, void*, void*)")
# 呼び出し: GetIScsiTargetInformationA(TargetName, DiscoveryMechanism, InfoClass, BufferSize, Buffer)
# TargetName : LPSTR -> "char*"
# DiscoveryMechanism : LPSTR optional -> "char*"
# InfoClass : TARGET_INFORMATION_CLASS -> "int"
# BufferSize : DWORD* in/out -> "void*"
# Buffer : void* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "iscsidsc" fn GetIScsiTargetInformationA(
TargetName: [*c]const u8, // LPSTR
DiscoveryMechanism: [*c]const u8, // LPSTR optional
InfoClass: i32, // TARGET_INFORMATION_CLASS
BufferSize: [*c]u32, // DWORD* in/out
Buffer: ?*anyopaque // void* in/out
) callconv(std.os.windows.WINAPI) u32;proc GetIScsiTargetInformationA(
TargetName: cstring, # LPSTR
DiscoveryMechanism: cstring, # LPSTR optional
InfoClass: int32, # TARGET_INFORMATION_CLASS
BufferSize: ptr uint32, # DWORD* in/out
Buffer: pointer # void* in/out
): uint32 {.importc: "GetIScsiTargetInformationA", stdcall, dynlib: "ISCSIDSC.dll".}pragma(lib, "iscsidsc");
extern(Windows)
uint GetIScsiTargetInformationA(
const(char)* TargetName, // LPSTR
const(char)* DiscoveryMechanism, // LPSTR optional
int InfoClass, // TARGET_INFORMATION_CLASS
uint* BufferSize, // DWORD* in/out
void* Buffer // void* in/out
);ccall((:GetIScsiTargetInformationA, "ISCSIDSC.dll"), stdcall, UInt32,
(Cstring, Cstring, Int32, Ptr{UInt32}, Ptr{Cvoid}),
TargetName, DiscoveryMechanism, InfoClass, BufferSize, Buffer)
# TargetName : LPSTR -> Cstring
# DiscoveryMechanism : LPSTR optional -> Cstring
# InfoClass : TARGET_INFORMATION_CLASS -> Int32
# BufferSize : DWORD* in/out -> Ptr{UInt32}
# Buffer : void* in/out -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
uint32_t GetIScsiTargetInformationA(
const char* TargetName,
const char* DiscoveryMechanism,
int32_t InfoClass,
uint32_t* BufferSize,
void* Buffer);
]]
local iscsidsc = ffi.load("iscsidsc")
-- iscsidsc.GetIScsiTargetInformationA(TargetName, DiscoveryMechanism, InfoClass, BufferSize, Buffer)
-- TargetName : LPSTR
-- DiscoveryMechanism : LPSTR optional
-- InfoClass : TARGET_INFORMATION_CLASS
-- BufferSize : DWORD* in/out
-- Buffer : void* in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('ISCSIDSC.dll');
const GetIScsiTargetInformationA = lib.func('__stdcall', 'GetIScsiTargetInformationA', 'uint32_t', ['str', 'str', 'int32_t', 'uint32_t *', 'void *']);
// GetIScsiTargetInformationA(TargetName, DiscoveryMechanism, InfoClass, BufferSize, Buffer)
// TargetName : LPSTR -> 'str'
// DiscoveryMechanism : LPSTR optional -> 'str'
// InfoClass : TARGET_INFORMATION_CLASS -> 'int32_t'
// BufferSize : DWORD* in/out -> 'uint32_t *'
// Buffer : void* in/out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("ISCSIDSC.dll", {
GetIScsiTargetInformationA: { parameters: ["buffer", "buffer", "i32", "pointer", "pointer"], result: "u32" },
});
// lib.symbols.GetIScsiTargetInformationA(TargetName, DiscoveryMechanism, InfoClass, BufferSize, Buffer)
// TargetName : LPSTR -> "buffer"
// DiscoveryMechanism : LPSTR optional -> "buffer"
// InfoClass : TARGET_INFORMATION_CLASS -> "i32"
// BufferSize : DWORD* in/out -> "pointer"
// Buffer : void* in/out -> "pointer"
// 文字列は "buffer"。ANSI(-A) は new TextEncoder() で UTF-8/ANSI バイト列(末尾に \x00)を渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
uint32_t GetIScsiTargetInformationA(
const char* TargetName,
const char* DiscoveryMechanism,
int32_t InfoClass,
uint32_t* BufferSize,
void* Buffer);
C, "ISCSIDSC.dll");
// $ffi->GetIScsiTargetInformationA(TargetName, DiscoveryMechanism, InfoClass, BufferSize, Buffer);
// TargetName : LPSTR
// DiscoveryMechanism : LPSTR optional
// InfoClass : TARGET_INFORMATION_CLASS
// BufferSize : DWORD* in/out
// Buffer : void* in/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 Iscsidsc extends StdCallLibrary {
Iscsidsc INSTANCE = Native.load("iscsidsc", Iscsidsc.class, W32APIOptions.ASCII_OPTIONS);
int GetIScsiTargetInformationA(
String TargetName, // LPSTR
String DiscoveryMechanism, // LPSTR optional
int InfoClass, // TARGET_INFORMATION_CLASS
IntByReference BufferSize, // DWORD* in/out
Pointer Buffer // void* in/out
);
}@[Link("iscsidsc")]
lib LibISCSIDSC
fun GetIScsiTargetInformationA = GetIScsiTargetInformationA(
TargetName : UInt8*, # LPSTR
DiscoveryMechanism : UInt8*, # LPSTR optional
InfoClass : Int32, # TARGET_INFORMATION_CLASS
BufferSize : UInt32*, # DWORD* in/out
Buffer : Void* # void* in/out
) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef GetIScsiTargetInformationANative = Uint32 Function(Pointer<Utf8>, Pointer<Utf8>, Int32, Pointer<Uint32>, Pointer<Void>);
typedef GetIScsiTargetInformationADart = int Function(Pointer<Utf8>, Pointer<Utf8>, int, Pointer<Uint32>, Pointer<Void>);
final GetIScsiTargetInformationA = DynamicLibrary.open('ISCSIDSC.dll')
.lookupFunction<GetIScsiTargetInformationANative, GetIScsiTargetInformationADart>('GetIScsiTargetInformationA');
// TargetName : LPSTR -> Pointer<Utf8>
// DiscoveryMechanism : LPSTR optional -> Pointer<Utf8>
// InfoClass : TARGET_INFORMATION_CLASS -> Int32
// BufferSize : DWORD* in/out -> Pointer<Uint32>
// Buffer : void* in/out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function GetIScsiTargetInformationA(
TargetName: PAnsiChar; // LPSTR
DiscoveryMechanism: PAnsiChar; // LPSTR optional
InfoClass: Integer; // TARGET_INFORMATION_CLASS
BufferSize: Pointer; // DWORD* in/out
Buffer: Pointer // void* in/out
): DWORD; stdcall;
external 'ISCSIDSC.dll' name 'GetIScsiTargetInformationA';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "GetIScsiTargetInformationA"
c_GetIScsiTargetInformationA :: CString -> CString -> Int32 -> Ptr Word32 -> Ptr () -> IO Word32
-- TargetName : LPSTR -> CString
-- DiscoveryMechanism : LPSTR optional -> CString
-- InfoClass : TARGET_INFORMATION_CLASS -> Int32
-- BufferSize : DWORD* in/out -> Ptr Word32
-- Buffer : void* in/out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let getiscsitargetinformationa =
foreign "GetIScsiTargetInformationA"
(string @-> string @-> int32_t @-> (ptr uint32_t) @-> (ptr void) @-> returning uint32_t)
(* TargetName : LPSTR -> string *)
(* DiscoveryMechanism : LPSTR optional -> string *)
(* InfoClass : TARGET_INFORMATION_CLASS -> int32_t *)
(* BufferSize : DWORD* in/out -> (ptr uint32_t) *)
(* Buffer : void* in/out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library iscsidsc (t "ISCSIDSC.dll"))
(cffi:use-foreign-library iscsidsc)
(cffi:defcfun ("GetIScsiTargetInformationA" get-iscsi-target-information-a :convention :stdcall) :uint32
(target-name :string) ; LPSTR
(discovery-mechanism :string) ; LPSTR optional
(info-class :int32) ; TARGET_INFORMATION_CLASS
(buffer-size :pointer) ; DWORD* in/out
(buffer :pointer)) ; void* in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $GetIScsiTargetInformationA = Win32::API::More->new('ISCSIDSC',
'DWORD GetIScsiTargetInformationA(LPCSTR TargetName, LPCSTR DiscoveryMechanism, int InfoClass, LPVOID BufferSize, LPVOID Buffer)');
# my $ret = $GetIScsiTargetInformationA->Call($TargetName, $DiscoveryMechanism, $InfoClass, $BufferSize, $Buffer);
# TargetName : LPSTR -> LPCSTR
# DiscoveryMechanism : LPSTR optional -> LPCSTR
# InfoClass : TARGET_INFORMATION_CLASS -> int
# BufferSize : DWORD* in/out -> LPVOID
# Buffer : void* in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
文字セット違い
- f GetIScsiTargetInformationW (Unicode版) — 指定iSCSIターゲットの情報を取得する。