Win32 API 日本語リファレンス
ホームStorage.FileSystem › CreateBindLink

CreateBindLink

関数
仮想パスを実体パスへ結び付けるバインドリンクを作成する。
DLLBINDFLTAPI.dll呼出規約winapi

シグネチャ

// BINDFLTAPI.dll
#include <windows.h>

HRESULT CreateBindLink(
    LPCWSTR virtualPath,
    LPCWSTR backingPath,
    CREATE_BIND_LINK_FLAGS createBindLinkFlags,
    DWORD exceptionCount,
    LPCWSTR* exceptionPaths   // optional
);

パラメーター

名前方向
virtualPathLPCWSTRin
backingPathLPCWSTRin
createBindLinkFlagsCREATE_BIND_LINK_FLAGSin
exceptionCountDWORDin
exceptionPathsLPCWSTR*inoptional

戻り値の型: HRESULT

各言語での呼び出し定義

// BINDFLTAPI.dll
#include <windows.h>

HRESULT CreateBindLink(
    LPCWSTR virtualPath,
    LPCWSTR backingPath,
    CREATE_BIND_LINK_FLAGS createBindLinkFlags,
    DWORD exceptionCount,
    LPCWSTR* exceptionPaths   // optional
);
[DllImport("BINDFLTAPI.dll", ExactSpelling = true)]
static extern int CreateBindLink(
    [MarshalAs(UnmanagedType.LPWStr)] string virtualPath,   // LPCWSTR
    [MarshalAs(UnmanagedType.LPWStr)] string backingPath,   // LPCWSTR
    int createBindLinkFlags,   // CREATE_BIND_LINK_FLAGS
    uint exceptionCount,   // DWORD
    IntPtr exceptionPaths   // LPCWSTR* optional
);
<DllImport("BINDFLTAPI.dll", ExactSpelling:=True)>
Public Shared Function CreateBindLink(
    <MarshalAs(UnmanagedType.LPWStr)> virtualPath As String,   ' LPCWSTR
    <MarshalAs(UnmanagedType.LPWStr)> backingPath As String,   ' LPCWSTR
    createBindLinkFlags As Integer,   ' CREATE_BIND_LINK_FLAGS
    exceptionCount As UInteger,   ' DWORD
    exceptionPaths As IntPtr   ' LPCWSTR* optional
) As Integer
End Function
' virtualPath : LPCWSTR
' backingPath : LPCWSTR
' createBindLinkFlags : CREATE_BIND_LINK_FLAGS
' exceptionCount : DWORD
' exceptionPaths : LPCWSTR* optional
Declare PtrSafe Function CreateBindLink Lib "bindfltapi" ( _
    ByVal virtualPath As LongPtr, _
    ByVal backingPath As LongPtr, _
    ByVal createBindLinkFlags As Long, _
    ByVal exceptionCount As Long, _
    ByVal exceptionPaths As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

CreateBindLink = ctypes.windll.bindfltapi.CreateBindLink
CreateBindLink.restype = ctypes.c_int
CreateBindLink.argtypes = [
    wintypes.LPCWSTR,  # virtualPath : LPCWSTR
    wintypes.LPCWSTR,  # backingPath : LPCWSTR
    ctypes.c_int,  # createBindLinkFlags : CREATE_BIND_LINK_FLAGS
    wintypes.DWORD,  # exceptionCount : DWORD
    ctypes.c_void_p,  # exceptionPaths : LPCWSTR* optional
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('BINDFLTAPI.dll')
CreateBindLink = Fiddle::Function.new(
  lib['CreateBindLink'],
  [
    Fiddle::TYPE_VOIDP,  # virtualPath : LPCWSTR
    Fiddle::TYPE_VOIDP,  # backingPath : LPCWSTR
    Fiddle::TYPE_INT,  # createBindLinkFlags : CREATE_BIND_LINK_FLAGS
    -Fiddle::TYPE_INT,  # exceptionCount : DWORD
    Fiddle::TYPE_VOIDP,  # exceptionPaths : LPCWSTR* optional
  ],
  Fiddle::TYPE_INT)
#[link(name = "bindfltapi")]
extern "system" {
    fn CreateBindLink(
        virtualPath: *const u16,  // LPCWSTR
        backingPath: *const u16,  // LPCWSTR
        createBindLinkFlags: i32,  // CREATE_BIND_LINK_FLAGS
        exceptionCount: u32,  // DWORD
        exceptionPaths: *const *const u16  // LPCWSTR* optional
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("BINDFLTAPI.dll")]
public static extern int CreateBindLink([MarshalAs(UnmanagedType.LPWStr)] string virtualPath, [MarshalAs(UnmanagedType.LPWStr)] string backingPath, int createBindLinkFlags, uint exceptionCount, IntPtr exceptionPaths);
"@
$api = Add-Type -MemberDefinition $sig -Name 'BINDFLTAPI_CreateBindLink' -Namespace Win32 -PassThru
# $api::CreateBindLink(virtualPath, backingPath, createBindLinkFlags, exceptionCount, exceptionPaths)
#uselib "BINDFLTAPI.dll"
#func global CreateBindLink "CreateBindLink" sptr, sptr, sptr, sptr, sptr
; CreateBindLink virtualPath, backingPath, createBindLinkFlags, exceptionCount, varptr(exceptionPaths)   ; 戻り値は stat
; virtualPath : LPCWSTR -> "sptr"
; backingPath : LPCWSTR -> "sptr"
; createBindLinkFlags : CREATE_BIND_LINK_FLAGS -> "sptr"
; exceptionCount : DWORD -> "sptr"
; exceptionPaths : LPCWSTR* optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "BINDFLTAPI.dll"
#cfunc global CreateBindLink "CreateBindLink" wstr, wstr, int, int, var
; res = CreateBindLink(virtualPath, backingPath, createBindLinkFlags, exceptionCount, exceptionPaths)
; virtualPath : LPCWSTR -> "wstr"
; backingPath : LPCWSTR -> "wstr"
; createBindLinkFlags : CREATE_BIND_LINK_FLAGS -> "int"
; exceptionCount : DWORD -> "int"
; exceptionPaths : LPCWSTR* optional -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; HRESULT CreateBindLink(LPCWSTR virtualPath, LPCWSTR backingPath, CREATE_BIND_LINK_FLAGS createBindLinkFlags, DWORD exceptionCount, LPCWSTR* exceptionPaths)
#uselib "BINDFLTAPI.dll"
#cfunc global CreateBindLink "CreateBindLink" wstr, wstr, int, int, var
; res = CreateBindLink(virtualPath, backingPath, createBindLinkFlags, exceptionCount, exceptionPaths)
; virtualPath : LPCWSTR -> "wstr"
; backingPath : LPCWSTR -> "wstr"
; createBindLinkFlags : CREATE_BIND_LINK_FLAGS -> "int"
; exceptionCount : DWORD -> "int"
; exceptionPaths : LPCWSTR* optional -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	bindfltapi = windows.NewLazySystemDLL("BINDFLTAPI.dll")
	procCreateBindLink = bindfltapi.NewProc("CreateBindLink")
)

// virtualPath (LPCWSTR), backingPath (LPCWSTR), createBindLinkFlags (CREATE_BIND_LINK_FLAGS), exceptionCount (DWORD), exceptionPaths (LPCWSTR* optional)
r1, _, err := procCreateBindLink.Call(
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(virtualPath))),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(backingPath))),
	uintptr(createBindLinkFlags),
	uintptr(exceptionCount),
	uintptr(exceptionPaths),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function CreateBindLink(
  virtualPath: PWideChar;   // LPCWSTR
  backingPath: PWideChar;   // LPCWSTR
  createBindLinkFlags: Integer;   // CREATE_BIND_LINK_FLAGS
  exceptionCount: DWORD;   // DWORD
  exceptionPaths: PPWideChar   // LPCWSTR* optional
): Integer; stdcall;
  external 'BINDFLTAPI.dll' name 'CreateBindLink';
result := DllCall("BINDFLTAPI\CreateBindLink"
    , "WStr", virtualPath   ; LPCWSTR
    , "WStr", backingPath   ; LPCWSTR
    , "Int", createBindLinkFlags   ; CREATE_BIND_LINK_FLAGS
    , "UInt", exceptionCount   ; DWORD
    , "Ptr", exceptionPaths   ; LPCWSTR* optional
    , "Int")   ; return: HRESULT
●CreateBindLink(virtualPath, backingPath, createBindLinkFlags, exceptionCount, exceptionPaths) = DLL("BINDFLTAPI.dll", "int CreateBindLink(char*, char*, int, dword, void*)")
# 呼び出し: CreateBindLink(virtualPath, backingPath, createBindLinkFlags, exceptionCount, exceptionPaths)
# virtualPath : LPCWSTR -> "char*"
# backingPath : LPCWSTR -> "char*"
# createBindLinkFlags : CREATE_BIND_LINK_FLAGS -> "int"
# exceptionCount : DWORD -> "dword"
# exceptionPaths : LPCWSTR* optional -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。