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
InfoBuffervoid*out
InfoBufferLengthDWORDin
ReturnedLengthDWORD*outoptional

戻り値の型: 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)。