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