SHCreateShellItemArray
関数複数PIDLからシェルアイテム配列を作成する。
シグネチャ
// SHELL32.dll
#include <windows.h>
HRESULT SHCreateShellItemArray(
ITEMIDLIST* pidlParent, // optional
IShellFolder* psf, // optional
DWORD cidl,
ITEMIDLIST** ppidl, // optional
IShellItemArray** ppsiItemArray
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| pidlParent | ITEMIDLIST* | inoptional |
| psf | IShellFolder* | inoptional |
| cidl | DWORD | in |
| ppidl | ITEMIDLIST** | inoptional |
| ppsiItemArray | IShellItemArray** | out |
戻り値の型: HRESULT
各言語での呼び出し定義
// SHELL32.dll
#include <windows.h>
HRESULT SHCreateShellItemArray(
ITEMIDLIST* pidlParent, // optional
IShellFolder* psf, // optional
DWORD cidl,
ITEMIDLIST** ppidl, // optional
IShellItemArray** ppsiItemArray
);[DllImport("SHELL32.dll", ExactSpelling = true)]
static extern int SHCreateShellItemArray(
IntPtr pidlParent, // ITEMIDLIST* optional
IntPtr psf, // IShellFolder* optional
uint cidl, // DWORD
IntPtr ppidl, // ITEMIDLIST** optional
IntPtr ppsiItemArray // IShellItemArray** out
);<DllImport("SHELL32.dll", ExactSpelling:=True)>
Public Shared Function SHCreateShellItemArray(
pidlParent As IntPtr, ' ITEMIDLIST* optional
psf As IntPtr, ' IShellFolder* optional
cidl As UInteger, ' DWORD
ppidl As IntPtr, ' ITEMIDLIST** optional
ppsiItemArray As IntPtr ' IShellItemArray** out
) As Integer
End Function' pidlParent : ITEMIDLIST* optional
' psf : IShellFolder* optional
' cidl : DWORD
' ppidl : ITEMIDLIST** optional
' ppsiItemArray : IShellItemArray** out
Declare PtrSafe Function SHCreateShellItemArray Lib "shell32" ( _
ByVal pidlParent As LongPtr, _
ByVal psf As LongPtr, _
ByVal cidl As Long, _
ByVal ppidl As LongPtr, _
ByVal ppsiItemArray As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
SHCreateShellItemArray = ctypes.windll.shell32.SHCreateShellItemArray
SHCreateShellItemArray.restype = ctypes.c_int
SHCreateShellItemArray.argtypes = [
ctypes.c_void_p, # pidlParent : ITEMIDLIST* optional
ctypes.c_void_p, # psf : IShellFolder* optional
wintypes.DWORD, # cidl : DWORD
ctypes.c_void_p, # ppidl : ITEMIDLIST** optional
ctypes.c_void_p, # ppsiItemArray : IShellItemArray** out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('SHELL32.dll')
SHCreateShellItemArray = Fiddle::Function.new(
lib['SHCreateShellItemArray'],
[
Fiddle::TYPE_VOIDP, # pidlParent : ITEMIDLIST* optional
Fiddle::TYPE_VOIDP, # psf : IShellFolder* optional
-Fiddle::TYPE_INT, # cidl : DWORD
Fiddle::TYPE_VOIDP, # ppidl : ITEMIDLIST** optional
Fiddle::TYPE_VOIDP, # ppsiItemArray : IShellItemArray** out
],
Fiddle::TYPE_INT)#[link(name = "shell32")]
extern "system" {
fn SHCreateShellItemArray(
pidlParent: *mut ITEMIDLIST, // ITEMIDLIST* optional
psf: *mut core::ffi::c_void, // IShellFolder* optional
cidl: u32, // DWORD
ppidl: *mut *mut ITEMIDLIST, // ITEMIDLIST** optional
ppsiItemArray: *mut *mut core::ffi::c_void // IShellItemArray** out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("SHELL32.dll")]
public static extern int SHCreateShellItemArray(IntPtr pidlParent, IntPtr psf, uint cidl, IntPtr ppidl, IntPtr ppsiItemArray);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SHELL32_SHCreateShellItemArray' -Namespace Win32 -PassThru
# $api::SHCreateShellItemArray(pidlParent, psf, cidl, ppidl, ppsiItemArray)#uselib "SHELL32.dll"
#func global SHCreateShellItemArray "SHCreateShellItemArray" sptr, sptr, sptr, sptr, sptr
; SHCreateShellItemArray varptr(pidlParent), psf, cidl, varptr(ppidl), ppsiItemArray ; 戻り値は stat
; pidlParent : ITEMIDLIST* optional -> "sptr"
; psf : IShellFolder* optional -> "sptr"
; cidl : DWORD -> "sptr"
; ppidl : ITEMIDLIST** optional -> "sptr"
; ppsiItemArray : IShellItemArray** out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "SHELL32.dll" #cfunc global SHCreateShellItemArray "SHCreateShellItemArray" var, sptr, int, var, sptr ; res = SHCreateShellItemArray(pidlParent, psf, cidl, ppidl, ppsiItemArray) ; pidlParent : ITEMIDLIST* optional -> "var" ; psf : IShellFolder* optional -> "sptr" ; cidl : DWORD -> "int" ; ppidl : ITEMIDLIST** optional -> "var" ; ppsiItemArray : IShellItemArray** out -> "sptr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "SHELL32.dll" #cfunc global SHCreateShellItemArray "SHCreateShellItemArray" sptr, sptr, int, sptr, sptr ; res = SHCreateShellItemArray(varptr(pidlParent), psf, cidl, varptr(ppidl), ppsiItemArray) ; pidlParent : ITEMIDLIST* optional -> "sptr" ; psf : IShellFolder* optional -> "sptr" ; cidl : DWORD -> "int" ; ppidl : ITEMIDLIST** optional -> "sptr" ; ppsiItemArray : IShellItemArray** out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HRESULT SHCreateShellItemArray(ITEMIDLIST* pidlParent, IShellFolder* psf, DWORD cidl, ITEMIDLIST** ppidl, IShellItemArray** ppsiItemArray) #uselib "SHELL32.dll" #cfunc global SHCreateShellItemArray "SHCreateShellItemArray" var, intptr, int, var, intptr ; res = SHCreateShellItemArray(pidlParent, psf, cidl, ppidl, ppsiItemArray) ; pidlParent : ITEMIDLIST* optional -> "var" ; psf : IShellFolder* optional -> "intptr" ; cidl : DWORD -> "int" ; ppidl : ITEMIDLIST** optional -> "var" ; ppsiItemArray : IShellItemArray** out -> "intptr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HRESULT SHCreateShellItemArray(ITEMIDLIST* pidlParent, IShellFolder* psf, DWORD cidl, ITEMIDLIST** ppidl, IShellItemArray** ppsiItemArray) #uselib "SHELL32.dll" #cfunc global SHCreateShellItemArray "SHCreateShellItemArray" intptr, intptr, int, intptr, intptr ; res = SHCreateShellItemArray(varptr(pidlParent), psf, cidl, varptr(ppidl), ppsiItemArray) ; pidlParent : ITEMIDLIST* optional -> "intptr" ; psf : IShellFolder* optional -> "intptr" ; cidl : DWORD -> "int" ; ppidl : ITEMIDLIST** optional -> "intptr" ; ppsiItemArray : IShellItemArray** out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
shell32 = windows.NewLazySystemDLL("SHELL32.dll")
procSHCreateShellItemArray = shell32.NewProc("SHCreateShellItemArray")
)
// pidlParent (ITEMIDLIST* optional), psf (IShellFolder* optional), cidl (DWORD), ppidl (ITEMIDLIST** optional), ppsiItemArray (IShellItemArray** out)
r1, _, err := procSHCreateShellItemArray.Call(
uintptr(pidlParent),
uintptr(psf),
uintptr(cidl),
uintptr(ppidl),
uintptr(ppsiItemArray),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction SHCreateShellItemArray(
pidlParent: Pointer; // ITEMIDLIST* optional
psf: Pointer; // IShellFolder* optional
cidl: DWORD; // DWORD
ppidl: Pointer; // ITEMIDLIST** optional
ppsiItemArray: Pointer // IShellItemArray** out
): Integer; stdcall;
external 'SHELL32.dll' name 'SHCreateShellItemArray';result := DllCall("SHELL32\SHCreateShellItemArray"
, "Ptr", pidlParent ; ITEMIDLIST* optional
, "Ptr", psf ; IShellFolder* optional
, "UInt", cidl ; DWORD
, "Ptr", ppidl ; ITEMIDLIST** optional
, "Ptr", ppsiItemArray ; IShellItemArray** out
, "Int") ; return: HRESULT●SHCreateShellItemArray(pidlParent, psf, cidl, ppidl, ppsiItemArray) = DLL("SHELL32.dll", "int SHCreateShellItemArray(void*, void*, dword, void*, void*)")
# 呼び出し: SHCreateShellItemArray(pidlParent, psf, cidl, ppidl, ppsiItemArray)
# pidlParent : ITEMIDLIST* optional -> "void*"
# psf : IShellFolder* optional -> "void*"
# cidl : DWORD -> "dword"
# ppidl : ITEMIDLIST** optional -> "void*"
# ppsiItemArray : IShellItemArray** out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。