StrChrW
関数文字列内で最初に出現する指定文字を検索する。
シグネチャ
// SHLWAPI.dll (Unicode / -W)
#include <windows.h>
LPWSTR StrChrW(
LPCWSTR pszStart,
WCHAR wMatch
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| pszStart | LPCWSTR | in |
| wMatch | WCHAR | in |
戻り値の型: LPWSTR
各言語での呼び出し定義
// SHLWAPI.dll (Unicode / -W)
#include <windows.h>
LPWSTR StrChrW(
LPCWSTR pszStart,
WCHAR wMatch
);[DllImport("SHLWAPI.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern IntPtr StrChrW(
[MarshalAs(UnmanagedType.LPWStr)] string pszStart, // LPCWSTR
char wMatch // WCHAR
);<DllImport("SHLWAPI.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function StrChrW(
<MarshalAs(UnmanagedType.LPWStr)> pszStart As String, ' LPCWSTR
wMatch As Char ' WCHAR
) As IntPtr
End Function' pszStart : LPCWSTR
' wMatch : WCHAR
Declare PtrSafe Function StrChrW Lib "shlwapi" ( _
ByVal pszStart As LongPtr, _
ByVal wMatch As Integer) As LongPtr
' 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
StrChrW = ctypes.windll.shlwapi.StrChrW
StrChrW.restype = wintypes.LPWSTR
StrChrW.argtypes = [
wintypes.LPCWSTR, # pszStart : LPCWSTR
ctypes.c_wchar, # wMatch : WCHAR
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('SHLWAPI.dll')
StrChrW = Fiddle::Function.new(
lib['StrChrW'],
[
Fiddle::TYPE_VOIDP, # pszStart : LPCWSTR
Fiddle::TYPE_SHORT, # wMatch : WCHAR
],
Fiddle::TYPE_VOIDP)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"#[link(name = "shlwapi")]
extern "system" {
fn StrChrW(
pszStart: *const u16, // LPCWSTR
wMatch: u16 // WCHAR
) -> *mut u16;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("SHLWAPI.dll", CharSet = CharSet.Unicode)]
public static extern IntPtr StrChrW([MarshalAs(UnmanagedType.LPWStr)] string pszStart, char wMatch);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SHLWAPI_StrChrW' -Namespace Win32 -PassThru
# $api::StrChrW(pszStart, wMatch)#uselib "SHLWAPI.dll"
#func global StrChrW "StrChrW" wptr, wptr
; StrChrW pszStart, wMatch ; 戻り値は stat
; pszStart : LPCWSTR -> "wptr"
; wMatch : WCHAR -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "SHLWAPI.dll"
#cfunc global StrChrW "StrChrW" wstr, int
; res = StrChrW(pszStart, wMatch)
; pszStart : LPCWSTR -> "wstr"
; wMatch : WCHAR -> "int"; LPWSTR StrChrW(LPCWSTR pszStart, WCHAR wMatch)
#uselib "SHLWAPI.dll"
#cfunc global StrChrW "StrChrW" wstr, int
; res = StrChrW(pszStart, wMatch)
; pszStart : LPCWSTR -> "wstr"
; wMatch : WCHAR -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
shlwapi = windows.NewLazySystemDLL("SHLWAPI.dll")
procStrChrW = shlwapi.NewProc("StrChrW")
)
// pszStart (LPCWSTR), wMatch (WCHAR)
r1, _, err := procStrChrW.Call(
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pszStart))),
uintptr(wMatch),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // LPWSTRfunction StrChrW(
pszStart: PWideChar; // LPCWSTR
wMatch: WideChar // WCHAR
): PWideChar; stdcall;
external 'SHLWAPI.dll' name 'StrChrW';result := DllCall("SHLWAPI\StrChrW"
, "WStr", pszStart ; LPCWSTR
, "Short", wMatch ; WCHAR
, "Ptr") ; return: LPWSTR●StrChrW(pszStart, wMatch) = DLL("SHLWAPI.dll", "char* StrChrW(char*, int)")
# 呼び出し: StrChrW(pszStart, wMatch)
# pszStart : LPCWSTR -> "char*"
# wMatch : WCHAR -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。