Win32 API 日本語リファレンス
ホームUI.Shell › IStream_Write

IStream_Write

関数
ストリームへ指定バイト数を確実に書き込む。
DLLSHLWAPI.dll呼出規約winapi対応OSWindows Vista 以降

シグネチャ

// SHLWAPI.dll
#include <windows.h>

HRESULT IStream_Write(
    IStream* pstm,
    const void* pv,
    DWORD cb
);

パラメーター

名前方向
pstmIStream*in
pvvoid*in
cbDWORDin

戻り値の型: HRESULT

各言語での呼び出し定義

// SHLWAPI.dll
#include <windows.h>

HRESULT IStream_Write(
    IStream* pstm,
    const void* pv,
    DWORD cb
);
[DllImport("SHLWAPI.dll", ExactSpelling = true)]
static extern int IStream_Write(
    IntPtr pstm,   // IStream*
    IntPtr pv,   // void*
    uint cb   // DWORD
);
<DllImport("SHLWAPI.dll", ExactSpelling:=True)>
Public Shared Function IStream_Write(
    pstm As IntPtr,   ' IStream*
    pv As IntPtr,   ' void*
    cb As UInteger   ' DWORD
) As Integer
End Function
' pstm : IStream*
' pv : void*
' cb : DWORD
Declare PtrSafe Function IStream_Write Lib "shlwapi" ( _
    ByVal pstm As LongPtr, _
    ByVal pv As LongPtr, _
    ByVal cb As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

IStream_Write = ctypes.windll.shlwapi.IStream_Write
IStream_Write.restype = ctypes.c_int
IStream_Write.argtypes = [
    ctypes.c_void_p,  # pstm : IStream*
    ctypes.POINTER(None),  # pv : void*
    wintypes.DWORD,  # cb : DWORD
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('SHLWAPI.dll')
IStream_Write = Fiddle::Function.new(
  lib['IStream_Write'],
  [
    Fiddle::TYPE_VOIDP,  # pstm : IStream*
    Fiddle::TYPE_VOIDP,  # pv : void*
    -Fiddle::TYPE_INT,  # cb : DWORD
  ],
  Fiddle::TYPE_INT)
#[link(name = "shlwapi")]
extern "system" {
    fn IStream_Write(
        pstm: *mut core::ffi::c_void,  // IStream*
        pv: *const (),  // void*
        cb: u32  // DWORD
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("SHLWAPI.dll")]
public static extern int IStream_Write(IntPtr pstm, IntPtr pv, uint cb);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SHLWAPI_IStream_Write' -Namespace Win32 -PassThru
# $api::IStream_Write(pstm, pv, cb)
#uselib "SHLWAPI.dll"
#func global IStream_Write "IStream_Write" sptr, sptr, sptr
; IStream_Write pstm, pv, cb   ; 戻り値は stat
; pstm : IStream* -> "sptr"
; pv : void* -> "sptr"
; cb : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "SHLWAPI.dll"
#cfunc global IStream_Write "IStream_Write" sptr, sptr, int
; res = IStream_Write(pstm, pv, cb)
; pstm : IStream* -> "sptr"
; pv : void* -> "sptr"
; cb : DWORD -> "int"
; HRESULT IStream_Write(IStream* pstm, void* pv, DWORD cb)
#uselib "SHLWAPI.dll"
#cfunc global IStream_Write "IStream_Write" intptr, intptr, int
; res = IStream_Write(pstm, pv, cb)
; pstm : IStream* -> "intptr"
; pv : void* -> "intptr"
; cb : DWORD -> "int"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	shlwapi = windows.NewLazySystemDLL("SHLWAPI.dll")
	procIStream_Write = shlwapi.NewProc("IStream_Write")
)

// pstm (IStream*), pv (void*), cb (DWORD)
r1, _, err := procIStream_Write.Call(
	uintptr(pstm),
	uintptr(pv),
	uintptr(cb),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function IStream_Write(
  pstm: Pointer;   // IStream*
  pv: Pointer;   // void*
  cb: DWORD   // DWORD
): Integer; stdcall;
  external 'SHLWAPI.dll' name 'IStream_Write';
result := DllCall("SHLWAPI\IStream_Write"
    , "Ptr", pstm   ; IStream*
    , "Ptr", pv   ; void*
    , "UInt", cb   ; DWORD
    , "Int")   ; return: HRESULT
●IStream_Write(pstm, pv, cb) = DLL("SHLWAPI.dll", "int IStream_Write(void*, void*, dword)")
# 呼び出し: IStream_Write(pstm, pv, cb)
# pstm : IStream* -> "void*"
# pv : void* -> "void*"
# cb : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。