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