Win32 API 日本語リファレンス
ホームUI.Shell › PathGetCharTypeW

PathGetCharTypeW

関数
パス中の1文字が持つ意味の種類を示すフラグを取得する。
DLLSHLWAPI.dll文字セットUnicode (-W)呼出規約winapi対応OSWindows 2000 以降

シグネチャ

// SHLWAPI.dll  (Unicode / -W)
#include <windows.h>

DWORD PathGetCharTypeW(
    WCHAR ch
);

パラメーター

名前方向
chWCHARin

戻り値の型: DWORD

各言語での呼び出し定義

// SHLWAPI.dll  (Unicode / -W)
#include <windows.h>

DWORD PathGetCharTypeW(
    WCHAR ch
);
[DllImport("SHLWAPI.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern uint PathGetCharTypeW(
    char ch   // WCHAR
);
<DllImport("SHLWAPI.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function PathGetCharTypeW(
    ch As Char   ' WCHAR
) As UInteger
End Function
' ch : WCHAR
Declare PtrSafe Function PathGetCharTypeW Lib "shlwapi" ( _
    ByVal ch As Integer) 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

PathGetCharTypeW = ctypes.windll.shlwapi.PathGetCharTypeW
PathGetCharTypeW.restype = wintypes.DWORD
PathGetCharTypeW.argtypes = [
    ctypes.c_wchar,  # ch : WCHAR
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('SHLWAPI.dll')
PathGetCharTypeW = Fiddle::Function.new(
  lib['PathGetCharTypeW'],
  [
    Fiddle::TYPE_SHORT,  # ch : WCHAR
  ],
  -Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"
#[link(name = "shlwapi")]
extern "system" {
    fn PathGetCharTypeW(
        ch: u16  // WCHAR
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("SHLWAPI.dll", CharSet = CharSet.Unicode)]
public static extern uint PathGetCharTypeW(char ch);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SHLWAPI_PathGetCharTypeW' -Namespace Win32 -PassThru
# $api::PathGetCharTypeW(ch)
#uselib "SHLWAPI.dll"
#func global PathGetCharTypeW "PathGetCharTypeW" wptr
; PathGetCharTypeW ch   ; 戻り値は stat
; ch : WCHAR -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "SHLWAPI.dll"
#cfunc global PathGetCharTypeW "PathGetCharTypeW" int
; res = PathGetCharTypeW(ch)
; ch : WCHAR -> "int"
; DWORD PathGetCharTypeW(WCHAR ch)
#uselib "SHLWAPI.dll"
#cfunc global PathGetCharTypeW "PathGetCharTypeW" int
; res = PathGetCharTypeW(ch)
; ch : WCHAR -> "int"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	shlwapi = windows.NewLazySystemDLL("SHLWAPI.dll")
	procPathGetCharTypeW = shlwapi.NewProc("PathGetCharTypeW")
)

// ch (WCHAR)
r1, _, err := procPathGetCharTypeW.Call(
	uintptr(ch),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function PathGetCharTypeW(
  ch: WideChar   // WCHAR
): DWORD; stdcall;
  external 'SHLWAPI.dll' name 'PathGetCharTypeW';
result := DllCall("SHLWAPI\PathGetCharTypeW"
    , "Short", ch   ; WCHAR
    , "UInt")   ; return: DWORD
●PathGetCharTypeW(ch) = DLL("SHLWAPI.dll", "dword PathGetCharTypeW(int)")
# 呼び出し: PathGetCharTypeW(ch)
# ch : WCHAR -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。