ホーム › Devices.Display › EngGetCurrentCodePage
EngGetCurrentCodePage
関数現在のOEMおよびANSIコードページを取得する。
シグネチャ
// GDI32.dll
#include <windows.h>
void EngGetCurrentCodePage(
WORD* OemCodePage,
WORD* AnsiCodePage
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| OemCodePage | WORD* | out | システムの既定の OEM コードページを受け取る USHORT へのポインターです。 |
| AnsiCodePage | WORD* | out | システムの既定の ANSI コードページを受け取る USHORT へのポインターです。 |
戻り値の型: void
公式ドキュメント
EngGetCurrentCodePage 関数は、システムの既定の OEM コードページおよび ANSI コードページを返します。
戻り値
なし
解説(Remarks)
EngGetCurrentCodePage は、ANSI から Unicode へ変換するためにシステムが使用する既定のコードページを返します。これらの値は、ロケール設定に従って起動時に設定されます。
出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// GDI32.dll
#include <windows.h>
void EngGetCurrentCodePage(
WORD* OemCodePage,
WORD* AnsiCodePage
);[DllImport("GDI32.dll", ExactSpelling = true)]
static extern void EngGetCurrentCodePage(
out ushort OemCodePage, // WORD* out
out ushort AnsiCodePage // WORD* out
);<DllImport("GDI32.dll", ExactSpelling:=True)>
Public Shared Sub EngGetCurrentCodePage(
<Out> ByRef OemCodePage As UShort, ' WORD* out
<Out> ByRef AnsiCodePage As UShort ' WORD* out
)
End Sub' OemCodePage : WORD* out
' AnsiCodePage : WORD* out
Declare PtrSafe Sub EngGetCurrentCodePage Lib "gdi32" ( _
ByRef OemCodePage As Integer, _
ByRef AnsiCodePage As Integer)
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
EngGetCurrentCodePage = ctypes.windll.gdi32.EngGetCurrentCodePage
EngGetCurrentCodePage.restype = None
EngGetCurrentCodePage.argtypes = [
ctypes.POINTER(ctypes.c_ushort), # OemCodePage : WORD* out
ctypes.POINTER(ctypes.c_ushort), # AnsiCodePage : WORD* out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('GDI32.dll')
EngGetCurrentCodePage = Fiddle::Function.new(
lib['EngGetCurrentCodePage'],
[
Fiddle::TYPE_VOIDP, # OemCodePage : WORD* out
Fiddle::TYPE_VOIDP, # AnsiCodePage : WORD* out
],
Fiddle::TYPE_VOID)#[link(name = "gdi32")]
extern "system" {
fn EngGetCurrentCodePage(
OemCodePage: *mut u16, // WORD* out
AnsiCodePage: *mut u16 // WORD* out
);
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("GDI32.dll")]
public static extern void EngGetCurrentCodePage(out ushort OemCodePage, out ushort AnsiCodePage);
"@
$api = Add-Type -MemberDefinition $sig -Name 'GDI32_EngGetCurrentCodePage' -Namespace Win32 -PassThru
# $api::EngGetCurrentCodePage(OemCodePage, AnsiCodePage)#uselib "GDI32.dll"
#func global EngGetCurrentCodePage "EngGetCurrentCodePage" sptr, sptr
; EngGetCurrentCodePage varptr(OemCodePage), varptr(AnsiCodePage)
; OemCodePage : WORD* out -> "sptr"
; AnsiCodePage : WORD* out -> "sptr"出力引数:
#uselib "GDI32.dll" #func global EngGetCurrentCodePage "EngGetCurrentCodePage" var, var ; EngGetCurrentCodePage OemCodePage, AnsiCodePage ; OemCodePage : WORD* out -> "var" ; AnsiCodePage : WORD* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "GDI32.dll" #func global EngGetCurrentCodePage "EngGetCurrentCodePage" sptr, sptr ; EngGetCurrentCodePage varptr(OemCodePage), varptr(AnsiCodePage) ; OemCodePage : WORD* out -> "sptr" ; AnsiCodePage : WORD* out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; void EngGetCurrentCodePage(WORD* OemCodePage, WORD* AnsiCodePage) #uselib "GDI32.dll" #func global EngGetCurrentCodePage "EngGetCurrentCodePage" var, var ; EngGetCurrentCodePage OemCodePage, AnsiCodePage ; OemCodePage : WORD* out -> "var" ; AnsiCodePage : WORD* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; void EngGetCurrentCodePage(WORD* OemCodePage, WORD* AnsiCodePage) #uselib "GDI32.dll" #func global EngGetCurrentCodePage "EngGetCurrentCodePage" intptr, intptr ; EngGetCurrentCodePage varptr(OemCodePage), varptr(AnsiCodePage) ; OemCodePage : WORD* out -> "intptr" ; AnsiCodePage : WORD* out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
gdi32 = windows.NewLazySystemDLL("GDI32.dll")
procEngGetCurrentCodePage = gdi32.NewProc("EngGetCurrentCodePage")
)
// OemCodePage (WORD* out), AnsiCodePage (WORD* out)
r1, _, err := procEngGetCurrentCodePage.Call(
uintptr(OemCodePage),
uintptr(AnsiCodePage),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // voidprocedure EngGetCurrentCodePage(
OemCodePage: Pointer; // WORD* out
AnsiCodePage: Pointer // WORD* out
); stdcall;
external 'GDI32.dll' name 'EngGetCurrentCodePage';result := DllCall("GDI32\EngGetCurrentCodePage"
, "Ptr", OemCodePage ; WORD* out
, "Ptr", AnsiCodePage ; WORD* out
, "Int") ; return: void●EngGetCurrentCodePage(OemCodePage, AnsiCodePage) = DLL("GDI32.dll", "int EngGetCurrentCodePage(void*, void*)")
# 呼び出し: EngGetCurrentCodePage(OemCodePage, AnsiCodePage)
# OemCodePage : WORD* out -> "void*"
# AnsiCodePage : WORD* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "gdi32" fn EngGetCurrentCodePage(
OemCodePage: [*c]u16, // WORD* out
AnsiCodePage: [*c]u16 // WORD* out
) callconv(std.os.windows.WINAPI) void;proc EngGetCurrentCodePage(
OemCodePage: ptr uint16, # WORD* out
AnsiCodePage: ptr uint16 # WORD* out
) {.importc: "EngGetCurrentCodePage", stdcall, dynlib: "GDI32.dll".}pragma(lib, "gdi32");
extern(Windows)
void EngGetCurrentCodePage(
ushort* OemCodePage, // WORD* out
ushort* AnsiCodePage // WORD* out
);ccall((:EngGetCurrentCodePage, "GDI32.dll"), stdcall, Cvoid,
(Ptr{UInt16}, Ptr{UInt16}),
OemCodePage, AnsiCodePage)
# OemCodePage : WORD* out -> Ptr{UInt16}
# AnsiCodePage : WORD* out -> Ptr{UInt16}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
void EngGetCurrentCodePage(
uint16_t* OemCodePage,
uint16_t* AnsiCodePage);
]]
local gdi32 = ffi.load("gdi32")
-- gdi32.EngGetCurrentCodePage(OemCodePage, AnsiCodePage)
-- OemCodePage : WORD* out
-- AnsiCodePage : WORD* out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('GDI32.dll');
const EngGetCurrentCodePage = lib.func('__stdcall', 'EngGetCurrentCodePage', 'void', ['uint16_t *', 'uint16_t *']);
// EngGetCurrentCodePage(OemCodePage, AnsiCodePage)
// OemCodePage : WORD* out -> 'uint16_t *'
// AnsiCodePage : WORD* out -> 'uint16_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("GDI32.dll", {
EngGetCurrentCodePage: { parameters: ["pointer", "pointer"], result: "void" },
});
// lib.symbols.EngGetCurrentCodePage(OemCodePage, AnsiCodePage)
// OemCodePage : WORD* out -> "pointer"
// AnsiCodePage : WORD* out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
void EngGetCurrentCodePage(
uint16_t* OemCodePage,
uint16_t* AnsiCodePage);
C, "GDI32.dll");
// $ffi->EngGetCurrentCodePage(OemCodePage, AnsiCodePage);
// OemCodePage : WORD* out
// AnsiCodePage : WORD* 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 Gdi32 extends StdCallLibrary {
Gdi32 INSTANCE = Native.load("gdi32", Gdi32.class);
void EngGetCurrentCodePage(
ShortByReference OemCodePage, // WORD* out
ShortByReference AnsiCodePage // WORD* out
);
}@[Link("gdi32")]
lib LibGDI32
fun EngGetCurrentCodePage = EngGetCurrentCodePage(
OemCodePage : UInt16*, # WORD* out
AnsiCodePage : UInt16* # WORD* out
) : Void
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef EngGetCurrentCodePageNative = Void Function(Pointer<Uint16>, Pointer<Uint16>);
typedef EngGetCurrentCodePageDart = void Function(Pointer<Uint16>, Pointer<Uint16>);
final EngGetCurrentCodePage = DynamicLibrary.open('GDI32.dll')
.lookupFunction<EngGetCurrentCodePageNative, EngGetCurrentCodePageDart>('EngGetCurrentCodePage');
// OemCodePage : WORD* out -> Pointer<Uint16>
// AnsiCodePage : WORD* out -> Pointer<Uint16>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
procedure EngGetCurrentCodePage(
OemCodePage: Pointer; // WORD* out
AnsiCodePage: Pointer // WORD* out
); stdcall;
external 'GDI32.dll' name 'EngGetCurrentCodePage';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "EngGetCurrentCodePage"
c_EngGetCurrentCodePage :: Ptr Word16 -> Ptr Word16 -> IO ()
-- OemCodePage : WORD* out -> Ptr Word16
-- AnsiCodePage : WORD* out -> Ptr Word16
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let enggetcurrentcodepage =
foreign "EngGetCurrentCodePage"
((ptr uint16_t) @-> (ptr uint16_t) @-> returning void)
(* OemCodePage : WORD* out -> (ptr uint16_t) *)
(* AnsiCodePage : WORD* out -> (ptr uint16_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library gdi32 (t "GDI32.dll"))
(cffi:use-foreign-library gdi32)
(cffi:defcfun ("EngGetCurrentCodePage" eng-get-current-code-page :convention :stdcall) :void
(oem-code-page :pointer) ; WORD* out
(ansi-code-page :pointer)) ; WORD* out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $EngGetCurrentCodePage = Win32::API::More->new('GDI32',
'void EngGetCurrentCodePage(LPVOID OemCodePage, LPVOID AnsiCodePage)');
# my $ret = $EngGetCurrentCodePage->Call($OemCodePage, $AnsiCodePage);
# OemCodePage : WORD* out -> LPVOID
# AnsiCodePage : WORD* out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
公式の関連項目
- f STROBJ_dwGetCodePage — 文字列オブジェクトのコードページを取得する。