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