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

CfGetSyncRootInfoByHandle

関数
ハンドル指定で同期ルートの情報を取得する。
DLLcldapi.dll呼出規約winapi対応OSWindows 10 以降

シグネチャ

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

HRESULT CfGetSyncRootInfoByHandle(
    HANDLE FileHandle,
    CF_SYNC_ROOT_INFO_CLASS InfoClass,
    void* InfoBuffer,
    DWORD InfoBufferLength,
    DWORD* ReturnedLength   // optional
);

パラメーター

名前方向説明
FileHandleHANDLEin情報を取得する同期ルート配下のファイルハンドル。
InfoClassCF_SYNC_ROOT_INFO_CLASSin取得する情報の種別を示すCF_SYNC_ROOT_INFO_CLASS列挙値。
InfoBuffervoid*out取得した同期ルート情報を受け取るバッファへのポインタ。出力用。
InfoBufferLengthDWORDinInfoBufferのバイト単位のサイズ。
ReturnedLengthDWORD*outoptional実際に書き込まれたバイト数を受け取るDWORDへのポインタ。出力用。NULL可。

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT CfGetSyncRootInfoByHandle(
    HANDLE FileHandle,
    CF_SYNC_ROOT_INFO_CLASS InfoClass,
    void* InfoBuffer,
    DWORD InfoBufferLength,
    DWORD* ReturnedLength   // optional
);
[DllImport("cldapi.dll", ExactSpelling = true)]
static extern int CfGetSyncRootInfoByHandle(
    IntPtr FileHandle,   // HANDLE
    int InfoClass,   // CF_SYNC_ROOT_INFO_CLASS
    IntPtr InfoBuffer,   // void* out
    uint InfoBufferLength,   // DWORD
    IntPtr ReturnedLength   // DWORD* optional, out
);
<DllImport("cldapi.dll", ExactSpelling:=True)>
Public Shared Function CfGetSyncRootInfoByHandle(
    FileHandle As IntPtr,   ' HANDLE
    InfoClass As Integer,   ' CF_SYNC_ROOT_INFO_CLASS
    InfoBuffer As IntPtr,   ' void* out
    InfoBufferLength As UInteger,   ' DWORD
    ReturnedLength As IntPtr   ' DWORD* optional, out
) As Integer
End Function
' FileHandle : HANDLE
' InfoClass : CF_SYNC_ROOT_INFO_CLASS
' InfoBuffer : void* out
' InfoBufferLength : DWORD
' ReturnedLength : DWORD* optional, out
Declare PtrSafe Function CfGetSyncRootInfoByHandle Lib "cldapi" ( _
    ByVal FileHandle As LongPtr, _
    ByVal InfoClass As Long, _
    ByVal InfoBuffer As LongPtr, _
    ByVal InfoBufferLength As Long, _
    ByVal ReturnedLength As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

CfGetSyncRootInfoByHandle = ctypes.windll.cldapi.CfGetSyncRootInfoByHandle
CfGetSyncRootInfoByHandle.restype = ctypes.c_int
CfGetSyncRootInfoByHandle.argtypes = [
    wintypes.HANDLE,  # FileHandle : HANDLE
    ctypes.c_int,  # InfoClass : CF_SYNC_ROOT_INFO_CLASS
    ctypes.POINTER(None),  # InfoBuffer : void* out
    wintypes.DWORD,  # InfoBufferLength : DWORD
    ctypes.POINTER(wintypes.DWORD),  # ReturnedLength : DWORD* optional, out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('cldapi.dll')
CfGetSyncRootInfoByHandle = Fiddle::Function.new(
  lib['CfGetSyncRootInfoByHandle'],
  [
    Fiddle::TYPE_VOIDP,  # FileHandle : HANDLE
    Fiddle::TYPE_INT,  # InfoClass : CF_SYNC_ROOT_INFO_CLASS
    Fiddle::TYPE_VOIDP,  # InfoBuffer : void* out
    -Fiddle::TYPE_INT,  # InfoBufferLength : DWORD
    Fiddle::TYPE_VOIDP,  # ReturnedLength : DWORD* optional, out
  ],
  Fiddle::TYPE_INT)
#[link(name = "cldapi")]
extern "system" {
    fn CfGetSyncRootInfoByHandle(
        FileHandle: *mut core::ffi::c_void,  // HANDLE
        InfoClass: i32,  // CF_SYNC_ROOT_INFO_CLASS
        InfoBuffer: *mut (),  // void* out
        InfoBufferLength: u32,  // DWORD
        ReturnedLength: *mut u32  // DWORD* optional, out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("cldapi.dll")]
public static extern int CfGetSyncRootInfoByHandle(IntPtr FileHandle, int InfoClass, IntPtr InfoBuffer, uint InfoBufferLength, IntPtr ReturnedLength);
"@
$api = Add-Type -MemberDefinition $sig -Name 'cldapi_CfGetSyncRootInfoByHandle' -Namespace Win32 -PassThru
# $api::CfGetSyncRootInfoByHandle(FileHandle, InfoClass, InfoBuffer, InfoBufferLength, ReturnedLength)
#uselib "cldapi.dll"
#func global CfGetSyncRootInfoByHandle "CfGetSyncRootInfoByHandle" sptr, sptr, sptr, sptr, sptr
; CfGetSyncRootInfoByHandle FileHandle, InfoClass, InfoBuffer, InfoBufferLength, varptr(ReturnedLength)   ; 戻り値は stat
; FileHandle : HANDLE -> "sptr"
; InfoClass : CF_SYNC_ROOT_INFO_CLASS -> "sptr"
; InfoBuffer : void* out -> "sptr"
; InfoBufferLength : DWORD -> "sptr"
; ReturnedLength : DWORD* optional, out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "cldapi.dll"
#cfunc global CfGetSyncRootInfoByHandle "CfGetSyncRootInfoByHandle" sptr, int, sptr, int, var
; res = CfGetSyncRootInfoByHandle(FileHandle, InfoClass, InfoBuffer, InfoBufferLength, ReturnedLength)
; FileHandle : HANDLE -> "sptr"
; InfoClass : CF_SYNC_ROOT_INFO_CLASS -> "int"
; InfoBuffer : void* out -> "sptr"
; InfoBufferLength : DWORD -> "int"
; ReturnedLength : DWORD* optional, out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; HRESULT CfGetSyncRootInfoByHandle(HANDLE FileHandle, CF_SYNC_ROOT_INFO_CLASS InfoClass, void* InfoBuffer, DWORD InfoBufferLength, DWORD* ReturnedLength)
#uselib "cldapi.dll"
#cfunc global CfGetSyncRootInfoByHandle "CfGetSyncRootInfoByHandle" intptr, int, intptr, int, var
; res = CfGetSyncRootInfoByHandle(FileHandle, InfoClass, InfoBuffer, InfoBufferLength, ReturnedLength)
; FileHandle : HANDLE -> "intptr"
; InfoClass : CF_SYNC_ROOT_INFO_CLASS -> "int"
; InfoBuffer : void* out -> "intptr"
; InfoBufferLength : DWORD -> "int"
; ReturnedLength : DWORD* optional, out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	cldapi = windows.NewLazySystemDLL("cldapi.dll")
	procCfGetSyncRootInfoByHandle = cldapi.NewProc("CfGetSyncRootInfoByHandle")
)

// FileHandle (HANDLE), InfoClass (CF_SYNC_ROOT_INFO_CLASS), InfoBuffer (void* out), InfoBufferLength (DWORD), ReturnedLength (DWORD* optional, out)
r1, _, err := procCfGetSyncRootInfoByHandle.Call(
	uintptr(FileHandle),
	uintptr(InfoClass),
	uintptr(InfoBuffer),
	uintptr(InfoBufferLength),
	uintptr(ReturnedLength),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function CfGetSyncRootInfoByHandle(
  FileHandle: THandle;   // HANDLE
  InfoClass: Integer;   // CF_SYNC_ROOT_INFO_CLASS
  InfoBuffer: Pointer;   // void* out
  InfoBufferLength: DWORD;   // DWORD
  ReturnedLength: Pointer   // DWORD* optional, out
): Integer; stdcall;
  external 'cldapi.dll' name 'CfGetSyncRootInfoByHandle';
result := DllCall("cldapi\CfGetSyncRootInfoByHandle"
    , "Ptr", FileHandle   ; HANDLE
    , "Int", InfoClass   ; CF_SYNC_ROOT_INFO_CLASS
    , "Ptr", InfoBuffer   ; void* out
    , "UInt", InfoBufferLength   ; DWORD
    , "Ptr", ReturnedLength   ; DWORD* optional, out
    , "Int")   ; return: HRESULT
●CfGetSyncRootInfoByHandle(FileHandle, InfoClass, InfoBuffer, InfoBufferLength, ReturnedLength) = DLL("cldapi.dll", "int CfGetSyncRootInfoByHandle(void*, int, void*, dword, void*)")
# 呼び出し: CfGetSyncRootInfoByHandle(FileHandle, InfoClass, InfoBuffer, InfoBufferLength, ReturnedLength)
# FileHandle : HANDLE -> "void*"
# InfoClass : CF_SYNC_ROOT_INFO_CLASS -> "int"
# InfoBuffer : void* out -> "void*"
# InfoBufferLength : DWORD -> "dword"
# ReturnedLength : DWORD* optional, out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

extern "cldapi" fn CfGetSyncRootInfoByHandle(
    FileHandle: ?*anyopaque, // HANDLE
    InfoClass: i32, // CF_SYNC_ROOT_INFO_CLASS
    InfoBuffer: ?*anyopaque, // void* out
    InfoBufferLength: u32, // DWORD
    ReturnedLength: [*c]u32 // DWORD* optional, out
) callconv(std.os.windows.WINAPI) i32;
proc CfGetSyncRootInfoByHandle(
    FileHandle: pointer,  # HANDLE
    InfoClass: int32,  # CF_SYNC_ROOT_INFO_CLASS
    InfoBuffer: pointer,  # void* out
    InfoBufferLength: uint32,  # DWORD
    ReturnedLength: ptr uint32  # DWORD* optional, out
): int32 {.importc: "CfGetSyncRootInfoByHandle", stdcall, dynlib: "cldapi.dll".}
pragma(lib, "cldapi");
extern(Windows)
int CfGetSyncRootInfoByHandle(
    void* FileHandle,   // HANDLE
    int InfoClass,   // CF_SYNC_ROOT_INFO_CLASS
    void* InfoBuffer,   // void* out
    uint InfoBufferLength,   // DWORD
    uint* ReturnedLength   // DWORD* optional, out
);
ccall((:CfGetSyncRootInfoByHandle, "cldapi.dll"), stdcall, Int32,
      (Ptr{Cvoid}, Int32, Ptr{Cvoid}, UInt32, Ptr{UInt32}),
      FileHandle, InfoClass, InfoBuffer, InfoBufferLength, ReturnedLength)
# FileHandle : HANDLE -> Ptr{Cvoid}
# InfoClass : CF_SYNC_ROOT_INFO_CLASS -> Int32
# InfoBuffer : void* out -> Ptr{Cvoid}
# InfoBufferLength : DWORD -> UInt32
# ReturnedLength : DWORD* optional, out -> Ptr{UInt32}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t CfGetSyncRootInfoByHandle(
    void* FileHandle,
    int32_t InfoClass,
    void* InfoBuffer,
    uint32_t InfoBufferLength,
    uint32_t* ReturnedLength);
]]
local cldapi = ffi.load("cldapi")
-- cldapi.CfGetSyncRootInfoByHandle(FileHandle, InfoClass, InfoBuffer, InfoBufferLength, ReturnedLength)
-- FileHandle : HANDLE
-- InfoClass : CF_SYNC_ROOT_INFO_CLASS
-- InfoBuffer : void* out
-- InfoBufferLength : DWORD
-- ReturnedLength : DWORD* optional, out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('cldapi.dll');
const CfGetSyncRootInfoByHandle = lib.func('__stdcall', 'CfGetSyncRootInfoByHandle', 'int32_t', ['void *', 'int32_t', 'void *', 'uint32_t', 'uint32_t *']);
// CfGetSyncRootInfoByHandle(FileHandle, InfoClass, InfoBuffer, InfoBufferLength, ReturnedLength)
// FileHandle : HANDLE -> 'void *'
// InfoClass : CF_SYNC_ROOT_INFO_CLASS -> 'int32_t'
// InfoBuffer : void* out -> 'void *'
// InfoBufferLength : DWORD -> 'uint32_t'
// ReturnedLength : DWORD* optional, out -> 'uint32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("cldapi.dll", {
  CfGetSyncRootInfoByHandle: { parameters: ["pointer", "i32", "pointer", "u32", "pointer"], result: "i32" },
});
// lib.symbols.CfGetSyncRootInfoByHandle(FileHandle, InfoClass, InfoBuffer, InfoBufferLength, ReturnedLength)
// FileHandle : HANDLE -> "pointer"
// InfoClass : CF_SYNC_ROOT_INFO_CLASS -> "i32"
// InfoBuffer : void* out -> "pointer"
// InfoBufferLength : DWORD -> "u32"
// ReturnedLength : DWORD* optional, out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t CfGetSyncRootInfoByHandle(
    void* FileHandle,
    int32_t InfoClass,
    void* InfoBuffer,
    uint32_t InfoBufferLength,
    uint32_t* ReturnedLength);
C, "cldapi.dll");
// $ffi->CfGetSyncRootInfoByHandle(FileHandle, InfoClass, InfoBuffer, InfoBufferLength, ReturnedLength);
// FileHandle : HANDLE
// InfoClass : CF_SYNC_ROOT_INFO_CLASS
// InfoBuffer : void* out
// InfoBufferLength : DWORD
// ReturnedLength : 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 CfGetSyncRootInfoByHandle(
        Pointer FileHandle,   // HANDLE
        int InfoClass,   // CF_SYNC_ROOT_INFO_CLASS
        Pointer InfoBuffer,   // void* out
        int InfoBufferLength,   // DWORD
        IntByReference ReturnedLength   // DWORD* optional, out
    );
}
@[Link("cldapi")]
lib Libcldapi
  fun CfGetSyncRootInfoByHandle = CfGetSyncRootInfoByHandle(
    FileHandle : Void*,   # HANDLE
    InfoClass : Int32,   # CF_SYNC_ROOT_INFO_CLASS
    InfoBuffer : Void*,   # void* out
    InfoBufferLength : UInt32,   # DWORD
    ReturnedLength : 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 CfGetSyncRootInfoByHandleNative = Int32 Function(Pointer<Void>, Int32, Pointer<Void>, Uint32, Pointer<Uint32>);
typedef CfGetSyncRootInfoByHandleDart = int Function(Pointer<Void>, int, Pointer<Void>, int, Pointer<Uint32>);
final CfGetSyncRootInfoByHandle = DynamicLibrary.open('cldapi.dll')
    .lookupFunction<CfGetSyncRootInfoByHandleNative, CfGetSyncRootInfoByHandleDart>('CfGetSyncRootInfoByHandle');
// FileHandle : HANDLE -> Pointer<Void>
// InfoClass : CF_SYNC_ROOT_INFO_CLASS -> Int32
// InfoBuffer : void* out -> Pointer<Void>
// InfoBufferLength : DWORD -> Uint32
// ReturnedLength : DWORD* optional, out -> Pointer<Uint32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function CfGetSyncRootInfoByHandle(
  FileHandle: THandle;   // HANDLE
  InfoClass: Integer;   // CF_SYNC_ROOT_INFO_CLASS
  InfoBuffer: Pointer;   // void* out
  InfoBufferLength: DWORD;   // DWORD
  ReturnedLength: Pointer   // DWORD* optional, out
): Integer; stdcall;
  external 'cldapi.dll' name 'CfGetSyncRootInfoByHandle';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "CfGetSyncRootInfoByHandle"
  c_CfGetSyncRootInfoByHandle :: Ptr () -> Int32 -> Ptr () -> Word32 -> Ptr Word32 -> IO Int32
-- FileHandle : HANDLE -> Ptr ()
-- InfoClass : CF_SYNC_ROOT_INFO_CLASS -> Int32
-- InfoBuffer : void* out -> Ptr ()
-- InfoBufferLength : DWORD -> Word32
-- ReturnedLength : DWORD* optional, out -> Ptr Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let cfgetsyncrootinfobyhandle =
  foreign "CfGetSyncRootInfoByHandle"
    ((ptr void) @-> int32_t @-> (ptr void) @-> uint32_t @-> (ptr uint32_t) @-> returning int32_t)
(* FileHandle : HANDLE -> (ptr void) *)
(* InfoClass : CF_SYNC_ROOT_INFO_CLASS -> int32_t *)
(* InfoBuffer : void* out -> (ptr void) *)
(* InfoBufferLength : DWORD -> uint32_t *)
(* ReturnedLength : 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 ("CfGetSyncRootInfoByHandle" cf-get-sync-root-info-by-handle :convention :stdcall) :int32
  (file-handle :pointer)   ; HANDLE
  (info-class :int32)   ; CF_SYNC_ROOT_INFO_CLASS
  (info-buffer :pointer)   ; void* out
  (info-buffer-length :uint32)   ; DWORD
  (returned-length :pointer))   ; DWORD* optional, out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $CfGetSyncRootInfoByHandle = Win32::API::More->new('cldapi',
    'int CfGetSyncRootInfoByHandle(HANDLE FileHandle, int InfoClass, LPVOID InfoBuffer, DWORD InfoBufferLength, LPVOID ReturnedLength)');
# my $ret = $CfGetSyncRootInfoByHandle->Call($FileHandle, $InfoClass, $InfoBuffer, $InfoBufferLength, $ReturnedLength);
# FileHandle : HANDLE -> HANDLE
# InfoClass : CF_SYNC_ROOT_INFO_CLASS -> int
# InfoBuffer : void* out -> LPVOID
# InfoBufferLength : DWORD -> DWORD
# ReturnedLength : DWORD* optional, out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

使用する型