Win32 API 日本語リファレンス
ホームGraphics.Gdi › CreateMetaFileW

CreateMetaFileW

関数
メタファイルへの描画用デバイスコンテキストを作成する。
DLLGDI32.dll文字セットUnicode (-W)呼出規約winapi対応OSWindows 2000 以降

シグネチャ

// GDI32.dll  (Unicode / -W)
#include <windows.h>

HDC CreateMetaFileW(
    LPCWSTR pszFile   // optional
);

パラメーター

名前方向
pszFileLPCWSTRinoptional

戻り値の型: HDC

各言語での呼び出し定義

// GDI32.dll  (Unicode / -W)
#include <windows.h>

HDC CreateMetaFileW(
    LPCWSTR pszFile   // optional
);
[DllImport("GDI32.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern IntPtr CreateMetaFileW(
    [MarshalAs(UnmanagedType.LPWStr)] string pszFile   // LPCWSTR optional
);
<DllImport("GDI32.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function CreateMetaFileW(
    <MarshalAs(UnmanagedType.LPWStr)> pszFile As String   ' LPCWSTR optional
) As IntPtr
End Function
' pszFile : LPCWSTR optional
Declare PtrSafe Function CreateMetaFileW Lib "gdi32" ( _
    ByVal pszFile As LongPtr) As LongPtr
' Unicode(W): 文字列は ByVal As LongPtr とし StrPtr(unicodeStr) を渡す
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

CreateMetaFileW = ctypes.windll.gdi32.CreateMetaFileW
CreateMetaFileW.restype = ctypes.c_void_p
CreateMetaFileW.argtypes = [
    wintypes.LPCWSTR,  # pszFile : LPCWSTR optional
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('GDI32.dll')
CreateMetaFileW = Fiddle::Function.new(
  lib['CreateMetaFileW'],
  [
    Fiddle::TYPE_VOIDP,  # pszFile : LPCWSTR optional
  ],
  Fiddle::TYPE_VOIDP)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"
#[link(name = "gdi32")]
extern "system" {
    fn CreateMetaFileW(
        pszFile: *const u16  // LPCWSTR optional
    ) -> *mut core::ffi::c_void;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("GDI32.dll", CharSet = CharSet.Unicode)]
public static extern IntPtr CreateMetaFileW([MarshalAs(UnmanagedType.LPWStr)] string pszFile);
"@
$api = Add-Type -MemberDefinition $sig -Name 'GDI32_CreateMetaFileW' -Namespace Win32 -PassThru
# $api::CreateMetaFileW(pszFile)
#uselib "GDI32.dll"
#func global CreateMetaFileW "CreateMetaFileW" wptr
; CreateMetaFileW pszFile   ; 戻り値は stat
; pszFile : LPCWSTR optional -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "GDI32.dll"
#cfunc global CreateMetaFileW "CreateMetaFileW" wstr
; res = CreateMetaFileW(pszFile)
; pszFile : LPCWSTR optional -> "wstr"
; HDC CreateMetaFileW(LPCWSTR pszFile)
#uselib "GDI32.dll"
#cfunc global CreateMetaFileW "CreateMetaFileW" wstr
; res = CreateMetaFileW(pszFile)
; pszFile : LPCWSTR optional -> "wstr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	gdi32 = windows.NewLazySystemDLL("GDI32.dll")
	procCreateMetaFileW = gdi32.NewProc("CreateMetaFileW")
)

// pszFile (LPCWSTR optional)
r1, _, err := procCreateMetaFileW.Call(
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pszFile))),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HDC
function CreateMetaFileW(
  pszFile: PWideChar   // LPCWSTR optional
): THandle; stdcall;
  external 'GDI32.dll' name 'CreateMetaFileW';
result := DllCall("GDI32\CreateMetaFileW"
    , "WStr", pszFile   ; LPCWSTR optional
    , "Ptr")   ; return: HDC
●CreateMetaFileW(pszFile) = DLL("GDI32.dll", "void* CreateMetaFileW(char*)")
# 呼び出し: CreateMetaFileW(pszFile)
# pszFile : LPCWSTR optional -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。