SHCloneSpecialIDList
関数CSIDLで指定した特殊フォルダーのPIDLを複製して取得する。
シグネチャ
// SHELL32.dll
#include <windows.h>
ITEMIDLIST* SHCloneSpecialIDList(
HWND hwnd, // optional
INT csidl,
BOOL fCreate
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| hwnd | HWND | optional | 予約されています。 |
| csidl | INT | in | 対象のフォルダーを識別する CSIDL 値です。 |
| fCreate | BOOL | in | フォルダーがまだ存在しない場合に作成するかどうかを示す BOOL 型の値です。fCreate が TRUE の場合、フォルダーが作成されます。FALSE の場合、フォルダーは作成されません。 |
戻り値の型: ITEMIDLIST*
公式ドキュメント
SHCloneSpecialIDList は変更されるか、利用できなくなる可能性があります。代わりに SHGetSpecialFolderLocation を使用してください。
戻り値
型: PIDLIST_ABSOLUTE
csidl で指定された特殊フォルダーの ITEMIDLIST 構造体へのポインターを返します。fCreate が TRUE の場合、この関数はフォルダーを作成します。
解説(Remarks)
処理が完了したら、複製されたフォルダーへのポインターを ILFree で解放する必要があります。
出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// 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)。const std = @import("std");
extern "shell32" fn SHCloneSpecialIDList(
hwnd: ?*anyopaque, // HWND optional
csidl: i32, // INT
fCreate: i32 // BOOL
) callconv(std.os.windows.WINAPI) [*c]ITEMIDLIST;proc SHCloneSpecialIDList(
hwnd: pointer, # HWND optional
csidl: int32, # INT
fCreate: int32 # BOOL
): ptr ITEMIDLIST {.importc: "SHCloneSpecialIDList", stdcall, dynlib: "SHELL32.dll".}pragma(lib, "shell32");
extern(Windows)
ITEMIDLIST* SHCloneSpecialIDList(
void* hwnd, // HWND optional
int csidl, // INT
int fCreate // BOOL
);ccall((:SHCloneSpecialIDList, "SHELL32.dll"), stdcall, Ptr{ITEMIDLIST},
(Ptr{Cvoid}, Int32, Int32),
hwnd, csidl, fCreate)
# hwnd : HWND optional -> Ptr{Cvoid}
# csidl : INT -> Int32
# fCreate : BOOL -> Int32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
void* SHCloneSpecialIDList(
void* hwnd,
int32_t csidl,
int32_t fCreate);
]]
local shell32 = ffi.load("shell32")
-- shell32.SHCloneSpecialIDList(hwnd, csidl, fCreate)
-- hwnd : HWND optional
-- csidl : INT
-- fCreate : BOOL
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('SHELL32.dll');
const SHCloneSpecialIDList = lib.func('__stdcall', 'SHCloneSpecialIDList', 'void *', ['void *', 'int32_t', 'int32_t']);
// SHCloneSpecialIDList(hwnd, csidl, fCreate)
// hwnd : HWND optional -> 'void *'
// csidl : INT -> 'int32_t'
// fCreate : BOOL -> 'int32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("SHELL32.dll", {
SHCloneSpecialIDList: { parameters: ["pointer", "i32", "i32"], result: "pointer" },
});
// lib.symbols.SHCloneSpecialIDList(hwnd, csidl, fCreate)
// hwnd : HWND optional -> "pointer"
// csidl : INT -> "i32"
// fCreate : BOOL -> "i32"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
void* SHCloneSpecialIDList(
void* hwnd,
int32_t csidl,
int32_t fCreate);
C, "SHELL32.dll");
// $ffi->SHCloneSpecialIDList(hwnd, csidl, fCreate);
// hwnd : HWND optional
// csidl : INT
// fCreate : BOOL
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
public interface Shell32 extends StdCallLibrary {
Shell32 INSTANCE = Native.load("shell32", Shell32.class);
Pointer SHCloneSpecialIDList(
Pointer hwnd, // HWND optional
int csidl, // INT
boolean fCreate // BOOL
);
}@[Link("shell32")]
lib LibSHELL32
fun SHCloneSpecialIDList = SHCloneSpecialIDList(
hwnd : Void*, # HWND optional
csidl : Int32, # INT
fCreate : Int32 # BOOL
) : ITEMIDLIST*
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef SHCloneSpecialIDListNative = Pointer<Void> Function(Pointer<Void>, Int32, Int32);
typedef SHCloneSpecialIDListDart = Pointer<Void> Function(Pointer<Void>, int, int);
final SHCloneSpecialIDList = DynamicLibrary.open('SHELL32.dll')
.lookupFunction<SHCloneSpecialIDListNative, SHCloneSpecialIDListDart>('SHCloneSpecialIDList');
// hwnd : HWND optional -> Pointer<Void>
// csidl : INT -> Int32
// fCreate : BOOL -> Int32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function SHCloneSpecialIDList(
hwnd: THandle; // HWND optional
csidl: Integer; // INT
fCreate: BOOL // BOOL
): Pointer; stdcall;
external 'SHELL32.dll' name 'SHCloneSpecialIDList';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "SHCloneSpecialIDList"
c_SHCloneSpecialIDList :: Ptr () -> Int32 -> CInt -> IO (Ptr ())
-- hwnd : HWND optional -> Ptr ()
-- csidl : INT -> Int32
-- fCreate : BOOL -> CInt
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let shclonespecialidlist =
foreign "SHCloneSpecialIDList"
((ptr void) @-> int32_t @-> int32_t @-> returning (ptr void))
(* hwnd : HWND optional -> (ptr void) *)
(* csidl : INT -> int32_t *)
(* fCreate : BOOL -> int32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library shell32 (t "SHELL32.dll"))
(cffi:use-foreign-library shell32)
(cffi:defcfun ("SHCloneSpecialIDList" shclone-special-idlist :convention :stdcall) :pointer
(hwnd :pointer) ; HWND optional
(csidl :int32) ; INT
(f-create :int32)) ; BOOL
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $SHCloneSpecialIDList = Win32::API::More->new('SHELL32',
'LPVOID SHCloneSpecialIDList(HANDLE hwnd, int csidl, BOOL fCreate)');
# my $ret = $SHCloneSpecialIDList->Call($hwnd, $csidl, $fCreate);
# hwnd : HWND optional -> HANDLE
# csidl : INT -> int
# fCreate : BOOL -> BOOL
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
使用する型