SHMapPIDLToSystemImageListIndex
関数PIDLをシステムイメージリストのアイコンインデックスに対応付ける。
シグネチャ
// SHELL32.dll
#include <windows.h>
INT SHMapPIDLToSystemImageListIndex(
IShellFolder* pshf,
ITEMIDLIST* pidl,
INT* piIndexSel // optional
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| pshf | IShellFolder* | in | 項目を含むフォルダーの IShellFolder インターフェイスポインターです。 |
| pidl | ITEMIDLIST* | in | 項目の ITEMIDLIST 構造体へのポインターです。 |
| piIndexSel | INT* | outoptional | この関数が成功して返ったときに、システムイメージリスト内の項目の開いている状態のアイコンのインデックスを受け取る int へのポインターです。項目に特別な開いている状態のアイコンがない場合は、通常のアイコンのインデックスが返されます。開いている状態のアイコンが存在するものの取得できない場合は、piIndex が指す値に -1 が設定されます。呼び出し元のアプリケーションが開いている状態のアイコンを必要としない場合、このパラメーターは NULL にできます。 |
戻り値の型: INT
公式ドキュメント
SHMapPIDLToSystemImageListIndex は変更されるか、利用できなくなる可能性があります。
戻り値
型: int
成功した場合はシステムイメージリスト内の項目の通常のアイコンのインデックスを返し、それ以外の場合は -1 を返します。
出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// SHELL32.dll
#include <windows.h>
INT SHMapPIDLToSystemImageListIndex(
IShellFolder* pshf,
ITEMIDLIST* pidl,
INT* piIndexSel // optional
);[DllImport("SHELL32.dll", ExactSpelling = true)]
static extern int SHMapPIDLToSystemImageListIndex(
IntPtr pshf, // IShellFolder*
IntPtr pidl, // ITEMIDLIST*
IntPtr piIndexSel // INT* optional, out
);<DllImport("SHELL32.dll", ExactSpelling:=True)>
Public Shared Function SHMapPIDLToSystemImageListIndex(
pshf As IntPtr, ' IShellFolder*
pidl As IntPtr, ' ITEMIDLIST*
piIndexSel As IntPtr ' INT* optional, out
) As Integer
End Function' pshf : IShellFolder*
' pidl : ITEMIDLIST*
' piIndexSel : INT* optional, out
Declare PtrSafe Function SHMapPIDLToSystemImageListIndex Lib "shell32" ( _
ByVal pshf As LongPtr, _
ByVal pidl As LongPtr, _
ByVal piIndexSel As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
SHMapPIDLToSystemImageListIndex = ctypes.windll.shell32.SHMapPIDLToSystemImageListIndex
SHMapPIDLToSystemImageListIndex.restype = ctypes.c_int
SHMapPIDLToSystemImageListIndex.argtypes = [
ctypes.c_void_p, # pshf : IShellFolder*
ctypes.c_void_p, # pidl : ITEMIDLIST*
ctypes.POINTER(ctypes.c_int), # piIndexSel : INT* optional, out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('SHELL32.dll')
SHMapPIDLToSystemImageListIndex = Fiddle::Function.new(
lib['SHMapPIDLToSystemImageListIndex'],
[
Fiddle::TYPE_VOIDP, # pshf : IShellFolder*
Fiddle::TYPE_VOIDP, # pidl : ITEMIDLIST*
Fiddle::TYPE_VOIDP, # piIndexSel : INT* optional, out
],
Fiddle::TYPE_INT)#[link(name = "shell32")]
extern "system" {
fn SHMapPIDLToSystemImageListIndex(
pshf: *mut core::ffi::c_void, // IShellFolder*
pidl: *mut ITEMIDLIST, // ITEMIDLIST*
piIndexSel: *mut i32 // INT* optional, out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("SHELL32.dll")]
public static extern int SHMapPIDLToSystemImageListIndex(IntPtr pshf, IntPtr pidl, IntPtr piIndexSel);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SHELL32_SHMapPIDLToSystemImageListIndex' -Namespace Win32 -PassThru
# $api::SHMapPIDLToSystemImageListIndex(pshf, pidl, piIndexSel)#uselib "SHELL32.dll"
#func global SHMapPIDLToSystemImageListIndex "SHMapPIDLToSystemImageListIndex" sptr, sptr, sptr
; SHMapPIDLToSystemImageListIndex pshf, varptr(pidl), varptr(piIndexSel) ; 戻り値は stat
; pshf : IShellFolder* -> "sptr"
; pidl : ITEMIDLIST* -> "sptr"
; piIndexSel : INT* optional, out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "SHELL32.dll" #cfunc global SHMapPIDLToSystemImageListIndex "SHMapPIDLToSystemImageListIndex" sptr, var, var ; res = SHMapPIDLToSystemImageListIndex(pshf, pidl, piIndexSel) ; pshf : IShellFolder* -> "sptr" ; pidl : ITEMIDLIST* -> "var" ; piIndexSel : INT* optional, out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "SHELL32.dll" #cfunc global SHMapPIDLToSystemImageListIndex "SHMapPIDLToSystemImageListIndex" sptr, sptr, sptr ; res = SHMapPIDLToSystemImageListIndex(pshf, varptr(pidl), varptr(piIndexSel)) ; pshf : IShellFolder* -> "sptr" ; pidl : ITEMIDLIST* -> "sptr" ; piIndexSel : INT* optional, out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; INT SHMapPIDLToSystemImageListIndex(IShellFolder* pshf, ITEMIDLIST* pidl, INT* piIndexSel) #uselib "SHELL32.dll" #cfunc global SHMapPIDLToSystemImageListIndex "SHMapPIDLToSystemImageListIndex" intptr, var, var ; res = SHMapPIDLToSystemImageListIndex(pshf, pidl, piIndexSel) ; pshf : IShellFolder* -> "intptr" ; pidl : ITEMIDLIST* -> "var" ; piIndexSel : INT* optional, out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; INT SHMapPIDLToSystemImageListIndex(IShellFolder* pshf, ITEMIDLIST* pidl, INT* piIndexSel) #uselib "SHELL32.dll" #cfunc global SHMapPIDLToSystemImageListIndex "SHMapPIDLToSystemImageListIndex" intptr, intptr, intptr ; res = SHMapPIDLToSystemImageListIndex(pshf, varptr(pidl), varptr(piIndexSel)) ; pshf : IShellFolder* -> "intptr" ; pidl : ITEMIDLIST* -> "intptr" ; piIndexSel : INT* optional, out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
shell32 = windows.NewLazySystemDLL("SHELL32.dll")
procSHMapPIDLToSystemImageListIndex = shell32.NewProc("SHMapPIDLToSystemImageListIndex")
)
// pshf (IShellFolder*), pidl (ITEMIDLIST*), piIndexSel (INT* optional, out)
r1, _, err := procSHMapPIDLToSystemImageListIndex.Call(
uintptr(pshf),
uintptr(pidl),
uintptr(piIndexSel),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // INTfunction SHMapPIDLToSystemImageListIndex(
pshf: Pointer; // IShellFolder*
pidl: Pointer; // ITEMIDLIST*
piIndexSel: Pointer // INT* optional, out
): Integer; stdcall;
external 'SHELL32.dll' name 'SHMapPIDLToSystemImageListIndex';result := DllCall("SHELL32\SHMapPIDLToSystemImageListIndex"
, "Ptr", pshf ; IShellFolder*
, "Ptr", pidl ; ITEMIDLIST*
, "Ptr", piIndexSel ; INT* optional, out
, "Int") ; return: INT●SHMapPIDLToSystemImageListIndex(pshf, pidl, piIndexSel) = DLL("SHELL32.dll", "int SHMapPIDLToSystemImageListIndex(void*, void*, void*)")
# 呼び出し: SHMapPIDLToSystemImageListIndex(pshf, pidl, piIndexSel)
# pshf : IShellFolder* -> "void*"
# pidl : ITEMIDLIST* -> "void*"
# piIndexSel : INT* optional, out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "shell32" fn SHMapPIDLToSystemImageListIndex(
pshf: ?*anyopaque, // IShellFolder*
pidl: [*c]ITEMIDLIST, // ITEMIDLIST*
piIndexSel: [*c]i32 // INT* optional, out
) callconv(std.os.windows.WINAPI) i32;proc SHMapPIDLToSystemImageListIndex(
pshf: pointer, # IShellFolder*
pidl: ptr ITEMIDLIST, # ITEMIDLIST*
piIndexSel: ptr int32 # INT* optional, out
): int32 {.importc: "SHMapPIDLToSystemImageListIndex", stdcall, dynlib: "SHELL32.dll".}pragma(lib, "shell32");
extern(Windows)
int SHMapPIDLToSystemImageListIndex(
void* pshf, // IShellFolder*
ITEMIDLIST* pidl, // ITEMIDLIST*
int* piIndexSel // INT* optional, out
);ccall((:SHMapPIDLToSystemImageListIndex, "SHELL32.dll"), stdcall, Int32,
(Ptr{Cvoid}, Ptr{ITEMIDLIST}, Ptr{Int32}),
pshf, pidl, piIndexSel)
# pshf : IShellFolder* -> Ptr{Cvoid}
# pidl : ITEMIDLIST* -> Ptr{ITEMIDLIST}
# piIndexSel : INT* optional, out -> Ptr{Int32}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t SHMapPIDLToSystemImageListIndex(
void* pshf,
void* pidl,
int32_t* piIndexSel);
]]
local shell32 = ffi.load("shell32")
-- shell32.SHMapPIDLToSystemImageListIndex(pshf, pidl, piIndexSel)
-- pshf : IShellFolder*
-- pidl : ITEMIDLIST*
-- piIndexSel : INT* optional, out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('SHELL32.dll');
const SHMapPIDLToSystemImageListIndex = lib.func('__stdcall', 'SHMapPIDLToSystemImageListIndex', 'int32_t', ['void *', 'void *', 'int32_t *']);
// SHMapPIDLToSystemImageListIndex(pshf, pidl, piIndexSel)
// pshf : IShellFolder* -> 'void *'
// pidl : ITEMIDLIST* -> 'void *'
// piIndexSel : INT* optional, out -> 'int32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("SHELL32.dll", {
SHMapPIDLToSystemImageListIndex: { parameters: ["pointer", "pointer", "pointer"], result: "i32" },
});
// lib.symbols.SHMapPIDLToSystemImageListIndex(pshf, pidl, piIndexSel)
// pshf : IShellFolder* -> "pointer"
// pidl : ITEMIDLIST* -> "pointer"
// piIndexSel : INT* optional, out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t SHMapPIDLToSystemImageListIndex(
void* pshf,
void* pidl,
int32_t* piIndexSel);
C, "SHELL32.dll");
// $ffi->SHMapPIDLToSystemImageListIndex(pshf, pidl, piIndexSel);
// pshf : IShellFolder*
// pidl : ITEMIDLIST*
// piIndexSel : INT* optional, out
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
public interface Shell32 extends StdCallLibrary {
Shell32 INSTANCE = Native.load("shell32", Shell32.class);
int SHMapPIDLToSystemImageListIndex(
Pointer pshf, // IShellFolder*
Pointer pidl, // ITEMIDLIST*
IntByReference piIndexSel // INT* optional, out
);
}@[Link("shell32")]
lib LibSHELL32
fun SHMapPIDLToSystemImageListIndex = SHMapPIDLToSystemImageListIndex(
pshf : Void*, # IShellFolder*
pidl : ITEMIDLIST*, # ITEMIDLIST*
piIndexSel : Int32* # INT* optional, out
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef SHMapPIDLToSystemImageListIndexNative = Int32 Function(Pointer<Void>, Pointer<Void>, Pointer<Int32>);
typedef SHMapPIDLToSystemImageListIndexDart = int Function(Pointer<Void>, Pointer<Void>, Pointer<Int32>);
final SHMapPIDLToSystemImageListIndex = DynamicLibrary.open('SHELL32.dll')
.lookupFunction<SHMapPIDLToSystemImageListIndexNative, SHMapPIDLToSystemImageListIndexDart>('SHMapPIDLToSystemImageListIndex');
// pshf : IShellFolder* -> Pointer<Void>
// pidl : ITEMIDLIST* -> Pointer<Void>
// piIndexSel : INT* optional, out -> Pointer<Int32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function SHMapPIDLToSystemImageListIndex(
pshf: Pointer; // IShellFolder*
pidl: Pointer; // ITEMIDLIST*
piIndexSel: Pointer // INT* optional, out
): Integer; stdcall;
external 'SHELL32.dll' name 'SHMapPIDLToSystemImageListIndex';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "SHMapPIDLToSystemImageListIndex"
c_SHMapPIDLToSystemImageListIndex :: Ptr () -> Ptr () -> Ptr Int32 -> IO Int32
-- pshf : IShellFolder* -> Ptr ()
-- pidl : ITEMIDLIST* -> Ptr ()
-- piIndexSel : INT* optional, out -> Ptr Int32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let shmappidltosystemimagelistindex =
foreign "SHMapPIDLToSystemImageListIndex"
((ptr void) @-> (ptr void) @-> (ptr int32_t) @-> returning int32_t)
(* pshf : IShellFolder* -> (ptr void) *)
(* pidl : ITEMIDLIST* -> (ptr void) *)
(* piIndexSel : INT* optional, out -> (ptr int32_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library shell32 (t "SHELL32.dll"))
(cffi:use-foreign-library shell32)
(cffi:defcfun ("SHMapPIDLToSystemImageListIndex" shmap-pidlto-system-image-list-index :convention :stdcall) :int32
(pshf :pointer) ; IShellFolder*
(pidl :pointer) ; ITEMIDLIST*
(pi-index-sel :pointer)) ; INT* optional, out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $SHMapPIDLToSystemImageListIndex = Win32::API::More->new('SHELL32',
'int SHMapPIDLToSystemImageListIndex(LPVOID pshf, LPVOID pidl, LPVOID piIndexSel)');
# my $ret = $SHMapPIDLToSystemImageListIndex->Call($pshf, $pidl, $piIndexSel);
# pshf : IShellFolder* -> LPVOID
# pidl : ITEMIDLIST* -> LPVOID
# piIndexSel : INT* optional, out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。