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

StgOpenLayoutDocfile

関数
レイアウト最適化された複合ドキュメントファイルを開く。
DLLdflayout.dll呼出規約winapi

シグネチャ

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

HRESULT StgOpenLayoutDocfile(
    LPCWSTR pwcsDfName,
    DWORD grfMode,
    DWORD reserved,
    IStorage** ppstgOpen
);

パラメーター

名前方向
pwcsDfNameLPCWSTRin
grfModeDWORDin
reservedDWORDin
ppstgOpenIStorage**out

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT StgOpenLayoutDocfile(
    LPCWSTR pwcsDfName,
    DWORD grfMode,
    DWORD reserved,
    IStorage** ppstgOpen
);
[DllImport("dflayout.dll", ExactSpelling = true)]
static extern int StgOpenLayoutDocfile(
    [MarshalAs(UnmanagedType.LPWStr)] string pwcsDfName,   // LPCWSTR
    uint grfMode,   // DWORD
    uint reserved,   // DWORD
    IntPtr ppstgOpen   // IStorage** out
);
<DllImport("dflayout.dll", ExactSpelling:=True)>
Public Shared Function StgOpenLayoutDocfile(
    <MarshalAs(UnmanagedType.LPWStr)> pwcsDfName As String,   ' LPCWSTR
    grfMode As UInteger,   ' DWORD
    reserved As UInteger,   ' DWORD
    ppstgOpen As IntPtr   ' IStorage** out
) As Integer
End Function
' pwcsDfName : LPCWSTR
' grfMode : DWORD
' reserved : DWORD
' ppstgOpen : IStorage** out
Declare PtrSafe Function StgOpenLayoutDocfile Lib "dflayout" ( _
    ByVal pwcsDfName As LongPtr, _
    ByVal grfMode As Long, _
    ByVal reserved As Long, _
    ByVal ppstgOpen As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

StgOpenLayoutDocfile = ctypes.windll.dflayout.StgOpenLayoutDocfile
StgOpenLayoutDocfile.restype = ctypes.c_int
StgOpenLayoutDocfile.argtypes = [
    wintypes.LPCWSTR,  # pwcsDfName : LPCWSTR
    wintypes.DWORD,  # grfMode : DWORD
    wintypes.DWORD,  # reserved : DWORD
    ctypes.c_void_p,  # ppstgOpen : IStorage** out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('dflayout.dll')
StgOpenLayoutDocfile = Fiddle::Function.new(
  lib['StgOpenLayoutDocfile'],
  [
    Fiddle::TYPE_VOIDP,  # pwcsDfName : LPCWSTR
    -Fiddle::TYPE_INT,  # grfMode : DWORD
    -Fiddle::TYPE_INT,  # reserved : DWORD
    Fiddle::TYPE_VOIDP,  # ppstgOpen : IStorage** out
  ],
  Fiddle::TYPE_INT)
#[link(name = "dflayout")]
extern "system" {
    fn StgOpenLayoutDocfile(
        pwcsDfName: *const u16,  // LPCWSTR
        grfMode: u32,  // DWORD
        reserved: u32,  // DWORD
        ppstgOpen: *mut *mut core::ffi::c_void  // IStorage** out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("dflayout.dll")]
public static extern int StgOpenLayoutDocfile([MarshalAs(UnmanagedType.LPWStr)] string pwcsDfName, uint grfMode, uint reserved, IntPtr ppstgOpen);
"@
$api = Add-Type -MemberDefinition $sig -Name 'dflayout_StgOpenLayoutDocfile' -Namespace Win32 -PassThru
# $api::StgOpenLayoutDocfile(pwcsDfName, grfMode, reserved, ppstgOpen)
#uselib "dflayout.dll"
#func global StgOpenLayoutDocfile "StgOpenLayoutDocfile" sptr, sptr, sptr, sptr
; StgOpenLayoutDocfile pwcsDfName, grfMode, reserved, ppstgOpen   ; 戻り値は stat
; pwcsDfName : LPCWSTR -> "sptr"
; grfMode : DWORD -> "sptr"
; reserved : DWORD -> "sptr"
; ppstgOpen : IStorage** out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "dflayout.dll"
#cfunc global StgOpenLayoutDocfile "StgOpenLayoutDocfile" wstr, int, int, sptr
; res = StgOpenLayoutDocfile(pwcsDfName, grfMode, reserved, ppstgOpen)
; pwcsDfName : LPCWSTR -> "wstr"
; grfMode : DWORD -> "int"
; reserved : DWORD -> "int"
; ppstgOpen : IStorage** out -> "sptr"
; HRESULT StgOpenLayoutDocfile(LPCWSTR pwcsDfName, DWORD grfMode, DWORD reserved, IStorage** ppstgOpen)
#uselib "dflayout.dll"
#cfunc global StgOpenLayoutDocfile "StgOpenLayoutDocfile" wstr, int, int, intptr
; res = StgOpenLayoutDocfile(pwcsDfName, grfMode, reserved, ppstgOpen)
; pwcsDfName : LPCWSTR -> "wstr"
; grfMode : DWORD -> "int"
; reserved : DWORD -> "int"
; ppstgOpen : IStorage** out -> "intptr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	dflayout = windows.NewLazySystemDLL("dflayout.dll")
	procStgOpenLayoutDocfile = dflayout.NewProc("StgOpenLayoutDocfile")
)

// pwcsDfName (LPCWSTR), grfMode (DWORD), reserved (DWORD), ppstgOpen (IStorage** out)
r1, _, err := procStgOpenLayoutDocfile.Call(
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pwcsDfName))),
	uintptr(grfMode),
	uintptr(reserved),
	uintptr(ppstgOpen),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function StgOpenLayoutDocfile(
  pwcsDfName: PWideChar;   // LPCWSTR
  grfMode: DWORD;   // DWORD
  reserved: DWORD;   // DWORD
  ppstgOpen: Pointer   // IStorage** out
): Integer; stdcall;
  external 'dflayout.dll' name 'StgOpenLayoutDocfile';
result := DllCall("dflayout\StgOpenLayoutDocfile"
    , "WStr", pwcsDfName   ; LPCWSTR
    , "UInt", grfMode   ; DWORD
    , "UInt", reserved   ; DWORD
    , "Ptr", ppstgOpen   ; IStorage** out
    , "Int")   ; return: HRESULT
●StgOpenLayoutDocfile(pwcsDfName, grfMode, reserved, ppstgOpen) = DLL("dflayout.dll", "int StgOpenLayoutDocfile(char*, dword, dword, void*)")
# 呼び出し: StgOpenLayoutDocfile(pwcsDfName, grfMode, reserved, ppstgOpen)
# pwcsDfName : LPCWSTR -> "char*"
# grfMode : DWORD -> "dword"
# reserved : DWORD -> "dword"
# ppstgOpen : IStorage** out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。