ホーム › Storage.CloudFilters › CfConnectSyncRoot
CfConnectSyncRoot
関数同期ルートにコールバックを接続し通信を確立する。
シグネチャ
// cldapi.dll
#include <windows.h>
HRESULT CfConnectSyncRoot(
LPCWSTR SyncRootPath,
const CF_CALLBACK_REGISTRATION* CallbackTable,
const void* CallbackContext, // optional
CF_CONNECT_FLAGS ConnectFlags,
CF_CONNECTION_KEY* ConnectionKey
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| SyncRootPath | LPCWSTR | in | 接続する同期ルートディレクトリのフルパスを示すワイド文字列。 |
| CallbackTable | CF_CALLBACK_REGISTRATION* | in | プラットフォームからの要求を処理するコールバック群を登録するCF_CALLBACK_REGISTRATION配列へのポインタ。 |
| CallbackContext | void* | inoptional | 各コールバックへ引き渡されるアプリケーション定義のコンテキストポインタ。NULL可。 |
| ConnectFlags | CF_CONNECT_FLAGS | in | 接続動作を制御するCF_CONNECT_FLAGSフラグ。要求された情報の種別等を指定する。 |
| ConnectionKey | CF_CONNECTION_KEY* | out | 接続を識別するキーを受け取るCF_CONNECTION_KEYへのポインタ。出力用で以後の操作に使う。 |
戻り値の型: HRESULT
各言語での呼び出し定義
// cldapi.dll
#include <windows.h>
HRESULT CfConnectSyncRoot(
LPCWSTR SyncRootPath,
const CF_CALLBACK_REGISTRATION* CallbackTable,
const void* CallbackContext, // optional
CF_CONNECT_FLAGS ConnectFlags,
CF_CONNECTION_KEY* ConnectionKey
);[DllImport("cldapi.dll", ExactSpelling = true)]
static extern int CfConnectSyncRoot(
[MarshalAs(UnmanagedType.LPWStr)] string SyncRootPath, // LPCWSTR
IntPtr CallbackTable, // CF_CALLBACK_REGISTRATION*
IntPtr CallbackContext, // void* optional
int ConnectFlags, // CF_CONNECT_FLAGS
out long ConnectionKey // CF_CONNECTION_KEY* out
);<DllImport("cldapi.dll", ExactSpelling:=True)>
Public Shared Function CfConnectSyncRoot(
<MarshalAs(UnmanagedType.LPWStr)> SyncRootPath As String, ' LPCWSTR
CallbackTable As IntPtr, ' CF_CALLBACK_REGISTRATION*
CallbackContext As IntPtr, ' void* optional
ConnectFlags As Integer, ' CF_CONNECT_FLAGS
<Out> ByRef ConnectionKey As Long ' CF_CONNECTION_KEY* out
) As Integer
End Function' SyncRootPath : LPCWSTR
' CallbackTable : CF_CALLBACK_REGISTRATION*
' CallbackContext : void* optional
' ConnectFlags : CF_CONNECT_FLAGS
' ConnectionKey : CF_CONNECTION_KEY* out
Declare PtrSafe Function CfConnectSyncRoot Lib "cldapi" ( _
ByVal SyncRootPath As LongPtr, _
ByVal CallbackTable As LongPtr, _
ByVal CallbackContext As LongPtr, _
ByVal ConnectFlags As Long, _
ByRef ConnectionKey As LongLong) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
CfConnectSyncRoot = ctypes.windll.cldapi.CfConnectSyncRoot
CfConnectSyncRoot.restype = ctypes.c_int
CfConnectSyncRoot.argtypes = [
wintypes.LPCWSTR, # SyncRootPath : LPCWSTR
ctypes.c_void_p, # CallbackTable : CF_CALLBACK_REGISTRATION*
ctypes.POINTER(None), # CallbackContext : void* optional
ctypes.c_int, # ConnectFlags : CF_CONNECT_FLAGS
ctypes.c_void_p, # ConnectionKey : CF_CONNECTION_KEY* out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('cldapi.dll')
CfConnectSyncRoot = Fiddle::Function.new(
lib['CfConnectSyncRoot'],
[
Fiddle::TYPE_VOIDP, # SyncRootPath : LPCWSTR
Fiddle::TYPE_VOIDP, # CallbackTable : CF_CALLBACK_REGISTRATION*
Fiddle::TYPE_VOIDP, # CallbackContext : void* optional
Fiddle::TYPE_INT, # ConnectFlags : CF_CONNECT_FLAGS
Fiddle::TYPE_VOIDP, # ConnectionKey : CF_CONNECTION_KEY* out
],
Fiddle::TYPE_INT)#[link(name = "cldapi")]
extern "system" {
fn CfConnectSyncRoot(
SyncRootPath: *const u16, // LPCWSTR
CallbackTable: *const CF_CALLBACK_REGISTRATION, // CF_CALLBACK_REGISTRATION*
CallbackContext: *const (), // void* optional
ConnectFlags: i32, // CF_CONNECT_FLAGS
ConnectionKey: *mut i64 // CF_CONNECTION_KEY* out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("cldapi.dll")]
public static extern int CfConnectSyncRoot([MarshalAs(UnmanagedType.LPWStr)] string SyncRootPath, IntPtr CallbackTable, IntPtr CallbackContext, int ConnectFlags, out long ConnectionKey);
"@
$api = Add-Type -MemberDefinition $sig -Name 'cldapi_CfConnectSyncRoot' -Namespace Win32 -PassThru
# $api::CfConnectSyncRoot(SyncRootPath, CallbackTable, CallbackContext, ConnectFlags, ConnectionKey)#uselib "cldapi.dll"
#func global CfConnectSyncRoot "CfConnectSyncRoot" sptr, sptr, sptr, sptr, sptr
; CfConnectSyncRoot SyncRootPath, varptr(CallbackTable), CallbackContext, ConnectFlags, varptr(ConnectionKey) ; 戻り値は stat
; SyncRootPath : LPCWSTR -> "sptr"
; CallbackTable : CF_CALLBACK_REGISTRATION* -> "sptr"
; CallbackContext : void* optional -> "sptr"
; ConnectFlags : CF_CONNECT_FLAGS -> "sptr"
; ConnectionKey : CF_CONNECTION_KEY* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "cldapi.dll" #cfunc global CfConnectSyncRoot "CfConnectSyncRoot" wstr, var, sptr, int, var ; res = CfConnectSyncRoot(SyncRootPath, CallbackTable, CallbackContext, ConnectFlags, ConnectionKey) ; SyncRootPath : LPCWSTR -> "wstr" ; CallbackTable : CF_CALLBACK_REGISTRATION* -> "var" ; CallbackContext : void* optional -> "sptr" ; ConnectFlags : CF_CONNECT_FLAGS -> "int" ; ConnectionKey : CF_CONNECTION_KEY* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "cldapi.dll" #cfunc global CfConnectSyncRoot "CfConnectSyncRoot" wstr, sptr, sptr, int, sptr ; res = CfConnectSyncRoot(SyncRootPath, varptr(CallbackTable), CallbackContext, ConnectFlags, varptr(ConnectionKey)) ; SyncRootPath : LPCWSTR -> "wstr" ; CallbackTable : CF_CALLBACK_REGISTRATION* -> "sptr" ; CallbackContext : void* optional -> "sptr" ; ConnectFlags : CF_CONNECT_FLAGS -> "int" ; ConnectionKey : CF_CONNECTION_KEY* out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HRESULT CfConnectSyncRoot(LPCWSTR SyncRootPath, CF_CALLBACK_REGISTRATION* CallbackTable, void* CallbackContext, CF_CONNECT_FLAGS ConnectFlags, CF_CONNECTION_KEY* ConnectionKey) #uselib "cldapi.dll" #cfunc global CfConnectSyncRoot "CfConnectSyncRoot" wstr, var, intptr, int, var ; res = CfConnectSyncRoot(SyncRootPath, CallbackTable, CallbackContext, ConnectFlags, ConnectionKey) ; SyncRootPath : LPCWSTR -> "wstr" ; CallbackTable : CF_CALLBACK_REGISTRATION* -> "var" ; CallbackContext : void* optional -> "intptr" ; ConnectFlags : CF_CONNECT_FLAGS -> "int" ; ConnectionKey : CF_CONNECTION_KEY* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HRESULT CfConnectSyncRoot(LPCWSTR SyncRootPath, CF_CALLBACK_REGISTRATION* CallbackTable, void* CallbackContext, CF_CONNECT_FLAGS ConnectFlags, CF_CONNECTION_KEY* ConnectionKey) #uselib "cldapi.dll" #cfunc global CfConnectSyncRoot "CfConnectSyncRoot" wstr, intptr, intptr, int, intptr ; res = CfConnectSyncRoot(SyncRootPath, varptr(CallbackTable), CallbackContext, ConnectFlags, varptr(ConnectionKey)) ; SyncRootPath : LPCWSTR -> "wstr" ; CallbackTable : CF_CALLBACK_REGISTRATION* -> "intptr" ; CallbackContext : void* optional -> "intptr" ; ConnectFlags : CF_CONNECT_FLAGS -> "int" ; ConnectionKey : CF_CONNECTION_KEY* out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
cldapi = windows.NewLazySystemDLL("cldapi.dll")
procCfConnectSyncRoot = cldapi.NewProc("CfConnectSyncRoot")
)
// SyncRootPath (LPCWSTR), CallbackTable (CF_CALLBACK_REGISTRATION*), CallbackContext (void* optional), ConnectFlags (CF_CONNECT_FLAGS), ConnectionKey (CF_CONNECTION_KEY* out)
r1, _, err := procCfConnectSyncRoot.Call(
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(SyncRootPath))),
uintptr(CallbackTable),
uintptr(CallbackContext),
uintptr(ConnectFlags),
uintptr(ConnectionKey),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction CfConnectSyncRoot(
SyncRootPath: PWideChar; // LPCWSTR
CallbackTable: Pointer; // CF_CALLBACK_REGISTRATION*
CallbackContext: Pointer; // void* optional
ConnectFlags: Integer; // CF_CONNECT_FLAGS
ConnectionKey: Pointer // CF_CONNECTION_KEY* out
): Integer; stdcall;
external 'cldapi.dll' name 'CfConnectSyncRoot';result := DllCall("cldapi\CfConnectSyncRoot"
, "WStr", SyncRootPath ; LPCWSTR
, "Ptr", CallbackTable ; CF_CALLBACK_REGISTRATION*
, "Ptr", CallbackContext ; void* optional
, "Int", ConnectFlags ; CF_CONNECT_FLAGS
, "Ptr", ConnectionKey ; CF_CONNECTION_KEY* out
, "Int") ; return: HRESULT●CfConnectSyncRoot(SyncRootPath, CallbackTable, CallbackContext, ConnectFlags, ConnectionKey) = DLL("cldapi.dll", "int CfConnectSyncRoot(char*, void*, void*, int, void*)")
# 呼び出し: CfConnectSyncRoot(SyncRootPath, CallbackTable, CallbackContext, ConnectFlags, ConnectionKey)
# SyncRootPath : LPCWSTR -> "char*"
# CallbackTable : CF_CALLBACK_REGISTRATION* -> "void*"
# CallbackContext : void* optional -> "void*"
# ConnectFlags : CF_CONNECT_FLAGS -> "int"
# ConnectionKey : CF_CONNECTION_KEY* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "cldapi" fn CfConnectSyncRoot(
SyncRootPath: [*c]const u16, // LPCWSTR
CallbackTable: [*c]CF_CALLBACK_REGISTRATION, // CF_CALLBACK_REGISTRATION*
CallbackContext: ?*anyopaque, // void* optional
ConnectFlags: i32, // CF_CONNECT_FLAGS
ConnectionKey: [*c]i64 // CF_CONNECTION_KEY* out
) callconv(std.os.windows.WINAPI) i32;proc CfConnectSyncRoot(
SyncRootPath: WideCString, # LPCWSTR
CallbackTable: ptr CF_CALLBACK_REGISTRATION, # CF_CALLBACK_REGISTRATION*
CallbackContext: pointer, # void* optional
ConnectFlags: int32, # CF_CONNECT_FLAGS
ConnectionKey: ptr int64 # CF_CONNECTION_KEY* out
): int32 {.importc: "CfConnectSyncRoot", stdcall, dynlib: "cldapi.dll".}pragma(lib, "cldapi");
extern(Windows)
int CfConnectSyncRoot(
const(wchar)* SyncRootPath, // LPCWSTR
CF_CALLBACK_REGISTRATION* CallbackTable, // CF_CALLBACK_REGISTRATION*
void* CallbackContext, // void* optional
int ConnectFlags, // CF_CONNECT_FLAGS
long* ConnectionKey // CF_CONNECTION_KEY* out
);ccall((:CfConnectSyncRoot, "cldapi.dll"), stdcall, Int32,
(Cwstring, Ptr{CF_CALLBACK_REGISTRATION}, Ptr{Cvoid}, Int32, Ptr{Int64}),
SyncRootPath, CallbackTable, CallbackContext, ConnectFlags, ConnectionKey)
# SyncRootPath : LPCWSTR -> Cwstring
# CallbackTable : CF_CALLBACK_REGISTRATION* -> Ptr{CF_CALLBACK_REGISTRATION}
# CallbackContext : void* optional -> Ptr{Cvoid}
# ConnectFlags : CF_CONNECT_FLAGS -> Int32
# ConnectionKey : CF_CONNECTION_KEY* out -> Ptr{Int64}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t CfConnectSyncRoot(
const uint16_t* SyncRootPath,
void* CallbackTable,
void* CallbackContext,
int32_t ConnectFlags,
int64_t* ConnectionKey);
]]
local cldapi = ffi.load("cldapi")
-- cldapi.CfConnectSyncRoot(SyncRootPath, CallbackTable, CallbackContext, ConnectFlags, ConnectionKey)
-- SyncRootPath : LPCWSTR
-- CallbackTable : CF_CALLBACK_REGISTRATION*
-- CallbackContext : void* optional
-- ConnectFlags : CF_CONNECT_FLAGS
-- ConnectionKey : CF_CONNECTION_KEY* out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('cldapi.dll');
const CfConnectSyncRoot = lib.func('__stdcall', 'CfConnectSyncRoot', 'int32_t', ['str16', 'void *', 'void *', 'int32_t', 'int64_t *']);
// CfConnectSyncRoot(SyncRootPath, CallbackTable, CallbackContext, ConnectFlags, ConnectionKey)
// SyncRootPath : LPCWSTR -> 'str16'
// CallbackTable : CF_CALLBACK_REGISTRATION* -> 'void *'
// CallbackContext : void* optional -> 'void *'
// ConnectFlags : CF_CONNECT_FLAGS -> 'int32_t'
// ConnectionKey : CF_CONNECTION_KEY* out -> 'int64_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("cldapi.dll", {
CfConnectSyncRoot: { parameters: ["buffer", "pointer", "pointer", "i32", "pointer"], result: "i32" },
});
// lib.symbols.CfConnectSyncRoot(SyncRootPath, CallbackTable, CallbackContext, ConnectFlags, ConnectionKey)
// SyncRootPath : LPCWSTR -> "buffer"
// CallbackTable : CF_CALLBACK_REGISTRATION* -> "pointer"
// CallbackContext : void* optional -> "pointer"
// ConnectFlags : CF_CONNECT_FLAGS -> "i32"
// ConnectionKey : CF_CONNECTION_KEY* out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t CfConnectSyncRoot(
const uint16_t* SyncRootPath,
void* CallbackTable,
void* CallbackContext,
int32_t ConnectFlags,
int64_t* ConnectionKey);
C, "cldapi.dll");
// $ffi->CfConnectSyncRoot(SyncRootPath, CallbackTable, CallbackContext, ConnectFlags, ConnectionKey);
// SyncRootPath : LPCWSTR
// CallbackTable : CF_CALLBACK_REGISTRATION*
// CallbackContext : void* optional
// ConnectFlags : CF_CONNECT_FLAGS
// ConnectionKey : CF_CONNECTION_KEY* 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 CfConnectSyncRoot(
WString SyncRootPath, // LPCWSTR
Pointer CallbackTable, // CF_CALLBACK_REGISTRATION*
Pointer CallbackContext, // void* optional
int ConnectFlags, // CF_CONNECT_FLAGS
LongByReference ConnectionKey // CF_CONNECTION_KEY* out
);
}@[Link("cldapi")]
lib Libcldapi
fun CfConnectSyncRoot = CfConnectSyncRoot(
SyncRootPath : UInt16*, # LPCWSTR
CallbackTable : CF_CALLBACK_REGISTRATION*, # CF_CALLBACK_REGISTRATION*
CallbackContext : Void*, # void* optional
ConnectFlags : Int32, # CF_CONNECT_FLAGS
ConnectionKey : Int64* # CF_CONNECTION_KEY* out
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef CfConnectSyncRootNative = Int32 Function(Pointer<Utf16>, Pointer<Void>, Pointer<Void>, Int32, Pointer<Int64>);
typedef CfConnectSyncRootDart = int Function(Pointer<Utf16>, Pointer<Void>, Pointer<Void>, int, Pointer<Int64>);
final CfConnectSyncRoot = DynamicLibrary.open('cldapi.dll')
.lookupFunction<CfConnectSyncRootNative, CfConnectSyncRootDart>('CfConnectSyncRoot');
// SyncRootPath : LPCWSTR -> Pointer<Utf16>
// CallbackTable : CF_CALLBACK_REGISTRATION* -> Pointer<Void>
// CallbackContext : void* optional -> Pointer<Void>
// ConnectFlags : CF_CONNECT_FLAGS -> Int32
// ConnectionKey : CF_CONNECTION_KEY* out -> Pointer<Int64>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function CfConnectSyncRoot(
SyncRootPath: PWideChar; // LPCWSTR
CallbackTable: Pointer; // CF_CALLBACK_REGISTRATION*
CallbackContext: Pointer; // void* optional
ConnectFlags: Integer; // CF_CONNECT_FLAGS
ConnectionKey: Pointer // CF_CONNECTION_KEY* out
): Integer; stdcall;
external 'cldapi.dll' name 'CfConnectSyncRoot';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "CfConnectSyncRoot"
c_CfConnectSyncRoot :: CWString -> Ptr () -> Ptr () -> Int32 -> Ptr Int64 -> IO Int32
-- SyncRootPath : LPCWSTR -> CWString
-- CallbackTable : CF_CALLBACK_REGISTRATION* -> Ptr ()
-- CallbackContext : void* optional -> Ptr ()
-- ConnectFlags : CF_CONNECT_FLAGS -> Int32
-- ConnectionKey : CF_CONNECTION_KEY* out -> Ptr Int64
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let cfconnectsyncroot =
foreign "CfConnectSyncRoot"
((ptr uint16_t) @-> (ptr void) @-> (ptr void) @-> int32_t @-> (ptr int64_t) @-> returning int32_t)
(* SyncRootPath : LPCWSTR -> (ptr uint16_t) *)
(* CallbackTable : CF_CALLBACK_REGISTRATION* -> (ptr void) *)
(* CallbackContext : void* optional -> (ptr void) *)
(* ConnectFlags : CF_CONNECT_FLAGS -> int32_t *)
(* ConnectionKey : CF_CONNECTION_KEY* out -> (ptr int64_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library cldapi (t "cldapi.dll"))
(cffi:use-foreign-library cldapi)
(cffi:defcfun ("CfConnectSyncRoot" cf-connect-sync-root :convention :stdcall) :int32
(sync-root-path (:string :encoding :utf-16le)) ; LPCWSTR
(callback-table :pointer) ; CF_CALLBACK_REGISTRATION*
(callback-context :pointer) ; void* optional
(connect-flags :int32) ; CF_CONNECT_FLAGS
(connection-key :pointer)) ; CF_CONNECTION_KEY* out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $CfConnectSyncRoot = Win32::API::More->new('cldapi',
'int CfConnectSyncRoot(LPCWSTR SyncRootPath, LPVOID CallbackTable, LPVOID CallbackContext, int ConnectFlags, LPVOID ConnectionKey)');
# my $ret = $CfConnectSyncRoot->Call($SyncRootPath, $CallbackTable, $CallbackContext, $ConnectFlags, $ConnectionKey);
# SyncRootPath : LPCWSTR -> LPCWSTR
# CallbackTable : CF_CALLBACK_REGISTRATION* -> LPVOID
# CallbackContext : void* optional -> LPVOID
# ConnectFlags : CF_CONNECT_FLAGS -> int
# ConnectionKey : CF_CONNECTION_KEY* out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。