Win32 API 日本語リファレンス
ホームStorage.CloudFilters › CfCreatePlaceholders

CfCreatePlaceholders

関数
指定ディレクトリにプレースホルダーファイルを作成する。
DLLcldapi.dll呼出規約winapi対応OSWindows 10 以降

シグネチャ

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

HRESULT CfCreatePlaceholders(
    LPCWSTR BaseDirectoryPath,
    CF_PLACEHOLDER_CREATE_INFO* PlaceholderArray,
    DWORD PlaceholderCount,
    CF_CREATE_FLAGS CreateFlags,
    DWORD* EntriesProcessed   // optional
);

パラメーター

名前方向説明
BaseDirectoryPathLPCWSTRinプレースホルダーを作成する基準ディレクトリのフルパスを示すワイド文字列。
PlaceholderArrayCF_PLACEHOLDER_CREATE_INFO*inout作成する各プレースホルダー情報を保持するCF_PLACEHOLDER_CREATE_INFO配列へのポインタ。
PlaceholderCountDWORDinPlaceholderArrayに含まれるエントリ数。
CreateFlagsCF_CREATE_FLAGSin作成動作を制御するCF_CREATE_FLAGSフラグ。
EntriesProcessedDWORD*outoptional実際に処理されたエントリ数を受け取るDWORDへのポインタ。出力用。

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT CfCreatePlaceholders(
    LPCWSTR BaseDirectoryPath,
    CF_PLACEHOLDER_CREATE_INFO* PlaceholderArray,
    DWORD PlaceholderCount,
    CF_CREATE_FLAGS CreateFlags,
    DWORD* EntriesProcessed   // optional
);
[DllImport("cldapi.dll", ExactSpelling = true)]
static extern int CfCreatePlaceholders(
    [MarshalAs(UnmanagedType.LPWStr)] string BaseDirectoryPath,   // LPCWSTR
    IntPtr PlaceholderArray,   // CF_PLACEHOLDER_CREATE_INFO* in/out
    uint PlaceholderCount,   // DWORD
    int CreateFlags,   // CF_CREATE_FLAGS
    IntPtr EntriesProcessed   // DWORD* optional, out
);
<DllImport("cldapi.dll", ExactSpelling:=True)>
Public Shared Function CfCreatePlaceholders(
    <MarshalAs(UnmanagedType.LPWStr)> BaseDirectoryPath As String,   ' LPCWSTR
    PlaceholderArray As IntPtr,   ' CF_PLACEHOLDER_CREATE_INFO* in/out
    PlaceholderCount As UInteger,   ' DWORD
    CreateFlags As Integer,   ' CF_CREATE_FLAGS
    EntriesProcessed As IntPtr   ' DWORD* optional, out
) As Integer
End Function
' BaseDirectoryPath : LPCWSTR
' PlaceholderArray : CF_PLACEHOLDER_CREATE_INFO* in/out
' PlaceholderCount : DWORD
' CreateFlags : CF_CREATE_FLAGS
' EntriesProcessed : DWORD* optional, out
Declare PtrSafe Function CfCreatePlaceholders Lib "cldapi" ( _
    ByVal BaseDirectoryPath As LongPtr, _
    ByVal PlaceholderArray As LongPtr, _
    ByVal PlaceholderCount As Long, _
    ByVal CreateFlags As Long, _
    ByVal EntriesProcessed As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

CfCreatePlaceholders = ctypes.windll.cldapi.CfCreatePlaceholders
CfCreatePlaceholders.restype = ctypes.c_int
CfCreatePlaceholders.argtypes = [
    wintypes.LPCWSTR,  # BaseDirectoryPath : LPCWSTR
    ctypes.c_void_p,  # PlaceholderArray : CF_PLACEHOLDER_CREATE_INFO* in/out
    wintypes.DWORD,  # PlaceholderCount : DWORD
    ctypes.c_int,  # CreateFlags : CF_CREATE_FLAGS
    ctypes.POINTER(wintypes.DWORD),  # EntriesProcessed : DWORD* optional, out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('cldapi.dll')
CfCreatePlaceholders = Fiddle::Function.new(
  lib['CfCreatePlaceholders'],
  [
    Fiddle::TYPE_VOIDP,  # BaseDirectoryPath : LPCWSTR
    Fiddle::TYPE_VOIDP,  # PlaceholderArray : CF_PLACEHOLDER_CREATE_INFO* in/out
    -Fiddle::TYPE_INT,  # PlaceholderCount : DWORD
    Fiddle::TYPE_INT,  # CreateFlags : CF_CREATE_FLAGS
    Fiddle::TYPE_VOIDP,  # EntriesProcessed : DWORD* optional, out
  ],
  Fiddle::TYPE_INT)
#[link(name = "cldapi")]
extern "system" {
    fn CfCreatePlaceholders(
        BaseDirectoryPath: *const u16,  // LPCWSTR
        PlaceholderArray: *mut CF_PLACEHOLDER_CREATE_INFO,  // CF_PLACEHOLDER_CREATE_INFO* in/out
        PlaceholderCount: u32,  // DWORD
        CreateFlags: i32,  // CF_CREATE_FLAGS
        EntriesProcessed: *mut u32  // DWORD* optional, out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("cldapi.dll")]
public static extern int CfCreatePlaceholders([MarshalAs(UnmanagedType.LPWStr)] string BaseDirectoryPath, IntPtr PlaceholderArray, uint PlaceholderCount, int CreateFlags, IntPtr EntriesProcessed);
"@
$api = Add-Type -MemberDefinition $sig -Name 'cldapi_CfCreatePlaceholders' -Namespace Win32 -PassThru
# $api::CfCreatePlaceholders(BaseDirectoryPath, PlaceholderArray, PlaceholderCount, CreateFlags, EntriesProcessed)
#uselib "cldapi.dll"
#func global CfCreatePlaceholders "CfCreatePlaceholders" sptr, sptr, sptr, sptr, sptr
; CfCreatePlaceholders BaseDirectoryPath, varptr(PlaceholderArray), PlaceholderCount, CreateFlags, varptr(EntriesProcessed)   ; 戻り値は stat
; BaseDirectoryPath : LPCWSTR -> "sptr"
; PlaceholderArray : CF_PLACEHOLDER_CREATE_INFO* in/out -> "sptr"
; PlaceholderCount : DWORD -> "sptr"
; CreateFlags : CF_CREATE_FLAGS -> "sptr"
; EntriesProcessed : DWORD* optional, out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "cldapi.dll"
#cfunc global CfCreatePlaceholders "CfCreatePlaceholders" wstr, var, int, int, var
; res = CfCreatePlaceholders(BaseDirectoryPath, PlaceholderArray, PlaceholderCount, CreateFlags, EntriesProcessed)
; BaseDirectoryPath : LPCWSTR -> "wstr"
; PlaceholderArray : CF_PLACEHOLDER_CREATE_INFO* in/out -> "var"
; PlaceholderCount : DWORD -> "int"
; CreateFlags : CF_CREATE_FLAGS -> "int"
; EntriesProcessed : DWORD* optional, out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; HRESULT CfCreatePlaceholders(LPCWSTR BaseDirectoryPath, CF_PLACEHOLDER_CREATE_INFO* PlaceholderArray, DWORD PlaceholderCount, CF_CREATE_FLAGS CreateFlags, DWORD* EntriesProcessed)
#uselib "cldapi.dll"
#cfunc global CfCreatePlaceholders "CfCreatePlaceholders" wstr, var, int, int, var
; res = CfCreatePlaceholders(BaseDirectoryPath, PlaceholderArray, PlaceholderCount, CreateFlags, EntriesProcessed)
; BaseDirectoryPath : LPCWSTR -> "wstr"
; PlaceholderArray : CF_PLACEHOLDER_CREATE_INFO* in/out -> "var"
; PlaceholderCount : DWORD -> "int"
; CreateFlags : CF_CREATE_FLAGS -> "int"
; EntriesProcessed : DWORD* optional, out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	cldapi = windows.NewLazySystemDLL("cldapi.dll")
	procCfCreatePlaceholders = cldapi.NewProc("CfCreatePlaceholders")
)

// BaseDirectoryPath (LPCWSTR), PlaceholderArray (CF_PLACEHOLDER_CREATE_INFO* in/out), PlaceholderCount (DWORD), CreateFlags (CF_CREATE_FLAGS), EntriesProcessed (DWORD* optional, out)
r1, _, err := procCfCreatePlaceholders.Call(
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(BaseDirectoryPath))),
	uintptr(PlaceholderArray),
	uintptr(PlaceholderCount),
	uintptr(CreateFlags),
	uintptr(EntriesProcessed),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function CfCreatePlaceholders(
  BaseDirectoryPath: PWideChar;   // LPCWSTR
  PlaceholderArray: Pointer;   // CF_PLACEHOLDER_CREATE_INFO* in/out
  PlaceholderCount: DWORD;   // DWORD
  CreateFlags: Integer;   // CF_CREATE_FLAGS
  EntriesProcessed: Pointer   // DWORD* optional, out
): Integer; stdcall;
  external 'cldapi.dll' name 'CfCreatePlaceholders';
result := DllCall("cldapi\CfCreatePlaceholders"
    , "WStr", BaseDirectoryPath   ; LPCWSTR
    , "Ptr", PlaceholderArray   ; CF_PLACEHOLDER_CREATE_INFO* in/out
    , "UInt", PlaceholderCount   ; DWORD
    , "Int", CreateFlags   ; CF_CREATE_FLAGS
    , "Ptr", EntriesProcessed   ; DWORD* optional, out
    , "Int")   ; return: HRESULT
●CfCreatePlaceholders(BaseDirectoryPath, PlaceholderArray, PlaceholderCount, CreateFlags, EntriesProcessed) = DLL("cldapi.dll", "int CfCreatePlaceholders(char*, void*, dword, int, void*)")
# 呼び出し: CfCreatePlaceholders(BaseDirectoryPath, PlaceholderArray, PlaceholderCount, CreateFlags, EntriesProcessed)
# BaseDirectoryPath : LPCWSTR -> "char*"
# PlaceholderArray : CF_PLACEHOLDER_CREATE_INFO* in/out -> "void*"
# PlaceholderCount : DWORD -> "dword"
# CreateFlags : CF_CREATE_FLAGS -> "int"
# EntriesProcessed : DWORD* optional, out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

extern "cldapi" fn CfCreatePlaceholders(
    BaseDirectoryPath: [*c]const u16, // LPCWSTR
    PlaceholderArray: [*c]CF_PLACEHOLDER_CREATE_INFO, // CF_PLACEHOLDER_CREATE_INFO* in/out
    PlaceholderCount: u32, // DWORD
    CreateFlags: i32, // CF_CREATE_FLAGS
    EntriesProcessed: [*c]u32 // DWORD* optional, out
) callconv(std.os.windows.WINAPI) i32;
proc CfCreatePlaceholders(
    BaseDirectoryPath: WideCString,  # LPCWSTR
    PlaceholderArray: ptr CF_PLACEHOLDER_CREATE_INFO,  # CF_PLACEHOLDER_CREATE_INFO* in/out
    PlaceholderCount: uint32,  # DWORD
    CreateFlags: int32,  # CF_CREATE_FLAGS
    EntriesProcessed: ptr uint32  # DWORD* optional, out
): int32 {.importc: "CfCreatePlaceholders", stdcall, dynlib: "cldapi.dll".}
pragma(lib, "cldapi");
extern(Windows)
int CfCreatePlaceholders(
    const(wchar)* BaseDirectoryPath,   // LPCWSTR
    CF_PLACEHOLDER_CREATE_INFO* PlaceholderArray,   // CF_PLACEHOLDER_CREATE_INFO* in/out
    uint PlaceholderCount,   // DWORD
    int CreateFlags,   // CF_CREATE_FLAGS
    uint* EntriesProcessed   // DWORD* optional, out
);
ccall((:CfCreatePlaceholders, "cldapi.dll"), stdcall, Int32,
      (Cwstring, Ptr{CF_PLACEHOLDER_CREATE_INFO}, UInt32, Int32, Ptr{UInt32}),
      BaseDirectoryPath, PlaceholderArray, PlaceholderCount, CreateFlags, EntriesProcessed)
# BaseDirectoryPath : LPCWSTR -> Cwstring
# PlaceholderArray : CF_PLACEHOLDER_CREATE_INFO* in/out -> Ptr{CF_PLACEHOLDER_CREATE_INFO}
# PlaceholderCount : DWORD -> UInt32
# CreateFlags : CF_CREATE_FLAGS -> Int32
# EntriesProcessed : DWORD* optional, out -> Ptr{UInt32}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t CfCreatePlaceholders(
    const uint16_t* BaseDirectoryPath,
    void* PlaceholderArray,
    uint32_t PlaceholderCount,
    int32_t CreateFlags,
    uint32_t* EntriesProcessed);
]]
local cldapi = ffi.load("cldapi")
-- cldapi.CfCreatePlaceholders(BaseDirectoryPath, PlaceholderArray, PlaceholderCount, CreateFlags, EntriesProcessed)
-- BaseDirectoryPath : LPCWSTR
-- PlaceholderArray : CF_PLACEHOLDER_CREATE_INFO* in/out
-- PlaceholderCount : DWORD
-- CreateFlags : CF_CREATE_FLAGS
-- EntriesProcessed : DWORD* optional, out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('cldapi.dll');
const CfCreatePlaceholders = lib.func('__stdcall', 'CfCreatePlaceholders', 'int32_t', ['str16', 'void *', 'uint32_t', 'int32_t', 'uint32_t *']);
// CfCreatePlaceholders(BaseDirectoryPath, PlaceholderArray, PlaceholderCount, CreateFlags, EntriesProcessed)
// BaseDirectoryPath : LPCWSTR -> 'str16'
// PlaceholderArray : CF_PLACEHOLDER_CREATE_INFO* in/out -> 'void *'
// PlaceholderCount : DWORD -> 'uint32_t'
// CreateFlags : CF_CREATE_FLAGS -> 'int32_t'
// EntriesProcessed : DWORD* optional, out -> 'uint32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("cldapi.dll", {
  CfCreatePlaceholders: { parameters: ["buffer", "pointer", "u32", "i32", "pointer"], result: "i32" },
});
// lib.symbols.CfCreatePlaceholders(BaseDirectoryPath, PlaceholderArray, PlaceholderCount, CreateFlags, EntriesProcessed)
// BaseDirectoryPath : LPCWSTR -> "buffer"
// PlaceholderArray : CF_PLACEHOLDER_CREATE_INFO* in/out -> "pointer"
// PlaceholderCount : DWORD -> "u32"
// CreateFlags : CF_CREATE_FLAGS -> "i32"
// EntriesProcessed : DWORD* optional, out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t CfCreatePlaceholders(
    const uint16_t* BaseDirectoryPath,
    void* PlaceholderArray,
    uint32_t PlaceholderCount,
    int32_t CreateFlags,
    uint32_t* EntriesProcessed);
C, "cldapi.dll");
// $ffi->CfCreatePlaceholders(BaseDirectoryPath, PlaceholderArray, PlaceholderCount, CreateFlags, EntriesProcessed);
// BaseDirectoryPath : LPCWSTR
// PlaceholderArray : CF_PLACEHOLDER_CREATE_INFO* in/out
// PlaceholderCount : DWORD
// CreateFlags : CF_CREATE_FLAGS
// EntriesProcessed : DWORD* optional, out
// 構造体/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 Cldapi extends StdCallLibrary {
    Cldapi INSTANCE = Native.load("cldapi", Cldapi.class);
    int CfCreatePlaceholders(
        WString BaseDirectoryPath,   // LPCWSTR
        Pointer PlaceholderArray,   // CF_PLACEHOLDER_CREATE_INFO* in/out
        int PlaceholderCount,   // DWORD
        int CreateFlags,   // CF_CREATE_FLAGS
        IntByReference EntriesProcessed   // DWORD* optional, out
    );
}
@[Link("cldapi")]
lib Libcldapi
  fun CfCreatePlaceholders = CfCreatePlaceholders(
    BaseDirectoryPath : UInt16*,   # LPCWSTR
    PlaceholderArray : CF_PLACEHOLDER_CREATE_INFO*,   # CF_PLACEHOLDER_CREATE_INFO* in/out
    PlaceholderCount : UInt32,   # DWORD
    CreateFlags : Int32,   # CF_CREATE_FLAGS
    EntriesProcessed : UInt32*   # DWORD* optional, out
  ) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef CfCreatePlaceholdersNative = Int32 Function(Pointer<Utf16>, Pointer<Void>, Uint32, Int32, Pointer<Uint32>);
typedef CfCreatePlaceholdersDart = int Function(Pointer<Utf16>, Pointer<Void>, int, int, Pointer<Uint32>);
final CfCreatePlaceholders = DynamicLibrary.open('cldapi.dll')
    .lookupFunction<CfCreatePlaceholdersNative, CfCreatePlaceholdersDart>('CfCreatePlaceholders');
// BaseDirectoryPath : LPCWSTR -> Pointer<Utf16>
// PlaceholderArray : CF_PLACEHOLDER_CREATE_INFO* in/out -> Pointer<Void>
// PlaceholderCount : DWORD -> Uint32
// CreateFlags : CF_CREATE_FLAGS -> Int32
// EntriesProcessed : DWORD* optional, out -> Pointer<Uint32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function CfCreatePlaceholders(
  BaseDirectoryPath: PWideChar;   // LPCWSTR
  PlaceholderArray: Pointer;   // CF_PLACEHOLDER_CREATE_INFO* in/out
  PlaceholderCount: DWORD;   // DWORD
  CreateFlags: Integer;   // CF_CREATE_FLAGS
  EntriesProcessed: Pointer   // DWORD* optional, out
): Integer; stdcall;
  external 'cldapi.dll' name 'CfCreatePlaceholders';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "CfCreatePlaceholders"
  c_CfCreatePlaceholders :: CWString -> Ptr () -> Word32 -> Int32 -> Ptr Word32 -> IO Int32
-- BaseDirectoryPath : LPCWSTR -> CWString
-- PlaceholderArray : CF_PLACEHOLDER_CREATE_INFO* in/out -> Ptr ()
-- PlaceholderCount : DWORD -> Word32
-- CreateFlags : CF_CREATE_FLAGS -> Int32
-- EntriesProcessed : DWORD* optional, out -> Ptr Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let cfcreateplaceholders =
  foreign "CfCreatePlaceholders"
    ((ptr uint16_t) @-> (ptr void) @-> uint32_t @-> int32_t @-> (ptr uint32_t) @-> returning int32_t)
(* BaseDirectoryPath : LPCWSTR -> (ptr uint16_t) *)
(* PlaceholderArray : CF_PLACEHOLDER_CREATE_INFO* in/out -> (ptr void) *)
(* PlaceholderCount : DWORD -> uint32_t *)
(* CreateFlags : CF_CREATE_FLAGS -> int32_t *)
(* EntriesProcessed : DWORD* optional, out -> (ptr uint32_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library cldapi (t "cldapi.dll"))
(cffi:use-foreign-library cldapi)

(cffi:defcfun ("CfCreatePlaceholders" cf-create-placeholders :convention :stdcall) :int32
  (base-directory-path (:string :encoding :utf-16le))   ; LPCWSTR
  (placeholder-array :pointer)   ; CF_PLACEHOLDER_CREATE_INFO* in/out
  (placeholder-count :uint32)   ; DWORD
  (create-flags :int32)   ; CF_CREATE_FLAGS
  (entries-processed :pointer))   ; DWORD* optional, out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $CfCreatePlaceholders = Win32::API::More->new('cldapi',
    'int CfCreatePlaceholders(LPCWSTR BaseDirectoryPath, LPVOID PlaceholderArray, DWORD PlaceholderCount, int CreateFlags, LPVOID EntriesProcessed)');
# my $ret = $CfCreatePlaceholders->Call($BaseDirectoryPath, $PlaceholderArray, $PlaceholderCount, $CreateFlags, $EntriesProcessed);
# BaseDirectoryPath : LPCWSTR -> LPCWSTR
# PlaceholderArray : CF_PLACEHOLDER_CREATE_INFO* in/out -> LPVOID
# PlaceholderCount : DWORD -> DWORD
# CreateFlags : CF_CREATE_FLAGS -> int
# EntriesProcessed : DWORD* optional, out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

使用する型