SHCreateMemStream
関数メモリ上のバッファを基にしたストリームを生成する。
シグネチャ
// SHLWAPI.dll
#include <windows.h>
IStream* SHCreateMemStream(
const BYTE* pInit, // optional
DWORD cbInit
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| pInit | BYTE* | inoptional |
| cbInit | DWORD | in |
戻り値の型: IStream*
各言語での呼び出し定義
// SHLWAPI.dll
#include <windows.h>
IStream* SHCreateMemStream(
const BYTE* pInit, // optional
DWORD cbInit
);[DllImport("SHLWAPI.dll", ExactSpelling = true)]
static extern IntPtr SHCreateMemStream(
IntPtr pInit, // BYTE* optional
uint cbInit // DWORD
);<DllImport("SHLWAPI.dll", ExactSpelling:=True)>
Public Shared Function SHCreateMemStream(
pInit As IntPtr, ' BYTE* optional
cbInit As UInteger ' DWORD
) As IntPtr
End Function' pInit : BYTE* optional
' cbInit : DWORD
Declare PtrSafe Function SHCreateMemStream Lib "shlwapi" ( _
ByVal pInit As LongPtr, _
ByVal cbInit As Long) As LongPtr
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
SHCreateMemStream = ctypes.windll.shlwapi.SHCreateMemStream
SHCreateMemStream.restype = ctypes.c_void_p
SHCreateMemStream.argtypes = [
ctypes.POINTER(ctypes.c_ubyte), # pInit : BYTE* optional
wintypes.DWORD, # cbInit : DWORD
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('SHLWAPI.dll')
SHCreateMemStream = Fiddle::Function.new(
lib['SHCreateMemStream'],
[
Fiddle::TYPE_VOIDP, # pInit : BYTE* optional
-Fiddle::TYPE_INT, # cbInit : DWORD
],
Fiddle::TYPE_VOIDP)#[link(name = "shlwapi")]
extern "system" {
fn SHCreateMemStream(
pInit: *const u8, // BYTE* optional
cbInit: u32 // DWORD
) -> *mut core::ffi::c_void;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("SHLWAPI.dll")]
public static extern IntPtr SHCreateMemStream(IntPtr pInit, uint cbInit);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SHLWAPI_SHCreateMemStream' -Namespace Win32 -PassThru
# $api::SHCreateMemStream(pInit, cbInit)#uselib "SHLWAPI.dll"
#func global SHCreateMemStream "SHCreateMemStream" sptr, sptr
; SHCreateMemStream varptr(pInit), cbInit ; 戻り値は stat
; pInit : BYTE* optional -> "sptr"
; cbInit : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "SHLWAPI.dll" #cfunc global SHCreateMemStream "SHCreateMemStream" var, int ; res = SHCreateMemStream(pInit, cbInit) ; pInit : BYTE* optional -> "var" ; cbInit : DWORD -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "SHLWAPI.dll" #cfunc global SHCreateMemStream "SHCreateMemStream" sptr, int ; res = SHCreateMemStream(varptr(pInit), cbInit) ; pInit : BYTE* optional -> "sptr" ; cbInit : DWORD -> "int" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; IStream* SHCreateMemStream(BYTE* pInit, DWORD cbInit) #uselib "SHLWAPI.dll" #cfunc global SHCreateMemStream "SHCreateMemStream" var, int ; res = SHCreateMemStream(pInit, cbInit) ; pInit : BYTE* optional -> "var" ; cbInit : DWORD -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; IStream* SHCreateMemStream(BYTE* pInit, DWORD cbInit) #uselib "SHLWAPI.dll" #cfunc global SHCreateMemStream "SHCreateMemStream" intptr, int ; res = SHCreateMemStream(varptr(pInit), cbInit) ; pInit : BYTE* optional -> "intptr" ; cbInit : DWORD -> "int" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
shlwapi = windows.NewLazySystemDLL("SHLWAPI.dll")
procSHCreateMemStream = shlwapi.NewProc("SHCreateMemStream")
)
// pInit (BYTE* optional), cbInit (DWORD)
r1, _, err := procSHCreateMemStream.Call(
uintptr(pInit),
uintptr(cbInit),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // IStream*function SHCreateMemStream(
pInit: Pointer; // BYTE* optional
cbInit: DWORD // DWORD
): Pointer; stdcall;
external 'SHLWAPI.dll' name 'SHCreateMemStream';result := DllCall("SHLWAPI\SHCreateMemStream"
, "Ptr", pInit ; BYTE* optional
, "UInt", cbInit ; DWORD
, "Ptr") ; return: IStream*●SHCreateMemStream(pInit, cbInit) = DLL("SHLWAPI.dll", "void* SHCreateMemStream(void*, dword)")
# 呼び出し: SHCreateMemStream(pInit, cbInit)
# pInit : BYTE* optional -> "void*"
# cbInit : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。