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