GetCurrencyFormatA
関数シグネチャ
// KERNEL32.dll (ANSI / -A)
#include <windows.h>
INT GetCurrencyFormatA(
DWORD Locale,
DWORD dwFlags,
LPCSTR lpValue,
const CURRENCYFMTA* lpFormat, // optional
LPSTR lpCurrencyStr, // optional
INT cchCurrency
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| Locale | DWORD | in | この関数が通貨文字列を書式設定する対象のロケールを指定するロケール識別子です。MAKELCID マクロを使用してロケール識別子を作成するか、次の定義済みの値のいずれかを使用できます。 |
| dwFlags | DWORD | in | 通貨の書式を制御するフラグです。lpFormat が NULL に設定されていない場合、アプリケーションはこのパラメーターを 0 に設定する必要があります。この場合、関数はロケールの既定の通貨書式に対するユーザーの上書き設定を使用して文字列を書式設定します。lpFormat が NULL に設定されている場合、アプリケーションは LOCALE_NOUSEROVERRIDE を指定して、指定されたロケールのシステム既定の通貨書式を使用して文字列を書式設定できます。 注意 LOCALE_NOUSEROVERRIDE はユーザー設定を無効にするため、その使用は強く推奨されません。
|
| lpValue | LPCSTR | in | 詳細については、GetCurrencyFormatEx の lpValue パラメーターを参照してください。 |
| lpFormat | CURRENCYFMTA* | inoptional | 通貨の書式設定情報を格納する CURRENCYFMT 構造体へのポインターです。構造体のすべてのメンバーには適切な値を格納する必要があります。関数が指定されたロケールの通貨書式を使用する場合、アプリケーションはこのパラメーターを NULL に設定できます。このパラメーターが NULL に設定されていない場合、関数は CURRENCYFMT 構造体で指定されていない書式設定情報(たとえばロケールで使用される負符号の文字列値など)に対してのみ、指定されたロケールを使用します。 |
| lpCurrencyStr | LPSTR | outoptional | この関数が書式設定済みの通貨文字列を取得するバッファーへのポインターです。 |
| cchCurrency | INT | in | lpCurrencyStr バッファーのサイズ(文字数単位)です。書式設定済みの通貨文字列を格納するために必要なバッファーのサイズを関数に返させる場合、アプリケーションはこのパラメーターを 0 に設定します。この場合、lpCurrencyStr パラメーターは使用されません。 |
戻り値の型: INT
公式ドキュメント
数値文字列を、識別子で指定されたロケールの通貨文字列として書式設定します。(ANSI)
戻り値
成功した場合、lpCurrencyStr で示されるバッファーに取得された文字数を返します。cchCurrency パラメーターが 0 に設定されている場合、関数は終端の null 文字を含めて、書式設定済みの通貨文字列を格納するために必要なバッファーのサイズを返します。
関数が成功しなかった場合は 0 を返します。拡張エラー情報を取得するには、アプリケーションは GetLastError を呼び出します。この関数は次のいずれかのエラーコードを返すことがあります。
- ERROR_INSUFFICIENT_BUFFER。指定されたバッファーサイズが十分な大きさでなかったか、誤って NULL に設定されていました。
- ERROR_INVALID_FLAGS。フラグに指定された値が無効でした。
- ERROR_INVALID_PARAMETER。いずれかのパラメーター値が無効でした。
解説(Remarks)
この関数はカスタムロケールからデータを取得できます。データはコンピューター間やアプリケーションの実行ごとに同一であることは保証されません。アプリケーションがデータを永続化または送信する必要がある場合は、Using Persistent Locale Data を参照してください。
この関数の ANSI バージョンを Unicode 専用のロケール識別子と共に使用すると、オペレーティングシステムがシステムコードページを使用するため、呼び出しが成功する場合があります。ただし、システムコードページで未定義の文字は、文字列内では疑問符 (?) として表示されます。
winnls.h ヘッダーは GetCurrencyFormat を、UNICODE プリプロセッサ定数の定義に基づいてこの関数の ANSI バージョンまたは Unicode バージョンを自動的に選択するエイリアスとして定義します。エンコーディング非依存のエイリアスの使用を、エンコーディング非依存ではないコードと混在させると、不一致が生じ、コンパイルエラーまたは実行時エラーを引き起こす可能性があります。詳細については、Conventions for Function Prototypes を参照してください。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// KERNEL32.dll (ANSI / -A)
#include <windows.h>
INT GetCurrencyFormatA(
DWORD Locale,
DWORD dwFlags,
LPCSTR lpValue,
const CURRENCYFMTA* lpFormat, // optional
LPSTR lpCurrencyStr, // optional
INT cchCurrency
);[DllImport("KERNEL32.dll", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
static extern int GetCurrencyFormatA(
uint Locale, // DWORD
uint dwFlags, // DWORD
[MarshalAs(UnmanagedType.LPStr)] string lpValue, // LPCSTR
IntPtr lpFormat, // CURRENCYFMTA* optional
[MarshalAs(UnmanagedType.LPStr)] System.Text.StringBuilder lpCurrencyStr, // LPSTR optional, out
int cchCurrency // INT
);<DllImport("KERNEL32.dll", CharSet:=CharSet.Ansi, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function GetCurrencyFormatA(
Locale As UInteger, ' DWORD
dwFlags As UInteger, ' DWORD
<MarshalAs(UnmanagedType.LPStr)> lpValue As String, ' LPCSTR
lpFormat As IntPtr, ' CURRENCYFMTA* optional
<MarshalAs(UnmanagedType.LPStr)> lpCurrencyStr As System.Text.StringBuilder, ' LPSTR optional, out
cchCurrency As Integer ' INT
) As Integer
End Function' Locale : DWORD
' dwFlags : DWORD
' lpValue : LPCSTR
' lpFormat : CURRENCYFMTA* optional
' lpCurrencyStr : LPSTR optional, out
' cchCurrency : INT
Declare PtrSafe Function GetCurrencyFormatA Lib "kernel32" ( _
ByVal Locale As Long, _
ByVal dwFlags As Long, _
ByVal lpValue As String, _
ByVal lpFormat As LongPtr, _
ByVal lpCurrencyStr As String, _
ByVal cchCurrency As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
GetCurrencyFormatA = ctypes.windll.kernel32.GetCurrencyFormatA
GetCurrencyFormatA.restype = ctypes.c_int
GetCurrencyFormatA.argtypes = [
wintypes.DWORD, # Locale : DWORD
wintypes.DWORD, # dwFlags : DWORD
wintypes.LPCSTR, # lpValue : LPCSTR
ctypes.c_void_p, # lpFormat : CURRENCYFMTA* optional
wintypes.LPSTR, # lpCurrencyStr : LPSTR optional, out
ctypes.c_int, # cchCurrency : INT
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('KERNEL32.dll')
GetCurrencyFormatA = Fiddle::Function.new(
lib['GetCurrencyFormatA'],
[
-Fiddle::TYPE_INT, # Locale : DWORD
-Fiddle::TYPE_INT, # dwFlags : DWORD
Fiddle::TYPE_VOIDP, # lpValue : LPCSTR
Fiddle::TYPE_VOIDP, # lpFormat : CURRENCYFMTA* optional
Fiddle::TYPE_VOIDP, # lpCurrencyStr : LPSTR optional, out
Fiddle::TYPE_INT, # cchCurrency : INT
],
Fiddle::TYPE_INT)#[link(name = "kernel32")]
extern "system" {
fn GetCurrencyFormatA(
Locale: u32, // DWORD
dwFlags: u32, // DWORD
lpValue: *const u8, // LPCSTR
lpFormat: *const CURRENCYFMTA, // CURRENCYFMTA* optional
lpCurrencyStr: *mut u8, // LPSTR optional, out
cchCurrency: i32 // INT
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("KERNEL32.dll", CharSet = CharSet.Ansi, SetLastError = true)]
public static extern int GetCurrencyFormatA(uint Locale, uint dwFlags, [MarshalAs(UnmanagedType.LPStr)] string lpValue, IntPtr lpFormat, [MarshalAs(UnmanagedType.LPStr)] System.Text.StringBuilder lpCurrencyStr, int cchCurrency);
"@
$api = Add-Type -MemberDefinition $sig -Name 'KERNEL32_GetCurrencyFormatA' -Namespace Win32 -PassThru
# $api::GetCurrencyFormatA(Locale, dwFlags, lpValue, lpFormat, lpCurrencyStr, cchCurrency)#uselib "KERNEL32.dll"
#func global GetCurrencyFormatA "GetCurrencyFormatA" sptr, sptr, sptr, sptr, sptr, sptr
; GetCurrencyFormatA Locale, dwFlags, lpValue, varptr(lpFormat), varptr(lpCurrencyStr), cchCurrency ; 戻り値は stat
; Locale : DWORD -> "sptr"
; dwFlags : DWORD -> "sptr"
; lpValue : LPCSTR -> "sptr"
; lpFormat : CURRENCYFMTA* optional -> "sptr"
; lpCurrencyStr : LPSTR optional, out -> "sptr"
; cchCurrency : INT -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "KERNEL32.dll" #cfunc global GetCurrencyFormatA "GetCurrencyFormatA" int, int, str, var, var, int ; res = GetCurrencyFormatA(Locale, dwFlags, lpValue, lpFormat, lpCurrencyStr, cchCurrency) ; Locale : DWORD -> "int" ; dwFlags : DWORD -> "int" ; lpValue : LPCSTR -> "str" ; lpFormat : CURRENCYFMTA* optional -> "var" ; lpCurrencyStr : LPSTR optional, out -> "var" ; cchCurrency : INT -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "KERNEL32.dll" #cfunc global GetCurrencyFormatA "GetCurrencyFormatA" int, int, str, sptr, sptr, int ; res = GetCurrencyFormatA(Locale, dwFlags, lpValue, varptr(lpFormat), varptr(lpCurrencyStr), cchCurrency) ; Locale : DWORD -> "int" ; dwFlags : DWORD -> "int" ; lpValue : LPCSTR -> "str" ; lpFormat : CURRENCYFMTA* optional -> "sptr" ; lpCurrencyStr : LPSTR optional, out -> "sptr" ; cchCurrency : INT -> "int" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
; INT GetCurrencyFormatA(DWORD Locale, DWORD dwFlags, LPCSTR lpValue, CURRENCYFMTA* lpFormat, LPSTR lpCurrencyStr, INT cchCurrency) #uselib "KERNEL32.dll" #cfunc global GetCurrencyFormatA "GetCurrencyFormatA" int, int, str, var, var, int ; res = GetCurrencyFormatA(Locale, dwFlags, lpValue, lpFormat, lpCurrencyStr, cchCurrency) ; Locale : DWORD -> "int" ; dwFlags : DWORD -> "int" ; lpValue : LPCSTR -> "str" ; lpFormat : CURRENCYFMTA* optional -> "var" ; lpCurrencyStr : LPSTR optional, out -> "var" ; cchCurrency : INT -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; INT GetCurrencyFormatA(DWORD Locale, DWORD dwFlags, LPCSTR lpValue, CURRENCYFMTA* lpFormat, LPSTR lpCurrencyStr, INT cchCurrency) #uselib "KERNEL32.dll" #cfunc global GetCurrencyFormatA "GetCurrencyFormatA" int, int, str, intptr, intptr, int ; res = GetCurrencyFormatA(Locale, dwFlags, lpValue, varptr(lpFormat), varptr(lpCurrencyStr), cchCurrency) ; Locale : DWORD -> "int" ; dwFlags : DWORD -> "int" ; lpValue : LPCSTR -> "str" ; lpFormat : CURRENCYFMTA* optional -> "intptr" ; lpCurrencyStr : LPSTR optional, out -> "intptr" ; cchCurrency : INT -> "int" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
kernel32 = windows.NewLazySystemDLL("KERNEL32.dll")
procGetCurrencyFormatA = kernel32.NewProc("GetCurrencyFormatA")
)
// Locale (DWORD), dwFlags (DWORD), lpValue (LPCSTR), lpFormat (CURRENCYFMTA* optional), lpCurrencyStr (LPSTR optional, out), cchCurrency (INT)
r1, _, err := procGetCurrencyFormatA.Call(
uintptr(Locale),
uintptr(dwFlags),
uintptr(unsafe.Pointer(windows.BytePtrFromString(lpValue))),
uintptr(lpFormat),
uintptr(lpCurrencyStr),
uintptr(cchCurrency),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // INTfunction GetCurrencyFormatA(
Locale: DWORD; // DWORD
dwFlags: DWORD; // DWORD
lpValue: PAnsiChar; // LPCSTR
lpFormat: Pointer; // CURRENCYFMTA* optional
lpCurrencyStr: PAnsiChar; // LPSTR optional, out
cchCurrency: Integer // INT
): Integer; stdcall;
external 'KERNEL32.dll' name 'GetCurrencyFormatA';result := DllCall("KERNEL32\GetCurrencyFormatA"
, "UInt", Locale ; DWORD
, "UInt", dwFlags ; DWORD
, "AStr", lpValue ; LPCSTR
, "Ptr", lpFormat ; CURRENCYFMTA* optional
, "Ptr", lpCurrencyStr ; LPSTR optional, out
, "Int", cchCurrency ; INT
, "Int") ; return: INT●GetCurrencyFormatA(Locale, dwFlags, lpValue, lpFormat, lpCurrencyStr, cchCurrency) = DLL("KERNEL32.dll", "int GetCurrencyFormatA(dword, dword, char*, void*, char*, int)")
# 呼び出し: GetCurrencyFormatA(Locale, dwFlags, lpValue, lpFormat, lpCurrencyStr, cchCurrency)
# Locale : DWORD -> "dword"
# dwFlags : DWORD -> "dword"
# lpValue : LPCSTR -> "char*"
# lpFormat : CURRENCYFMTA* optional -> "void*"
# lpCurrencyStr : LPSTR optional, out -> "char*"
# cchCurrency : INT -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "kernel32" fn GetCurrencyFormatA(
Locale: u32, // DWORD
dwFlags: u32, // DWORD
lpValue: [*c]const u8, // LPCSTR
lpFormat: [*c]CURRENCYFMTA, // CURRENCYFMTA* optional
lpCurrencyStr: [*c]u8, // LPSTR optional, out
cchCurrency: i32 // INT
) callconv(std.os.windows.WINAPI) i32;proc GetCurrencyFormatA(
Locale: uint32, # DWORD
dwFlags: uint32, # DWORD
lpValue: cstring, # LPCSTR
lpFormat: ptr CURRENCYFMTA, # CURRENCYFMTA* optional
lpCurrencyStr: ptr char, # LPSTR optional, out
cchCurrency: int32 # INT
): int32 {.importc: "GetCurrencyFormatA", stdcall, dynlib: "KERNEL32.dll".}pragma(lib, "kernel32");
extern(Windows)
int GetCurrencyFormatA(
uint Locale, // DWORD
uint dwFlags, // DWORD
const(char)* lpValue, // LPCSTR
CURRENCYFMTA* lpFormat, // CURRENCYFMTA* optional
char* lpCurrencyStr, // LPSTR optional, out
int cchCurrency // INT
);ccall((:GetCurrencyFormatA, "KERNEL32.dll"), stdcall, Int32,
(UInt32, UInt32, Cstring, Ptr{CURRENCYFMTA}, Ptr{UInt8}, Int32),
Locale, dwFlags, lpValue, lpFormat, lpCurrencyStr, cchCurrency)
# Locale : DWORD -> UInt32
# dwFlags : DWORD -> UInt32
# lpValue : LPCSTR -> Cstring
# lpFormat : CURRENCYFMTA* optional -> Ptr{CURRENCYFMTA}
# lpCurrencyStr : LPSTR optional, out -> Ptr{UInt8}
# cchCurrency : INT -> Int32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t GetCurrencyFormatA(
uint32_t Locale,
uint32_t dwFlags,
const char* lpValue,
void* lpFormat,
char* lpCurrencyStr,
int32_t cchCurrency);
]]
local kernel32 = ffi.load("kernel32")
-- kernel32.GetCurrencyFormatA(Locale, dwFlags, lpValue, lpFormat, lpCurrencyStr, cchCurrency)
-- Locale : DWORD
-- dwFlags : DWORD
-- lpValue : LPCSTR
-- lpFormat : CURRENCYFMTA* optional
-- lpCurrencyStr : LPSTR optional, out
-- cchCurrency : INT
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('KERNEL32.dll');
const GetCurrencyFormatA = lib.func('__stdcall', 'GetCurrencyFormatA', 'int32_t', ['uint32_t', 'uint32_t', 'str', 'void *', 'char *', 'int32_t']);
// GetCurrencyFormatA(Locale, dwFlags, lpValue, lpFormat, lpCurrencyStr, cchCurrency)
// Locale : DWORD -> 'uint32_t'
// dwFlags : DWORD -> 'uint32_t'
// lpValue : LPCSTR -> 'str'
// lpFormat : CURRENCYFMTA* optional -> 'void *'
// lpCurrencyStr : LPSTR optional, out -> 'char *'
// cchCurrency : INT -> 'int32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("KERNEL32.dll", {
GetCurrencyFormatA: { parameters: ["u32", "u32", "buffer", "pointer", "buffer", "i32"], result: "i32" },
});
// lib.symbols.GetCurrencyFormatA(Locale, dwFlags, lpValue, lpFormat, lpCurrencyStr, cchCurrency)
// Locale : DWORD -> "u32"
// dwFlags : DWORD -> "u32"
// lpValue : LPCSTR -> "buffer"
// lpFormat : CURRENCYFMTA* optional -> "pointer"
// lpCurrencyStr : LPSTR optional, out -> "buffer"
// cchCurrency : INT -> "i32"
// 文字列は "buffer"。ANSI(-A) は new TextEncoder() で UTF-8/ANSI バイト列(末尾に \x00)を渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t GetCurrencyFormatA(
uint32_t Locale,
uint32_t dwFlags,
const char* lpValue,
void* lpFormat,
char* lpCurrencyStr,
int32_t cchCurrency);
C, "KERNEL32.dll");
// $ffi->GetCurrencyFormatA(Locale, dwFlags, lpValue, lpFormat, lpCurrencyStr, cchCurrency);
// Locale : DWORD
// dwFlags : DWORD
// lpValue : LPCSTR
// lpFormat : CURRENCYFMTA* optional
// lpCurrencyStr : LPSTR optional, out
// cchCurrency : INT
// 構造体/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 Kernel32 extends StdCallLibrary {
Kernel32 INSTANCE = Native.load("kernel32", Kernel32.class, W32APIOptions.ASCII_OPTIONS);
int GetCurrencyFormatA(
int Locale, // DWORD
int dwFlags, // DWORD
String lpValue, // LPCSTR
Pointer lpFormat, // CURRENCYFMTA* optional
byte[] lpCurrencyStr, // LPSTR optional, out
int cchCurrency // INT
);
}@[Link("kernel32")]
lib LibKERNEL32
fun GetCurrencyFormatA = GetCurrencyFormatA(
Locale : UInt32, # DWORD
dwFlags : UInt32, # DWORD
lpValue : UInt8*, # LPCSTR
lpFormat : CURRENCYFMTA*, # CURRENCYFMTA* optional
lpCurrencyStr : UInt8*, # LPSTR optional, out
cchCurrency : Int32 # INT
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef GetCurrencyFormatANative = Int32 Function(Uint32, Uint32, Pointer<Utf8>, Pointer<Void>, Pointer<Utf8>, Int32);
typedef GetCurrencyFormatADart = int Function(int, int, Pointer<Utf8>, Pointer<Void>, Pointer<Utf8>, int);
final GetCurrencyFormatA = DynamicLibrary.open('KERNEL32.dll')
.lookupFunction<GetCurrencyFormatANative, GetCurrencyFormatADart>('GetCurrencyFormatA');
// Locale : DWORD -> Uint32
// dwFlags : DWORD -> Uint32
// lpValue : LPCSTR -> Pointer<Utf8>
// lpFormat : CURRENCYFMTA* optional -> Pointer<Void>
// lpCurrencyStr : LPSTR optional, out -> Pointer<Utf8>
// cchCurrency : INT -> Int32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function GetCurrencyFormatA(
Locale: DWORD; // DWORD
dwFlags: DWORD; // DWORD
lpValue: PAnsiChar; // LPCSTR
lpFormat: Pointer; // CURRENCYFMTA* optional
lpCurrencyStr: PAnsiChar; // LPSTR optional, out
cchCurrency: Integer // INT
): Integer; stdcall;
external 'KERNEL32.dll' name 'GetCurrencyFormatA';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "GetCurrencyFormatA"
c_GetCurrencyFormatA :: Word32 -> Word32 -> CString -> Ptr () -> CString -> Int32 -> IO Int32
-- Locale : DWORD -> Word32
-- dwFlags : DWORD -> Word32
-- lpValue : LPCSTR -> CString
-- lpFormat : CURRENCYFMTA* optional -> Ptr ()
-- lpCurrencyStr : LPSTR optional, out -> CString
-- cchCurrency : INT -> Int32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let getcurrencyformata =
foreign "GetCurrencyFormatA"
(uint32_t @-> uint32_t @-> string @-> (ptr void) @-> string @-> int32_t @-> returning int32_t)
(* Locale : DWORD -> uint32_t *)
(* dwFlags : DWORD -> uint32_t *)
(* lpValue : LPCSTR -> string *)
(* lpFormat : CURRENCYFMTA* optional -> (ptr void) *)
(* lpCurrencyStr : LPSTR optional, out -> string *)
(* cchCurrency : INT -> int32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library kernel32 (t "KERNEL32.dll"))
(cffi:use-foreign-library kernel32)
(cffi:defcfun ("GetCurrencyFormatA" get-currency-format-a :convention :stdcall) :int32
(locale :uint32) ; DWORD
(dw-flags :uint32) ; DWORD
(lp-value :string) ; LPCSTR
(lp-format :pointer) ; CURRENCYFMTA* optional
(lp-currency-str :pointer) ; LPSTR optional, out
(cch-currency :int32)) ; INT
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $GetCurrencyFormatA = Win32::API::More->new('KERNEL32',
'int GetCurrencyFormatA(DWORD Locale, DWORD dwFlags, LPCSTR lpValue, LPVOID lpFormat, LPSTR lpCurrencyStr, int cchCurrency)');
# my $ret = $GetCurrencyFormatA->Call($Locale, $dwFlags, $lpValue, $lpFormat, $lpCurrencyStr, $cchCurrency);
# Locale : DWORD -> DWORD
# dwFlags : DWORD -> DWORD
# lpValue : LPCSTR -> LPCSTR
# lpFormat : CURRENCYFMTA* optional -> LPVOID
# lpCurrencyStr : LPSTR optional, out -> LPSTR
# cchCurrency : INT -> int
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
- f GetCurrencyFormatW (Unicode版) — 指定ロケールに従い通貨を文字列へ整形する。Unicode版。
- f GetCurrencyFormatEx — ロケール名に従って数値を通貨書式の文字列に整形する。
- f GetNumberFormatA — 指定ロケールに従い数値を文字列へ整形する。ANSI版。