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作成するストレージのパス名(ワイド文字列)。NULLで一時ファイル。
grfModeSTGMinアクセス・作成方法を示すSTGMフラグ。
stgfmtSTGFMTinストレージの格納形式を示すSTGFMT値。Docfileやファイルシステム等。
grfAttrsDWORDin予約属性フラグ。通常0を指定する。
pStgOptionsSTGOPTIONS*inoutoptionalセクタサイズ等を指定するSTGOPTIONS構造体へのポインタ。NULL可。
pSecurityDescriptorPSECURITY_DESCRIPTORinoptional適用するセキュリティ記述子へのポインタ。NULL可。
riidGUID*in取得したいインターフェイスのIID(GUID)へのポインタ。
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)。
const std = @import("std");

extern "ole32" fn StgCreateStorageEx(
    pwcsName: [*c]const u16, // LPCWSTR optional
    grfMode: u32, // STGM
    stgfmt: u32, // STGFMT
    grfAttrs: u32, // DWORD
    pStgOptions: [*c]STGOPTIONS, // STGOPTIONS* optional, in/out
    pSecurityDescriptor: ?*anyopaque, // PSECURITY_DESCRIPTOR optional
    riid: [*c]GUID, // GUID*
    ppObjectOpen: ?*anyopaque // void** out
) callconv(std.os.windows.WINAPI) i32;
proc StgCreateStorageEx(
    pwcsName: WideCString,  # LPCWSTR optional
    grfMode: uint32,  # STGM
    stgfmt: uint32,  # STGFMT
    grfAttrs: uint32,  # DWORD
    pStgOptions: ptr STGOPTIONS,  # STGOPTIONS* optional, in/out
    pSecurityDescriptor: pointer,  # PSECURITY_DESCRIPTOR optional
    riid: ptr GUID,  # GUID*
    ppObjectOpen: pointer  # void** out
): int32 {.importc: "StgCreateStorageEx", stdcall, dynlib: "OLE32.dll".}
pragma(lib, "ole32");
extern(Windows)
int StgCreateStorageEx(
    const(wchar)* pwcsName,   // LPCWSTR optional
    uint grfMode,   // STGM
    uint stgfmt,   // STGFMT
    uint grfAttrs,   // DWORD
    STGOPTIONS* pStgOptions,   // STGOPTIONS* optional, in/out
    void* pSecurityDescriptor,   // PSECURITY_DESCRIPTOR optional
    GUID* riid,   // GUID*
    void** ppObjectOpen   // void** out
);
ccall((:StgCreateStorageEx, "OLE32.dll"), stdcall, Int32,
      (Cwstring, UInt32, UInt32, UInt32, Ptr{STGOPTIONS}, Ptr{Cvoid}, Ptr{GUID}, Ptr{Cvoid}),
      pwcsName, grfMode, stgfmt, grfAttrs, pStgOptions, pSecurityDescriptor, riid, ppObjectOpen)
# pwcsName : LPCWSTR optional -> Cwstring
# grfMode : STGM -> UInt32
# stgfmt : STGFMT -> UInt32
# grfAttrs : DWORD -> UInt32
# pStgOptions : STGOPTIONS* optional, in/out -> Ptr{STGOPTIONS}
# pSecurityDescriptor : PSECURITY_DESCRIPTOR optional -> Ptr{Cvoid}
# riid : GUID* -> Ptr{GUID}
# ppObjectOpen : void** out -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t StgCreateStorageEx(
    const uint16_t* pwcsName,
    uint32_t grfMode,
    uint32_t stgfmt,
    uint32_t grfAttrs,
    void* pStgOptions,
    void* pSecurityDescriptor,
    void* riid,
    void** ppObjectOpen);
]]
local ole32 = ffi.load("ole32")
-- ole32.StgCreateStorageEx(pwcsName, grfMode, stgfmt, grfAttrs, pStgOptions, pSecurityDescriptor, riid, ppObjectOpen)
-- pwcsName : LPCWSTR optional
-- grfMode : STGM
-- stgfmt : STGFMT
-- grfAttrs : DWORD
-- pStgOptions : STGOPTIONS* optional, in/out
-- pSecurityDescriptor : PSECURITY_DESCRIPTOR optional
-- riid : GUID*
-- ppObjectOpen : void** out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('OLE32.dll');
const StgCreateStorageEx = lib.func('__stdcall', 'StgCreateStorageEx', 'int32_t', ['str16', 'uint32_t', 'uint32_t', 'uint32_t', 'void *', 'void *', 'void *', 'void *']);
// StgCreateStorageEx(pwcsName, grfMode, stgfmt, grfAttrs, pStgOptions, pSecurityDescriptor, riid, ppObjectOpen)
// pwcsName : LPCWSTR optional -> 'str16'
// grfMode : STGM -> 'uint32_t'
// stgfmt : STGFMT -> 'uint32_t'
// grfAttrs : DWORD -> 'uint32_t'
// pStgOptions : STGOPTIONS* optional, in/out -> 'void *'
// pSecurityDescriptor : PSECURITY_DESCRIPTOR optional -> 'void *'
// riid : GUID* -> 'void *'
// ppObjectOpen : void** out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("OLE32.dll", {
  StgCreateStorageEx: { parameters: ["buffer", "u32", "u32", "u32", "pointer", "pointer", "pointer", "pointer"], result: "i32" },
});
// lib.symbols.StgCreateStorageEx(pwcsName, grfMode, stgfmt, grfAttrs, pStgOptions, pSecurityDescriptor, riid, ppObjectOpen)
// pwcsName : LPCWSTR optional -> "buffer"
// grfMode : STGM -> "u32"
// stgfmt : STGFMT -> "u32"
// grfAttrs : DWORD -> "u32"
// pStgOptions : STGOPTIONS* optional, in/out -> "pointer"
// pSecurityDescriptor : PSECURITY_DESCRIPTOR optional -> "pointer"
// riid : GUID* -> "pointer"
// ppObjectOpen : void** out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t StgCreateStorageEx(
    const uint16_t* pwcsName,
    uint32_t grfMode,
    uint32_t stgfmt,
    uint32_t grfAttrs,
    void* pStgOptions,
    void* pSecurityDescriptor,
    void* riid,
    void** ppObjectOpen);
C, "OLE32.dll");
// $ffi->StgCreateStorageEx(pwcsName, grfMode, stgfmt, grfAttrs, pStgOptions, pSecurityDescriptor, riid, ppObjectOpen);
// pwcsName : LPCWSTR optional
// grfMode : STGM
// stgfmt : STGFMT
// grfAttrs : DWORD
// pStgOptions : STGOPTIONS* optional, in/out
// pSecurityDescriptor : PSECURITY_DESCRIPTOR optional
// riid : GUID*
// ppObjectOpen : void** 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 StgCreateStorageEx(
        WString pwcsName,   // LPCWSTR optional
        int grfMode,   // STGM
        int stgfmt,   // STGFMT
        int grfAttrs,   // DWORD
        Pointer pStgOptions,   // STGOPTIONS* optional, in/out
        Pointer pSecurityDescriptor,   // PSECURITY_DESCRIPTOR optional
        Pointer riid,   // GUID*
        Pointer ppObjectOpen   // void** out
    );
}
@[Link("ole32")]
lib LibOLE32
  fun StgCreateStorageEx = StgCreateStorageEx(
    pwcsName : UInt16*,   # LPCWSTR optional
    grfMode : UInt32,   # STGM
    stgfmt : UInt32,   # STGFMT
    grfAttrs : UInt32,   # DWORD
    pStgOptions : STGOPTIONS*,   # STGOPTIONS* optional, in/out
    pSecurityDescriptor : Void*,   # PSECURITY_DESCRIPTOR optional
    riid : GUID*,   # GUID*
    ppObjectOpen : Void**   # void** out
  ) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef StgCreateStorageExNative = Int32 Function(Pointer<Utf16>, Uint32, Uint32, Uint32, Pointer<Void>, Pointer<Void>, Pointer<Void>, Pointer<Void>);
typedef StgCreateStorageExDart = int Function(Pointer<Utf16>, int, int, int, Pointer<Void>, Pointer<Void>, Pointer<Void>, Pointer<Void>);
final StgCreateStorageEx = DynamicLibrary.open('OLE32.dll')
    .lookupFunction<StgCreateStorageExNative, StgCreateStorageExDart>('StgCreateStorageEx');
// pwcsName : LPCWSTR optional -> Pointer<Utf16>
// grfMode : STGM -> Uint32
// stgfmt : STGFMT -> Uint32
// grfAttrs : DWORD -> Uint32
// pStgOptions : STGOPTIONS* optional, in/out -> Pointer<Void>
// pSecurityDescriptor : PSECURITY_DESCRIPTOR optional -> Pointer<Void>
// riid : GUID* -> Pointer<Void>
// ppObjectOpen : void** out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
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';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "StgCreateStorageEx"
  c_StgCreateStorageEx :: CWString -> Word32 -> Word32 -> Word32 -> Ptr () -> Ptr () -> Ptr () -> Ptr () -> IO Int32
-- pwcsName : LPCWSTR optional -> CWString
-- grfMode : STGM -> Word32
-- stgfmt : STGFMT -> Word32
-- grfAttrs : DWORD -> Word32
-- pStgOptions : STGOPTIONS* optional, in/out -> Ptr ()
-- pSecurityDescriptor : PSECURITY_DESCRIPTOR optional -> Ptr ()
-- riid : GUID* -> Ptr ()
-- ppObjectOpen : void** out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let stgcreatestorageex =
  foreign "StgCreateStorageEx"
    ((ptr uint16_t) @-> uint32_t @-> uint32_t @-> uint32_t @-> (ptr void) @-> (ptr void) @-> (ptr void) @-> (ptr void) @-> returning int32_t)
(* pwcsName : LPCWSTR optional -> (ptr uint16_t) *)
(* grfMode : STGM -> uint32_t *)
(* stgfmt : STGFMT -> uint32_t *)
(* grfAttrs : DWORD -> uint32_t *)
(* pStgOptions : STGOPTIONS* optional, in/out -> (ptr void) *)
(* pSecurityDescriptor : PSECURITY_DESCRIPTOR optional -> (ptr void) *)
(* riid : GUID* -> (ptr void) *)
(* ppObjectOpen : void** 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 ("StgCreateStorageEx" stg-create-storage-ex :convention :stdcall) :int32
  (pwcs-name (:string :encoding :utf-16le))   ; LPCWSTR optional
  (grf-mode :uint32)   ; STGM
  (stgfmt :uint32)   ; STGFMT
  (grf-attrs :uint32)   ; DWORD
  (p-stg-options :pointer)   ; STGOPTIONS* optional, in/out
  (p-security-descriptor :pointer)   ; PSECURITY_DESCRIPTOR optional
  (riid :pointer)   ; GUID*
  (pp-object-open :pointer))   ; void** out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $StgCreateStorageEx = Win32::API::More->new('OLE32',
    'int StgCreateStorageEx(LPCWSTR pwcsName, DWORD grfMode, DWORD stgfmt, DWORD grfAttrs, LPVOID pStgOptions, HANDLE pSecurityDescriptor, LPVOID riid, LPVOID ppObjectOpen)');
# my $ret = $StgCreateStorageEx->Call($pwcsName, $grfMode, $stgfmt, $grfAttrs, $pStgOptions, $pSecurityDescriptor, $riid, $ppObjectOpen);
# pwcsName : LPCWSTR optional -> LPCWSTR
# grfMode : STGM -> DWORD
# stgfmt : STGFMT -> DWORD
# grfAttrs : DWORD -> DWORD
# pStgOptions : STGOPTIONS* optional, in/out -> LPVOID
# pSecurityDescriptor : PSECURITY_DESCRIPTOR optional -> HANDLE
# riid : GUID* -> LPVOID
# ppObjectOpen : void** out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

使用する型