ホーム › Globalization › GetCPInfoExA
GetCPInfoExA
関数指定コードページの拡張情報を取得する。ANSI版。
シグネチャ
// KERNEL32.dll (ANSI / -A)
#include <windows.h>
BOOL GetCPInfoExA(
DWORD CodePage,
DWORD dwFlags,
CPINFOEXA* lpCPInfoEx
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| CodePage | DWORD | in |
| dwFlags | DWORD | in |
| lpCPInfoEx | CPINFOEXA* | out |
戻り値の型: BOOL
各言語での呼び出し定義
// KERNEL32.dll (ANSI / -A)
#include <windows.h>
BOOL GetCPInfoExA(
DWORD CodePage,
DWORD dwFlags,
CPINFOEXA* lpCPInfoEx
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("KERNEL32.dll", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
static extern bool GetCPInfoExA(
uint CodePage, // DWORD
uint dwFlags, // DWORD
IntPtr lpCPInfoEx // CPINFOEXA* out
);<DllImport("KERNEL32.dll", CharSet:=CharSet.Ansi, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function GetCPInfoExA(
CodePage As UInteger, ' DWORD
dwFlags As UInteger, ' DWORD
lpCPInfoEx As IntPtr ' CPINFOEXA* out
) As Boolean
End Function' CodePage : DWORD
' dwFlags : DWORD
' lpCPInfoEx : CPINFOEXA* out
Declare PtrSafe Function GetCPInfoExA Lib "kernel32" ( _
ByVal CodePage As Long, _
ByVal dwFlags As Long, _
ByVal lpCPInfoEx As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
GetCPInfoExA = ctypes.windll.kernel32.GetCPInfoExA
GetCPInfoExA.restype = wintypes.BOOL
GetCPInfoExA.argtypes = [
wintypes.DWORD, # CodePage : DWORD
wintypes.DWORD, # dwFlags : DWORD
ctypes.c_void_p, # lpCPInfoEx : CPINFOEXA* out
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('KERNEL32.dll')
GetCPInfoExA = Fiddle::Function.new(
lib['GetCPInfoExA'],
[
-Fiddle::TYPE_INT, # CodePage : DWORD
-Fiddle::TYPE_INT, # dwFlags : DWORD
Fiddle::TYPE_VOIDP, # lpCPInfoEx : CPINFOEXA* out
],
Fiddle::TYPE_INT)#[link(name = "kernel32")]
extern "system" {
fn GetCPInfoExA(
CodePage: u32, // DWORD
dwFlags: u32, // DWORD
lpCPInfoEx: *mut CPINFOEXA // CPINFOEXA* out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("KERNEL32.dll", CharSet = CharSet.Ansi, SetLastError = true)]
public static extern bool GetCPInfoExA(uint CodePage, uint dwFlags, IntPtr lpCPInfoEx);
"@
$api = Add-Type -MemberDefinition $sig -Name 'KERNEL32_GetCPInfoExA' -Namespace Win32 -PassThru
# $api::GetCPInfoExA(CodePage, dwFlags, lpCPInfoEx)#uselib "KERNEL32.dll"
#func global GetCPInfoExA "GetCPInfoExA" sptr, sptr, sptr
; GetCPInfoExA CodePage, dwFlags, varptr(lpCPInfoEx) ; 戻り値は stat
; CodePage : DWORD -> "sptr"
; dwFlags : DWORD -> "sptr"
; lpCPInfoEx : CPINFOEXA* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "KERNEL32.dll" #cfunc global GetCPInfoExA "GetCPInfoExA" int, int, var ; res = GetCPInfoExA(CodePage, dwFlags, lpCPInfoEx) ; CodePage : DWORD -> "int" ; dwFlags : DWORD -> "int" ; lpCPInfoEx : CPINFOEXA* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "KERNEL32.dll" #cfunc global GetCPInfoExA "GetCPInfoExA" int, int, sptr ; res = GetCPInfoExA(CodePage, dwFlags, varptr(lpCPInfoEx)) ; CodePage : DWORD -> "int" ; dwFlags : DWORD -> "int" ; lpCPInfoEx : CPINFOEXA* out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; BOOL GetCPInfoExA(DWORD CodePage, DWORD dwFlags, CPINFOEXA* lpCPInfoEx) #uselib "KERNEL32.dll" #cfunc global GetCPInfoExA "GetCPInfoExA" int, int, var ; res = GetCPInfoExA(CodePage, dwFlags, lpCPInfoEx) ; CodePage : DWORD -> "int" ; dwFlags : DWORD -> "int" ; lpCPInfoEx : CPINFOEXA* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; BOOL GetCPInfoExA(DWORD CodePage, DWORD dwFlags, CPINFOEXA* lpCPInfoEx) #uselib "KERNEL32.dll" #cfunc global GetCPInfoExA "GetCPInfoExA" int, int, intptr ; res = GetCPInfoExA(CodePage, dwFlags, varptr(lpCPInfoEx)) ; CodePage : DWORD -> "int" ; dwFlags : DWORD -> "int" ; lpCPInfoEx : CPINFOEXA* out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
kernel32 = windows.NewLazySystemDLL("KERNEL32.dll")
procGetCPInfoExA = kernel32.NewProc("GetCPInfoExA")
)
// CodePage (DWORD), dwFlags (DWORD), lpCPInfoEx (CPINFOEXA* out)
r1, _, err := procGetCPInfoExA.Call(
uintptr(CodePage),
uintptr(dwFlags),
uintptr(lpCPInfoEx),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction GetCPInfoExA(
CodePage: DWORD; // DWORD
dwFlags: DWORD; // DWORD
lpCPInfoEx: Pointer // CPINFOEXA* out
): BOOL; stdcall;
external 'KERNEL32.dll' name 'GetCPInfoExA';result := DllCall("KERNEL32\GetCPInfoExA"
, "UInt", CodePage ; DWORD
, "UInt", dwFlags ; DWORD
, "Ptr", lpCPInfoEx ; CPINFOEXA* out
, "Int") ; return: BOOL●GetCPInfoExA(CodePage, dwFlags, lpCPInfoEx) = DLL("KERNEL32.dll", "bool GetCPInfoExA(dword, dword, void*)")
# 呼び出し: GetCPInfoExA(CodePage, dwFlags, lpCPInfoEx)
# CodePage : DWORD -> "dword"
# dwFlags : DWORD -> "dword"
# lpCPInfoEx : CPINFOEXA* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。