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

ReadFmtUserTypeStg

関数
ストレージからクリップボード形式とユーザー型文字列を読み取る。
DLLOLE32.dll呼出規約winapi対応OSWindows 2000 以降

シグネチャ

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

HRESULT ReadFmtUserTypeStg(
    IStorage* pstg,
    WORD* pcf,
    LPWSTR* lplpszUserType   // optional
);

パラメーター

名前方向
pstgIStorage*in
pcfWORD*out
lplpszUserTypeLPWSTR*outoptional

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT ReadFmtUserTypeStg(
    IStorage* pstg,
    WORD* pcf,
    LPWSTR* lplpszUserType   // optional
);
[DllImport("OLE32.dll", ExactSpelling = true)]
static extern int ReadFmtUserTypeStg(
    IntPtr pstg,   // IStorage*
    out ushort pcf,   // WORD* out
    IntPtr lplpszUserType   // LPWSTR* optional, out
);
<DllImport("OLE32.dll", ExactSpelling:=True)>
Public Shared Function ReadFmtUserTypeStg(
    pstg As IntPtr,   ' IStorage*
    <Out> ByRef pcf As UShort,   ' WORD* out
    lplpszUserType As IntPtr   ' LPWSTR* optional, out
) As Integer
End Function
' pstg : IStorage*
' pcf : WORD* out
' lplpszUserType : LPWSTR* optional, out
Declare PtrSafe Function ReadFmtUserTypeStg Lib "ole32" ( _
    ByVal pstg As LongPtr, _
    ByRef pcf As Integer, _
    ByVal lplpszUserType As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

ReadFmtUserTypeStg = ctypes.windll.ole32.ReadFmtUserTypeStg
ReadFmtUserTypeStg.restype = ctypes.c_int
ReadFmtUserTypeStg.argtypes = [
    ctypes.c_void_p,  # pstg : IStorage*
    ctypes.POINTER(ctypes.c_ushort),  # pcf : WORD* out
    ctypes.c_void_p,  # lplpszUserType : LPWSTR* optional, out
]
require 'fiddle'
require 'fiddle/import'

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

var (
	ole32 = windows.NewLazySystemDLL("OLE32.dll")
	procReadFmtUserTypeStg = ole32.NewProc("ReadFmtUserTypeStg")
)

// pstg (IStorage*), pcf (WORD* out), lplpszUserType (LPWSTR* optional, out)
r1, _, err := procReadFmtUserTypeStg.Call(
	uintptr(pstg),
	uintptr(pcf),
	uintptr(lplpszUserType),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function ReadFmtUserTypeStg(
  pstg: Pointer;   // IStorage*
  pcf: Pointer;   // WORD* out
  lplpszUserType: PPWideChar   // LPWSTR* optional, out
): Integer; stdcall;
  external 'OLE32.dll' name 'ReadFmtUserTypeStg';
result := DllCall("OLE32\ReadFmtUserTypeStg"
    , "Ptr", pstg   ; IStorage*
    , "Ptr", pcf   ; WORD* out
    , "Ptr", lplpszUserType   ; LPWSTR* optional, out
    , "Int")   ; return: HRESULT
●ReadFmtUserTypeStg(pstg, pcf, lplpszUserType) = DLL("OLE32.dll", "int ReadFmtUserTypeStg(void*, void*, void*)")
# 呼び出し: ReadFmtUserTypeStg(pstg, pcf, lplpszUserType)
# pstg : IStorage* -> "void*"
# pcf : WORD* out -> "void*"
# lplpszUserType : LPWSTR* optional, out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。