StrRChrIA
関数大小文字無視で最後に出現する指定文字を検索する。
シグネチャ
// SHLWAPI.dll (ANSI / -A)
#include <windows.h>
LPSTR StrRChrIA(
LPCSTR pszStart,
LPCSTR pszEnd, // optional
WORD wMatch
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| pszStart | LPCSTR | in |
| pszEnd | LPCSTR | inoptional |
| wMatch | WORD | in |
戻り値の型: LPSTR
各言語での呼び出し定義
// SHLWAPI.dll (ANSI / -A)
#include <windows.h>
LPSTR StrRChrIA(
LPCSTR pszStart,
LPCSTR pszEnd, // optional
WORD wMatch
);[DllImport("SHLWAPI.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern IntPtr StrRChrIA(
[MarshalAs(UnmanagedType.LPStr)] string pszStart, // LPCSTR
[MarshalAs(UnmanagedType.LPStr)] string pszEnd, // LPCSTR optional
ushort wMatch // WORD
);<DllImport("SHLWAPI.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Function StrRChrIA(
<MarshalAs(UnmanagedType.LPStr)> pszStart As String, ' LPCSTR
<MarshalAs(UnmanagedType.LPStr)> pszEnd As String, ' LPCSTR optional
wMatch As UShort ' WORD
) As IntPtr
End Function' pszStart : LPCSTR
' pszEnd : LPCSTR optional
' wMatch : WORD
Declare PtrSafe Function StrRChrIA Lib "shlwapi" ( _
ByVal pszStart As String, _
ByVal pszEnd As String, _
ByVal wMatch As Integer) As LongPtr
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
StrRChrIA = ctypes.windll.shlwapi.StrRChrIA
StrRChrIA.restype = wintypes.LPSTR
StrRChrIA.argtypes = [
wintypes.LPCSTR, # pszStart : LPCSTR
wintypes.LPCSTR, # pszEnd : LPCSTR optional
ctypes.c_ushort, # wMatch : WORD
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('SHLWAPI.dll')
StrRChrIA = Fiddle::Function.new(
lib['StrRChrIA'],
[
Fiddle::TYPE_VOIDP, # pszStart : LPCSTR
Fiddle::TYPE_VOIDP, # pszEnd : LPCSTR optional
-Fiddle::TYPE_SHORT, # wMatch : WORD
],
Fiddle::TYPE_VOIDP)#[link(name = "shlwapi")]
extern "system" {
fn StrRChrIA(
pszStart: *const u8, // LPCSTR
pszEnd: *const u8, // LPCSTR optional
wMatch: u16 // WORD
) -> *mut u8;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("SHLWAPI.dll", CharSet = CharSet.Ansi)]
public static extern IntPtr StrRChrIA([MarshalAs(UnmanagedType.LPStr)] string pszStart, [MarshalAs(UnmanagedType.LPStr)] string pszEnd, ushort wMatch);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SHLWAPI_StrRChrIA' -Namespace Win32 -PassThru
# $api::StrRChrIA(pszStart, pszEnd, wMatch)#uselib "SHLWAPI.dll"
#func global StrRChrIA "StrRChrIA" sptr, sptr, sptr
; StrRChrIA pszStart, pszEnd, wMatch ; 戻り値は stat
; pszStart : LPCSTR -> "sptr"
; pszEnd : LPCSTR optional -> "sptr"
; wMatch : WORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "SHLWAPI.dll"
#cfunc global StrRChrIA "StrRChrIA" str, str, int
; res = StrRChrIA(pszStart, pszEnd, wMatch)
; pszStart : LPCSTR -> "str"
; pszEnd : LPCSTR optional -> "str"
; wMatch : WORD -> "int"; LPSTR StrRChrIA(LPCSTR pszStart, LPCSTR pszEnd, WORD wMatch)
#uselib "SHLWAPI.dll"
#cfunc global StrRChrIA "StrRChrIA" str, str, int
; res = StrRChrIA(pszStart, pszEnd, wMatch)
; pszStart : LPCSTR -> "str"
; pszEnd : LPCSTR optional -> "str"
; wMatch : WORD -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
shlwapi = windows.NewLazySystemDLL("SHLWAPI.dll")
procStrRChrIA = shlwapi.NewProc("StrRChrIA")
)
// pszStart (LPCSTR), pszEnd (LPCSTR optional), wMatch (WORD)
r1, _, err := procStrRChrIA.Call(
uintptr(unsafe.Pointer(windows.BytePtrFromString(pszStart))),
uintptr(unsafe.Pointer(windows.BytePtrFromString(pszEnd))),
uintptr(wMatch),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // LPSTRfunction StrRChrIA(
pszStart: PAnsiChar; // LPCSTR
pszEnd: PAnsiChar; // LPCSTR optional
wMatch: Word // WORD
): PAnsiChar; stdcall;
external 'SHLWAPI.dll' name 'StrRChrIA';result := DllCall("SHLWAPI\StrRChrIA"
, "AStr", pszStart ; LPCSTR
, "AStr", pszEnd ; LPCSTR optional
, "UShort", wMatch ; WORD
, "Ptr") ; return: LPSTR●StrRChrIA(pszStart, pszEnd, wMatch) = DLL("SHLWAPI.dll", "char* StrRChrIA(char*, char*, int)")
# 呼び出し: StrRChrIA(pszStart, pszEnd, wMatch)
# pszStart : LPCSTR -> "char*"
# pszEnd : LPCSTR optional -> "char*"
# wMatch : WORD -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。