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

SHCloneSpecialIDList

関数
CSIDLで指定した特殊フォルダーのPIDLを複製して取得する。
DLLSHELL32.dll呼出規約winapi対応OSWindows XP 以降

シグネチャ

// SHELL32.dll
#include <windows.h>

ITEMIDLIST* SHCloneSpecialIDList(
    HWND hwnd,   // optional
    INT csidl,
    BOOL fCreate
);

パラメーター

名前方向
hwndHWNDoptional
csidlINTin
fCreateBOOLin

戻り値の型: ITEMIDLIST*

各言語での呼び出し定義

// SHELL32.dll
#include <windows.h>

ITEMIDLIST* SHCloneSpecialIDList(
    HWND hwnd,   // optional
    INT csidl,
    BOOL fCreate
);
[DllImport("SHELL32.dll", ExactSpelling = true)]
static extern IntPtr SHCloneSpecialIDList(
    IntPtr hwnd,   // HWND optional
    int csidl,   // INT
    bool fCreate   // BOOL
);
<DllImport("SHELL32.dll", ExactSpelling:=True)>
Public Shared Function SHCloneSpecialIDList(
    hwnd As IntPtr,   ' HWND optional
    csidl As Integer,   ' INT
    fCreate As Boolean   ' BOOL
) As IntPtr
End Function
' hwnd : HWND optional
' csidl : INT
' fCreate : BOOL
Declare PtrSafe Function SHCloneSpecialIDList Lib "shell32" ( _
    ByVal hwnd As LongPtr, _
    ByVal csidl As Long, _
    ByVal fCreate As Long) As LongPtr
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

SHCloneSpecialIDList = ctypes.windll.shell32.SHCloneSpecialIDList
SHCloneSpecialIDList.restype = ctypes.c_void_p
SHCloneSpecialIDList.argtypes = [
    wintypes.HANDLE,  # hwnd : HWND optional
    ctypes.c_int,  # csidl : INT
    wintypes.BOOL,  # fCreate : BOOL
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('SHELL32.dll')
SHCloneSpecialIDList = Fiddle::Function.new(
  lib['SHCloneSpecialIDList'],
  [
    Fiddle::TYPE_VOIDP,  # hwnd : HWND optional
    Fiddle::TYPE_INT,  # csidl : INT
    Fiddle::TYPE_INT,  # fCreate : BOOL
  ],
  Fiddle::TYPE_VOIDP)
#[link(name = "shell32")]
extern "system" {
    fn SHCloneSpecialIDList(
        hwnd: *mut core::ffi::c_void,  // HWND optional
        csidl: i32,  // INT
        fCreate: i32  // BOOL
    ) -> *mut ITEMIDLIST;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("SHELL32.dll")]
public static extern IntPtr SHCloneSpecialIDList(IntPtr hwnd, int csidl, bool fCreate);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SHELL32_SHCloneSpecialIDList' -Namespace Win32 -PassThru
# $api::SHCloneSpecialIDList(hwnd, csidl, fCreate)
#uselib "SHELL32.dll"
#func global SHCloneSpecialIDList "SHCloneSpecialIDList" sptr, sptr, sptr
; SHCloneSpecialIDList hwnd, csidl, fCreate   ; 戻り値は stat
; hwnd : HWND optional -> "sptr"
; csidl : INT -> "sptr"
; fCreate : BOOL -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "SHELL32.dll"
#cfunc global SHCloneSpecialIDList "SHCloneSpecialIDList" sptr, int, int
; res = SHCloneSpecialIDList(hwnd, csidl, fCreate)
; hwnd : HWND optional -> "sptr"
; csidl : INT -> "int"
; fCreate : BOOL -> "int"
; ITEMIDLIST* SHCloneSpecialIDList(HWND hwnd, INT csidl, BOOL fCreate)
#uselib "SHELL32.dll"
#cfunc global SHCloneSpecialIDList "SHCloneSpecialIDList" intptr, int, int
; res = SHCloneSpecialIDList(hwnd, csidl, fCreate)
; hwnd : HWND optional -> "intptr"
; csidl : INT -> "int"
; fCreate : BOOL -> "int"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	shell32 = windows.NewLazySystemDLL("SHELL32.dll")
	procSHCloneSpecialIDList = shell32.NewProc("SHCloneSpecialIDList")
)

// hwnd (HWND optional), csidl (INT), fCreate (BOOL)
r1, _, err := procSHCloneSpecialIDList.Call(
	uintptr(hwnd),
	uintptr(csidl),
	uintptr(fCreate),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // ITEMIDLIST*
function SHCloneSpecialIDList(
  hwnd: THandle;   // HWND optional
  csidl: Integer;   // INT
  fCreate: BOOL   // BOOL
): Pointer; stdcall;
  external 'SHELL32.dll' name 'SHCloneSpecialIDList';
result := DllCall("SHELL32\SHCloneSpecialIDList"
    , "Ptr", hwnd   ; HWND optional
    , "Int", csidl   ; INT
    , "Int", fCreate   ; BOOL
    , "Ptr")   ; return: ITEMIDLIST*
●SHCloneSpecialIDList(hwnd, csidl, fCreate) = DLL("SHELL32.dll", "void* SHCloneSpecialIDList(void*, int, bool)")
# 呼び出し: SHCloneSpecialIDList(hwnd, csidl, fCreate)
# hwnd : HWND optional -> "void*"
# csidl : INT -> "int"
# fCreate : BOOL -> "bool"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。