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

AddPersistentIScsiDeviceW

関数
永続的に再接続するiSCSIデバイスを追加する。
DLLISCSIDSC.dll文字セットUnicode (-W)呼出規約winapi対応OSWindows Vista 以降

シグネチャ

// ISCSIDSC.dll  (Unicode / -W)
#include <windows.h>

DWORD AddPersistentIScsiDeviceW(
    LPWSTR DevicePath
);

パラメーター

名前方向
DevicePathLPWSTRin

戻り値の型: DWORD

各言語での呼び出し定義

// ISCSIDSC.dll  (Unicode / -W)
#include <windows.h>

DWORD AddPersistentIScsiDeviceW(
    LPWSTR DevicePath
);
[DllImport("ISCSIDSC.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern uint AddPersistentIScsiDeviceW(
    [MarshalAs(UnmanagedType.LPWStr)] string DevicePath   // LPWSTR
);
<DllImport("ISCSIDSC.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function AddPersistentIScsiDeviceW(
    <MarshalAs(UnmanagedType.LPWStr)> DevicePath As String   ' LPWSTR
) As UInteger
End Function
' DevicePath : LPWSTR
Declare PtrSafe Function AddPersistentIScsiDeviceW Lib "iscsidsc" ( _
    ByVal DevicePath 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

AddPersistentIScsiDeviceW = ctypes.windll.iscsidsc.AddPersistentIScsiDeviceW
AddPersistentIScsiDeviceW.restype = wintypes.DWORD
AddPersistentIScsiDeviceW.argtypes = [
    wintypes.LPCWSTR,  # DevicePath : LPWSTR
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('ISCSIDSC.dll')
AddPersistentIScsiDeviceW = Fiddle::Function.new(
  lib['AddPersistentIScsiDeviceW'],
  [
    Fiddle::TYPE_VOIDP,  # DevicePath : LPWSTR
  ],
  -Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"
#[link(name = "iscsidsc")]
extern "system" {
    fn AddPersistentIScsiDeviceW(
        DevicePath: *mut u16  // LPWSTR
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("ISCSIDSC.dll", CharSet = CharSet.Unicode)]
public static extern uint AddPersistentIScsiDeviceW([MarshalAs(UnmanagedType.LPWStr)] string DevicePath);
"@
$api = Add-Type -MemberDefinition $sig -Name 'ISCSIDSC_AddPersistentIScsiDeviceW' -Namespace Win32 -PassThru
# $api::AddPersistentIScsiDeviceW(DevicePath)
#uselib "ISCSIDSC.dll"
#func global AddPersistentIScsiDeviceW "AddPersistentIScsiDeviceW" wptr
; AddPersistentIScsiDeviceW DevicePath   ; 戻り値は stat
; DevicePath : LPWSTR -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "ISCSIDSC.dll"
#cfunc global AddPersistentIScsiDeviceW "AddPersistentIScsiDeviceW" wstr
; res = AddPersistentIScsiDeviceW(DevicePath)
; DevicePath : LPWSTR -> "wstr"
; DWORD AddPersistentIScsiDeviceW(LPWSTR DevicePath)
#uselib "ISCSIDSC.dll"
#cfunc global AddPersistentIScsiDeviceW "AddPersistentIScsiDeviceW" wstr
; res = AddPersistentIScsiDeviceW(DevicePath)
; DevicePath : LPWSTR -> "wstr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	iscsidsc = windows.NewLazySystemDLL("ISCSIDSC.dll")
	procAddPersistentIScsiDeviceW = iscsidsc.NewProc("AddPersistentIScsiDeviceW")
)

// DevicePath (LPWSTR)
r1, _, err := procAddPersistentIScsiDeviceW.Call(
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(DevicePath))),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function AddPersistentIScsiDeviceW(
  DevicePath: PWideChar   // LPWSTR
): DWORD; stdcall;
  external 'ISCSIDSC.dll' name 'AddPersistentIScsiDeviceW';
result := DllCall("ISCSIDSC\AddPersistentIScsiDeviceW"
    , "WStr", DevicePath   ; LPWSTR
    , "UInt")   ; return: DWORD
●AddPersistentIScsiDeviceW(DevicePath) = DLL("ISCSIDSC.dll", "dword AddPersistentIScsiDeviceW(char*)")
# 呼び出し: AddPersistentIScsiDeviceW(DevicePath)
# DevicePath : LPWSTR -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。