Win32 API 日本語リファレンス
ホームSystem.Ole › OleCreate

OleCreate

関数
指定したCLSIDの新しい埋め込みOLEオブジェクトを作成する。
DLLOLE32.dll呼出規約winapi対応OSWindows 2000 以降

シグネチャ

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

HRESULT OleCreate(
    const GUID* rclsid,
    const GUID* riid,
    DWORD renderopt,
    FORMATETC* pFormatEtc,
    IOleClientSite* pClientSite,
    IStorage* pStg,
    void** ppvObj
);

パラメーター

名前方向
rclsidGUID*in
riidGUID*in
renderoptDWORDin
pFormatEtcFORMATETC*in
pClientSiteIOleClientSite*in
pStgIStorage*in
ppvObjvoid**out

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT OleCreate(
    const GUID* rclsid,
    const GUID* riid,
    DWORD renderopt,
    FORMATETC* pFormatEtc,
    IOleClientSite* pClientSite,
    IStorage* pStg,
    void** ppvObj
);
[DllImport("OLE32.dll", ExactSpelling = true)]
static extern int OleCreate(
    ref Guid rclsid,   // GUID*
    ref Guid riid,   // GUID*
    uint renderopt,   // DWORD
    IntPtr pFormatEtc,   // FORMATETC*
    IntPtr pClientSite,   // IOleClientSite*
    IntPtr pStg,   // IStorage*
    IntPtr ppvObj   // void** out
);
<DllImport("OLE32.dll", ExactSpelling:=True)>
Public Shared Function OleCreate(
    ByRef rclsid As Guid,   ' GUID*
    ByRef riid As Guid,   ' GUID*
    renderopt As UInteger,   ' DWORD
    pFormatEtc As IntPtr,   ' FORMATETC*
    pClientSite As IntPtr,   ' IOleClientSite*
    pStg As IntPtr,   ' IStorage*
    ppvObj As IntPtr   ' void** out
) As Integer
End Function
' rclsid : GUID*
' riid : GUID*
' renderopt : DWORD
' pFormatEtc : FORMATETC*
' pClientSite : IOleClientSite*
' pStg : IStorage*
' ppvObj : void** out
Declare PtrSafe Function OleCreate Lib "ole32" ( _
    ByVal rclsid As LongPtr, _
    ByVal riid As LongPtr, _
    ByVal renderopt As Long, _
    ByVal pFormatEtc As LongPtr, _
    ByVal pClientSite As LongPtr, _
    ByVal pStg As LongPtr, _
    ByVal ppvObj As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

OleCreate = ctypes.windll.ole32.OleCreate
OleCreate.restype = ctypes.c_int
OleCreate.argtypes = [
    ctypes.c_void_p,  # rclsid : GUID*
    ctypes.c_void_p,  # riid : GUID*
    wintypes.DWORD,  # renderopt : DWORD
    ctypes.c_void_p,  # pFormatEtc : FORMATETC*
    ctypes.c_void_p,  # pClientSite : IOleClientSite*
    ctypes.c_void_p,  # pStg : IStorage*
    ctypes.c_void_p,  # ppvObj : void** out
]
require 'fiddle'
require 'fiddle/import'

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

var (
	ole32 = windows.NewLazySystemDLL("OLE32.dll")
	procOleCreate = ole32.NewProc("OleCreate")
)

// rclsid (GUID*), riid (GUID*), renderopt (DWORD), pFormatEtc (FORMATETC*), pClientSite (IOleClientSite*), pStg (IStorage*), ppvObj (void** out)
r1, _, err := procOleCreate.Call(
	uintptr(rclsid),
	uintptr(riid),
	uintptr(renderopt),
	uintptr(pFormatEtc),
	uintptr(pClientSite),
	uintptr(pStg),
	uintptr(ppvObj),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function OleCreate(
  rclsid: PGUID;   // GUID*
  riid: PGUID;   // GUID*
  renderopt: DWORD;   // DWORD
  pFormatEtc: Pointer;   // FORMATETC*
  pClientSite: Pointer;   // IOleClientSite*
  pStg: Pointer;   // IStorage*
  ppvObj: Pointer   // void** out
): Integer; stdcall;
  external 'OLE32.dll' name 'OleCreate';
result := DllCall("OLE32\OleCreate"
    , "Ptr", rclsid   ; GUID*
    , "Ptr", riid   ; GUID*
    , "UInt", renderopt   ; DWORD
    , "Ptr", pFormatEtc   ; FORMATETC*
    , "Ptr", pClientSite   ; IOleClientSite*
    , "Ptr", pStg   ; IStorage*
    , "Ptr", ppvObj   ; void** out
    , "Int")   ; return: HRESULT
●OleCreate(rclsid, riid, renderopt, pFormatEtc, pClientSite, pStg, ppvObj) = DLL("OLE32.dll", "int OleCreate(void*, void*, dword, void*, void*, void*, void*)")
# 呼び出し: OleCreate(rclsid, riid, renderopt, pFormatEtc, pClientSite, pStg, ppvObj)
# rclsid : GUID* -> "void*"
# riid : GUID* -> "void*"
# renderopt : DWORD -> "dword"
# pFormatEtc : FORMATETC* -> "void*"
# pClientSite : IOleClientSite* -> "void*"
# pStg : IStorage* -> "void*"
# ppvObj : void** out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。