ホーム › NetworkManagement.WebDav › DavGetTheLockOwnerOfTheFile
DavGetTheLockOwnerOfTheFile
関数WebDAVファイルのロック所有者の名前を取得する。
シグネチャ
// davclnt.dll
#include <windows.h>
DWORD DavGetTheLockOwnerOfTheFile(
LPCWSTR FileName,
LPWSTR LockOwnerName, // optional
DWORD* LockOwnerNameLengthInBytes
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| FileName | LPCWSTR | in | ロック所有者を問い合わせる対象ファイルのパス。 |
| LockOwnerName | LPWSTR | outoptional | ロック所有者名を受け取る呼び出し側確保のバッファ。 |
| LockOwnerNameLengthInBytes | DWORD* | inout | 入力でバッファサイズ、出力で必要バイト数を受け渡すDWORDポインタ。 |
戻り値の型: DWORD
各言語での呼び出し定義
// davclnt.dll
#include <windows.h>
DWORD DavGetTheLockOwnerOfTheFile(
LPCWSTR FileName,
LPWSTR LockOwnerName, // optional
DWORD* LockOwnerNameLengthInBytes
);[DllImport("davclnt.dll", ExactSpelling = true)]
static extern uint DavGetTheLockOwnerOfTheFile(
[MarshalAs(UnmanagedType.LPWStr)] string FileName, // LPCWSTR
[MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder LockOwnerName, // LPWSTR optional, out
ref uint LockOwnerNameLengthInBytes // DWORD* in/out
);<DllImport("davclnt.dll", ExactSpelling:=True)>
Public Shared Function DavGetTheLockOwnerOfTheFile(
<MarshalAs(UnmanagedType.LPWStr)> FileName As String, ' LPCWSTR
<MarshalAs(UnmanagedType.LPWStr)> LockOwnerName As System.Text.StringBuilder, ' LPWSTR optional, out
ByRef LockOwnerNameLengthInBytes As UInteger ' DWORD* in/out
) As UInteger
End Function' FileName : LPCWSTR
' LockOwnerName : LPWSTR optional, out
' LockOwnerNameLengthInBytes : DWORD* in/out
Declare PtrSafe Function DavGetTheLockOwnerOfTheFile Lib "davclnt" ( _
ByVal FileName As LongPtr, _
ByVal LockOwnerName As LongPtr, _
ByRef LockOwnerNameLengthInBytes As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
DavGetTheLockOwnerOfTheFile = ctypes.windll.davclnt.DavGetTheLockOwnerOfTheFile
DavGetTheLockOwnerOfTheFile.restype = wintypes.DWORD
DavGetTheLockOwnerOfTheFile.argtypes = [
wintypes.LPCWSTR, # FileName : LPCWSTR
wintypes.LPWSTR, # LockOwnerName : LPWSTR optional, out
ctypes.POINTER(wintypes.DWORD), # LockOwnerNameLengthInBytes : DWORD* in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('davclnt.dll')
DavGetTheLockOwnerOfTheFile = Fiddle::Function.new(
lib['DavGetTheLockOwnerOfTheFile'],
[
Fiddle::TYPE_VOIDP, # FileName : LPCWSTR
Fiddle::TYPE_VOIDP, # LockOwnerName : LPWSTR optional, out
Fiddle::TYPE_VOIDP, # LockOwnerNameLengthInBytes : DWORD* in/out
],
-Fiddle::TYPE_INT)#[link(name = "davclnt")]
extern "system" {
fn DavGetTheLockOwnerOfTheFile(
FileName: *const u16, // LPCWSTR
LockOwnerName: *mut u16, // LPWSTR optional, out
LockOwnerNameLengthInBytes: *mut u32 // DWORD* in/out
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("davclnt.dll")]
public static extern uint DavGetTheLockOwnerOfTheFile([MarshalAs(UnmanagedType.LPWStr)] string FileName, [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder LockOwnerName, ref uint LockOwnerNameLengthInBytes);
"@
$api = Add-Type -MemberDefinition $sig -Name 'davclnt_DavGetTheLockOwnerOfTheFile' -Namespace Win32 -PassThru
# $api::DavGetTheLockOwnerOfTheFile(FileName, LockOwnerName, LockOwnerNameLengthInBytes)#uselib "davclnt.dll"
#func global DavGetTheLockOwnerOfTheFile "DavGetTheLockOwnerOfTheFile" sptr, sptr, sptr
; DavGetTheLockOwnerOfTheFile FileName, varptr(LockOwnerName), varptr(LockOwnerNameLengthInBytes) ; 戻り値は stat
; FileName : LPCWSTR -> "sptr"
; LockOwnerName : LPWSTR optional, out -> "sptr"
; LockOwnerNameLengthInBytes : DWORD* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "davclnt.dll" #cfunc global DavGetTheLockOwnerOfTheFile "DavGetTheLockOwnerOfTheFile" wstr, var, var ; res = DavGetTheLockOwnerOfTheFile(FileName, LockOwnerName, LockOwnerNameLengthInBytes) ; FileName : LPCWSTR -> "wstr" ; LockOwnerName : LPWSTR optional, out -> "var" ; LockOwnerNameLengthInBytes : DWORD* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "davclnt.dll" #cfunc global DavGetTheLockOwnerOfTheFile "DavGetTheLockOwnerOfTheFile" wstr, sptr, sptr ; res = DavGetTheLockOwnerOfTheFile(FileName, varptr(LockOwnerName), varptr(LockOwnerNameLengthInBytes)) ; FileName : LPCWSTR -> "wstr" ; LockOwnerName : LPWSTR optional, out -> "sptr" ; LockOwnerNameLengthInBytes : DWORD* in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; DWORD DavGetTheLockOwnerOfTheFile(LPCWSTR FileName, LPWSTR LockOwnerName, DWORD* LockOwnerNameLengthInBytes) #uselib "davclnt.dll" #cfunc global DavGetTheLockOwnerOfTheFile "DavGetTheLockOwnerOfTheFile" wstr, var, var ; res = DavGetTheLockOwnerOfTheFile(FileName, LockOwnerName, LockOwnerNameLengthInBytes) ; FileName : LPCWSTR -> "wstr" ; LockOwnerName : LPWSTR optional, out -> "var" ; LockOwnerNameLengthInBytes : DWORD* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; DWORD DavGetTheLockOwnerOfTheFile(LPCWSTR FileName, LPWSTR LockOwnerName, DWORD* LockOwnerNameLengthInBytes) #uselib "davclnt.dll" #cfunc global DavGetTheLockOwnerOfTheFile "DavGetTheLockOwnerOfTheFile" wstr, intptr, intptr ; res = DavGetTheLockOwnerOfTheFile(FileName, varptr(LockOwnerName), varptr(LockOwnerNameLengthInBytes)) ; FileName : LPCWSTR -> "wstr" ; LockOwnerName : LPWSTR optional, out -> "intptr" ; LockOwnerNameLengthInBytes : DWORD* in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
davclnt = windows.NewLazySystemDLL("davclnt.dll")
procDavGetTheLockOwnerOfTheFile = davclnt.NewProc("DavGetTheLockOwnerOfTheFile")
)
// FileName (LPCWSTR), LockOwnerName (LPWSTR optional, out), LockOwnerNameLengthInBytes (DWORD* in/out)
r1, _, err := procDavGetTheLockOwnerOfTheFile.Call(
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(FileName))),
uintptr(LockOwnerName),
uintptr(LockOwnerNameLengthInBytes),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction DavGetTheLockOwnerOfTheFile(
FileName: PWideChar; // LPCWSTR
LockOwnerName: PWideChar; // LPWSTR optional, out
LockOwnerNameLengthInBytes: Pointer // DWORD* in/out
): DWORD; stdcall;
external 'davclnt.dll' name 'DavGetTheLockOwnerOfTheFile';result := DllCall("davclnt\DavGetTheLockOwnerOfTheFile"
, "WStr", FileName ; LPCWSTR
, "Ptr", LockOwnerName ; LPWSTR optional, out
, "Ptr", LockOwnerNameLengthInBytes ; DWORD* in/out
, "UInt") ; return: DWORD●DavGetTheLockOwnerOfTheFile(FileName, LockOwnerName, LockOwnerNameLengthInBytes) = DLL("davclnt.dll", "dword DavGetTheLockOwnerOfTheFile(char*, char*, void*)")
# 呼び出し: DavGetTheLockOwnerOfTheFile(FileName, LockOwnerName, LockOwnerNameLengthInBytes)
# FileName : LPCWSTR -> "char*"
# LockOwnerName : LPWSTR optional, out -> "char*"
# LockOwnerNameLengthInBytes : DWORD* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "davclnt" fn DavGetTheLockOwnerOfTheFile(
FileName: [*c]const u16, // LPCWSTR
LockOwnerName: [*c]u16, // LPWSTR optional, out
LockOwnerNameLengthInBytes: [*c]u32 // DWORD* in/out
) callconv(std.os.windows.WINAPI) u32;proc DavGetTheLockOwnerOfTheFile(
FileName: WideCString, # LPCWSTR
LockOwnerName: ptr uint16, # LPWSTR optional, out
LockOwnerNameLengthInBytes: ptr uint32 # DWORD* in/out
): uint32 {.importc: "DavGetTheLockOwnerOfTheFile", stdcall, dynlib: "davclnt.dll".}pragma(lib, "davclnt");
extern(Windows)
uint DavGetTheLockOwnerOfTheFile(
const(wchar)* FileName, // LPCWSTR
wchar* LockOwnerName, // LPWSTR optional, out
uint* LockOwnerNameLengthInBytes // DWORD* in/out
);ccall((:DavGetTheLockOwnerOfTheFile, "davclnt.dll"), stdcall, UInt32,
(Cwstring, Ptr{UInt16}, Ptr{UInt32}),
FileName, LockOwnerName, LockOwnerNameLengthInBytes)
# FileName : LPCWSTR -> Cwstring
# LockOwnerName : LPWSTR optional, out -> Ptr{UInt16}
# LockOwnerNameLengthInBytes : DWORD* in/out -> Ptr{UInt32}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
uint32_t DavGetTheLockOwnerOfTheFile(
const uint16_t* FileName,
uint16_t* LockOwnerName,
uint32_t* LockOwnerNameLengthInBytes);
]]
local davclnt = ffi.load("davclnt")
-- davclnt.DavGetTheLockOwnerOfTheFile(FileName, LockOwnerName, LockOwnerNameLengthInBytes)
-- FileName : LPCWSTR
-- LockOwnerName : LPWSTR optional, out
-- LockOwnerNameLengthInBytes : DWORD* in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('davclnt.dll');
const DavGetTheLockOwnerOfTheFile = lib.func('__stdcall', 'DavGetTheLockOwnerOfTheFile', 'uint32_t', ['str16', 'uint16_t *', 'uint32_t *']);
// DavGetTheLockOwnerOfTheFile(FileName, LockOwnerName, LockOwnerNameLengthInBytes)
// FileName : LPCWSTR -> 'str16'
// LockOwnerName : LPWSTR optional, out -> 'uint16_t *'
// LockOwnerNameLengthInBytes : DWORD* in/out -> 'uint32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("davclnt.dll", {
DavGetTheLockOwnerOfTheFile: { parameters: ["buffer", "buffer", "pointer"], result: "u32" },
});
// lib.symbols.DavGetTheLockOwnerOfTheFile(FileName, LockOwnerName, LockOwnerNameLengthInBytes)
// FileName : LPCWSTR -> "buffer"
// LockOwnerName : LPWSTR optional, out -> "buffer"
// LockOwnerNameLengthInBytes : DWORD* in/out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
uint32_t DavGetTheLockOwnerOfTheFile(
const uint16_t* FileName,
uint16_t* LockOwnerName,
uint32_t* LockOwnerNameLengthInBytes);
C, "davclnt.dll");
// $ffi->DavGetTheLockOwnerOfTheFile(FileName, LockOwnerName, LockOwnerNameLengthInBytes);
// FileName : LPCWSTR
// LockOwnerName : LPWSTR optional, out
// LockOwnerNameLengthInBytes : DWORD* in/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 Davclnt extends StdCallLibrary {
Davclnt INSTANCE = Native.load("davclnt", Davclnt.class);
int DavGetTheLockOwnerOfTheFile(
WString FileName, // LPCWSTR
char[] LockOwnerName, // LPWSTR optional, out
IntByReference LockOwnerNameLengthInBytes // DWORD* in/out
);
}@[Link("davclnt")]
lib Libdavclnt
fun DavGetTheLockOwnerOfTheFile = DavGetTheLockOwnerOfTheFile(
FileName : UInt16*, # LPCWSTR
LockOwnerName : UInt16*, # LPWSTR optional, out
LockOwnerNameLengthInBytes : UInt32* # DWORD* in/out
) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef DavGetTheLockOwnerOfTheFileNative = Uint32 Function(Pointer<Utf16>, Pointer<Utf16>, Pointer<Uint32>);
typedef DavGetTheLockOwnerOfTheFileDart = int Function(Pointer<Utf16>, Pointer<Utf16>, Pointer<Uint32>);
final DavGetTheLockOwnerOfTheFile = DynamicLibrary.open('davclnt.dll')
.lookupFunction<DavGetTheLockOwnerOfTheFileNative, DavGetTheLockOwnerOfTheFileDart>('DavGetTheLockOwnerOfTheFile');
// FileName : LPCWSTR -> Pointer<Utf16>
// LockOwnerName : LPWSTR optional, out -> Pointer<Utf16>
// LockOwnerNameLengthInBytes : DWORD* in/out -> Pointer<Uint32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function DavGetTheLockOwnerOfTheFile(
FileName: PWideChar; // LPCWSTR
LockOwnerName: PWideChar; // LPWSTR optional, out
LockOwnerNameLengthInBytes: Pointer // DWORD* in/out
): DWORD; stdcall;
external 'davclnt.dll' name 'DavGetTheLockOwnerOfTheFile';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "DavGetTheLockOwnerOfTheFile"
c_DavGetTheLockOwnerOfTheFile :: CWString -> CWString -> Ptr Word32 -> IO Word32
-- FileName : LPCWSTR -> CWString
-- LockOwnerName : LPWSTR optional, out -> CWString
-- LockOwnerNameLengthInBytes : DWORD* in/out -> Ptr Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let davgetthelockownerofthefile =
foreign "DavGetTheLockOwnerOfTheFile"
((ptr uint16_t) @-> (ptr uint16_t) @-> (ptr uint32_t) @-> returning uint32_t)
(* FileName : LPCWSTR -> (ptr uint16_t) *)
(* LockOwnerName : LPWSTR optional, out -> (ptr uint16_t) *)
(* LockOwnerNameLengthInBytes : DWORD* in/out -> (ptr uint32_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library davclnt (t "davclnt.dll"))
(cffi:use-foreign-library davclnt)
(cffi:defcfun ("DavGetTheLockOwnerOfTheFile" dav-get-the-lock-owner-of-the-file :convention :stdcall) :uint32
(file-name (:string :encoding :utf-16le)) ; LPCWSTR
(lock-owner-name :pointer) ; LPWSTR optional, out
(lock-owner-name-length-in-bytes :pointer)) ; DWORD* in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $DavGetTheLockOwnerOfTheFile = Win32::API::More->new('davclnt',
'DWORD DavGetTheLockOwnerOfTheFile(LPCWSTR FileName, LPWSTR LockOwnerName, LPVOID LockOwnerNameLengthInBytes)');
# my $ret = $DavGetTheLockOwnerOfTheFile->Call($FileName, $LockOwnerName, $LockOwnerNameLengthInBytes);
# FileName : LPCWSTR -> LPCWSTR
# LockOwnerName : LPWSTR optional, out -> LPWSTR
# LockOwnerNameLengthInBytes : DWORD* in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。