Win32 API 日本語リファレンス
ホームGlobalization › umsg_setLocale

umsg_setLocale

関数
メッセージフォーマッタのロケールを設定する。
DLLicuin.dll呼出規約cdecl

シグネチャ

// icuin.dll
#include <windows.h>

void umsg_setLocale(
    void** fmt,
    LPCSTR locale
);

パラメーター

名前方向説明
fmtvoid**inout対象のUMessageFormatハンドル。
localeLPCSTRin設定するロケール名。NUL終端のASCII文字列で指定する。

戻り値の型: void

各言語での呼び出し定義

// icuin.dll
#include <windows.h>

void umsg_setLocale(
    void** fmt,
    LPCSTR locale
);
[DllImport("icuin.dll", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
static extern void umsg_setLocale(
    IntPtr fmt,   // void** in/out
    [MarshalAs(UnmanagedType.LPStr)] string locale   // LPCSTR
);
<DllImport("icuin.dll", ExactSpelling:=True, CallingConvention:=CallingConvention.Cdecl)>
Public Shared Sub umsg_setLocale(
    fmt As IntPtr,   ' void** in/out
    <MarshalAs(UnmanagedType.LPStr)> locale As String   ' LPCSTR
)
End Sub
' fmt : void** in/out
' locale : LPCSTR
Declare PtrSafe Sub umsg_setLocale Lib "icuin" ( _
    ByVal fmt As LongPtr, _
    ByVal locale As String)
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

umsg_setLocale = ctypes.cdll.icuin.umsg_setLocale
umsg_setLocale.restype = None
umsg_setLocale.argtypes = [
    ctypes.c_void_p,  # fmt : void** in/out
    wintypes.LPCSTR,  # locale : LPCSTR
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('icuin.dll')
umsg_setLocale = Fiddle::Function.new(
  lib['umsg_setLocale'],
  [
    Fiddle::TYPE_VOIDP,  # fmt : void** in/out
    Fiddle::TYPE_VOIDP,  # locale : LPCSTR
  ],
  Fiddle::TYPE_VOID, Fiddle::Function::CDECL)
#[link(name = "icuin")]
extern "C" {
    fn umsg_setLocale(
        fmt: *mut *mut (),  // void** in/out
        locale: *const u8  // LPCSTR
    );
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("icuin.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern void umsg_setLocale(IntPtr fmt, [MarshalAs(UnmanagedType.LPStr)] string locale);
"@
$api = Add-Type -MemberDefinition $sig -Name 'icuin_umsg_setLocale' -Namespace Win32 -PassThru
# $api::umsg_setLocale(fmt, locale)
#uselib "icuin.dll"
#func global umsg_setLocale "umsg_setLocale" sptr, sptr
; umsg_setLocale fmt, locale
; fmt : void** in/out -> "sptr"
; locale : LPCSTR -> "sptr"
#uselib "icuin.dll"
#func global umsg_setLocale "umsg_setLocale" sptr, str
; umsg_setLocale fmt, locale
; fmt : void** in/out -> "sptr"
; locale : LPCSTR -> "str"
; void umsg_setLocale(void** fmt, LPCSTR locale)
#uselib "icuin.dll"
#func global umsg_setLocale "umsg_setLocale" intptr, str
; umsg_setLocale fmt, locale
; fmt : void** in/out -> "intptr"
; locale : LPCSTR -> "str"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	icuin = windows.NewLazySystemDLL("icuin.dll")
	procumsg_setLocale = icuin.NewProc("umsg_setLocale")
)

// fmt (void** in/out), locale (LPCSTR)
r1, _, err := procumsg_setLocale.Call(
	uintptr(fmt),
	uintptr(unsafe.Pointer(windows.BytePtrFromString(locale))),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // void
procedure umsg_setLocale(
  fmt: Pointer;   // void** in/out
  locale: PAnsiChar   // LPCSTR
); cdecl;
  external 'icuin.dll' name 'umsg_setLocale';
result := DllCall("icuin\umsg_setLocale"
    , "Ptr", fmt   ; void** in/out
    , "AStr", locale   ; LPCSTR
    , "Cdecl Int")   ; return: void
●umsg_setLocale(fmt, locale) = DLL("icuin.dll", "int umsg_setLocale(void*, char*)")
# 呼び出し: umsg_setLocale(fmt, locale)
# fmt : void** in/out -> "void*"
# locale : LPCSTR -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※cdecl関数。DLL()宣言はstdcall前提。cdeclは EXEC_PTR(`cdecl`,…) を使用。
const std = @import("std");

extern "icuin" fn umsg_setLocale(
    fmt: ?*anyopaque, // void** in/out
    locale: [*c]const u8 // LPCSTR
) callconv(.c) void;
proc umsg_setLocale(
    fmt: pointer,  # void** in/out
    locale: cstring  # LPCSTR
) {.importc: "umsg_setLocale", cdecl, dynlib: "icuin.dll".}
pragma(lib, "icuin");
extern(C)
void umsg_setLocale(
    void** fmt,   // void** in/out
    const(char)* locale   // LPCSTR
);
ccall((:umsg_setLocale, "icuin.dll"), Cvoid,
      (Ptr{Cvoid}, Cstring),
      fmt, locale)
# fmt : void** in/out -> Ptr{Cvoid}
# locale : LPCSTR -> Cstring
local ffi = require("ffi")
ffi.cdef[[
void umsg_setLocale(
    void** fmt,
    const char* locale);
]]
local icuin = ffi.load("icuin")
-- icuin.umsg_setLocale(fmt, locale)
-- fmt : void** in/out
-- locale : LPCSTR
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('icuin.dll');
const umsg_setLocale = lib.func('__cdecl', 'umsg_setLocale', 'void', ['void *', 'str']);
// umsg_setLocale(fmt, locale)
// fmt : void** in/out -> 'void *'
// locale : LPCSTR -> 'str'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("icuin.dll", {
  umsg_setLocale: { parameters: ["pointer", "buffer"], result: "void" },
});
// lib.symbols.umsg_setLocale(fmt, locale)
// fmt : void** in/out -> "pointer"
// locale : LPCSTR -> "buffer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
void umsg_setLocale(
    void** fmt,
    const char* locale);
C, "icuin.dll");
// $ffi->umsg_setLocale(fmt, locale);
// fmt : void** in/out
// locale : LPCSTR
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;

public interface Icuin extends Library {
    Icuin INSTANCE = Native.load("icuin", Icuin.class);
    void umsg_setLocale(
        Pointer fmt,   // void** in/out
        String locale   // LPCSTR
    );
}
@[Link("icuin")]
lib Libicuin
  fun umsg_setLocale = umsg_setLocale(
    fmt : Void**,   # void** in/out
    locale : UInt8*   # LPCSTR
  ) : Void
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef umsg_setLocaleNative = Void Function(Pointer<Void>, Pointer<Utf8>);
typedef umsg_setLocaleDart = void Function(Pointer<Void>, Pointer<Utf8>);
final umsg_setLocale = DynamicLibrary.open('icuin.dll')
    .lookupFunction<umsg_setLocaleNative, umsg_setLocaleDart>('umsg_setLocale');
// fmt : void** in/out -> Pointer<Void>
// locale : LPCSTR -> Pointer<Utf8>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
procedure umsg_setLocale(
  fmt: Pointer;   // void** in/out
  locale: PAnsiChar   // LPCSTR
); cdecl;
  external 'icuin.dll' name 'umsg_setLocale';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import ccall safe "umsg_setLocale"
  c_umsg_setLocale :: Ptr () -> CString -> IO ()
-- fmt : void** in/out -> Ptr ()
-- locale : LPCSTR -> CString
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let umsg_setlocale =
  foreign "umsg_setLocale"
    ((ptr void) @-> string @-> returning void)
(* fmt : void** in/out -> (ptr void) *)
(* locale : LPCSTR -> string *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library icuin (t "icuin.dll"))
(cffi:use-foreign-library icuin)

(cffi:defcfun ("umsg_setLocale" umsg-set-locale :convention :cdecl) :void
  (fmt :pointer)   ; void** in/out
  (locale :string))   ; LPCSTR
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $umsg_setLocale = Win32::API::More->new('icuin',
    'void umsg_setLocale(LPVOID fmt, LPCSTR locale)');
# my $ret = $umsg_setLocale->Call($fmt, $locale);
# fmt : void** in/out -> LPVOID
# locale : LPCSTR -> LPCSTR
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。