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

CreateMetaFileA

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

シグネチャ

// GDI32.dll  (ANSI / -A)
#include <windows.h>

HDC CreateMetaFileA(
    LPCSTR pszFile   // optional
);

パラメーター

名前方向
pszFileLPCSTRinoptional

戻り値の型: HDC

各言語での呼び出し定義

// GDI32.dll  (ANSI / -A)
#include <windows.h>

HDC CreateMetaFileA(
    LPCSTR pszFile   // optional
);
[DllImport("GDI32.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern IntPtr CreateMetaFileA(
    [MarshalAs(UnmanagedType.LPStr)] string pszFile   // LPCSTR optional
);
<DllImport("GDI32.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Function CreateMetaFileA(
    <MarshalAs(UnmanagedType.LPStr)> pszFile As String   ' LPCSTR optional
) As IntPtr
End Function
' pszFile : LPCSTR optional
Declare PtrSafe Function CreateMetaFileA Lib "gdi32" ( _
    ByVal pszFile As String) As LongPtr
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

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

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

var (
	gdi32 = windows.NewLazySystemDLL("GDI32.dll")
	procCreateMetaFileA = gdi32.NewProc("CreateMetaFileA")
)

// pszFile (LPCSTR optional)
r1, _, err := procCreateMetaFileA.Call(
	uintptr(unsafe.Pointer(windows.BytePtrFromString(pszFile))),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HDC
function CreateMetaFileA(
  pszFile: PAnsiChar   // LPCSTR optional
): THandle; stdcall;
  external 'GDI32.dll' name 'CreateMetaFileA';
result := DllCall("GDI32\CreateMetaFileA"
    , "AStr", pszFile   ; LPCSTR optional
    , "Ptr")   ; return: HDC
●CreateMetaFileA(pszFile) = DLL("GDI32.dll", "void* CreateMetaFileA(char*)")
# 呼び出し: CreateMetaFileA(pszFile)
# pszFile : LPCSTR optional -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。