Win32 API 日本語リファレンス
ホームSystem.Com.StructuredStorage › StgOpenPropStg

StgOpenPropStg

関数
指定書式IDの既存プロパティストレージを開く。
DLLOLE32.dll呼出規約winapi対応OSWindows 2000 以降

シグネチャ

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

HRESULT StgOpenPropStg(
    IUnknown* pUnk,
    const GUID* fmtid,
    DWORD grfFlags,
    DWORD dwReserved,   // optional
    IPropertyStorage** ppPropStg
);

パラメーター

名前方向
pUnkIUnknown*in
fmtidGUID*in
grfFlagsDWORDin
dwReservedDWORDoptional
ppPropStgIPropertyStorage**out

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT StgOpenPropStg(
    IUnknown* pUnk,
    const GUID* fmtid,
    DWORD grfFlags,
    DWORD dwReserved,   // optional
    IPropertyStorage** ppPropStg
);
[DllImport("OLE32.dll", ExactSpelling = true)]
static extern int StgOpenPropStg(
    IntPtr pUnk,   // IUnknown*
    ref Guid fmtid,   // GUID*
    uint grfFlags,   // DWORD
    uint dwReserved,   // DWORD optional
    IntPtr ppPropStg   // IPropertyStorage** out
);
<DllImport("OLE32.dll", ExactSpelling:=True)>
Public Shared Function StgOpenPropStg(
    pUnk As IntPtr,   ' IUnknown*
    ByRef fmtid As Guid,   ' GUID*
    grfFlags As UInteger,   ' DWORD
    dwReserved As UInteger,   ' DWORD optional
    ppPropStg As IntPtr   ' IPropertyStorage** out
) As Integer
End Function
' pUnk : IUnknown*
' fmtid : GUID*
' grfFlags : DWORD
' dwReserved : DWORD optional
' ppPropStg : IPropertyStorage** out
Declare PtrSafe Function StgOpenPropStg Lib "ole32" ( _
    ByVal pUnk As LongPtr, _
    ByVal fmtid As LongPtr, _
    ByVal grfFlags As Long, _
    ByVal dwReserved As Long, _
    ByVal ppPropStg As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

StgOpenPropStg = ctypes.windll.ole32.StgOpenPropStg
StgOpenPropStg.restype = ctypes.c_int
StgOpenPropStg.argtypes = [
    ctypes.c_void_p,  # pUnk : IUnknown*
    ctypes.c_void_p,  # fmtid : GUID*
    wintypes.DWORD,  # grfFlags : DWORD
    wintypes.DWORD,  # dwReserved : DWORD optional
    ctypes.c_void_p,  # ppPropStg : IPropertyStorage** out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('OLE32.dll')
StgOpenPropStg = Fiddle::Function.new(
  lib['StgOpenPropStg'],
  [
    Fiddle::TYPE_VOIDP,  # pUnk : IUnknown*
    Fiddle::TYPE_VOIDP,  # fmtid : GUID*
    -Fiddle::TYPE_INT,  # grfFlags : DWORD
    -Fiddle::TYPE_INT,  # dwReserved : DWORD optional
    Fiddle::TYPE_VOIDP,  # ppPropStg : IPropertyStorage** out
  ],
  Fiddle::TYPE_INT)
#[link(name = "ole32")]
extern "system" {
    fn StgOpenPropStg(
        pUnk: *mut core::ffi::c_void,  // IUnknown*
        fmtid: *const GUID,  // GUID*
        grfFlags: u32,  // DWORD
        dwReserved: u32,  // DWORD optional
        ppPropStg: *mut *mut core::ffi::c_void  // IPropertyStorage** out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("OLE32.dll")]
public static extern int StgOpenPropStg(IntPtr pUnk, ref Guid fmtid, uint grfFlags, uint dwReserved, IntPtr ppPropStg);
"@
$api = Add-Type -MemberDefinition $sig -Name 'OLE32_StgOpenPropStg' -Namespace Win32 -PassThru
# $api::StgOpenPropStg(pUnk, fmtid, grfFlags, dwReserved, ppPropStg)
#uselib "OLE32.dll"
#func global StgOpenPropStg "StgOpenPropStg" sptr, sptr, sptr, sptr, sptr
; StgOpenPropStg pUnk, varptr(fmtid), grfFlags, dwReserved, ppPropStg   ; 戻り値は stat
; pUnk : IUnknown* -> "sptr"
; fmtid : GUID* -> "sptr"
; grfFlags : DWORD -> "sptr"
; dwReserved : DWORD optional -> "sptr"
; ppPropStg : IPropertyStorage** out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "OLE32.dll"
#cfunc global StgOpenPropStg "StgOpenPropStg" sptr, var, int, int, sptr
; res = StgOpenPropStg(pUnk, fmtid, grfFlags, dwReserved, ppPropStg)
; pUnk : IUnknown* -> "sptr"
; fmtid : GUID* -> "var"
; grfFlags : DWORD -> "int"
; dwReserved : DWORD optional -> "int"
; ppPropStg : IPropertyStorage** out -> "sptr"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; HRESULT StgOpenPropStg(IUnknown* pUnk, GUID* fmtid, DWORD grfFlags, DWORD dwReserved, IPropertyStorage** ppPropStg)
#uselib "OLE32.dll"
#cfunc global StgOpenPropStg "StgOpenPropStg" intptr, var, int, int, intptr
; res = StgOpenPropStg(pUnk, fmtid, grfFlags, dwReserved, ppPropStg)
; pUnk : IUnknown* -> "intptr"
; fmtid : GUID* -> "var"
; grfFlags : DWORD -> "int"
; dwReserved : DWORD optional -> "int"
; ppPropStg : IPropertyStorage** out -> "intptr"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	ole32 = windows.NewLazySystemDLL("OLE32.dll")
	procStgOpenPropStg = ole32.NewProc("StgOpenPropStg")
)

// pUnk (IUnknown*), fmtid (GUID*), grfFlags (DWORD), dwReserved (DWORD optional), ppPropStg (IPropertyStorage** out)
r1, _, err := procStgOpenPropStg.Call(
	uintptr(pUnk),
	uintptr(fmtid),
	uintptr(grfFlags),
	uintptr(dwReserved),
	uintptr(ppPropStg),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function StgOpenPropStg(
  pUnk: Pointer;   // IUnknown*
  fmtid: PGUID;   // GUID*
  grfFlags: DWORD;   // DWORD
  dwReserved: DWORD;   // DWORD optional
  ppPropStg: Pointer   // IPropertyStorage** out
): Integer; stdcall;
  external 'OLE32.dll' name 'StgOpenPropStg';
result := DllCall("OLE32\StgOpenPropStg"
    , "Ptr", pUnk   ; IUnknown*
    , "Ptr", fmtid   ; GUID*
    , "UInt", grfFlags   ; DWORD
    , "UInt", dwReserved   ; DWORD optional
    , "Ptr", ppPropStg   ; IPropertyStorage** out
    , "Int")   ; return: HRESULT
●StgOpenPropStg(pUnk, fmtid, grfFlags, dwReserved, ppPropStg) = DLL("OLE32.dll", "int StgOpenPropStg(void*, void*, dword, dword, void*)")
# 呼び出し: StgOpenPropStg(pUnk, fmtid, grfFlags, dwReserved, ppPropStg)
# pUnk : IUnknown* -> "void*"
# fmtid : GUID* -> "void*"
# grfFlags : DWORD -> "dword"
# dwReserved : DWORD optional -> "dword"
# ppPropStg : IPropertyStorage** out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。