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

GetIScsiTargetInformationA

関数
指定iSCSIターゲットの情報を取得する(ANSI版)。
DLLISCSIDSC.dll文字セットANSI (-A)呼出規約winapi対応OSWindows Vista 以降

シグネチャ

// ISCSIDSC.dll  (ANSI / -A)
#include <windows.h>

DWORD GetIScsiTargetInformationA(
    LPSTR TargetName,
    LPSTR DiscoveryMechanism,   // optional
    TARGET_INFORMATION_CLASS InfoClass,
    DWORD* BufferSize,
    void* Buffer
);

パラメーター

名前方向
TargetNameLPSTRin
DiscoveryMechanismLPSTRinoptional
InfoClassTARGET_INFORMATION_CLASSin
BufferSizeDWORD*inout
Buffervoid*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 方式にも切替可。
出力引数:
; 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 方式にも切替可。
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   // DWORD
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';
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)。