ホーム › Storage.CloudFilters › CfGetSyncRootInfoByPath
CfGetSyncRootInfoByPath
関数パス指定で同期ルートの情報を取得する。
シグネチャ
// cldapi.dll
#include <windows.h>
HRESULT CfGetSyncRootInfoByPath(
LPCWSTR FilePath,
CF_SYNC_ROOT_INFO_CLASS InfoClass,
void* InfoBuffer,
DWORD InfoBufferLength,
DWORD* ReturnedLength // optional
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| FilePath | LPCWSTR | in | 情報を取得する同期ルート配下のファイルパスを示すワイド文字列。 |
| InfoClass | CF_SYNC_ROOT_INFO_CLASS | in | 取得する情報の種別を示すCF_SYNC_ROOT_INFO_CLASS列挙値。 |
| InfoBuffer | void* | out | 取得した同期ルート情報を受け取るバッファへのポインタ。出力用。 |
| InfoBufferLength | DWORD | in | InfoBufferのバイト単位のサイズ。 |
| ReturnedLength | DWORD* | outoptional | 実際に書き込まれたバイト数を受け取るDWORDへのポインタ。出力用。NULL可。 |
戻り値の型: HRESULT
各言語での呼び出し定義
// cldapi.dll
#include <windows.h>
HRESULT CfGetSyncRootInfoByPath(
LPCWSTR FilePath,
CF_SYNC_ROOT_INFO_CLASS InfoClass,
void* InfoBuffer,
DWORD InfoBufferLength,
DWORD* ReturnedLength // optional
);[DllImport("cldapi.dll", ExactSpelling = true)]
static extern int CfGetSyncRootInfoByPath(
[MarshalAs(UnmanagedType.LPWStr)] string FilePath, // LPCWSTR
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 CfGetSyncRootInfoByPath(
<MarshalAs(UnmanagedType.LPWStr)> FilePath As String, ' LPCWSTR
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' FilePath : LPCWSTR
' InfoClass : CF_SYNC_ROOT_INFO_CLASS
' InfoBuffer : void* out
' InfoBufferLength : DWORD
' ReturnedLength : DWORD* optional, out
Declare PtrSafe Function CfGetSyncRootInfoByPath Lib "cldapi" ( _
ByVal FilePath 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
CfGetSyncRootInfoByPath = ctypes.windll.cldapi.CfGetSyncRootInfoByPath
CfGetSyncRootInfoByPath.restype = ctypes.c_int
CfGetSyncRootInfoByPath.argtypes = [
wintypes.LPCWSTR, # FilePath : LPCWSTR
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')
CfGetSyncRootInfoByPath = Fiddle::Function.new(
lib['CfGetSyncRootInfoByPath'],
[
Fiddle::TYPE_VOIDP, # FilePath : LPCWSTR
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 CfGetSyncRootInfoByPath(
FilePath: *const u16, // LPCWSTR
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 CfGetSyncRootInfoByPath([MarshalAs(UnmanagedType.LPWStr)] string FilePath, int InfoClass, IntPtr InfoBuffer, uint InfoBufferLength, IntPtr ReturnedLength);
"@
$api = Add-Type -MemberDefinition $sig -Name 'cldapi_CfGetSyncRootInfoByPath' -Namespace Win32 -PassThru
# $api::CfGetSyncRootInfoByPath(FilePath, InfoClass, InfoBuffer, InfoBufferLength, ReturnedLength)#uselib "cldapi.dll"
#func global CfGetSyncRootInfoByPath "CfGetSyncRootInfoByPath" sptr, sptr, sptr, sptr, sptr
; CfGetSyncRootInfoByPath FilePath, InfoClass, InfoBuffer, InfoBufferLength, varptr(ReturnedLength) ; 戻り値は stat
; FilePath : LPCWSTR -> "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 CfGetSyncRootInfoByPath "CfGetSyncRootInfoByPath" wstr, int, sptr, int, var ; res = CfGetSyncRootInfoByPath(FilePath, InfoClass, InfoBuffer, InfoBufferLength, ReturnedLength) ; FilePath : LPCWSTR -> "wstr" ; InfoClass : CF_SYNC_ROOT_INFO_CLASS -> "int" ; InfoBuffer : void* out -> "sptr" ; InfoBufferLength : DWORD -> "int" ; ReturnedLength : DWORD* optional, out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "cldapi.dll" #cfunc global CfGetSyncRootInfoByPath "CfGetSyncRootInfoByPath" wstr, int, sptr, int, sptr ; res = CfGetSyncRootInfoByPath(FilePath, InfoClass, InfoBuffer, InfoBufferLength, varptr(ReturnedLength)) ; FilePath : LPCWSTR -> "wstr" ; InfoClass : CF_SYNC_ROOT_INFO_CLASS -> "int" ; InfoBuffer : void* out -> "sptr" ; InfoBufferLength : DWORD -> "int" ; ReturnedLength : DWORD* optional, out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HRESULT CfGetSyncRootInfoByPath(LPCWSTR FilePath, CF_SYNC_ROOT_INFO_CLASS InfoClass, void* InfoBuffer, DWORD InfoBufferLength, DWORD* ReturnedLength) #uselib "cldapi.dll" #cfunc global CfGetSyncRootInfoByPath "CfGetSyncRootInfoByPath" wstr, int, intptr, int, var ; res = CfGetSyncRootInfoByPath(FilePath, InfoClass, InfoBuffer, InfoBufferLength, ReturnedLength) ; FilePath : LPCWSTR -> "wstr" ; InfoClass : CF_SYNC_ROOT_INFO_CLASS -> "int" ; InfoBuffer : void* out -> "intptr" ; InfoBufferLength : DWORD -> "int" ; ReturnedLength : DWORD* optional, out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HRESULT CfGetSyncRootInfoByPath(LPCWSTR FilePath, CF_SYNC_ROOT_INFO_CLASS InfoClass, void* InfoBuffer, DWORD InfoBufferLength, DWORD* ReturnedLength) #uselib "cldapi.dll" #cfunc global CfGetSyncRootInfoByPath "CfGetSyncRootInfoByPath" wstr, int, intptr, int, intptr ; res = CfGetSyncRootInfoByPath(FilePath, InfoClass, InfoBuffer, InfoBufferLength, varptr(ReturnedLength)) ; FilePath : LPCWSTR -> "wstr" ; InfoClass : CF_SYNC_ROOT_INFO_CLASS -> "int" ; InfoBuffer : void* out -> "intptr" ; InfoBufferLength : DWORD -> "int" ; ReturnedLength : DWORD* optional, out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
cldapi = windows.NewLazySystemDLL("cldapi.dll")
procCfGetSyncRootInfoByPath = cldapi.NewProc("CfGetSyncRootInfoByPath")
)
// FilePath (LPCWSTR), InfoClass (CF_SYNC_ROOT_INFO_CLASS), InfoBuffer (void* out), InfoBufferLength (DWORD), ReturnedLength (DWORD* optional, out)
r1, _, err := procCfGetSyncRootInfoByPath.Call(
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(FilePath))),
uintptr(InfoClass),
uintptr(InfoBuffer),
uintptr(InfoBufferLength),
uintptr(ReturnedLength),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction CfGetSyncRootInfoByPath(
FilePath: PWideChar; // LPCWSTR
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 'CfGetSyncRootInfoByPath';result := DllCall("cldapi\CfGetSyncRootInfoByPath"
, "WStr", FilePath ; LPCWSTR
, "Int", InfoClass ; CF_SYNC_ROOT_INFO_CLASS
, "Ptr", InfoBuffer ; void* out
, "UInt", InfoBufferLength ; DWORD
, "Ptr", ReturnedLength ; DWORD* optional, out
, "Int") ; return: HRESULT●CfGetSyncRootInfoByPath(FilePath, InfoClass, InfoBuffer, InfoBufferLength, ReturnedLength) = DLL("cldapi.dll", "int CfGetSyncRootInfoByPath(char*, int, void*, dword, void*)")
# 呼び出し: CfGetSyncRootInfoByPath(FilePath, InfoClass, InfoBuffer, InfoBufferLength, ReturnedLength)
# FilePath : LPCWSTR -> "char*"
# 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 CfGetSyncRootInfoByPath(
FilePath: [*c]const u16, // LPCWSTR
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 CfGetSyncRootInfoByPath(
FilePath: WideCString, # LPCWSTR
InfoClass: int32, # CF_SYNC_ROOT_INFO_CLASS
InfoBuffer: pointer, # void* out
InfoBufferLength: uint32, # DWORD
ReturnedLength: ptr uint32 # DWORD* optional, out
): int32 {.importc: "CfGetSyncRootInfoByPath", stdcall, dynlib: "cldapi.dll".}pragma(lib, "cldapi");
extern(Windows)
int CfGetSyncRootInfoByPath(
const(wchar)* FilePath, // LPCWSTR
int InfoClass, // CF_SYNC_ROOT_INFO_CLASS
void* InfoBuffer, // void* out
uint InfoBufferLength, // DWORD
uint* ReturnedLength // DWORD* optional, out
);ccall((:CfGetSyncRootInfoByPath, "cldapi.dll"), stdcall, Int32,
(Cwstring, Int32, Ptr{Cvoid}, UInt32, Ptr{UInt32}),
FilePath, InfoClass, InfoBuffer, InfoBufferLength, ReturnedLength)
# FilePath : LPCWSTR -> Cwstring
# 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 CfGetSyncRootInfoByPath(
const uint16_t* FilePath,
int32_t InfoClass,
void* InfoBuffer,
uint32_t InfoBufferLength,
uint32_t* ReturnedLength);
]]
local cldapi = ffi.load("cldapi")
-- cldapi.CfGetSyncRootInfoByPath(FilePath, InfoClass, InfoBuffer, InfoBufferLength, ReturnedLength)
-- FilePath : LPCWSTR
-- 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 CfGetSyncRootInfoByPath = lib.func('__stdcall', 'CfGetSyncRootInfoByPath', 'int32_t', ['str16', 'int32_t', 'void *', 'uint32_t', 'uint32_t *']);
// CfGetSyncRootInfoByPath(FilePath, InfoClass, InfoBuffer, InfoBufferLength, ReturnedLength)
// FilePath : LPCWSTR -> 'str16'
// 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", {
CfGetSyncRootInfoByPath: { parameters: ["buffer", "i32", "pointer", "u32", "pointer"], result: "i32" },
});
// lib.symbols.CfGetSyncRootInfoByPath(FilePath, InfoClass, InfoBuffer, InfoBufferLength, ReturnedLength)
// FilePath : LPCWSTR -> "buffer"
// 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 CfGetSyncRootInfoByPath(
const uint16_t* FilePath,
int32_t InfoClass,
void* InfoBuffer,
uint32_t InfoBufferLength,
uint32_t* ReturnedLength);
C, "cldapi.dll");
// $ffi->CfGetSyncRootInfoByPath(FilePath, InfoClass, InfoBuffer, InfoBufferLength, ReturnedLength);
// FilePath : LPCWSTR
// 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 CfGetSyncRootInfoByPath(
WString FilePath, // LPCWSTR
int InfoClass, // CF_SYNC_ROOT_INFO_CLASS
Pointer InfoBuffer, // void* out
int InfoBufferLength, // DWORD
IntByReference ReturnedLength // DWORD* optional, out
);
}@[Link("cldapi")]
lib Libcldapi
fun CfGetSyncRootInfoByPath = CfGetSyncRootInfoByPath(
FilePath : UInt16*, # LPCWSTR
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 CfGetSyncRootInfoByPathNative = Int32 Function(Pointer<Utf16>, Int32, Pointer<Void>, Uint32, Pointer<Uint32>);
typedef CfGetSyncRootInfoByPathDart = int Function(Pointer<Utf16>, int, Pointer<Void>, int, Pointer<Uint32>);
final CfGetSyncRootInfoByPath = DynamicLibrary.open('cldapi.dll')
.lookupFunction<CfGetSyncRootInfoByPathNative, CfGetSyncRootInfoByPathDart>('CfGetSyncRootInfoByPath');
// FilePath : LPCWSTR -> Pointer<Utf16>
// 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 CfGetSyncRootInfoByPath(
FilePath: PWideChar; // LPCWSTR
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 'CfGetSyncRootInfoByPath';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "CfGetSyncRootInfoByPath"
c_CfGetSyncRootInfoByPath :: CWString -> Int32 -> Ptr () -> Word32 -> Ptr Word32 -> IO Int32
-- FilePath : LPCWSTR -> CWString
-- 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 cfgetsyncrootinfobypath =
foreign "CfGetSyncRootInfoByPath"
((ptr uint16_t) @-> int32_t @-> (ptr void) @-> uint32_t @-> (ptr uint32_t) @-> returning int32_t)
(* FilePath : LPCWSTR -> (ptr uint16_t) *)
(* 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 ("CfGetSyncRootInfoByPath" cf-get-sync-root-info-by-path :convention :stdcall) :int32
(file-path (:string :encoding :utf-16le)) ; LPCWSTR
(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 $CfGetSyncRootInfoByPath = Win32::API::More->new('cldapi',
'int CfGetSyncRootInfoByPath(LPCWSTR FilePath, int InfoClass, LPVOID InfoBuffer, DWORD InfoBufferLength, LPVOID ReturnedLength)');
# my $ret = $CfGetSyncRootInfoByPath->Call($FilePath, $InfoClass, $InfoBuffer, $InfoBufferLength, $ReturnedLength);
# FilePath : LPCWSTR -> LPCWSTR
# InfoClass : CF_SYNC_ROOT_INFO_CLASS -> int
# InfoBuffer : void* out -> LPVOID
# InfoBufferLength : DWORD -> DWORD
# ReturnedLength : DWORD* optional, out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。