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

IsDBCSLeadByte

関数
指定バイトがDBCS先頭バイトか既定コードページで判定する。
DLLKERNEL32.dll呼出規約winapiSetLastErrorあり対応OSWindows 2000 以降

シグネチャ

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

BOOL IsDBCSLeadByte(
    BYTE TestChar
);

パラメーター

名前方向
TestCharBYTEin

戻り値の型: BOOL

各言語での呼び出し定義

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

BOOL IsDBCSLeadByte(
    BYTE TestChar
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("KERNEL32.dll", SetLastError = true, ExactSpelling = true)]
static extern bool IsDBCSLeadByte(
    byte TestChar   // BYTE
);
<DllImport("KERNEL32.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function IsDBCSLeadByte(
    TestChar As Byte   ' BYTE
) As Boolean
End Function
' TestChar : BYTE
Declare PtrSafe Function IsDBCSLeadByte Lib "kernel32" ( _
    ByVal TestChar As Byte) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

IsDBCSLeadByte = ctypes.windll.kernel32.IsDBCSLeadByte
IsDBCSLeadByte.restype = wintypes.BOOL
IsDBCSLeadByte.argtypes = [
    ctypes.c_ubyte,  # TestChar : BYTE
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('KERNEL32.dll')
IsDBCSLeadByte = Fiddle::Function.new(
  lib['IsDBCSLeadByte'],
  [
    -Fiddle::TYPE_CHAR,  # TestChar : BYTE
  ],
  Fiddle::TYPE_INT)
#[link(name = "kernel32")]
extern "system" {
    fn IsDBCSLeadByte(
        TestChar: u8  // BYTE
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("KERNEL32.dll", SetLastError = true)]
public static extern bool IsDBCSLeadByte(byte TestChar);
"@
$api = Add-Type -MemberDefinition $sig -Name 'KERNEL32_IsDBCSLeadByte' -Namespace Win32 -PassThru
# $api::IsDBCSLeadByte(TestChar)
#uselib "KERNEL32.dll"
#func global IsDBCSLeadByte "IsDBCSLeadByte" sptr
; IsDBCSLeadByte TestChar   ; 戻り値は stat
; TestChar : BYTE -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "KERNEL32.dll"
#cfunc global IsDBCSLeadByte "IsDBCSLeadByte" int
; res = IsDBCSLeadByte(TestChar)
; TestChar : BYTE -> "int"
; BOOL IsDBCSLeadByte(BYTE TestChar)
#uselib "KERNEL32.dll"
#cfunc global IsDBCSLeadByte "IsDBCSLeadByte" int
; res = IsDBCSLeadByte(TestChar)
; TestChar : BYTE -> "int"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	kernel32 = windows.NewLazySystemDLL("KERNEL32.dll")
	procIsDBCSLeadByte = kernel32.NewProc("IsDBCSLeadByte")
)

// TestChar (BYTE)
r1, _, err := procIsDBCSLeadByte.Call(
	uintptr(TestChar),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function IsDBCSLeadByte(
  TestChar: Byte   // BYTE
): BOOL; stdcall;
  external 'KERNEL32.dll' name 'IsDBCSLeadByte';
result := DllCall("KERNEL32\IsDBCSLeadByte"
    , "UChar", TestChar   ; BYTE
    , "Int")   ; return: BOOL
●IsDBCSLeadByte(TestChar) = DLL("KERNEL32.dll", "bool IsDBCSLeadByte(byte)")
# 呼び出し: IsDBCSLeadByte(TestChar)
# TestChar : BYTE -> "byte"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。