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

StgCreateStorageEx

関数
指定形式と属性で新しいストレージオブジェクトを作成する。
DLLOLE32.dll呼出規約winapi対応OSWindows 2000 以降

シグネチャ

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

HRESULT StgCreateStorageEx(
    LPCWSTR pwcsName,   // optional
    STGM grfMode,
    STGFMT stgfmt,
    DWORD grfAttrs,
    STGOPTIONS* pStgOptions,   // optional
    PSECURITY_DESCRIPTOR pSecurityDescriptor,   // optional
    const GUID* riid,
    void** ppObjectOpen
);

パラメーター

名前方向
pwcsNameLPCWSTRinoptional
grfModeSTGMin
stgfmtSTGFMTin
grfAttrsDWORDin
pStgOptionsSTGOPTIONS*inoutoptional
pSecurityDescriptorPSECURITY_DESCRIPTORinoptional
riidGUID*in
ppObjectOpenvoid**out

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT StgCreateStorageEx(
    LPCWSTR pwcsName,   // optional
    STGM grfMode,
    STGFMT stgfmt,
    DWORD grfAttrs,
    STGOPTIONS* pStgOptions,   // optional
    PSECURITY_DESCRIPTOR pSecurityDescriptor,   // optional
    const GUID* riid,
    void** ppObjectOpen
);
[DllImport("OLE32.dll", ExactSpelling = true)]
static extern int StgCreateStorageEx(
    [MarshalAs(UnmanagedType.LPWStr)] string pwcsName,   // LPCWSTR optional
    uint grfMode,   // STGM
    uint stgfmt,   // STGFMT
    uint grfAttrs,   // DWORD
    IntPtr pStgOptions,   // STGOPTIONS* optional, in/out
    IntPtr pSecurityDescriptor,   // PSECURITY_DESCRIPTOR optional
    ref Guid riid,   // GUID*
    IntPtr ppObjectOpen   // void** out
);
<DllImport("OLE32.dll", ExactSpelling:=True)>
Public Shared Function StgCreateStorageEx(
    <MarshalAs(UnmanagedType.LPWStr)> pwcsName As String,   ' LPCWSTR optional
    grfMode As UInteger,   ' STGM
    stgfmt As UInteger,   ' STGFMT
    grfAttrs As UInteger,   ' DWORD
    pStgOptions As IntPtr,   ' STGOPTIONS* optional, in/out
    pSecurityDescriptor As IntPtr,   ' PSECURITY_DESCRIPTOR optional
    ByRef riid As Guid,   ' GUID*
    ppObjectOpen As IntPtr   ' void** out
) As Integer
End Function
' pwcsName : LPCWSTR optional
' grfMode : STGM
' stgfmt : STGFMT
' grfAttrs : DWORD
' pStgOptions : STGOPTIONS* optional, in/out
' pSecurityDescriptor : PSECURITY_DESCRIPTOR optional
' riid : GUID*
' ppObjectOpen : void** out
Declare PtrSafe Function StgCreateStorageEx Lib "ole32" ( _
    ByVal pwcsName As LongPtr, _
    ByVal grfMode As Long, _
    ByVal stgfmt As Long, _
    ByVal grfAttrs As Long, _
    ByVal pStgOptions As LongPtr, _
    ByVal pSecurityDescriptor As LongPtr, _
    ByVal riid As LongPtr, _
    ByVal ppObjectOpen As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

StgCreateStorageEx = ctypes.windll.ole32.StgCreateStorageEx
StgCreateStorageEx.restype = ctypes.c_int
StgCreateStorageEx.argtypes = [
    wintypes.LPCWSTR,  # pwcsName : LPCWSTR optional
    wintypes.DWORD,  # grfMode : STGM
    wintypes.DWORD,  # stgfmt : STGFMT
    wintypes.DWORD,  # grfAttrs : DWORD
    ctypes.c_void_p,  # pStgOptions : STGOPTIONS* optional, in/out
    wintypes.HANDLE,  # pSecurityDescriptor : PSECURITY_DESCRIPTOR optional
    ctypes.c_void_p,  # riid : GUID*
    ctypes.c_void_p,  # ppObjectOpen : void** out
]
require 'fiddle'
require 'fiddle/import'

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

var (
	ole32 = windows.NewLazySystemDLL("OLE32.dll")
	procStgCreateStorageEx = ole32.NewProc("StgCreateStorageEx")
)

// pwcsName (LPCWSTR optional), grfMode (STGM), stgfmt (STGFMT), grfAttrs (DWORD), pStgOptions (STGOPTIONS* optional, in/out), pSecurityDescriptor (PSECURITY_DESCRIPTOR optional), riid (GUID*), ppObjectOpen (void** out)
r1, _, err := procStgCreateStorageEx.Call(
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pwcsName))),
	uintptr(grfMode),
	uintptr(stgfmt),
	uintptr(grfAttrs),
	uintptr(pStgOptions),
	uintptr(pSecurityDescriptor),
	uintptr(riid),
	uintptr(ppObjectOpen),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function StgCreateStorageEx(
  pwcsName: PWideChar;   // LPCWSTR optional
  grfMode: DWORD;   // STGM
  stgfmt: DWORD;   // STGFMT
  grfAttrs: DWORD;   // DWORD
  pStgOptions: Pointer;   // STGOPTIONS* optional, in/out
  pSecurityDescriptor: THandle;   // PSECURITY_DESCRIPTOR optional
  riid: PGUID;   // GUID*
  ppObjectOpen: Pointer   // void** out
): Integer; stdcall;
  external 'OLE32.dll' name 'StgCreateStorageEx';
result := DllCall("OLE32\StgCreateStorageEx"
    , "WStr", pwcsName   ; LPCWSTR optional
    , "UInt", grfMode   ; STGM
    , "UInt", stgfmt   ; STGFMT
    , "UInt", grfAttrs   ; DWORD
    , "Ptr", pStgOptions   ; STGOPTIONS* optional, in/out
    , "Ptr", pSecurityDescriptor   ; PSECURITY_DESCRIPTOR optional
    , "Ptr", riid   ; GUID*
    , "Ptr", ppObjectOpen   ; void** out
    , "Int")   ; return: HRESULT
●StgCreateStorageEx(pwcsName, grfMode, stgfmt, grfAttrs, pStgOptions, pSecurityDescriptor, riid, ppObjectOpen) = DLL("OLE32.dll", "int StgCreateStorageEx(char*, dword, dword, dword, void*, void*, void*, void*)")
# 呼び出し: StgCreateStorageEx(pwcsName, grfMode, stgfmt, grfAttrs, pStgOptions, pSecurityDescriptor, riid, ppObjectOpen)
# pwcsName : LPCWSTR optional -> "char*"
# grfMode : STGM -> "dword"
# stgfmt : STGFMT -> "dword"
# grfAttrs : DWORD -> "dword"
# pStgOptions : STGOPTIONS* optional, in/out -> "void*"
# pSecurityDescriptor : PSECURITY_DESCRIPTOR optional -> "void*"
# riid : GUID* -> "void*"
# ppObjectOpen : void** out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。