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