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