Win32 API 日本語リファレンス
ホームUI.Shell › SHGetIconOverlayIndexW

SHGetIconOverlayIndexW

関数
指定アイコンのオーバーレイインデックスを取得する(Unicode版)。
DLLSHELL32.dll文字セットUnicode (-W)呼出規約winapi対応OSWindows 2000 以降

シグネチャ

// SHELL32.dll  (Unicode / -W)
#include <windows.h>

INT SHGetIconOverlayIndexW(
    LPCWSTR pszIconPath,   // optional
    INT iIconIndex
);

パラメーター

名前方向
pszIconPathLPCWSTRinoptional
iIconIndexINTin

戻り値の型: INT

各言語での呼び出し定義

// SHELL32.dll  (Unicode / -W)
#include <windows.h>

INT SHGetIconOverlayIndexW(
    LPCWSTR pszIconPath,   // optional
    INT iIconIndex
);
[DllImport("SHELL32.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern int SHGetIconOverlayIndexW(
    [MarshalAs(UnmanagedType.LPWStr)] string pszIconPath,   // LPCWSTR optional
    int iIconIndex   // INT
);
<DllImport("SHELL32.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function SHGetIconOverlayIndexW(
    <MarshalAs(UnmanagedType.LPWStr)> pszIconPath As String,   ' LPCWSTR optional
    iIconIndex As Integer   ' INT
) As Integer
End Function
' pszIconPath : LPCWSTR optional
' iIconIndex : INT
Declare PtrSafe Function SHGetIconOverlayIndexW Lib "shell32" ( _
    ByVal pszIconPath As LongPtr, _
    ByVal iIconIndex 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

SHGetIconOverlayIndexW = ctypes.windll.shell32.SHGetIconOverlayIndexW
SHGetIconOverlayIndexW.restype = ctypes.c_int
SHGetIconOverlayIndexW.argtypes = [
    wintypes.LPCWSTR,  # pszIconPath : LPCWSTR optional
    ctypes.c_int,  # iIconIndex : INT
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('SHELL32.dll')
SHGetIconOverlayIndexW = Fiddle::Function.new(
  lib['SHGetIconOverlayIndexW'],
  [
    Fiddle::TYPE_VOIDP,  # pszIconPath : LPCWSTR optional
    Fiddle::TYPE_INT,  # iIconIndex : INT
  ],
  Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"
#[link(name = "shell32")]
extern "system" {
    fn SHGetIconOverlayIndexW(
        pszIconPath: *const u16,  // LPCWSTR optional
        iIconIndex: i32  // INT
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("SHELL32.dll", CharSet = CharSet.Unicode)]
public static extern int SHGetIconOverlayIndexW([MarshalAs(UnmanagedType.LPWStr)] string pszIconPath, int iIconIndex);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SHELL32_SHGetIconOverlayIndexW' -Namespace Win32 -PassThru
# $api::SHGetIconOverlayIndexW(pszIconPath, iIconIndex)
#uselib "SHELL32.dll"
#func global SHGetIconOverlayIndexW "SHGetIconOverlayIndexW" wptr, wptr
; SHGetIconOverlayIndexW pszIconPath, iIconIndex   ; 戻り値は stat
; pszIconPath : LPCWSTR optional -> "wptr"
; iIconIndex : INT -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "SHELL32.dll"
#cfunc global SHGetIconOverlayIndexW "SHGetIconOverlayIndexW" wstr, int
; res = SHGetIconOverlayIndexW(pszIconPath, iIconIndex)
; pszIconPath : LPCWSTR optional -> "wstr"
; iIconIndex : INT -> "int"
; INT SHGetIconOverlayIndexW(LPCWSTR pszIconPath, INT iIconIndex)
#uselib "SHELL32.dll"
#cfunc global SHGetIconOverlayIndexW "SHGetIconOverlayIndexW" wstr, int
; res = SHGetIconOverlayIndexW(pszIconPath, iIconIndex)
; pszIconPath : LPCWSTR optional -> "wstr"
; iIconIndex : INT -> "int"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	shell32 = windows.NewLazySystemDLL("SHELL32.dll")
	procSHGetIconOverlayIndexW = shell32.NewProc("SHGetIconOverlayIndexW")
)

// pszIconPath (LPCWSTR optional), iIconIndex (INT)
r1, _, err := procSHGetIconOverlayIndexW.Call(
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pszIconPath))),
	uintptr(iIconIndex),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // INT
function SHGetIconOverlayIndexW(
  pszIconPath: PWideChar;   // LPCWSTR optional
  iIconIndex: Integer   // INT
): Integer; stdcall;
  external 'SHELL32.dll' name 'SHGetIconOverlayIndexW';
result := DllCall("SHELL32\SHGetIconOverlayIndexW"
    , "WStr", pszIconPath   ; LPCWSTR optional
    , "Int", iIconIndex   ; INT
    , "Int")   ; return: INT
●SHGetIconOverlayIndexW(pszIconPath, iIconIndex) = DLL("SHELL32.dll", "int SHGetIconOverlayIndexW(char*, int)")
# 呼び出し: SHGetIconOverlayIndexW(pszIconPath, iIconIndex)
# pszIconPath : LPCWSTR optional -> "char*"
# iIconIndex : INT -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。