Shell_GetCachedImageIndexW
関数キャッシュ済みアイコン(Unicode)のイメージリスト内インデックスを取得する。
シグネチャ
// SHELL32.dll (Unicode / -W)
#include <windows.h>
INT Shell_GetCachedImageIndexW(
LPCWSTR pszIconPath,
INT iIconIndex,
DWORD uIconFlags
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| pszIconPath | LPCWSTR | in |
| iIconIndex | INT | in |
| uIconFlags | DWORD | in |
戻り値の型: INT
各言語での呼び出し定義
// SHELL32.dll (Unicode / -W)
#include <windows.h>
INT Shell_GetCachedImageIndexW(
LPCWSTR pszIconPath,
INT iIconIndex,
DWORD uIconFlags
);[DllImport("SHELL32.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern int Shell_GetCachedImageIndexW(
[MarshalAs(UnmanagedType.LPWStr)] string pszIconPath, // LPCWSTR
int iIconIndex, // INT
uint uIconFlags // DWORD
);<DllImport("SHELL32.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function Shell_GetCachedImageIndexW(
<MarshalAs(UnmanagedType.LPWStr)> pszIconPath As String, ' LPCWSTR
iIconIndex As Integer, ' INT
uIconFlags As UInteger ' DWORD
) As Integer
End Function' pszIconPath : LPCWSTR
' iIconIndex : INT
' uIconFlags : DWORD
Declare PtrSafe Function Shell_GetCachedImageIndexW Lib "shell32" ( _
ByVal pszIconPath As LongPtr, _
ByVal iIconIndex As Long, _
ByVal uIconFlags As Long) 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
Shell_GetCachedImageIndexW = ctypes.windll.shell32.Shell_GetCachedImageIndexW
Shell_GetCachedImageIndexW.restype = ctypes.c_int
Shell_GetCachedImageIndexW.argtypes = [
wintypes.LPCWSTR, # pszIconPath : LPCWSTR
ctypes.c_int, # iIconIndex : INT
wintypes.DWORD, # uIconFlags : DWORD
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('SHELL32.dll')
Shell_GetCachedImageIndexW = Fiddle::Function.new(
lib['Shell_GetCachedImageIndexW'],
[
Fiddle::TYPE_VOIDP, # pszIconPath : LPCWSTR
Fiddle::TYPE_INT, # iIconIndex : INT
-Fiddle::TYPE_INT, # uIconFlags : DWORD
],
Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"#[link(name = "shell32")]
extern "system" {
fn Shell_GetCachedImageIndexW(
pszIconPath: *const u16, // LPCWSTR
iIconIndex: i32, // INT
uIconFlags: u32 // DWORD
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("SHELL32.dll", CharSet = CharSet.Unicode)]
public static extern int Shell_GetCachedImageIndexW([MarshalAs(UnmanagedType.LPWStr)] string pszIconPath, int iIconIndex, uint uIconFlags);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SHELL32_Shell_GetCachedImageIndexW' -Namespace Win32 -PassThru
# $api::Shell_GetCachedImageIndexW(pszIconPath, iIconIndex, uIconFlags)#uselib "SHELL32.dll"
#func global Shell_GetCachedImageIndexW "Shell_GetCachedImageIndexW" wptr, wptr, wptr
; Shell_GetCachedImageIndexW pszIconPath, iIconIndex, uIconFlags ; 戻り値は stat
; pszIconPath : LPCWSTR -> "wptr"
; iIconIndex : INT -> "wptr"
; uIconFlags : DWORD -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "SHELL32.dll"
#cfunc global Shell_GetCachedImageIndexW "Shell_GetCachedImageIndexW" wstr, int, int
; res = Shell_GetCachedImageIndexW(pszIconPath, iIconIndex, uIconFlags)
; pszIconPath : LPCWSTR -> "wstr"
; iIconIndex : INT -> "int"
; uIconFlags : DWORD -> "int"; INT Shell_GetCachedImageIndexW(LPCWSTR pszIconPath, INT iIconIndex, DWORD uIconFlags)
#uselib "SHELL32.dll"
#cfunc global Shell_GetCachedImageIndexW "Shell_GetCachedImageIndexW" wstr, int, int
; res = Shell_GetCachedImageIndexW(pszIconPath, iIconIndex, uIconFlags)
; pszIconPath : LPCWSTR -> "wstr"
; iIconIndex : INT -> "int"
; uIconFlags : DWORD -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
shell32 = windows.NewLazySystemDLL("SHELL32.dll")
procShell_GetCachedImageIndexW = shell32.NewProc("Shell_GetCachedImageIndexW")
)
// pszIconPath (LPCWSTR), iIconIndex (INT), uIconFlags (DWORD)
r1, _, err := procShell_GetCachedImageIndexW.Call(
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pszIconPath))),
uintptr(iIconIndex),
uintptr(uIconFlags),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // INTfunction Shell_GetCachedImageIndexW(
pszIconPath: PWideChar; // LPCWSTR
iIconIndex: Integer; // INT
uIconFlags: DWORD // DWORD
): Integer; stdcall;
external 'SHELL32.dll' name 'Shell_GetCachedImageIndexW';result := DllCall("SHELL32\Shell_GetCachedImageIndexW"
, "WStr", pszIconPath ; LPCWSTR
, "Int", iIconIndex ; INT
, "UInt", uIconFlags ; DWORD
, "Int") ; return: INT●Shell_GetCachedImageIndexW(pszIconPath, iIconIndex, uIconFlags) = DLL("SHELL32.dll", "int Shell_GetCachedImageIndexW(char*, int, dword)")
# 呼び出し: Shell_GetCachedImageIndexW(pszIconPath, iIconIndex, uIconFlags)
# pszIconPath : LPCWSTR -> "char*"
# iIconIndex : INT -> "int"
# uIconFlags : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。