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

SHUpdateImageW

関数
システムイメージリスト内のアイコン(Unicode)を更新する。
DLLSHELL32.dll文字セットUnicode (-W)呼出規約winapi対応OSWindows 2000 以降

シグネチャ

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

void SHUpdateImageW(
    LPCWSTR pszHashItem,
    INT iIndex,
    DWORD uFlags,
    INT iImageIndex
);

パラメーター

名前方向
pszHashItemLPCWSTRin
iIndexINTin
uFlagsDWORDin
iImageIndexINTin

戻り値の型: void

各言語での呼び出し定義

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

void SHUpdateImageW(
    LPCWSTR pszHashItem,
    INT iIndex,
    DWORD uFlags,
    INT iImageIndex
);
[DllImport("SHELL32.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern void SHUpdateImageW(
    [MarshalAs(UnmanagedType.LPWStr)] string pszHashItem,   // LPCWSTR
    int iIndex,   // INT
    uint uFlags,   // DWORD
    int iImageIndex   // INT
);
<DllImport("SHELL32.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Sub SHUpdateImageW(
    <MarshalAs(UnmanagedType.LPWStr)> pszHashItem As String,   ' LPCWSTR
    iIndex As Integer,   ' INT
    uFlags As UInteger,   ' DWORD
    iImageIndex As Integer   ' INT
)
End Sub
' pszHashItem : LPCWSTR
' iIndex : INT
' uFlags : DWORD
' iImageIndex : INT
Declare PtrSafe Sub SHUpdateImageW Lib "shell32" ( _
    ByVal pszHashItem As LongPtr, _
    ByVal iIndex As Long, _
    ByVal uFlags As Long, _
    ByVal iImageIndex 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

SHUpdateImageW = ctypes.windll.shell32.SHUpdateImageW
SHUpdateImageW.restype = None
SHUpdateImageW.argtypes = [
    wintypes.LPCWSTR,  # pszHashItem : LPCWSTR
    ctypes.c_int,  # iIndex : INT
    wintypes.DWORD,  # uFlags : DWORD
    ctypes.c_int,  # iImageIndex : INT
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('SHELL32.dll')
SHUpdateImageW = Fiddle::Function.new(
  lib['SHUpdateImageW'],
  [
    Fiddle::TYPE_VOIDP,  # pszHashItem : LPCWSTR
    Fiddle::TYPE_INT,  # iIndex : INT
    -Fiddle::TYPE_INT,  # uFlags : DWORD
    Fiddle::TYPE_INT,  # iImageIndex : INT
  ],
  Fiddle::TYPE_VOID)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"
#[link(name = "shell32")]
extern "system" {
    fn SHUpdateImageW(
        pszHashItem: *const u16,  // LPCWSTR
        iIndex: i32,  // INT
        uFlags: u32,  // DWORD
        iImageIndex: i32  // INT
    );
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("SHELL32.dll", CharSet = CharSet.Unicode)]
public static extern void SHUpdateImageW([MarshalAs(UnmanagedType.LPWStr)] string pszHashItem, int iIndex, uint uFlags, int iImageIndex);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SHELL32_SHUpdateImageW' -Namespace Win32 -PassThru
# $api::SHUpdateImageW(pszHashItem, iIndex, uFlags, iImageIndex)
#uselib "SHELL32.dll"
#func global SHUpdateImageW "SHUpdateImageW" wptr, wptr, wptr, wptr
; SHUpdateImageW pszHashItem, iIndex, uFlags, iImageIndex
; pszHashItem : LPCWSTR -> "wptr"
; iIndex : INT -> "wptr"
; uFlags : DWORD -> "wptr"
; iImageIndex : INT -> "wptr"
#uselib "SHELL32.dll"
#func global SHUpdateImageW "SHUpdateImageW" wstr, int, int, int
; SHUpdateImageW pszHashItem, iIndex, uFlags, iImageIndex
; pszHashItem : LPCWSTR -> "wstr"
; iIndex : INT -> "int"
; uFlags : DWORD -> "int"
; iImageIndex : INT -> "int"
; void SHUpdateImageW(LPCWSTR pszHashItem, INT iIndex, DWORD uFlags, INT iImageIndex)
#uselib "SHELL32.dll"
#func global SHUpdateImageW "SHUpdateImageW" wstr, int, int, int
; SHUpdateImageW pszHashItem, iIndex, uFlags, iImageIndex
; pszHashItem : LPCWSTR -> "wstr"
; iIndex : INT -> "int"
; uFlags : DWORD -> "int"
; iImageIndex : INT -> "int"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	shell32 = windows.NewLazySystemDLL("SHELL32.dll")
	procSHUpdateImageW = shell32.NewProc("SHUpdateImageW")
)

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