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