ホーム › Storage.IscsiDisc › GetIScsiTargetInformationW
GetIScsiTargetInformationW
関数指定iSCSIターゲットの情報を取得する。
シグネチャ
// ISCSIDSC.dll (Unicode / -W)
#include <windows.h>
DWORD GetIScsiTargetInformationW(
LPWSTR TargetName,
LPWSTR DiscoveryMechanism, // optional
TARGET_INFORMATION_CLASS InfoClass,
DWORD* BufferSize,
void* Buffer
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| TargetName | LPWSTR | in | 情報を取得する対象iSCSIターゲットの名前を指す。 |
| DiscoveryMechanism | LPWSTR | inoptional | ターゲットが発見された探索メカニズム名を指す。NULL可。 |
| InfoClass | TARGET_INFORMATION_CLASS | in | 取得する情報種別を指定するTARGET_INFORMATION_CLASS列挙値。 |
| BufferSize | DWORD* | inout | 入力でBufferのサイズ、出力で必要サイズを受け取るDWORDへのポインタ。 |
| Buffer | void* | inout | 取得した情報を受け取るバッファへのポインタ。 |
戻り値の型: DWORD
各言語での呼び出し定義
// ISCSIDSC.dll (Unicode / -W)
#include <windows.h>
DWORD GetIScsiTargetInformationW(
LPWSTR TargetName,
LPWSTR DiscoveryMechanism, // optional
TARGET_INFORMATION_CLASS InfoClass,
DWORD* BufferSize,
void* Buffer
);[DllImport("ISCSIDSC.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern uint GetIScsiTargetInformationW(
[MarshalAs(UnmanagedType.LPWStr)] string TargetName, // LPWSTR
[MarshalAs(UnmanagedType.LPWStr)] string DiscoveryMechanism, // LPWSTR optional
int InfoClass, // TARGET_INFORMATION_CLASS
ref uint BufferSize, // DWORD* in/out
IntPtr Buffer // void* in/out
);<DllImport("ISCSIDSC.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function GetIScsiTargetInformationW(
<MarshalAs(UnmanagedType.LPWStr)> TargetName As String, ' LPWSTR
<MarshalAs(UnmanagedType.LPWStr)> DiscoveryMechanism As String, ' LPWSTR 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 : LPWSTR
' DiscoveryMechanism : LPWSTR optional
' InfoClass : TARGET_INFORMATION_CLASS
' BufferSize : DWORD* in/out
' Buffer : void* in/out
Declare PtrSafe Function GetIScsiTargetInformationW Lib "iscsidsc" ( _
ByVal TargetName As LongPtr, _
ByVal DiscoveryMechanism As LongPtr, _
ByVal InfoClass As Long, _
ByRef BufferSize As Long, _
ByVal Buffer As LongPtr) As Long
' Unicode(W): 文字列は ByVal As LongPtr とし StrPtr(unicodeStr) を渡す
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
GetIScsiTargetInformationW = ctypes.windll.iscsidsc.GetIScsiTargetInformationW
GetIScsiTargetInformationW.restype = wintypes.DWORD
GetIScsiTargetInformationW.argtypes = [
wintypes.LPCWSTR, # TargetName : LPWSTR
wintypes.LPCWSTR, # DiscoveryMechanism : LPWSTR 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')
GetIScsiTargetInformationW = Fiddle::Function.new(
lib['GetIScsiTargetInformationW'],
[
Fiddle::TYPE_VOIDP, # TargetName : LPWSTR
Fiddle::TYPE_VOIDP, # DiscoveryMechanism : LPWSTR 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)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"#[link(name = "iscsidsc")]
extern "system" {
fn GetIScsiTargetInformationW(
TargetName: *mut u16, // LPWSTR
DiscoveryMechanism: *mut u16, // LPWSTR 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.Unicode)]
public static extern uint GetIScsiTargetInformationW([MarshalAs(UnmanagedType.LPWStr)] string TargetName, [MarshalAs(UnmanagedType.LPWStr)] string DiscoveryMechanism, int InfoClass, ref uint BufferSize, IntPtr Buffer);
"@
$api = Add-Type -MemberDefinition $sig -Name 'ISCSIDSC_GetIScsiTargetInformationW' -Namespace Win32 -PassThru
# $api::GetIScsiTargetInformationW(TargetName, DiscoveryMechanism, InfoClass, BufferSize, Buffer)#uselib "ISCSIDSC.dll"
#func global GetIScsiTargetInformationW "GetIScsiTargetInformationW" wptr, wptr, wptr, wptr, wptr
; GetIScsiTargetInformationW TargetName, DiscoveryMechanism, InfoClass, varptr(BufferSize), Buffer ; 戻り値は stat
; TargetName : LPWSTR -> "wptr"
; DiscoveryMechanism : LPWSTR optional -> "wptr"
; InfoClass : TARGET_INFORMATION_CLASS -> "wptr"
; BufferSize : DWORD* in/out -> "wptr"
; Buffer : void* in/out -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "ISCSIDSC.dll" #cfunc global GetIScsiTargetInformationW "GetIScsiTargetInformationW" wstr, wstr, int, var, sptr ; res = GetIScsiTargetInformationW(TargetName, DiscoveryMechanism, InfoClass, BufferSize, Buffer) ; TargetName : LPWSTR -> "wstr" ; DiscoveryMechanism : LPWSTR optional -> "wstr" ; InfoClass : TARGET_INFORMATION_CLASS -> "int" ; BufferSize : DWORD* in/out -> "var" ; Buffer : void* in/out -> "sptr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "ISCSIDSC.dll" #cfunc global GetIScsiTargetInformationW "GetIScsiTargetInformationW" wstr, wstr, int, sptr, sptr ; res = GetIScsiTargetInformationW(TargetName, DiscoveryMechanism, InfoClass, varptr(BufferSize), Buffer) ; TargetName : LPWSTR -> "wstr" ; DiscoveryMechanism : LPWSTR optional -> "wstr" ; InfoClass : TARGET_INFORMATION_CLASS -> "int" ; BufferSize : DWORD* in/out -> "sptr" ; Buffer : void* in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; DWORD GetIScsiTargetInformationW(LPWSTR TargetName, LPWSTR DiscoveryMechanism, TARGET_INFORMATION_CLASS InfoClass, DWORD* BufferSize, void* Buffer) #uselib "ISCSIDSC.dll" #cfunc global GetIScsiTargetInformationW "GetIScsiTargetInformationW" wstr, wstr, int, var, intptr ; res = GetIScsiTargetInformationW(TargetName, DiscoveryMechanism, InfoClass, BufferSize, Buffer) ; TargetName : LPWSTR -> "wstr" ; DiscoveryMechanism : LPWSTR optional -> "wstr" ; InfoClass : TARGET_INFORMATION_CLASS -> "int" ; BufferSize : DWORD* in/out -> "var" ; Buffer : void* in/out -> "intptr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; DWORD GetIScsiTargetInformationW(LPWSTR TargetName, LPWSTR DiscoveryMechanism, TARGET_INFORMATION_CLASS InfoClass, DWORD* BufferSize, void* Buffer) #uselib "ISCSIDSC.dll" #cfunc global GetIScsiTargetInformationW "GetIScsiTargetInformationW" wstr, wstr, int, intptr, intptr ; res = GetIScsiTargetInformationW(TargetName, DiscoveryMechanism, InfoClass, varptr(BufferSize), Buffer) ; TargetName : LPWSTR -> "wstr" ; DiscoveryMechanism : LPWSTR optional -> "wstr" ; 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")
procGetIScsiTargetInformationW = iscsidsc.NewProc("GetIScsiTargetInformationW")
)
// TargetName (LPWSTR), DiscoveryMechanism (LPWSTR optional), InfoClass (TARGET_INFORMATION_CLASS), BufferSize (DWORD* in/out), Buffer (void* in/out)
r1, _, err := procGetIScsiTargetInformationW.Call(
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(TargetName))),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(DiscoveryMechanism))),
uintptr(InfoClass),
uintptr(BufferSize),
uintptr(Buffer),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction GetIScsiTargetInformationW(
TargetName: PWideChar; // LPWSTR
DiscoveryMechanism: PWideChar; // LPWSTR optional
InfoClass: Integer; // TARGET_INFORMATION_CLASS
BufferSize: Pointer; // DWORD* in/out
Buffer: Pointer // void* in/out
): DWORD; stdcall;
external 'ISCSIDSC.dll' name 'GetIScsiTargetInformationW';result := DllCall("ISCSIDSC\GetIScsiTargetInformationW"
, "WStr", TargetName ; LPWSTR
, "WStr", DiscoveryMechanism ; LPWSTR optional
, "Int", InfoClass ; TARGET_INFORMATION_CLASS
, "Ptr", BufferSize ; DWORD* in/out
, "Ptr", Buffer ; void* in/out
, "UInt") ; return: DWORD●GetIScsiTargetInformationW(TargetName, DiscoveryMechanism, InfoClass, BufferSize, Buffer) = DLL("ISCSIDSC.dll", "dword GetIScsiTargetInformationW(char*, char*, int, void*, void*)")
# 呼び出し: GetIScsiTargetInformationW(TargetName, DiscoveryMechanism, InfoClass, BufferSize, Buffer)
# TargetName : LPWSTR -> "char*"
# DiscoveryMechanism : LPWSTR 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)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。const std = @import("std");
extern "iscsidsc" fn GetIScsiTargetInformationW(
TargetName: [*c]const u16, // LPWSTR
DiscoveryMechanism: [*c]const u16, // LPWSTR optional
InfoClass: i32, // TARGET_INFORMATION_CLASS
BufferSize: [*c]u32, // DWORD* in/out
Buffer: ?*anyopaque // void* in/out
) callconv(std.os.windows.WINAPI) u32;
// Unicode(-W): UTF-16LE のヌル終端バッファ([*c]const u16)を渡す。proc GetIScsiTargetInformationW(
TargetName: WideCString, # LPWSTR
DiscoveryMechanism: WideCString, # LPWSTR optional
InfoClass: int32, # TARGET_INFORMATION_CLASS
BufferSize: ptr uint32, # DWORD* in/out
Buffer: pointer # void* in/out
): uint32 {.importc: "GetIScsiTargetInformationW", stdcall, dynlib: "ISCSIDSC.dll".}
# Unicode(-W): WideCString は newWideCString("...") で生成。pragma(lib, "iscsidsc");
extern(Windows)
uint GetIScsiTargetInformationW(
const(wchar)* TargetName, // LPWSTR
const(wchar)* DiscoveryMechanism, // LPWSTR optional
int InfoClass, // TARGET_INFORMATION_CLASS
uint* BufferSize, // DWORD* in/out
void* Buffer // void* in/out
);ccall((:GetIScsiTargetInformationW, "ISCSIDSC.dll"), stdcall, UInt32,
(Cwstring, Cwstring, Int32, Ptr{UInt32}, Ptr{Cvoid}),
TargetName, DiscoveryMechanism, InfoClass, BufferSize, Buffer)
# TargetName : LPWSTR -> Cwstring
# DiscoveryMechanism : LPWSTR optional -> Cwstring
# InfoClass : TARGET_INFORMATION_CLASS -> Int32
# BufferSize : DWORD* in/out -> Ptr{UInt32}
# Buffer : void* in/out -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
# Unicode(-W): Cwstring には transcode(UInt16, "...") 等で UTF-16 を渡す。local ffi = require("ffi")
ffi.cdef[[
uint32_t GetIScsiTargetInformationW(
const uint16_t* TargetName,
const uint16_t* DiscoveryMechanism,
int32_t InfoClass,
uint32_t* BufferSize,
void* Buffer);
]]
local iscsidsc = ffi.load("iscsidsc")
-- iscsidsc.GetIScsiTargetInformationW(TargetName, DiscoveryMechanism, InfoClass, BufferSize, Buffer)
-- TargetName : LPWSTR
-- DiscoveryMechanism : LPWSTR optional
-- InfoClass : TARGET_INFORMATION_CLASS
-- BufferSize : DWORD* in/out
-- Buffer : void* in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
-- Unicode(-W): uint16_t* には UTF-16LE のバッファ(ffi.new("uint16_t[?]", ...))を渡す。const koffi = require('koffi');
const lib = koffi.load('ISCSIDSC.dll');
const GetIScsiTargetInformationW = lib.func('__stdcall', 'GetIScsiTargetInformationW', 'uint32_t', ['str16', 'str16', 'int32_t', 'uint32_t *', 'void *']);
// GetIScsiTargetInformationW(TargetName, DiscoveryMechanism, InfoClass, BufferSize, Buffer)
// TargetName : LPWSTR -> 'str16'
// DiscoveryMechanism : LPWSTR optional -> 'str16'
// 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", {
GetIScsiTargetInformationW: { parameters: ["buffer", "buffer", "i32", "pointer", "pointer"], result: "u32" },
});
// lib.symbols.GetIScsiTargetInformationW(TargetName, DiscoveryMechanism, InfoClass, BufferSize, Buffer)
// TargetName : LPWSTR -> "buffer"
// DiscoveryMechanism : LPWSTR optional -> "buffer"
// InfoClass : TARGET_INFORMATION_CLASS -> "i32"
// BufferSize : DWORD* in/out -> "pointer"
// Buffer : void* in/out -> "pointer"
// 文字列は "buffer"。Unicode(-W) は new TextEncoder() ではなく UTF-16LE のバイト列(末尾に \x00\x00)を Uint8Array で渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
uint32_t GetIScsiTargetInformationW(
const uint16_t* TargetName,
const uint16_t* DiscoveryMechanism,
int32_t InfoClass,
uint32_t* BufferSize,
void* Buffer);
C, "ISCSIDSC.dll");
// $ffi->GetIScsiTargetInformationW(TargetName, DiscoveryMechanism, InfoClass, BufferSize, Buffer);
// TargetName : LPWSTR
// DiscoveryMechanism : LPWSTR 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.UNICODE_OPTIONS);
int GetIScsiTargetInformationW(
WString TargetName, // LPWSTR
WString DiscoveryMechanism, // LPWSTR optional
int InfoClass, // TARGET_INFORMATION_CLASS
IntByReference BufferSize, // DWORD* in/out
Pointer Buffer // void* in/out
);
}
// Unicode(-W): WString(入力)/char[](出力)で UTF-16 をマーシャリング。@[Link("iscsidsc")]
lib LibISCSIDSC
fun GetIScsiTargetInformationW = GetIScsiTargetInformationW(
TargetName : UInt16*, # LPWSTR
DiscoveryMechanism : UInt16*, # LPWSTR 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 GetIScsiTargetInformationWNative = Uint32 Function(Pointer<Utf16>, Pointer<Utf16>, Int32, Pointer<Uint32>, Pointer<Void>);
typedef GetIScsiTargetInformationWDart = int Function(Pointer<Utf16>, Pointer<Utf16>, int, Pointer<Uint32>, Pointer<Void>);
final GetIScsiTargetInformationW = DynamicLibrary.open('ISCSIDSC.dll')
.lookupFunction<GetIScsiTargetInformationWNative, GetIScsiTargetInformationWDart>('GetIScsiTargetInformationW');
// TargetName : LPWSTR -> Pointer<Utf16>
// DiscoveryMechanism : LPWSTR optional -> Pointer<Utf16>
// 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 GetIScsiTargetInformationW(
TargetName: PWideChar; // LPWSTR
DiscoveryMechanism: PWideChar; // LPWSTR optional
InfoClass: Integer; // TARGET_INFORMATION_CLASS
BufferSize: Pointer; // DWORD* in/out
Buffer: Pointer // void* in/out
): DWORD; stdcall;
external 'ISCSIDSC.dll' name 'GetIScsiTargetInformationW';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "GetIScsiTargetInformationW"
c_GetIScsiTargetInformationW :: CWString -> CWString -> Int32 -> Ptr Word32 -> Ptr () -> IO Word32
-- TargetName : LPWSTR -> CWString
-- DiscoveryMechanism : LPWSTR optional -> CWString
-- 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 getiscsitargetinformationw =
foreign "GetIScsiTargetInformationW"
((ptr uint16_t) @-> (ptr uint16_t) @-> int32_t @-> (ptr uint32_t) @-> (ptr void) @-> returning uint32_t)
(* TargetName : LPWSTR -> (ptr uint16_t) *)
(* DiscoveryMechanism : LPWSTR optional -> (ptr uint16_t) *)
(* 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 ("GetIScsiTargetInformationW" get-iscsi-target-information-w :convention :stdcall) :uint32
(target-name (:string :encoding :utf-16le)) ; LPWSTR
(discovery-mechanism (:string :encoding :utf-16le)) ; LPWSTR 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 $GetIScsiTargetInformationW = Win32::API::More->new('ISCSIDSC',
'DWORD GetIScsiTargetInformationW(LPCWSTR TargetName, LPCWSTR DiscoveryMechanism, int InfoClass, LPVOID BufferSize, LPVOID Buffer)');
# my $ret = $GetIScsiTargetInformationW->Call($TargetName, $DiscoveryMechanism, $InfoClass, $BufferSize, $Buffer);
# TargetName : LPWSTR -> LPCWSTR
# DiscoveryMechanism : LPWSTR optional -> LPCWSTR
# InfoClass : TARGET_INFORMATION_CLASS -> int
# BufferSize : DWORD* in/out -> LPVOID
# Buffer : void* in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。
# Unicode(-W): LPCWSTR/LPWSTR は Win32::API が UTF-16 変換を行う。関連項目
文字セット違い
- f GetIScsiTargetInformationA (ANSI版) — 指定iSCSIターゲットの情報を取得する(ANSI版)。