PathParseIconLocationW
関数アイコン位置文字列からパスとアイコンインデックスを分離する。
シグネチャ
// SHLWAPI.dll (Unicode / -W)
#include <windows.h>
INT PathParseIconLocationW(
LPWSTR pszIconFile
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| pszIconFile | LPWSTR | inout |
戻り値の型: INT
各言語での呼び出し定義
// SHLWAPI.dll (Unicode / -W)
#include <windows.h>
INT PathParseIconLocationW(
LPWSTR pszIconFile
);[DllImport("SHLWAPI.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern int PathParseIconLocationW(
[MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder pszIconFile // LPWSTR in/out
);<DllImport("SHLWAPI.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function PathParseIconLocationW(
<MarshalAs(UnmanagedType.LPWStr)> pszIconFile As System.Text.StringBuilder ' LPWSTR in/out
) As Integer
End Function' pszIconFile : LPWSTR in/out
Declare PtrSafe Function PathParseIconLocationW Lib "shlwapi" ( _
ByVal pszIconFile As LongPtr) As Long
' 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
PathParseIconLocationW = ctypes.windll.shlwapi.PathParseIconLocationW
PathParseIconLocationW.restype = ctypes.c_int
PathParseIconLocationW.argtypes = [
wintypes.LPWSTR, # pszIconFile : LPWSTR in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('SHLWAPI.dll')
PathParseIconLocationW = Fiddle::Function.new(
lib['PathParseIconLocationW'],
[
Fiddle::TYPE_VOIDP, # pszIconFile : LPWSTR in/out
],
Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"#[link(name = "shlwapi")]
extern "system" {
fn PathParseIconLocationW(
pszIconFile: *mut u16 // LPWSTR in/out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("SHLWAPI.dll", CharSet = CharSet.Unicode)]
public static extern int PathParseIconLocationW([MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder pszIconFile);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SHLWAPI_PathParseIconLocationW' -Namespace Win32 -PassThru
# $api::PathParseIconLocationW(pszIconFile)#uselib "SHLWAPI.dll"
#func global PathParseIconLocationW "PathParseIconLocationW" wptr
; PathParseIconLocationW varptr(pszIconFile) ; 戻り値は stat
; pszIconFile : LPWSTR in/out -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "SHLWAPI.dll" #cfunc global PathParseIconLocationW "PathParseIconLocationW" var ; res = PathParseIconLocationW(pszIconFile) ; pszIconFile : LPWSTR in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "SHLWAPI.dll" #cfunc global PathParseIconLocationW "PathParseIconLocationW" sptr ; res = PathParseIconLocationW(varptr(pszIconFile)) ; pszIconFile : LPWSTR in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; INT PathParseIconLocationW(LPWSTR pszIconFile) #uselib "SHLWAPI.dll" #cfunc global PathParseIconLocationW "PathParseIconLocationW" var ; res = PathParseIconLocationW(pszIconFile) ; pszIconFile : LPWSTR in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; INT PathParseIconLocationW(LPWSTR pszIconFile) #uselib "SHLWAPI.dll" #cfunc global PathParseIconLocationW "PathParseIconLocationW" intptr ; res = PathParseIconLocationW(varptr(pszIconFile)) ; pszIconFile : LPWSTR in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
shlwapi = windows.NewLazySystemDLL("SHLWAPI.dll")
procPathParseIconLocationW = shlwapi.NewProc("PathParseIconLocationW")
)
// pszIconFile (LPWSTR in/out)
r1, _, err := procPathParseIconLocationW.Call(
uintptr(pszIconFile),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // INTfunction PathParseIconLocationW(
pszIconFile: PWideChar // LPWSTR in/out
): Integer; stdcall;
external 'SHLWAPI.dll' name 'PathParseIconLocationW';result := DllCall("SHLWAPI\PathParseIconLocationW"
, "Ptr", pszIconFile ; LPWSTR in/out
, "Int") ; return: INT●PathParseIconLocationW(pszIconFile) = DLL("SHLWAPI.dll", "int PathParseIconLocationW(char*)")
# 呼び出し: PathParseIconLocationW(pszIconFile)
# pszIconFile : LPWSTR in/out -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。