ホーム › System.Ole › OleCreateFromFile
OleCreateFromFile
関数指定ファイルから埋め込みOLEオブジェクトを作成する。
シグネチャ
// OLE32.dll
#include <windows.h>
HRESULT OleCreateFromFile(
const GUID* rclsid,
LPCWSTR lpszFileName,
const GUID* riid,
DWORD renderopt,
FORMATETC* lpFormatEtc,
IOleClientSite* pClientSite,
IStorage* pStg,
void** ppvObj
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| rclsid | GUID* | in |
| lpszFileName | LPCWSTR | in |
| riid | GUID* | in |
| renderopt | DWORD | in |
| lpFormatEtc | FORMATETC* | in |
| pClientSite | IOleClientSite* | in |
| pStg | IStorage* | in |
| ppvObj | void** | out |
戻り値の型: HRESULT
各言語での呼び出し定義
// OLE32.dll
#include <windows.h>
HRESULT OleCreateFromFile(
const GUID* rclsid,
LPCWSTR lpszFileName,
const GUID* riid,
DWORD renderopt,
FORMATETC* lpFormatEtc,
IOleClientSite* pClientSite,
IStorage* pStg,
void** ppvObj
);[DllImport("OLE32.dll", ExactSpelling = true)]
static extern int OleCreateFromFile(
ref Guid rclsid, // GUID*
[MarshalAs(UnmanagedType.LPWStr)] string lpszFileName, // LPCWSTR
ref Guid riid, // GUID*
uint renderopt, // DWORD
IntPtr lpFormatEtc, // FORMATETC*
IntPtr pClientSite, // IOleClientSite*
IntPtr pStg, // IStorage*
IntPtr ppvObj // void** out
);<DllImport("OLE32.dll", ExactSpelling:=True)>
Public Shared Function OleCreateFromFile(
ByRef rclsid As Guid, ' GUID*
<MarshalAs(UnmanagedType.LPWStr)> lpszFileName As String, ' LPCWSTR
ByRef riid As Guid, ' GUID*
renderopt As UInteger, ' DWORD
lpFormatEtc As IntPtr, ' FORMATETC*
pClientSite As IntPtr, ' IOleClientSite*
pStg As IntPtr, ' IStorage*
ppvObj As IntPtr ' void** out
) As Integer
End Function' rclsid : GUID*
' lpszFileName : LPCWSTR
' riid : GUID*
' renderopt : DWORD
' lpFormatEtc : FORMATETC*
' pClientSite : IOleClientSite*
' pStg : IStorage*
' ppvObj : void** out
Declare PtrSafe Function OleCreateFromFile Lib "ole32" ( _
ByVal rclsid As LongPtr, _
ByVal lpszFileName As LongPtr, _
ByVal riid As LongPtr, _
ByVal renderopt As Long, _
ByVal lpFormatEtc 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
OleCreateFromFile = ctypes.windll.ole32.OleCreateFromFile
OleCreateFromFile.restype = ctypes.c_int
OleCreateFromFile.argtypes = [
ctypes.c_void_p, # rclsid : GUID*
wintypes.LPCWSTR, # lpszFileName : LPCWSTR
ctypes.c_void_p, # riid : GUID*
wintypes.DWORD, # renderopt : DWORD
ctypes.c_void_p, # lpFormatEtc : 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')
OleCreateFromFile = Fiddle::Function.new(
lib['OleCreateFromFile'],
[
Fiddle::TYPE_VOIDP, # rclsid : GUID*
Fiddle::TYPE_VOIDP, # lpszFileName : LPCWSTR
Fiddle::TYPE_VOIDP, # riid : GUID*
-Fiddle::TYPE_INT, # renderopt : DWORD
Fiddle::TYPE_VOIDP, # lpFormatEtc : 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 OleCreateFromFile(
rclsid: *const GUID, // GUID*
lpszFileName: *const u16, // LPCWSTR
riid: *const GUID, // GUID*
renderopt: u32, // DWORD
lpFormatEtc: *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 OleCreateFromFile(ref Guid rclsid, [MarshalAs(UnmanagedType.LPWStr)] string lpszFileName, ref Guid riid, uint renderopt, IntPtr lpFormatEtc, IntPtr pClientSite, IntPtr pStg, IntPtr ppvObj);
"@
$api = Add-Type -MemberDefinition $sig -Name 'OLE32_OleCreateFromFile' -Namespace Win32 -PassThru
# $api::OleCreateFromFile(rclsid, lpszFileName, riid, renderopt, lpFormatEtc, pClientSite, pStg, ppvObj)#uselib "OLE32.dll"
#func global OleCreateFromFile "OleCreateFromFile" sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr
; OleCreateFromFile varptr(rclsid), lpszFileName, varptr(riid), renderopt, varptr(lpFormatEtc), pClientSite, pStg, ppvObj ; 戻り値は stat
; rclsid : GUID* -> "sptr"
; lpszFileName : LPCWSTR -> "sptr"
; riid : GUID* -> "sptr"
; renderopt : DWORD -> "sptr"
; lpFormatEtc : FORMATETC* -> "sptr"
; pClientSite : IOleClientSite* -> "sptr"
; pStg : IStorage* -> "sptr"
; ppvObj : void** out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "OLE32.dll" #cfunc global OleCreateFromFile "OleCreateFromFile" var, wstr, var, int, var, sptr, sptr, sptr ; res = OleCreateFromFile(rclsid, lpszFileName, riid, renderopt, lpFormatEtc, pClientSite, pStg, ppvObj) ; rclsid : GUID* -> "var" ; lpszFileName : LPCWSTR -> "wstr" ; riid : GUID* -> "var" ; renderopt : DWORD -> "int" ; lpFormatEtc : FORMATETC* -> "var" ; pClientSite : IOleClientSite* -> "sptr" ; pStg : IStorage* -> "sptr" ; ppvObj : void** out -> "sptr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "OLE32.dll" #cfunc global OleCreateFromFile "OleCreateFromFile" sptr, wstr, sptr, int, sptr, sptr, sptr, sptr ; res = OleCreateFromFile(varptr(rclsid), lpszFileName, varptr(riid), renderopt, varptr(lpFormatEtc), pClientSite, pStg, ppvObj) ; rclsid : GUID* -> "sptr" ; lpszFileName : LPCWSTR -> "wstr" ; riid : GUID* -> "sptr" ; renderopt : DWORD -> "int" ; lpFormatEtc : FORMATETC* -> "sptr" ; pClientSite : IOleClientSite* -> "sptr" ; pStg : IStorage* -> "sptr" ; ppvObj : void** out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HRESULT OleCreateFromFile(GUID* rclsid, LPCWSTR lpszFileName, GUID* riid, DWORD renderopt, FORMATETC* lpFormatEtc, IOleClientSite* pClientSite, IStorage* pStg, void** ppvObj) #uselib "OLE32.dll" #cfunc global OleCreateFromFile "OleCreateFromFile" var, wstr, var, int, var, intptr, intptr, intptr ; res = OleCreateFromFile(rclsid, lpszFileName, riid, renderopt, lpFormatEtc, pClientSite, pStg, ppvObj) ; rclsid : GUID* -> "var" ; lpszFileName : LPCWSTR -> "wstr" ; riid : GUID* -> "var" ; renderopt : DWORD -> "int" ; lpFormatEtc : FORMATETC* -> "var" ; pClientSite : IOleClientSite* -> "intptr" ; pStg : IStorage* -> "intptr" ; ppvObj : void** out -> "intptr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HRESULT OleCreateFromFile(GUID* rclsid, LPCWSTR lpszFileName, GUID* riid, DWORD renderopt, FORMATETC* lpFormatEtc, IOleClientSite* pClientSite, IStorage* pStg, void** ppvObj) #uselib "OLE32.dll" #cfunc global OleCreateFromFile "OleCreateFromFile" intptr, wstr, intptr, int, intptr, intptr, intptr, intptr ; res = OleCreateFromFile(varptr(rclsid), lpszFileName, varptr(riid), renderopt, varptr(lpFormatEtc), pClientSite, pStg, ppvObj) ; rclsid : GUID* -> "intptr" ; lpszFileName : LPCWSTR -> "wstr" ; riid : GUID* -> "intptr" ; renderopt : DWORD -> "int" ; lpFormatEtc : FORMATETC* -> "intptr" ; pClientSite : IOleClientSite* -> "intptr" ; pStg : IStorage* -> "intptr" ; ppvObj : void** out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
ole32 = windows.NewLazySystemDLL("OLE32.dll")
procOleCreateFromFile = ole32.NewProc("OleCreateFromFile")
)
// rclsid (GUID*), lpszFileName (LPCWSTR), riid (GUID*), renderopt (DWORD), lpFormatEtc (FORMATETC*), pClientSite (IOleClientSite*), pStg (IStorage*), ppvObj (void** out)
r1, _, err := procOleCreateFromFile.Call(
uintptr(rclsid),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(lpszFileName))),
uintptr(riid),
uintptr(renderopt),
uintptr(lpFormatEtc),
uintptr(pClientSite),
uintptr(pStg),
uintptr(ppvObj),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction OleCreateFromFile(
rclsid: PGUID; // GUID*
lpszFileName: PWideChar; // LPCWSTR
riid: PGUID; // GUID*
renderopt: DWORD; // DWORD
lpFormatEtc: Pointer; // FORMATETC*
pClientSite: Pointer; // IOleClientSite*
pStg: Pointer; // IStorage*
ppvObj: Pointer // void** out
): Integer; stdcall;
external 'OLE32.dll' name 'OleCreateFromFile';result := DllCall("OLE32\OleCreateFromFile"
, "Ptr", rclsid ; GUID*
, "WStr", lpszFileName ; LPCWSTR
, "Ptr", riid ; GUID*
, "UInt", renderopt ; DWORD
, "Ptr", lpFormatEtc ; FORMATETC*
, "Ptr", pClientSite ; IOleClientSite*
, "Ptr", pStg ; IStorage*
, "Ptr", ppvObj ; void** out
, "Int") ; return: HRESULT●OleCreateFromFile(rclsid, lpszFileName, riid, renderopt, lpFormatEtc, pClientSite, pStg, ppvObj) = DLL("OLE32.dll", "int OleCreateFromFile(void*, char*, void*, dword, void*, void*, void*, void*)")
# 呼び出し: OleCreateFromFile(rclsid, lpszFileName, riid, renderopt, lpFormatEtc, pClientSite, pStg, ppvObj)
# rclsid : GUID* -> "void*"
# lpszFileName : LPCWSTR -> "char*"
# riid : GUID* -> "void*"
# renderopt : DWORD -> "dword"
# lpFormatEtc : FORMATETC* -> "void*"
# pClientSite : IOleClientSite* -> "void*"
# pStg : IStorage* -> "void*"
# ppvObj : void** out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。