ホーム › System.Com.StructuredStorage › WriteFmtUserTypeStg
WriteFmtUserTypeStg
関数ストレージにクリップボード形式とユーザー型文字列を書き込む。
シグネチャ
// OLE32.dll
#include <windows.h>
HRESULT WriteFmtUserTypeStg(
IStorage* pstg,
WORD cf,
LPWSTR lpszUserType
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| pstg | IStorage* | in |
| cf | WORD | in |
| lpszUserType | LPWSTR | in |
戻り値の型: HRESULT
各言語での呼び出し定義
// OLE32.dll
#include <windows.h>
HRESULT WriteFmtUserTypeStg(
IStorage* pstg,
WORD cf,
LPWSTR lpszUserType
);[DllImport("OLE32.dll", ExactSpelling = true)]
static extern int WriteFmtUserTypeStg(
IntPtr pstg, // IStorage*
ushort cf, // WORD
[MarshalAs(UnmanagedType.LPWStr)] string lpszUserType // LPWSTR
);<DllImport("OLE32.dll", ExactSpelling:=True)>
Public Shared Function WriteFmtUserTypeStg(
pstg As IntPtr, ' IStorage*
cf As UShort, ' WORD
<MarshalAs(UnmanagedType.LPWStr)> lpszUserType As String ' LPWSTR
) As Integer
End Function' pstg : IStorage*
' cf : WORD
' lpszUserType : LPWSTR
Declare PtrSafe Function WriteFmtUserTypeStg Lib "ole32" ( _
ByVal pstg As LongPtr, _
ByVal cf As Integer, _
ByVal lpszUserType As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
WriteFmtUserTypeStg = ctypes.windll.ole32.WriteFmtUserTypeStg
WriteFmtUserTypeStg.restype = ctypes.c_int
WriteFmtUserTypeStg.argtypes = [
ctypes.c_void_p, # pstg : IStorage*
ctypes.c_ushort, # cf : WORD
wintypes.LPCWSTR, # lpszUserType : LPWSTR
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('OLE32.dll')
WriteFmtUserTypeStg = Fiddle::Function.new(
lib['WriteFmtUserTypeStg'],
[
Fiddle::TYPE_VOIDP, # pstg : IStorage*
-Fiddle::TYPE_SHORT, # cf : WORD
Fiddle::TYPE_VOIDP, # lpszUserType : LPWSTR
],
Fiddle::TYPE_INT)#[link(name = "ole32")]
extern "system" {
fn WriteFmtUserTypeStg(
pstg: *mut core::ffi::c_void, // IStorage*
cf: u16, // WORD
lpszUserType: *mut u16 // LPWSTR
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("OLE32.dll")]
public static extern int WriteFmtUserTypeStg(IntPtr pstg, ushort cf, [MarshalAs(UnmanagedType.LPWStr)] string lpszUserType);
"@
$api = Add-Type -MemberDefinition $sig -Name 'OLE32_WriteFmtUserTypeStg' -Namespace Win32 -PassThru
# $api::WriteFmtUserTypeStg(pstg, cf, lpszUserType)#uselib "OLE32.dll"
#func global WriteFmtUserTypeStg "WriteFmtUserTypeStg" sptr, sptr, sptr
; WriteFmtUserTypeStg pstg, cf, lpszUserType ; 戻り値は stat
; pstg : IStorage* -> "sptr"
; cf : WORD -> "sptr"
; lpszUserType : LPWSTR -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "OLE32.dll"
#cfunc global WriteFmtUserTypeStg "WriteFmtUserTypeStg" sptr, int, wstr
; res = WriteFmtUserTypeStg(pstg, cf, lpszUserType)
; pstg : IStorage* -> "sptr"
; cf : WORD -> "int"
; lpszUserType : LPWSTR -> "wstr"; HRESULT WriteFmtUserTypeStg(IStorage* pstg, WORD cf, LPWSTR lpszUserType)
#uselib "OLE32.dll"
#cfunc global WriteFmtUserTypeStg "WriteFmtUserTypeStg" intptr, int, wstr
; res = WriteFmtUserTypeStg(pstg, cf, lpszUserType)
; pstg : IStorage* -> "intptr"
; cf : WORD -> "int"
; lpszUserType : LPWSTR -> "wstr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
ole32 = windows.NewLazySystemDLL("OLE32.dll")
procWriteFmtUserTypeStg = ole32.NewProc("WriteFmtUserTypeStg")
)
// pstg (IStorage*), cf (WORD), lpszUserType (LPWSTR)
r1, _, err := procWriteFmtUserTypeStg.Call(
uintptr(pstg),
uintptr(cf),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(lpszUserType))),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction WriteFmtUserTypeStg(
pstg: Pointer; // IStorage*
cf: Word; // WORD
lpszUserType: PWideChar // LPWSTR
): Integer; stdcall;
external 'OLE32.dll' name 'WriteFmtUserTypeStg';result := DllCall("OLE32\WriteFmtUserTypeStg"
, "Ptr", pstg ; IStorage*
, "UShort", cf ; WORD
, "WStr", lpszUserType ; LPWSTR
, "Int") ; return: HRESULT●WriteFmtUserTypeStg(pstg, cf, lpszUserType) = DLL("OLE32.dll", "int WriteFmtUserTypeStg(void*, int, char*)")
# 呼び出し: WriteFmtUserTypeStg(pstg, cf, lpszUserType)
# pstg : IStorage* -> "void*"
# cf : WORD -> "int"
# lpszUserType : LPWSTR -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。