ホーム › Globalization › GetDistanceOfClosestLanguageInList
GetDistanceOfClosestLanguageInList
関数一覧内で最も近い言語との距離を取得する。
シグネチャ
// bcp47mrm.dll
#include <windows.h>
HRESULT GetDistanceOfClosestLanguageInList(
LPCWSTR pszLanguage,
LPCWSTR pszLanguagesList,
WCHAR wchListDelimiter,
DOUBLE* pClosestDistance
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| pszLanguage | LPCWSTR | in | 距離を測る基準となる言語のBCP-47タグ文字列へのポインター。 |
| pszLanguagesList | LPCWSTR | in | 比較対象の言語タグを区切り文字で連結したリスト文字列へのポインター。 |
| wchListDelimiter | WCHAR | in | 言語リストの区切りに用いる1文字(ワイド文字)。 |
| pClosestDistance | DOUBLE* | out | 最も近い言語との距離値(0.0が完全一致)を受け取るdouble出力ポインター。 |
戻り値の型: HRESULT
各言語での呼び出し定義
// bcp47mrm.dll
#include <windows.h>
HRESULT GetDistanceOfClosestLanguageInList(
LPCWSTR pszLanguage,
LPCWSTR pszLanguagesList,
WCHAR wchListDelimiter,
DOUBLE* pClosestDistance
);[DllImport("bcp47mrm.dll", ExactSpelling = true)]
static extern int GetDistanceOfClosestLanguageInList(
[MarshalAs(UnmanagedType.LPWStr)] string pszLanguage, // LPCWSTR
[MarshalAs(UnmanagedType.LPWStr)] string pszLanguagesList, // LPCWSTR
char wchListDelimiter, // WCHAR
out double pClosestDistance // DOUBLE* out
);<DllImport("bcp47mrm.dll", ExactSpelling:=True)>
Public Shared Function GetDistanceOfClosestLanguageInList(
<MarshalAs(UnmanagedType.LPWStr)> pszLanguage As String, ' LPCWSTR
<MarshalAs(UnmanagedType.LPWStr)> pszLanguagesList As String, ' LPCWSTR
wchListDelimiter As Char, ' WCHAR
<Out> ByRef pClosestDistance As Double ' DOUBLE* out
) As Integer
End Function' pszLanguage : LPCWSTR
' pszLanguagesList : LPCWSTR
' wchListDelimiter : WCHAR
' pClosestDistance : DOUBLE* out
Declare PtrSafe Function GetDistanceOfClosestLanguageInList Lib "bcp47mrm" ( _
ByVal pszLanguage As LongPtr, _
ByVal pszLanguagesList As LongPtr, _
ByVal wchListDelimiter As Integer, _
ByRef pClosestDistance As Double) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
GetDistanceOfClosestLanguageInList = ctypes.windll.bcp47mrm.GetDistanceOfClosestLanguageInList
GetDistanceOfClosestLanguageInList.restype = ctypes.c_int
GetDistanceOfClosestLanguageInList.argtypes = [
wintypes.LPCWSTR, # pszLanguage : LPCWSTR
wintypes.LPCWSTR, # pszLanguagesList : LPCWSTR
ctypes.c_wchar, # wchListDelimiter : WCHAR
ctypes.POINTER(ctypes.c_double), # pClosestDistance : DOUBLE* out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('bcp47mrm.dll')
GetDistanceOfClosestLanguageInList = Fiddle::Function.new(
lib['GetDistanceOfClosestLanguageInList'],
[
Fiddle::TYPE_VOIDP, # pszLanguage : LPCWSTR
Fiddle::TYPE_VOIDP, # pszLanguagesList : LPCWSTR
Fiddle::TYPE_SHORT, # wchListDelimiter : WCHAR
Fiddle::TYPE_VOIDP, # pClosestDistance : DOUBLE* out
],
Fiddle::TYPE_INT)#[link(name = "bcp47mrm")]
extern "system" {
fn GetDistanceOfClosestLanguageInList(
pszLanguage: *const u16, // LPCWSTR
pszLanguagesList: *const u16, // LPCWSTR
wchListDelimiter: u16, // WCHAR
pClosestDistance: *mut f64 // DOUBLE* out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("bcp47mrm.dll")]
public static extern int GetDistanceOfClosestLanguageInList([MarshalAs(UnmanagedType.LPWStr)] string pszLanguage, [MarshalAs(UnmanagedType.LPWStr)] string pszLanguagesList, char wchListDelimiter, out double pClosestDistance);
"@
$api = Add-Type -MemberDefinition $sig -Name 'bcp47mrm_GetDistanceOfClosestLanguageInList' -Namespace Win32 -PassThru
# $api::GetDistanceOfClosestLanguageInList(pszLanguage, pszLanguagesList, wchListDelimiter, pClosestDistance)#uselib "bcp47mrm.dll"
#func global GetDistanceOfClosestLanguageInList "GetDistanceOfClosestLanguageInList" sptr, sptr, sptr, sptr
; GetDistanceOfClosestLanguageInList pszLanguage, pszLanguagesList, wchListDelimiter, varptr(pClosestDistance) ; 戻り値は stat
; pszLanguage : LPCWSTR -> "sptr"
; pszLanguagesList : LPCWSTR -> "sptr"
; wchListDelimiter : WCHAR -> "sptr"
; pClosestDistance : DOUBLE* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "bcp47mrm.dll" #cfunc global GetDistanceOfClosestLanguageInList "GetDistanceOfClosestLanguageInList" wstr, wstr, int, var ; res = GetDistanceOfClosestLanguageInList(pszLanguage, pszLanguagesList, wchListDelimiter, pClosestDistance) ; pszLanguage : LPCWSTR -> "wstr" ; pszLanguagesList : LPCWSTR -> "wstr" ; wchListDelimiter : WCHAR -> "int" ; pClosestDistance : DOUBLE* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "bcp47mrm.dll" #cfunc global GetDistanceOfClosestLanguageInList "GetDistanceOfClosestLanguageInList" wstr, wstr, int, sptr ; res = GetDistanceOfClosestLanguageInList(pszLanguage, pszLanguagesList, wchListDelimiter, varptr(pClosestDistance)) ; pszLanguage : LPCWSTR -> "wstr" ; pszLanguagesList : LPCWSTR -> "wstr" ; wchListDelimiter : WCHAR -> "int" ; pClosestDistance : DOUBLE* out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HRESULT GetDistanceOfClosestLanguageInList(LPCWSTR pszLanguage, LPCWSTR pszLanguagesList, WCHAR wchListDelimiter, DOUBLE* pClosestDistance) #uselib "bcp47mrm.dll" #cfunc global GetDistanceOfClosestLanguageInList "GetDistanceOfClosestLanguageInList" wstr, wstr, int, var ; res = GetDistanceOfClosestLanguageInList(pszLanguage, pszLanguagesList, wchListDelimiter, pClosestDistance) ; pszLanguage : LPCWSTR -> "wstr" ; pszLanguagesList : LPCWSTR -> "wstr" ; wchListDelimiter : WCHAR -> "int" ; pClosestDistance : DOUBLE* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HRESULT GetDistanceOfClosestLanguageInList(LPCWSTR pszLanguage, LPCWSTR pszLanguagesList, WCHAR wchListDelimiter, DOUBLE* pClosestDistance) #uselib "bcp47mrm.dll" #cfunc global GetDistanceOfClosestLanguageInList "GetDistanceOfClosestLanguageInList" wstr, wstr, int, intptr ; res = GetDistanceOfClosestLanguageInList(pszLanguage, pszLanguagesList, wchListDelimiter, varptr(pClosestDistance)) ; pszLanguage : LPCWSTR -> "wstr" ; pszLanguagesList : LPCWSTR -> "wstr" ; wchListDelimiter : WCHAR -> "int" ; pClosestDistance : DOUBLE* out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
bcp47mrm = windows.NewLazySystemDLL("bcp47mrm.dll")
procGetDistanceOfClosestLanguageInList = bcp47mrm.NewProc("GetDistanceOfClosestLanguageInList")
)
// pszLanguage (LPCWSTR), pszLanguagesList (LPCWSTR), wchListDelimiter (WCHAR), pClosestDistance (DOUBLE* out)
r1, _, err := procGetDistanceOfClosestLanguageInList.Call(
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pszLanguage))),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pszLanguagesList))),
uintptr(wchListDelimiter),
uintptr(pClosestDistance),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction GetDistanceOfClosestLanguageInList(
pszLanguage: PWideChar; // LPCWSTR
pszLanguagesList: PWideChar; // LPCWSTR
wchListDelimiter: WideChar; // WCHAR
pClosestDistance: Pointer // DOUBLE* out
): Integer; stdcall;
external 'bcp47mrm.dll' name 'GetDistanceOfClosestLanguageInList';result := DllCall("bcp47mrm\GetDistanceOfClosestLanguageInList"
, "WStr", pszLanguage ; LPCWSTR
, "WStr", pszLanguagesList ; LPCWSTR
, "Short", wchListDelimiter ; WCHAR
, "Ptr", pClosestDistance ; DOUBLE* out
, "Int") ; return: HRESULT●GetDistanceOfClosestLanguageInList(pszLanguage, pszLanguagesList, wchListDelimiter, pClosestDistance) = DLL("bcp47mrm.dll", "int GetDistanceOfClosestLanguageInList(char*, char*, int, void*)")
# 呼び出し: GetDistanceOfClosestLanguageInList(pszLanguage, pszLanguagesList, wchListDelimiter, pClosestDistance)
# pszLanguage : LPCWSTR -> "char*"
# pszLanguagesList : LPCWSTR -> "char*"
# wchListDelimiter : WCHAR -> "int"
# pClosestDistance : DOUBLE* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。