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

StrRStrIW

関数
大小文字無視で最後に出現する部分文字列を検索する。
DLLSHLWAPI.dll文字セットUnicode (-W)呼出規約winapi対応OSWindows 2000 以降

シグネチャ

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

LPWSTR StrRStrIW(
    LPCWSTR pszSource,
    LPCWSTR pszLast,   // optional
    LPCWSTR pszSrch
);

パラメーター

名前方向
pszSourceLPCWSTRin
pszLastLPCWSTRinoptional
pszSrchLPCWSTRin

戻り値の型: LPWSTR

各言語での呼び出し定義

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

LPWSTR StrRStrIW(
    LPCWSTR pszSource,
    LPCWSTR pszLast,   // optional
    LPCWSTR pszSrch
);
[DllImport("SHLWAPI.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern IntPtr StrRStrIW(
    [MarshalAs(UnmanagedType.LPWStr)] string pszSource,   // LPCWSTR
    [MarshalAs(UnmanagedType.LPWStr)] string pszLast,   // LPCWSTR optional
    [MarshalAs(UnmanagedType.LPWStr)] string pszSrch   // LPCWSTR
);
<DllImport("SHLWAPI.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function StrRStrIW(
    <MarshalAs(UnmanagedType.LPWStr)> pszSource As String,   ' LPCWSTR
    <MarshalAs(UnmanagedType.LPWStr)> pszLast As String,   ' LPCWSTR optional
    <MarshalAs(UnmanagedType.LPWStr)> pszSrch As String   ' LPCWSTR
) As IntPtr
End Function
' pszSource : LPCWSTR
' pszLast : LPCWSTR optional
' pszSrch : LPCWSTR
Declare PtrSafe Function StrRStrIW Lib "shlwapi" ( _
    ByVal pszSource As LongPtr, _
    ByVal pszLast As LongPtr, _
    ByVal pszSrch As LongPtr) 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

StrRStrIW = ctypes.windll.shlwapi.StrRStrIW
StrRStrIW.restype = wintypes.LPWSTR
StrRStrIW.argtypes = [
    wintypes.LPCWSTR,  # pszSource : LPCWSTR
    wintypes.LPCWSTR,  # pszLast : LPCWSTR optional
    wintypes.LPCWSTR,  # pszSrch : LPCWSTR
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('SHLWAPI.dll')
StrRStrIW = Fiddle::Function.new(
  lib['StrRStrIW'],
  [
    Fiddle::TYPE_VOIDP,  # pszSource : LPCWSTR
    Fiddle::TYPE_VOIDP,  # pszLast : LPCWSTR optional
    Fiddle::TYPE_VOIDP,  # pszSrch : LPCWSTR
  ],
  Fiddle::TYPE_VOIDP)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"
#[link(name = "shlwapi")]
extern "system" {
    fn StrRStrIW(
        pszSource: *const u16,  // LPCWSTR
        pszLast: *const u16,  // LPCWSTR optional
        pszSrch: *const u16  // LPCWSTR
    ) -> *mut u16;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("SHLWAPI.dll", CharSet = CharSet.Unicode)]
public static extern IntPtr StrRStrIW([MarshalAs(UnmanagedType.LPWStr)] string pszSource, [MarshalAs(UnmanagedType.LPWStr)] string pszLast, [MarshalAs(UnmanagedType.LPWStr)] string pszSrch);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SHLWAPI_StrRStrIW' -Namespace Win32 -PassThru
# $api::StrRStrIW(pszSource, pszLast, pszSrch)
#uselib "SHLWAPI.dll"
#func global StrRStrIW "StrRStrIW" wptr, wptr, wptr
; StrRStrIW pszSource, pszLast, pszSrch   ; 戻り値は stat
; pszSource : LPCWSTR -> "wptr"
; pszLast : LPCWSTR optional -> "wptr"
; pszSrch : LPCWSTR -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "SHLWAPI.dll"
#cfunc global StrRStrIW "StrRStrIW" wstr, wstr, wstr
; res = StrRStrIW(pszSource, pszLast, pszSrch)
; pszSource : LPCWSTR -> "wstr"
; pszLast : LPCWSTR optional -> "wstr"
; pszSrch : LPCWSTR -> "wstr"
; LPWSTR StrRStrIW(LPCWSTR pszSource, LPCWSTR pszLast, LPCWSTR pszSrch)
#uselib "SHLWAPI.dll"
#cfunc global StrRStrIW "StrRStrIW" wstr, wstr, wstr
; res = StrRStrIW(pszSource, pszLast, pszSrch)
; pszSource : LPCWSTR -> "wstr"
; pszLast : LPCWSTR optional -> "wstr"
; pszSrch : LPCWSTR -> "wstr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	shlwapi = windows.NewLazySystemDLL("SHLWAPI.dll")
	procStrRStrIW = shlwapi.NewProc("StrRStrIW")
)

// pszSource (LPCWSTR), pszLast (LPCWSTR optional), pszSrch (LPCWSTR)
r1, _, err := procStrRStrIW.Call(
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pszSource))),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pszLast))),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pszSrch))),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // LPWSTR
function StrRStrIW(
  pszSource: PWideChar;   // LPCWSTR
  pszLast: PWideChar;   // LPCWSTR optional
  pszSrch: PWideChar   // LPCWSTR
): PWideChar; stdcall;
  external 'SHLWAPI.dll' name 'StrRStrIW';
result := DllCall("SHLWAPI\StrRStrIW"
    , "WStr", pszSource   ; LPCWSTR
    , "WStr", pszLast   ; LPCWSTR optional
    , "WStr", pszSrch   ; LPCWSTR
    , "Ptr")   ; return: LPWSTR
●StrRStrIW(pszSource, pszLast, pszSrch) = DLL("SHLWAPI.dll", "char* StrRStrIW(char*, char*, char*)")
# 呼び出し: StrRStrIW(pszSource, pszLast, pszSrch)
# pszSource : LPCWSTR -> "char*"
# pszLast : LPCWSTR optional -> "char*"
# pszSrch : LPCWSTR -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。