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