ホーム › System.Com.StructuredStorage › CreateStreamOnHGlobal
CreateStreamOnHGlobal
関数グローバルメモリ上にIStreamストリームオブジェクトを生成する。
シグネチャ
// OLE32.dll
#include <windows.h>
HRESULT CreateStreamOnHGlobal(
HGLOBAL hGlobal, // optional
BOOL fDeleteOnRelease,
IStream** ppstm
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hGlobal | HGLOBAL | optional |
| fDeleteOnRelease | BOOL | in |
| ppstm | IStream** | out |
戻り値の型: HRESULT
各言語での呼び出し定義
// OLE32.dll
#include <windows.h>
HRESULT CreateStreamOnHGlobal(
HGLOBAL hGlobal, // optional
BOOL fDeleteOnRelease,
IStream** ppstm
);[DllImport("OLE32.dll", ExactSpelling = true)]
static extern int CreateStreamOnHGlobal(
IntPtr hGlobal, // HGLOBAL optional
bool fDeleteOnRelease, // BOOL
IntPtr ppstm // IStream** out
);<DllImport("OLE32.dll", ExactSpelling:=True)>
Public Shared Function CreateStreamOnHGlobal(
hGlobal As IntPtr, ' HGLOBAL optional
fDeleteOnRelease As Boolean, ' BOOL
ppstm As IntPtr ' IStream** out
) As Integer
End Function' hGlobal : HGLOBAL optional
' fDeleteOnRelease : BOOL
' ppstm : IStream** out
Declare PtrSafe Function CreateStreamOnHGlobal Lib "ole32" ( _
ByVal hGlobal As LongPtr, _
ByVal fDeleteOnRelease As Long, _
ByVal ppstm As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
CreateStreamOnHGlobal = ctypes.windll.ole32.CreateStreamOnHGlobal
CreateStreamOnHGlobal.restype = ctypes.c_int
CreateStreamOnHGlobal.argtypes = [
wintypes.HANDLE, # hGlobal : HGLOBAL optional
wintypes.BOOL, # fDeleteOnRelease : BOOL
ctypes.c_void_p, # ppstm : IStream** out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('OLE32.dll')
CreateStreamOnHGlobal = Fiddle::Function.new(
lib['CreateStreamOnHGlobal'],
[
Fiddle::TYPE_VOIDP, # hGlobal : HGLOBAL optional
Fiddle::TYPE_INT, # fDeleteOnRelease : BOOL
Fiddle::TYPE_VOIDP, # ppstm : IStream** out
],
Fiddle::TYPE_INT)#[link(name = "ole32")]
extern "system" {
fn CreateStreamOnHGlobal(
hGlobal: *mut core::ffi::c_void, // HGLOBAL optional
fDeleteOnRelease: i32, // BOOL
ppstm: *mut *mut core::ffi::c_void // IStream** out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("OLE32.dll")]
public static extern int CreateStreamOnHGlobal(IntPtr hGlobal, bool fDeleteOnRelease, IntPtr ppstm);
"@
$api = Add-Type -MemberDefinition $sig -Name 'OLE32_CreateStreamOnHGlobal' -Namespace Win32 -PassThru
# $api::CreateStreamOnHGlobal(hGlobal, fDeleteOnRelease, ppstm)#uselib "OLE32.dll"
#func global CreateStreamOnHGlobal "CreateStreamOnHGlobal" sptr, sptr, sptr
; CreateStreamOnHGlobal hGlobal, fDeleteOnRelease, ppstm ; 戻り値は stat
; hGlobal : HGLOBAL optional -> "sptr"
; fDeleteOnRelease : BOOL -> "sptr"
; ppstm : IStream** out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "OLE32.dll"
#cfunc global CreateStreamOnHGlobal "CreateStreamOnHGlobal" sptr, int, sptr
; res = CreateStreamOnHGlobal(hGlobal, fDeleteOnRelease, ppstm)
; hGlobal : HGLOBAL optional -> "sptr"
; fDeleteOnRelease : BOOL -> "int"
; ppstm : IStream** out -> "sptr"; HRESULT CreateStreamOnHGlobal(HGLOBAL hGlobal, BOOL fDeleteOnRelease, IStream** ppstm)
#uselib "OLE32.dll"
#cfunc global CreateStreamOnHGlobal "CreateStreamOnHGlobal" intptr, int, intptr
; res = CreateStreamOnHGlobal(hGlobal, fDeleteOnRelease, ppstm)
; hGlobal : HGLOBAL optional -> "intptr"
; fDeleteOnRelease : BOOL -> "int"
; ppstm : IStream** out -> "intptr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
ole32 = windows.NewLazySystemDLL("OLE32.dll")
procCreateStreamOnHGlobal = ole32.NewProc("CreateStreamOnHGlobal")
)
// hGlobal (HGLOBAL optional), fDeleteOnRelease (BOOL), ppstm (IStream** out)
r1, _, err := procCreateStreamOnHGlobal.Call(
uintptr(hGlobal),
uintptr(fDeleteOnRelease),
uintptr(ppstm),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction CreateStreamOnHGlobal(
hGlobal: THandle; // HGLOBAL optional
fDeleteOnRelease: BOOL; // BOOL
ppstm: Pointer // IStream** out
): Integer; stdcall;
external 'OLE32.dll' name 'CreateStreamOnHGlobal';result := DllCall("OLE32\CreateStreamOnHGlobal"
, "Ptr", hGlobal ; HGLOBAL optional
, "Int", fDeleteOnRelease ; BOOL
, "Ptr", ppstm ; IStream** out
, "Int") ; return: HRESULT●CreateStreamOnHGlobal(hGlobal, fDeleteOnRelease, ppstm) = DLL("OLE32.dll", "int CreateStreamOnHGlobal(void*, bool, void*)")
# 呼び出し: CreateStreamOnHGlobal(hGlobal, fDeleteOnRelease, ppstm)
# hGlobal : HGLOBAL optional -> "void*"
# fDeleteOnRelease : BOOL -> "bool"
# ppstm : IStream** out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。