Win32 API 日本語リファレンス
ホームUI.Shell › ILCreateFromPathA

ILCreateFromPathA

関数
ファイルパス(ANSI)からPIDLを生成する。
DLLSHELL32.dll文字セットANSI (-A)呼出規約winapi対応OSWindows XP 以降

シグネチャ

// SHELL32.dll  (ANSI / -A)
#include <windows.h>

ITEMIDLIST* ILCreateFromPathA(
    LPCSTR pszPath
);

パラメーター

名前方向
pszPathLPCSTRin

戻り値の型: ITEMIDLIST*

各言語での呼び出し定義

// SHELL32.dll  (ANSI / -A)
#include <windows.h>

ITEMIDLIST* ILCreateFromPathA(
    LPCSTR pszPath
);
[DllImport("SHELL32.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern IntPtr ILCreateFromPathA(
    [MarshalAs(UnmanagedType.LPStr)] string pszPath   // LPCSTR
);
<DllImport("SHELL32.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Function ILCreateFromPathA(
    <MarshalAs(UnmanagedType.LPStr)> pszPath As String   ' LPCSTR
) As IntPtr
End Function
' pszPath : LPCSTR
Declare PtrSafe Function ILCreateFromPathA Lib "shell32" ( _
    ByVal pszPath As String) As LongPtr
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

ILCreateFromPathA = ctypes.windll.shell32.ILCreateFromPathA
ILCreateFromPathA.restype = ctypes.c_void_p
ILCreateFromPathA.argtypes = [
    wintypes.LPCSTR,  # pszPath : LPCSTR
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('SHELL32.dll')
ILCreateFromPathA = Fiddle::Function.new(
  lib['ILCreateFromPathA'],
  [
    Fiddle::TYPE_VOIDP,  # pszPath : LPCSTR
  ],
  Fiddle::TYPE_VOIDP)
#[link(name = "shell32")]
extern "system" {
    fn ILCreateFromPathA(
        pszPath: *const u8  // LPCSTR
    ) -> *mut ITEMIDLIST;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("SHELL32.dll", CharSet = CharSet.Ansi)]
public static extern IntPtr ILCreateFromPathA([MarshalAs(UnmanagedType.LPStr)] string pszPath);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SHELL32_ILCreateFromPathA' -Namespace Win32 -PassThru
# $api::ILCreateFromPathA(pszPath)
#uselib "SHELL32.dll"
#func global ILCreateFromPathA "ILCreateFromPathA" sptr
; ILCreateFromPathA pszPath   ; 戻り値は stat
; pszPath : LPCSTR -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "SHELL32.dll"
#cfunc global ILCreateFromPathA "ILCreateFromPathA" str
; res = ILCreateFromPathA(pszPath)
; pszPath : LPCSTR -> "str"
; ITEMIDLIST* ILCreateFromPathA(LPCSTR pszPath)
#uselib "SHELL32.dll"
#cfunc global ILCreateFromPathA "ILCreateFromPathA" str
; res = ILCreateFromPathA(pszPath)
; pszPath : LPCSTR -> "str"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	shell32 = windows.NewLazySystemDLL("SHELL32.dll")
	procILCreateFromPathA = shell32.NewProc("ILCreateFromPathA")
)

// pszPath (LPCSTR)
r1, _, err := procILCreateFromPathA.Call(
	uintptr(unsafe.Pointer(windows.BytePtrFromString(pszPath))),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // ITEMIDLIST*
function ILCreateFromPathA(
  pszPath: PAnsiChar   // LPCSTR
): Pointer; stdcall;
  external 'SHELL32.dll' name 'ILCreateFromPathA';
result := DllCall("SHELL32\ILCreateFromPathA"
    , "AStr", pszPath   ; LPCSTR
    , "Ptr")   ; return: ITEMIDLIST*
●ILCreateFromPathA(pszPath) = DLL("SHELL32.dll", "void* ILCreateFromPathA(char*)")
# 呼び出し: ILCreateFromPathA(pszPath)
# pszPath : LPCSTR -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。