ホーム › Storage.CloudFilters › CfRegisterSyncRoot
CfRegisterSyncRoot
関数指定パスを同期ルートとして登録する。
シグネチャ
// cldapi.dll
#include <windows.h>
HRESULT CfRegisterSyncRoot(
LPCWSTR SyncRootPath,
const CF_SYNC_REGISTRATION* Registration,
const CF_SYNC_POLICIES* Policies,
CF_REGISTER_FLAGS RegisterFlags
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| SyncRootPath | LPCWSTR | in |
| Registration | CF_SYNC_REGISTRATION* | in |
| Policies | CF_SYNC_POLICIES* | in |
| RegisterFlags | CF_REGISTER_FLAGS | in |
戻り値の型: HRESULT
各言語での呼び出し定義
// cldapi.dll
#include <windows.h>
HRESULT CfRegisterSyncRoot(
LPCWSTR SyncRootPath,
const CF_SYNC_REGISTRATION* Registration,
const CF_SYNC_POLICIES* Policies,
CF_REGISTER_FLAGS RegisterFlags
);[DllImport("cldapi.dll", ExactSpelling = true)]
static extern int CfRegisterSyncRoot(
[MarshalAs(UnmanagedType.LPWStr)] string SyncRootPath, // LPCWSTR
IntPtr Registration, // CF_SYNC_REGISTRATION*
IntPtr Policies, // CF_SYNC_POLICIES*
int RegisterFlags // CF_REGISTER_FLAGS
);<DllImport("cldapi.dll", ExactSpelling:=True)>
Public Shared Function CfRegisterSyncRoot(
<MarshalAs(UnmanagedType.LPWStr)> SyncRootPath As String, ' LPCWSTR
Registration As IntPtr, ' CF_SYNC_REGISTRATION*
Policies As IntPtr, ' CF_SYNC_POLICIES*
RegisterFlags As Integer ' CF_REGISTER_FLAGS
) As Integer
End Function' SyncRootPath : LPCWSTR
' Registration : CF_SYNC_REGISTRATION*
' Policies : CF_SYNC_POLICIES*
' RegisterFlags : CF_REGISTER_FLAGS
Declare PtrSafe Function CfRegisterSyncRoot Lib "cldapi" ( _
ByVal SyncRootPath As LongPtr, _
ByVal Registration As LongPtr, _
ByVal Policies As LongPtr, _
ByVal RegisterFlags As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
CfRegisterSyncRoot = ctypes.windll.cldapi.CfRegisterSyncRoot
CfRegisterSyncRoot.restype = ctypes.c_int
CfRegisterSyncRoot.argtypes = [
wintypes.LPCWSTR, # SyncRootPath : LPCWSTR
ctypes.c_void_p, # Registration : CF_SYNC_REGISTRATION*
ctypes.c_void_p, # Policies : CF_SYNC_POLICIES*
ctypes.c_int, # RegisterFlags : CF_REGISTER_FLAGS
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('cldapi.dll')
CfRegisterSyncRoot = Fiddle::Function.new(
lib['CfRegisterSyncRoot'],
[
Fiddle::TYPE_VOIDP, # SyncRootPath : LPCWSTR
Fiddle::TYPE_VOIDP, # Registration : CF_SYNC_REGISTRATION*
Fiddle::TYPE_VOIDP, # Policies : CF_SYNC_POLICIES*
Fiddle::TYPE_INT, # RegisterFlags : CF_REGISTER_FLAGS
],
Fiddle::TYPE_INT)#[link(name = "cldapi")]
extern "system" {
fn CfRegisterSyncRoot(
SyncRootPath: *const u16, // LPCWSTR
Registration: *const CF_SYNC_REGISTRATION, // CF_SYNC_REGISTRATION*
Policies: *const CF_SYNC_POLICIES, // CF_SYNC_POLICIES*
RegisterFlags: i32 // CF_REGISTER_FLAGS
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("cldapi.dll")]
public static extern int CfRegisterSyncRoot([MarshalAs(UnmanagedType.LPWStr)] string SyncRootPath, IntPtr Registration, IntPtr Policies, int RegisterFlags);
"@
$api = Add-Type -MemberDefinition $sig -Name 'cldapi_CfRegisterSyncRoot' -Namespace Win32 -PassThru
# $api::CfRegisterSyncRoot(SyncRootPath, Registration, Policies, RegisterFlags)#uselib "cldapi.dll"
#func global CfRegisterSyncRoot "CfRegisterSyncRoot" sptr, sptr, sptr, sptr
; CfRegisterSyncRoot SyncRootPath, varptr(Registration), varptr(Policies), RegisterFlags ; 戻り値は stat
; SyncRootPath : LPCWSTR -> "sptr"
; Registration : CF_SYNC_REGISTRATION* -> "sptr"
; Policies : CF_SYNC_POLICIES* -> "sptr"
; RegisterFlags : CF_REGISTER_FLAGS -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "cldapi.dll" #cfunc global CfRegisterSyncRoot "CfRegisterSyncRoot" wstr, var, var, int ; res = CfRegisterSyncRoot(SyncRootPath, Registration, Policies, RegisterFlags) ; SyncRootPath : LPCWSTR -> "wstr" ; Registration : CF_SYNC_REGISTRATION* -> "var" ; Policies : CF_SYNC_POLICIES* -> "var" ; RegisterFlags : CF_REGISTER_FLAGS -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "cldapi.dll" #cfunc global CfRegisterSyncRoot "CfRegisterSyncRoot" wstr, sptr, sptr, int ; res = CfRegisterSyncRoot(SyncRootPath, varptr(Registration), varptr(Policies), RegisterFlags) ; SyncRootPath : LPCWSTR -> "wstr" ; Registration : CF_SYNC_REGISTRATION* -> "sptr" ; Policies : CF_SYNC_POLICIES* -> "sptr" ; RegisterFlags : CF_REGISTER_FLAGS -> "int" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HRESULT CfRegisterSyncRoot(LPCWSTR SyncRootPath, CF_SYNC_REGISTRATION* Registration, CF_SYNC_POLICIES* Policies, CF_REGISTER_FLAGS RegisterFlags) #uselib "cldapi.dll" #cfunc global CfRegisterSyncRoot "CfRegisterSyncRoot" wstr, var, var, int ; res = CfRegisterSyncRoot(SyncRootPath, Registration, Policies, RegisterFlags) ; SyncRootPath : LPCWSTR -> "wstr" ; Registration : CF_SYNC_REGISTRATION* -> "var" ; Policies : CF_SYNC_POLICIES* -> "var" ; RegisterFlags : CF_REGISTER_FLAGS -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HRESULT CfRegisterSyncRoot(LPCWSTR SyncRootPath, CF_SYNC_REGISTRATION* Registration, CF_SYNC_POLICIES* Policies, CF_REGISTER_FLAGS RegisterFlags) #uselib "cldapi.dll" #cfunc global CfRegisterSyncRoot "CfRegisterSyncRoot" wstr, intptr, intptr, int ; res = CfRegisterSyncRoot(SyncRootPath, varptr(Registration), varptr(Policies), RegisterFlags) ; SyncRootPath : LPCWSTR -> "wstr" ; Registration : CF_SYNC_REGISTRATION* -> "intptr" ; Policies : CF_SYNC_POLICIES* -> "intptr" ; RegisterFlags : CF_REGISTER_FLAGS -> "int" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
cldapi = windows.NewLazySystemDLL("cldapi.dll")
procCfRegisterSyncRoot = cldapi.NewProc("CfRegisterSyncRoot")
)
// SyncRootPath (LPCWSTR), Registration (CF_SYNC_REGISTRATION*), Policies (CF_SYNC_POLICIES*), RegisterFlags (CF_REGISTER_FLAGS)
r1, _, err := procCfRegisterSyncRoot.Call(
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(SyncRootPath))),
uintptr(Registration),
uintptr(Policies),
uintptr(RegisterFlags),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction CfRegisterSyncRoot(
SyncRootPath: PWideChar; // LPCWSTR
Registration: Pointer; // CF_SYNC_REGISTRATION*
Policies: Pointer; // CF_SYNC_POLICIES*
RegisterFlags: Integer // CF_REGISTER_FLAGS
): Integer; stdcall;
external 'cldapi.dll' name 'CfRegisterSyncRoot';result := DllCall("cldapi\CfRegisterSyncRoot"
, "WStr", SyncRootPath ; LPCWSTR
, "Ptr", Registration ; CF_SYNC_REGISTRATION*
, "Ptr", Policies ; CF_SYNC_POLICIES*
, "Int", RegisterFlags ; CF_REGISTER_FLAGS
, "Int") ; return: HRESULT●CfRegisterSyncRoot(SyncRootPath, Registration, Policies, RegisterFlags) = DLL("cldapi.dll", "int CfRegisterSyncRoot(char*, void*, void*, int)")
# 呼び出し: CfRegisterSyncRoot(SyncRootPath, Registration, Policies, RegisterFlags)
# SyncRootPath : LPCWSTR -> "char*"
# Registration : CF_SYNC_REGISTRATION* -> "void*"
# Policies : CF_SYNC_POLICIES* -> "void*"
# RegisterFlags : CF_REGISTER_FLAGS -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。