ホーム › System.Com.StructuredStorage › WriteFmtUserTypeStg
WriteFmtUserTypeStg
関数ストレージにクリップボード形式とユーザー型文字列を書き込む。
シグネチャ
// OLE32.dll
#include <windows.h>
HRESULT WriteFmtUserTypeStg(
IStorage* pstg,
WORD cf,
LPWSTR lpszUserType
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| pstg | IStorage* | in | 書き込み対象のIStorageへのポインタ。 |
| cf | WORD | in | ストレージに記録するクリップボード形式(CLIPFORMAT)値。 |
| 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)。const std = @import("std");
extern "ole32" fn WriteFmtUserTypeStg(
pstg: ?*anyopaque, // IStorage*
cf: u16, // WORD
lpszUserType: [*c]const u16 // LPWSTR
) callconv(std.os.windows.WINAPI) i32;proc WriteFmtUserTypeStg(
pstg: pointer, # IStorage*
cf: uint16, # WORD
lpszUserType: WideCString # LPWSTR
): int32 {.importc: "WriteFmtUserTypeStg", stdcall, dynlib: "OLE32.dll".}pragma(lib, "ole32");
extern(Windows)
int WriteFmtUserTypeStg(
void* pstg, // IStorage*
ushort cf, // WORD
const(wchar)* lpszUserType // LPWSTR
);ccall((:WriteFmtUserTypeStg, "OLE32.dll"), stdcall, Int32,
(Ptr{Cvoid}, UInt16, Cwstring),
pstg, cf, lpszUserType)
# pstg : IStorage* -> Ptr{Cvoid}
# cf : WORD -> UInt16
# lpszUserType : LPWSTR -> Cwstring
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t WriteFmtUserTypeStg(
void* pstg,
uint16_t cf,
const uint16_t* lpszUserType);
]]
local ole32 = ffi.load("ole32")
-- ole32.WriteFmtUserTypeStg(pstg, cf, lpszUserType)
-- pstg : IStorage*
-- cf : WORD
-- lpszUserType : LPWSTR
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('OLE32.dll');
const WriteFmtUserTypeStg = lib.func('__stdcall', 'WriteFmtUserTypeStg', 'int32_t', ['void *', 'uint16_t', 'str16']);
// WriteFmtUserTypeStg(pstg, cf, lpszUserType)
// pstg : IStorage* -> 'void *'
// cf : WORD -> 'uint16_t'
// lpszUserType : LPWSTR -> 'str16'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("OLE32.dll", {
WriteFmtUserTypeStg: { parameters: ["pointer", "u16", "buffer"], result: "i32" },
});
// lib.symbols.WriteFmtUserTypeStg(pstg, cf, lpszUserType)
// pstg : IStorage* -> "pointer"
// cf : WORD -> "u16"
// lpszUserType : LPWSTR -> "buffer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t WriteFmtUserTypeStg(
void* pstg,
uint16_t cf,
const uint16_t* lpszUserType);
C, "OLE32.dll");
// $ffi->WriteFmtUserTypeStg(pstg, cf, lpszUserType);
// pstg : IStorage*
// cf : WORD
// lpszUserType : LPWSTR
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
public interface Ole32 extends StdCallLibrary {
Ole32 INSTANCE = Native.load("ole32", Ole32.class);
int WriteFmtUserTypeStg(
Pointer pstg, // IStorage*
short cf, // WORD
WString lpszUserType // LPWSTR
);
}@[Link("ole32")]
lib LibOLE32
fun WriteFmtUserTypeStg = WriteFmtUserTypeStg(
pstg : Void*, # IStorage*
cf : UInt16, # WORD
lpszUserType : UInt16* # LPWSTR
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef WriteFmtUserTypeStgNative = Int32 Function(Pointer<Void>, Uint16, Pointer<Utf16>);
typedef WriteFmtUserTypeStgDart = int Function(Pointer<Void>, int, Pointer<Utf16>);
final WriteFmtUserTypeStg = DynamicLibrary.open('OLE32.dll')
.lookupFunction<WriteFmtUserTypeStgNative, WriteFmtUserTypeStgDart>('WriteFmtUserTypeStg');
// pstg : IStorage* -> Pointer<Void>
// cf : WORD -> Uint16
// lpszUserType : LPWSTR -> Pointer<Utf16>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function WriteFmtUserTypeStg(
pstg: Pointer; // IStorage*
cf: Word; // WORD
lpszUserType: PWideChar // LPWSTR
): Integer; stdcall;
external 'OLE32.dll' name 'WriteFmtUserTypeStg';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "WriteFmtUserTypeStg"
c_WriteFmtUserTypeStg :: Ptr () -> Word16 -> CWString -> IO Int32
-- pstg : IStorage* -> Ptr ()
-- cf : WORD -> Word16
-- lpszUserType : LPWSTR -> CWString
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let writefmtusertypestg =
foreign "WriteFmtUserTypeStg"
((ptr void) @-> uint16_t @-> (ptr uint16_t) @-> returning int32_t)
(* pstg : IStorage* -> (ptr void) *)
(* cf : WORD -> uint16_t *)
(* lpszUserType : LPWSTR -> (ptr uint16_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library ole32 (t "OLE32.dll"))
(cffi:use-foreign-library ole32)
(cffi:defcfun ("WriteFmtUserTypeStg" write-fmt-user-type-stg :convention :stdcall) :int32
(pstg :pointer) ; IStorage*
(cf :uint16) ; WORD
(lpsz-user-type (:string :encoding :utf-16le))) ; LPWSTR
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $WriteFmtUserTypeStg = Win32::API::More->new('OLE32',
'int WriteFmtUserTypeStg(LPVOID pstg, WORD cf, LPCWSTR lpszUserType)');
# my $ret = $WriteFmtUserTypeStg->Call($pstg, $cf, $lpszUserType);
# pstg : IStorage* -> LPVOID
# cf : WORD -> WORD
# lpszUserType : LPWSTR -> LPCWSTR
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
使用する型