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