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

IStream_Read

関数
ストリームから指定バイト数を確実に読み取る。
DLLSHLWAPI.dll呼出規約winapi対応OSWindows 2000 以降

シグネチャ

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

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

パラメーター

名前方向
pstmIStream*in
pvvoid*out
cbDWORDin

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT IStream_Read(
    IStream* pstm,
    void* pv,
    DWORD cb
);
[DllImport("SHLWAPI.dll", ExactSpelling = true)]
static extern int IStream_Read(
    IntPtr pstm,   // IStream*
    IntPtr pv,   // void* out
    uint cb   // DWORD
);
<DllImport("SHLWAPI.dll", ExactSpelling:=True)>
Public Shared Function IStream_Read(
    pstm As IntPtr,   ' IStream*
    pv As IntPtr,   ' void* out
    cb As UInteger   ' DWORD
) As Integer
End Function
' pstm : IStream*
' pv : void* out
' cb : DWORD
Declare PtrSafe Function IStream_Read 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_Read = ctypes.windll.shlwapi.IStream_Read
IStream_Read.restype = ctypes.c_int
IStream_Read.argtypes = [
    ctypes.c_void_p,  # pstm : IStream*
    ctypes.POINTER(None),  # pv : void* out
    wintypes.DWORD,  # cb : DWORD
]
require 'fiddle'
require 'fiddle/import'

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

var (
	shlwapi = windows.NewLazySystemDLL("SHLWAPI.dll")
	procIStream_Read = shlwapi.NewProc("IStream_Read")
)

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