ホーム › System.Com.StructuredStorage › StgOpenStorageOnILockBytes
StgOpenStorageOnILockBytes
関数ILockBytes上の複合ドキュメントを開きルートストレージを取得する。
シグネチャ
// OLE32.dll
#include <windows.h>
HRESULT StgOpenStorageOnILockBytes(
ILockBytes* plkbyt,
IStorage* pstgPriority, // optional
STGM grfMode,
WORD** snbExclude, // optional
DWORD reserved, // optional
IStorage** ppstgOpen
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| plkbyt | ILockBytes* | in | 開くストレージの基となるILockBytesへのポインタ。 |
| pstgPriority | IStorage* | inoptional | 優先モードで先に開いたIStorageへのポインタ。通常NULL。 |
| grfMode | STGM | in | アクセスモードを示すSTGMフラグ。共有モードも含む。 |
| snbExclude | WORD** | inoptional | 開く際に除外する要素名のSNB(文字列名ブロック)。通常NULL。 |
| reserved | DWORD | optional | 予約パラメータ。0を指定する。 |
| ppstgOpen | IStorage** | out | 開いたルートストレージのIStorageを受け取る出力ポインタ。 |
戻り値の型: HRESULT
各言語での呼び出し定義
// OLE32.dll
#include <windows.h>
HRESULT StgOpenStorageOnILockBytes(
ILockBytes* plkbyt,
IStorage* pstgPriority, // optional
STGM grfMode,
WORD** snbExclude, // optional
DWORD reserved, // optional
IStorage** ppstgOpen
);[DllImport("OLE32.dll", ExactSpelling = true)]
static extern int StgOpenStorageOnILockBytes(
IntPtr plkbyt, // ILockBytes*
IntPtr pstgPriority, // IStorage* optional
uint grfMode, // STGM
IntPtr snbExclude, // WORD** optional
uint reserved, // DWORD optional
IntPtr ppstgOpen // IStorage** out
);<DllImport("OLE32.dll", ExactSpelling:=True)>
Public Shared Function StgOpenStorageOnILockBytes(
plkbyt As IntPtr, ' ILockBytes*
pstgPriority As IntPtr, ' IStorage* optional
grfMode As UInteger, ' STGM
snbExclude As IntPtr, ' WORD** optional
reserved As UInteger, ' DWORD optional
ppstgOpen As IntPtr ' IStorage** out
) As Integer
End Function' plkbyt : ILockBytes*
' pstgPriority : IStorage* optional
' grfMode : STGM
' snbExclude : WORD** optional
' reserved : DWORD optional
' ppstgOpen : IStorage** out
Declare PtrSafe Function StgOpenStorageOnILockBytes Lib "ole32" ( _
ByVal plkbyt As LongPtr, _
ByVal pstgPriority As LongPtr, _
ByVal grfMode As Long, _
ByVal snbExclude As LongPtr, _
ByVal reserved As Long, _
ByVal ppstgOpen As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
StgOpenStorageOnILockBytes = ctypes.windll.ole32.StgOpenStorageOnILockBytes
StgOpenStorageOnILockBytes.restype = ctypes.c_int
StgOpenStorageOnILockBytes.argtypes = [
ctypes.c_void_p, # plkbyt : ILockBytes*
ctypes.c_void_p, # pstgPriority : IStorage* optional
wintypes.DWORD, # grfMode : STGM
ctypes.c_void_p, # snbExclude : WORD** optional
wintypes.DWORD, # reserved : DWORD optional
ctypes.c_void_p, # ppstgOpen : IStorage** out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('OLE32.dll')
StgOpenStorageOnILockBytes = Fiddle::Function.new(
lib['StgOpenStorageOnILockBytes'],
[
Fiddle::TYPE_VOIDP, # plkbyt : ILockBytes*
Fiddle::TYPE_VOIDP, # pstgPriority : IStorage* optional
-Fiddle::TYPE_INT, # grfMode : STGM
Fiddle::TYPE_VOIDP, # snbExclude : WORD** optional
-Fiddle::TYPE_INT, # reserved : DWORD optional
Fiddle::TYPE_VOIDP, # ppstgOpen : IStorage** out
],
Fiddle::TYPE_INT)#[link(name = "ole32")]
extern "system" {
fn StgOpenStorageOnILockBytes(
plkbyt: *mut core::ffi::c_void, // ILockBytes*
pstgPriority: *mut core::ffi::c_void, // IStorage* optional
grfMode: u32, // STGM
snbExclude: *mut *mut u16, // WORD** optional
reserved: u32, // DWORD optional
ppstgOpen: *mut *mut core::ffi::c_void // IStorage** out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("OLE32.dll")]
public static extern int StgOpenStorageOnILockBytes(IntPtr plkbyt, IntPtr pstgPriority, uint grfMode, IntPtr snbExclude, uint reserved, IntPtr ppstgOpen);
"@
$api = Add-Type -MemberDefinition $sig -Name 'OLE32_StgOpenStorageOnILockBytes' -Namespace Win32 -PassThru
# $api::StgOpenStorageOnILockBytes(plkbyt, pstgPriority, grfMode, snbExclude, reserved, ppstgOpen)#uselib "OLE32.dll"
#func global StgOpenStorageOnILockBytes "StgOpenStorageOnILockBytes" sptr, sptr, sptr, sptr, sptr, sptr
; StgOpenStorageOnILockBytes plkbyt, pstgPriority, grfMode, varptr(snbExclude), reserved, ppstgOpen ; 戻り値は stat
; plkbyt : ILockBytes* -> "sptr"
; pstgPriority : IStorage* optional -> "sptr"
; grfMode : STGM -> "sptr"
; snbExclude : WORD** optional -> "sptr"
; reserved : DWORD optional -> "sptr"
; ppstgOpen : IStorage** out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "OLE32.dll" #cfunc global StgOpenStorageOnILockBytes "StgOpenStorageOnILockBytes" sptr, sptr, int, var, int, sptr ; res = StgOpenStorageOnILockBytes(plkbyt, pstgPriority, grfMode, snbExclude, reserved, ppstgOpen) ; plkbyt : ILockBytes* -> "sptr" ; pstgPriority : IStorage* optional -> "sptr" ; grfMode : STGM -> "int" ; snbExclude : WORD** optional -> "var" ; reserved : DWORD optional -> "int" ; ppstgOpen : IStorage** out -> "sptr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "OLE32.dll" #cfunc global StgOpenStorageOnILockBytes "StgOpenStorageOnILockBytes" sptr, sptr, int, sptr, int, sptr ; res = StgOpenStorageOnILockBytes(plkbyt, pstgPriority, grfMode, varptr(snbExclude), reserved, ppstgOpen) ; plkbyt : ILockBytes* -> "sptr" ; pstgPriority : IStorage* optional -> "sptr" ; grfMode : STGM -> "int" ; snbExclude : WORD** optional -> "sptr" ; reserved : DWORD optional -> "int" ; ppstgOpen : IStorage** out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HRESULT StgOpenStorageOnILockBytes(ILockBytes* plkbyt, IStorage* pstgPriority, STGM grfMode, WORD** snbExclude, DWORD reserved, IStorage** ppstgOpen) #uselib "OLE32.dll" #cfunc global StgOpenStorageOnILockBytes "StgOpenStorageOnILockBytes" intptr, intptr, int, var, int, intptr ; res = StgOpenStorageOnILockBytes(plkbyt, pstgPriority, grfMode, snbExclude, reserved, ppstgOpen) ; plkbyt : ILockBytes* -> "intptr" ; pstgPriority : IStorage* optional -> "intptr" ; grfMode : STGM -> "int" ; snbExclude : WORD** optional -> "var" ; reserved : DWORD optional -> "int" ; ppstgOpen : IStorage** out -> "intptr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HRESULT StgOpenStorageOnILockBytes(ILockBytes* plkbyt, IStorage* pstgPriority, STGM grfMode, WORD** snbExclude, DWORD reserved, IStorage** ppstgOpen) #uselib "OLE32.dll" #cfunc global StgOpenStorageOnILockBytes "StgOpenStorageOnILockBytes" intptr, intptr, int, intptr, int, intptr ; res = StgOpenStorageOnILockBytes(plkbyt, pstgPriority, grfMode, varptr(snbExclude), reserved, ppstgOpen) ; plkbyt : ILockBytes* -> "intptr" ; pstgPriority : IStorage* optional -> "intptr" ; grfMode : STGM -> "int" ; snbExclude : WORD** optional -> "intptr" ; reserved : DWORD optional -> "int" ; ppstgOpen : IStorage** out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
ole32 = windows.NewLazySystemDLL("OLE32.dll")
procStgOpenStorageOnILockBytes = ole32.NewProc("StgOpenStorageOnILockBytes")
)
// plkbyt (ILockBytes*), pstgPriority (IStorage* optional), grfMode (STGM), snbExclude (WORD** optional), reserved (DWORD optional), ppstgOpen (IStorage** out)
r1, _, err := procStgOpenStorageOnILockBytes.Call(
uintptr(plkbyt),
uintptr(pstgPriority),
uintptr(grfMode),
uintptr(snbExclude),
uintptr(reserved),
uintptr(ppstgOpen),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction StgOpenStorageOnILockBytes(
plkbyt: Pointer; // ILockBytes*
pstgPriority: Pointer; // IStorage* optional
grfMode: DWORD; // STGM
snbExclude: Pointer; // WORD** optional
reserved: DWORD; // DWORD optional
ppstgOpen: Pointer // IStorage** out
): Integer; stdcall;
external 'OLE32.dll' name 'StgOpenStorageOnILockBytes';result := DllCall("OLE32\StgOpenStorageOnILockBytes"
, "Ptr", plkbyt ; ILockBytes*
, "Ptr", pstgPriority ; IStorage* optional
, "UInt", grfMode ; STGM
, "Ptr", snbExclude ; WORD** optional
, "UInt", reserved ; DWORD optional
, "Ptr", ppstgOpen ; IStorage** out
, "Int") ; return: HRESULT●StgOpenStorageOnILockBytes(plkbyt, pstgPriority, grfMode, snbExclude, reserved, ppstgOpen) = DLL("OLE32.dll", "int StgOpenStorageOnILockBytes(void*, void*, dword, void*, dword, void*)")
# 呼び出し: StgOpenStorageOnILockBytes(plkbyt, pstgPriority, grfMode, snbExclude, reserved, ppstgOpen)
# plkbyt : ILockBytes* -> "void*"
# pstgPriority : IStorage* optional -> "void*"
# grfMode : STGM -> "dword"
# snbExclude : WORD** optional -> "void*"
# reserved : DWORD optional -> "dword"
# ppstgOpen : IStorage** out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "ole32" fn StgOpenStorageOnILockBytes(
plkbyt: ?*anyopaque, // ILockBytes*
pstgPriority: ?*anyopaque, // IStorage* optional
grfMode: u32, // STGM
snbExclude: [*c][*c]u16, // WORD** optional
reserved: u32, // DWORD optional
ppstgOpen: ?*anyopaque // IStorage** out
) callconv(std.os.windows.WINAPI) i32;proc StgOpenStorageOnILockBytes(
plkbyt: pointer, # ILockBytes*
pstgPriority: pointer, # IStorage* optional
grfMode: uint32, # STGM
snbExclude: ptr uint16, # WORD** optional
reserved: uint32, # DWORD optional
ppstgOpen: pointer # IStorage** out
): int32 {.importc: "StgOpenStorageOnILockBytes", stdcall, dynlib: "OLE32.dll".}pragma(lib, "ole32");
extern(Windows)
int StgOpenStorageOnILockBytes(
void* plkbyt, // ILockBytes*
void* pstgPriority, // IStorage* optional
uint grfMode, // STGM
ushort** snbExclude, // WORD** optional
uint reserved, // DWORD optional
void* ppstgOpen // IStorage** out
);ccall((:StgOpenStorageOnILockBytes, "OLE32.dll"), stdcall, Int32,
(Ptr{Cvoid}, Ptr{Cvoid}, UInt32, Ptr{UInt16}, UInt32, Ptr{Cvoid}),
plkbyt, pstgPriority, grfMode, snbExclude, reserved, ppstgOpen)
# plkbyt : ILockBytes* -> Ptr{Cvoid}
# pstgPriority : IStorage* optional -> Ptr{Cvoid}
# grfMode : STGM -> UInt32
# snbExclude : WORD** optional -> Ptr{UInt16}
# reserved : DWORD optional -> UInt32
# ppstgOpen : IStorage** out -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t StgOpenStorageOnILockBytes(
void* plkbyt,
void* pstgPriority,
uint32_t grfMode,
uint16_t** snbExclude,
uint32_t reserved,
void* ppstgOpen);
]]
local ole32 = ffi.load("ole32")
-- ole32.StgOpenStorageOnILockBytes(plkbyt, pstgPriority, grfMode, snbExclude, reserved, ppstgOpen)
-- plkbyt : ILockBytes*
-- pstgPriority : IStorage* optional
-- grfMode : STGM
-- snbExclude : WORD** optional
-- reserved : DWORD optional
-- ppstgOpen : IStorage** out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('OLE32.dll');
const StgOpenStorageOnILockBytes = lib.func('__stdcall', 'StgOpenStorageOnILockBytes', 'int32_t', ['void *', 'void *', 'uint32_t', 'uint16_t *', 'uint32_t', 'void *']);
// StgOpenStorageOnILockBytes(plkbyt, pstgPriority, grfMode, snbExclude, reserved, ppstgOpen)
// plkbyt : ILockBytes* -> 'void *'
// pstgPriority : IStorage* optional -> 'void *'
// grfMode : STGM -> 'uint32_t'
// snbExclude : WORD** optional -> 'uint16_t *'
// reserved : DWORD optional -> 'uint32_t'
// ppstgOpen : IStorage** out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("OLE32.dll", {
StgOpenStorageOnILockBytes: { parameters: ["pointer", "pointer", "u32", "pointer", "u32", "pointer"], result: "i32" },
});
// lib.symbols.StgOpenStorageOnILockBytes(plkbyt, pstgPriority, grfMode, snbExclude, reserved, ppstgOpen)
// plkbyt : ILockBytes* -> "pointer"
// pstgPriority : IStorage* optional -> "pointer"
// grfMode : STGM -> "u32"
// snbExclude : WORD** optional -> "pointer"
// reserved : DWORD optional -> "u32"
// ppstgOpen : IStorage** out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t StgOpenStorageOnILockBytes(
void* plkbyt,
void* pstgPriority,
uint32_t grfMode,
uint16_t** snbExclude,
uint32_t reserved,
void* ppstgOpen);
C, "OLE32.dll");
// $ffi->StgOpenStorageOnILockBytes(plkbyt, pstgPriority, grfMode, snbExclude, reserved, ppstgOpen);
// plkbyt : ILockBytes*
// pstgPriority : IStorage* optional
// grfMode : STGM
// snbExclude : WORD** optional
// reserved : DWORD optional
// ppstgOpen : IStorage** out
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
public interface Ole32 extends StdCallLibrary {
Ole32 INSTANCE = Native.load("ole32", Ole32.class);
int StgOpenStorageOnILockBytes(
Pointer plkbyt, // ILockBytes*
Pointer pstgPriority, // IStorage* optional
int grfMode, // STGM
Pointer snbExclude, // WORD** optional
int reserved, // DWORD optional
Pointer ppstgOpen // IStorage** out
);
}@[Link("ole32")]
lib LibOLE32
fun StgOpenStorageOnILockBytes = StgOpenStorageOnILockBytes(
plkbyt : Void*, # ILockBytes*
pstgPriority : Void*, # IStorage* optional
grfMode : UInt32, # STGM
snbExclude : UInt16**, # WORD** optional
reserved : UInt32, # DWORD optional
ppstgOpen : Void* # IStorage** out
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef StgOpenStorageOnILockBytesNative = Int32 Function(Pointer<Void>, Pointer<Void>, Uint32, Pointer<Uint16>, Uint32, Pointer<Void>);
typedef StgOpenStorageOnILockBytesDart = int Function(Pointer<Void>, Pointer<Void>, int, Pointer<Uint16>, int, Pointer<Void>);
final StgOpenStorageOnILockBytes = DynamicLibrary.open('OLE32.dll')
.lookupFunction<StgOpenStorageOnILockBytesNative, StgOpenStorageOnILockBytesDart>('StgOpenStorageOnILockBytes');
// plkbyt : ILockBytes* -> Pointer<Void>
// pstgPriority : IStorage* optional -> Pointer<Void>
// grfMode : STGM -> Uint32
// snbExclude : WORD** optional -> Pointer<Uint16>
// reserved : DWORD optional -> Uint32
// ppstgOpen : IStorage** out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function StgOpenStorageOnILockBytes(
plkbyt: Pointer; // ILockBytes*
pstgPriority: Pointer; // IStorage* optional
grfMode: DWORD; // STGM
snbExclude: Pointer; // WORD** optional
reserved: DWORD; // DWORD optional
ppstgOpen: Pointer // IStorage** out
): Integer; stdcall;
external 'OLE32.dll' name 'StgOpenStorageOnILockBytes';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "StgOpenStorageOnILockBytes"
c_StgOpenStorageOnILockBytes :: Ptr () -> Ptr () -> Word32 -> Ptr Word16 -> Word32 -> Ptr () -> IO Int32
-- plkbyt : ILockBytes* -> Ptr ()
-- pstgPriority : IStorage* optional -> Ptr ()
-- grfMode : STGM -> Word32
-- snbExclude : WORD** optional -> Ptr Word16
-- reserved : DWORD optional -> Word32
-- ppstgOpen : IStorage** out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let stgopenstorageonilockbytes =
foreign "StgOpenStorageOnILockBytes"
((ptr void) @-> (ptr void) @-> uint32_t @-> (ptr uint16_t) @-> uint32_t @-> (ptr void) @-> returning int32_t)
(* plkbyt : ILockBytes* -> (ptr void) *)
(* pstgPriority : IStorage* optional -> (ptr void) *)
(* grfMode : STGM -> uint32_t *)
(* snbExclude : WORD** optional -> (ptr uint16_t) *)
(* reserved : DWORD optional -> uint32_t *)
(* ppstgOpen : IStorage** out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library ole32 (t "OLE32.dll"))
(cffi:use-foreign-library ole32)
(cffi:defcfun ("StgOpenStorageOnILockBytes" stg-open-storage-on-ilock-bytes :convention :stdcall) :int32
(plkbyt :pointer) ; ILockBytes*
(pstg-priority :pointer) ; IStorage* optional
(grf-mode :uint32) ; STGM
(snb-exclude :pointer) ; WORD** optional
(reserved :uint32) ; DWORD optional
(ppstg-open :pointer)) ; IStorage** out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $StgOpenStorageOnILockBytes = Win32::API::More->new('OLE32',
'int StgOpenStorageOnILockBytes(LPVOID plkbyt, LPVOID pstgPriority, DWORD grfMode, LPVOID snbExclude, DWORD reserved, LPVOID ppstgOpen)');
# my $ret = $StgOpenStorageOnILockBytes->Call($plkbyt, $pstgPriority, $grfMode, $snbExclude, $reserved, $ppstgOpen);
# plkbyt : ILockBytes* -> LPVOID
# pstgPriority : IStorage* optional -> LPVOID
# grfMode : STGM -> DWORD
# snbExclude : WORD** optional -> LPVOID
# reserved : DWORD optional -> DWORD
# ppstgOpen : IStorage** out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。