ホーム › System.Com.Urlmon › CreateFormatEnumerator
CreateFormatEnumerator
関数FORMATETC配列から形式列挙子を作成する。
シグネチャ
// urlmon.dll
#include <windows.h>
HRESULT CreateFormatEnumerator(
DWORD cfmtetc,
FORMATETC* rgfmtetc,
IEnumFORMATETC** ppenumfmtetc
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| cfmtetc | DWORD | in | rgfmtetc配列の要素数。列挙対象のフォーマット数。 |
| rgfmtetc | FORMATETC* | in | 列挙対象のFORMATETC構造体配列へのポインタ。 |
| ppenumfmtetc | IEnumFORMATETC** | out | 生成されたフォーマット列挙子(IEnumFORMATETC)を受け取る出力ポインタ。 |
戻り値の型: HRESULT
各言語での呼び出し定義
// urlmon.dll
#include <windows.h>
HRESULT CreateFormatEnumerator(
DWORD cfmtetc,
FORMATETC* rgfmtetc,
IEnumFORMATETC** ppenumfmtetc
);[DllImport("urlmon.dll", ExactSpelling = true)]
static extern int CreateFormatEnumerator(
uint cfmtetc, // DWORD
IntPtr rgfmtetc, // FORMATETC*
IntPtr ppenumfmtetc // IEnumFORMATETC** out
);<DllImport("urlmon.dll", ExactSpelling:=True)>
Public Shared Function CreateFormatEnumerator(
cfmtetc As UInteger, ' DWORD
rgfmtetc As IntPtr, ' FORMATETC*
ppenumfmtetc As IntPtr ' IEnumFORMATETC** out
) As Integer
End Function' cfmtetc : DWORD
' rgfmtetc : FORMATETC*
' ppenumfmtetc : IEnumFORMATETC** out
Declare PtrSafe Function CreateFormatEnumerator Lib "urlmon" ( _
ByVal cfmtetc As Long, _
ByVal rgfmtetc As LongPtr, _
ByVal ppenumfmtetc As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
CreateFormatEnumerator = ctypes.windll.urlmon.CreateFormatEnumerator
CreateFormatEnumerator.restype = ctypes.c_int
CreateFormatEnumerator.argtypes = [
wintypes.DWORD, # cfmtetc : DWORD
ctypes.c_void_p, # rgfmtetc : FORMATETC*
ctypes.c_void_p, # ppenumfmtetc : IEnumFORMATETC** out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('urlmon.dll')
CreateFormatEnumerator = Fiddle::Function.new(
lib['CreateFormatEnumerator'],
[
-Fiddle::TYPE_INT, # cfmtetc : DWORD
Fiddle::TYPE_VOIDP, # rgfmtetc : FORMATETC*
Fiddle::TYPE_VOIDP, # ppenumfmtetc : IEnumFORMATETC** out
],
Fiddle::TYPE_INT)#[link(name = "urlmon")]
extern "system" {
fn CreateFormatEnumerator(
cfmtetc: u32, // DWORD
rgfmtetc: *mut FORMATETC, // FORMATETC*
ppenumfmtetc: *mut *mut core::ffi::c_void // IEnumFORMATETC** out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("urlmon.dll")]
public static extern int CreateFormatEnumerator(uint cfmtetc, IntPtr rgfmtetc, IntPtr ppenumfmtetc);
"@
$api = Add-Type -MemberDefinition $sig -Name 'urlmon_CreateFormatEnumerator' -Namespace Win32 -PassThru
# $api::CreateFormatEnumerator(cfmtetc, rgfmtetc, ppenumfmtetc)#uselib "urlmon.dll"
#func global CreateFormatEnumerator "CreateFormatEnumerator" sptr, sptr, sptr
; CreateFormatEnumerator cfmtetc, varptr(rgfmtetc), ppenumfmtetc ; 戻り値は stat
; cfmtetc : DWORD -> "sptr"
; rgfmtetc : FORMATETC* -> "sptr"
; ppenumfmtetc : IEnumFORMATETC** out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "urlmon.dll" #cfunc global CreateFormatEnumerator "CreateFormatEnumerator" int, var, sptr ; res = CreateFormatEnumerator(cfmtetc, rgfmtetc, ppenumfmtetc) ; cfmtetc : DWORD -> "int" ; rgfmtetc : FORMATETC* -> "var" ; ppenumfmtetc : IEnumFORMATETC** out -> "sptr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "urlmon.dll" #cfunc global CreateFormatEnumerator "CreateFormatEnumerator" int, sptr, sptr ; res = CreateFormatEnumerator(cfmtetc, varptr(rgfmtetc), ppenumfmtetc) ; cfmtetc : DWORD -> "int" ; rgfmtetc : FORMATETC* -> "sptr" ; ppenumfmtetc : IEnumFORMATETC** out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HRESULT CreateFormatEnumerator(DWORD cfmtetc, FORMATETC* rgfmtetc, IEnumFORMATETC** ppenumfmtetc) #uselib "urlmon.dll" #cfunc global CreateFormatEnumerator "CreateFormatEnumerator" int, var, intptr ; res = CreateFormatEnumerator(cfmtetc, rgfmtetc, ppenumfmtetc) ; cfmtetc : DWORD -> "int" ; rgfmtetc : FORMATETC* -> "var" ; ppenumfmtetc : IEnumFORMATETC** out -> "intptr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HRESULT CreateFormatEnumerator(DWORD cfmtetc, FORMATETC* rgfmtetc, IEnumFORMATETC** ppenumfmtetc) #uselib "urlmon.dll" #cfunc global CreateFormatEnumerator "CreateFormatEnumerator" int, intptr, intptr ; res = CreateFormatEnumerator(cfmtetc, varptr(rgfmtetc), ppenumfmtetc) ; cfmtetc : DWORD -> "int" ; rgfmtetc : FORMATETC* -> "intptr" ; ppenumfmtetc : IEnumFORMATETC** out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
urlmon = windows.NewLazySystemDLL("urlmon.dll")
procCreateFormatEnumerator = urlmon.NewProc("CreateFormatEnumerator")
)
// cfmtetc (DWORD), rgfmtetc (FORMATETC*), ppenumfmtetc (IEnumFORMATETC** out)
r1, _, err := procCreateFormatEnumerator.Call(
uintptr(cfmtetc),
uintptr(rgfmtetc),
uintptr(ppenumfmtetc),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction CreateFormatEnumerator(
cfmtetc: DWORD; // DWORD
rgfmtetc: Pointer; // FORMATETC*
ppenumfmtetc: Pointer // IEnumFORMATETC** out
): Integer; stdcall;
external 'urlmon.dll' name 'CreateFormatEnumerator';result := DllCall("urlmon\CreateFormatEnumerator"
, "UInt", cfmtetc ; DWORD
, "Ptr", rgfmtetc ; FORMATETC*
, "Ptr", ppenumfmtetc ; IEnumFORMATETC** out
, "Int") ; return: HRESULT●CreateFormatEnumerator(cfmtetc, rgfmtetc, ppenumfmtetc) = DLL("urlmon.dll", "int CreateFormatEnumerator(dword, void*, void*)")
# 呼び出し: CreateFormatEnumerator(cfmtetc, rgfmtetc, ppenumfmtetc)
# cfmtetc : DWORD -> "dword"
# rgfmtetc : FORMATETC* -> "void*"
# ppenumfmtetc : IEnumFORMATETC** out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "urlmon" fn CreateFormatEnumerator(
cfmtetc: u32, // DWORD
rgfmtetc: [*c]FORMATETC, // FORMATETC*
ppenumfmtetc: ?*anyopaque // IEnumFORMATETC** out
) callconv(std.os.windows.WINAPI) i32;proc CreateFormatEnumerator(
cfmtetc: uint32, # DWORD
rgfmtetc: ptr FORMATETC, # FORMATETC*
ppenumfmtetc: pointer # IEnumFORMATETC** out
): int32 {.importc: "CreateFormatEnumerator", stdcall, dynlib: "urlmon.dll".}pragma(lib, "urlmon");
extern(Windows)
int CreateFormatEnumerator(
uint cfmtetc, // DWORD
FORMATETC* rgfmtetc, // FORMATETC*
void* ppenumfmtetc // IEnumFORMATETC** out
);ccall((:CreateFormatEnumerator, "urlmon.dll"), stdcall, Int32,
(UInt32, Ptr{FORMATETC}, Ptr{Cvoid}),
cfmtetc, rgfmtetc, ppenumfmtetc)
# cfmtetc : DWORD -> UInt32
# rgfmtetc : FORMATETC* -> Ptr{FORMATETC}
# ppenumfmtetc : IEnumFORMATETC** out -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t CreateFormatEnumerator(
uint32_t cfmtetc,
void* rgfmtetc,
void* ppenumfmtetc);
]]
local urlmon = ffi.load("urlmon")
-- urlmon.CreateFormatEnumerator(cfmtetc, rgfmtetc, ppenumfmtetc)
-- cfmtetc : DWORD
-- rgfmtetc : FORMATETC*
-- ppenumfmtetc : IEnumFORMATETC** out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('urlmon.dll');
const CreateFormatEnumerator = lib.func('__stdcall', 'CreateFormatEnumerator', 'int32_t', ['uint32_t', 'void *', 'void *']);
// CreateFormatEnumerator(cfmtetc, rgfmtetc, ppenumfmtetc)
// cfmtetc : DWORD -> 'uint32_t'
// rgfmtetc : FORMATETC* -> 'void *'
// ppenumfmtetc : IEnumFORMATETC** out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("urlmon.dll", {
CreateFormatEnumerator: { parameters: ["u32", "pointer", "pointer"], result: "i32" },
});
// lib.symbols.CreateFormatEnumerator(cfmtetc, rgfmtetc, ppenumfmtetc)
// cfmtetc : DWORD -> "u32"
// rgfmtetc : FORMATETC* -> "pointer"
// ppenumfmtetc : IEnumFORMATETC** out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t CreateFormatEnumerator(
uint32_t cfmtetc,
void* rgfmtetc,
void* ppenumfmtetc);
C, "urlmon.dll");
// $ffi->CreateFormatEnumerator(cfmtetc, rgfmtetc, ppenumfmtetc);
// cfmtetc : DWORD
// rgfmtetc : FORMATETC*
// ppenumfmtetc : IEnumFORMATETC** out
// 構造体/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 Urlmon extends StdCallLibrary {
Urlmon INSTANCE = Native.load("urlmon", Urlmon.class);
int CreateFormatEnumerator(
int cfmtetc, // DWORD
Pointer rgfmtetc, // FORMATETC*
Pointer ppenumfmtetc // IEnumFORMATETC** out
);
}@[Link("urlmon")]
lib Liburlmon
fun CreateFormatEnumerator = CreateFormatEnumerator(
cfmtetc : UInt32, # DWORD
rgfmtetc : FORMATETC*, # FORMATETC*
ppenumfmtetc : Void* # IEnumFORMATETC** out
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef CreateFormatEnumeratorNative = Int32 Function(Uint32, Pointer<Void>, Pointer<Void>);
typedef CreateFormatEnumeratorDart = int Function(int, Pointer<Void>, Pointer<Void>);
final CreateFormatEnumerator = DynamicLibrary.open('urlmon.dll')
.lookupFunction<CreateFormatEnumeratorNative, CreateFormatEnumeratorDart>('CreateFormatEnumerator');
// cfmtetc : DWORD -> Uint32
// rgfmtetc : FORMATETC* -> Pointer<Void>
// ppenumfmtetc : IEnumFORMATETC** out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function CreateFormatEnumerator(
cfmtetc: DWORD; // DWORD
rgfmtetc: Pointer; // FORMATETC*
ppenumfmtetc: Pointer // IEnumFORMATETC** out
): Integer; stdcall;
external 'urlmon.dll' name 'CreateFormatEnumerator';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "CreateFormatEnumerator"
c_CreateFormatEnumerator :: Word32 -> Ptr () -> Ptr () -> IO Int32
-- cfmtetc : DWORD -> Word32
-- rgfmtetc : FORMATETC* -> Ptr ()
-- ppenumfmtetc : IEnumFORMATETC** out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let createformatenumerator =
foreign "CreateFormatEnumerator"
(uint32_t @-> (ptr void) @-> (ptr void) @-> returning int32_t)
(* cfmtetc : DWORD -> uint32_t *)
(* rgfmtetc : FORMATETC* -> (ptr void) *)
(* ppenumfmtetc : IEnumFORMATETC** out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library urlmon (t "urlmon.dll"))
(cffi:use-foreign-library urlmon)
(cffi:defcfun ("CreateFormatEnumerator" create-format-enumerator :convention :stdcall) :int32
(cfmtetc :uint32) ; DWORD
(rgfmtetc :pointer) ; FORMATETC*
(ppenumfmtetc :pointer)) ; IEnumFORMATETC** out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $CreateFormatEnumerator = Win32::API::More->new('urlmon',
'int CreateFormatEnumerator(DWORD cfmtetc, LPVOID rgfmtetc, LPVOID ppenumfmtetc)');
# my $ret = $CreateFormatEnumerator->Call($cfmtetc, $rgfmtetc, $ppenumfmtetc);
# cfmtetc : DWORD -> DWORD
# rgfmtetc : FORMATETC* -> LPVOID
# ppenumfmtetc : IEnumFORMATETC** out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。