ホーム › 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 |
| CallbackContext | void* | inoptional |
| ConnectFlags | CF_CONNECT_FLAGS | in |
| ConnectionKey | CF_CONNECTION_KEY* | out |
戻り値の型: 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, 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, int ; 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 -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "cldapi.dll" #cfunc global CfConnectSyncRoot "CfConnectSyncRoot" wstr, sptr, sptr, int, int ; res = CfConnectSyncRoot(SyncRootPath, varptr(CallbackTable), CallbackContext, ConnectFlags, ConnectionKey) ; SyncRootPath : LPCWSTR -> "wstr" ; CallbackTable : CF_CALLBACK_REGISTRATION* -> "sptr" ; CallbackContext : void* optional -> "sptr" ; ConnectFlags : CF_CONNECT_FLAGS -> "int" ; ConnectionKey : CF_CONNECTION_KEY* out -> "int" ; ※出力/バッファ引数はポインタ方式(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, int ; 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 -> "int" ; ※出力/バッファ引数は 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, int ; res = CfConnectSyncRoot(SyncRootPath, varptr(CallbackTable), CallbackContext, ConnectFlags, ConnectionKey) ; SyncRootPath : LPCWSTR -> "wstr" ; CallbackTable : CF_CALLBACK_REGISTRATION* -> "intptr" ; CallbackContext : void* optional -> "intptr" ; ConnectFlags : CF_CONNECT_FLAGS -> "int" ; ConnectionKey : CF_CONNECTION_KEY* out -> "int" ; ※出力/バッファ引数はポインタ方式(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)。