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