ホーム › Storage.FileSystem › WofIsExternalFile
WofIsExternalFile
関数ファイルがWOF外部ファイルかどうかを判定する。
シグネチャ
// WOFUTIL.dll
#include <windows.h>
HRESULT WofIsExternalFile(
LPCWSTR FilePath,
BOOL* IsExternalFile, // optional
DWORD* Provider, // optional
void* ExternalFileInfo, // optional
DWORD* BufferLength // optional
);パラメーター
| 名前 | 型 | 方向 | 説明 | ||||
|---|---|---|---|---|---|---|---|
| FilePath | LPCWSTR | in | 裏付け状態を取得したいファイルへのパスを指定します。 | ||||
| IsExternalFile | BOOL* | outoptional | オプションで BOOL 値を指すポインターです。正常に復帰した場合、オブジェクトが外部的に裏付けられている場合はこの値が TRUE に、物理ファイルである場合は FALSE になります。 | ||||
| Provider | DWORD* | outoptional | オプションで ULONG 値を指すポインターです。正常に復帰した場合、この値にはこのオブジェクトを外部的に裏付けるプロバイダーが設定されます。現在定義されているプロバイダーは次のとおりです。
| ||||
| ExternalFileInfo | void* | outoptional | オプションで呼び出し元が割り当てたバッファーを指すポインターです。正常に復帰した場合、このバッファーにはファイルの状態に関する追加情報が格納されます。この値を指定する場合は、BufferLength も指定する必要があります。定義されている各プロバイダーのデータ構造は次のとおりです。
| ||||
| BufferLength | DWORD* | inoutoptional | オプションで、ExternalFileInfo に指定したバッファーの長さを格納する値を指すポインターです。復帰時には、この値は消費されたバッファーのサイズ、または必要なバッファーのサイズに設定されます。バッファーの長さが不十分な場合、この関数は成功し、必要なサイズを示しますが、ExternalFileInfo のバッファーは設定しません。この長さは、上記で定義した構造体のいずれかに対応している必要があります。
|
戻り値の型: HRESULT
公式ドキュメント
ファイルが物理ファイルによって裏付けられているか、システムデータプロバイダーによって裏付けられているかを判定するために使用します。また、オプションでどのプロバイダーであるか、またはファイルに関する追加情報を示します。
戻り値
この関数は、成功または失敗の理由を示す HRESULT を返します。ExternalFileInfo に指定したバッファーのサイズが正しくない場合、関数は S_OK を返し、BufferLength に必要なバッファーサイズを示します。
出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// WOFUTIL.dll
#include <windows.h>
HRESULT WofIsExternalFile(
LPCWSTR FilePath,
BOOL* IsExternalFile, // optional
DWORD* Provider, // optional
void* ExternalFileInfo, // optional
DWORD* BufferLength // optional
);[DllImport("WOFUTIL.dll", ExactSpelling = true)]
static extern int WofIsExternalFile(
[MarshalAs(UnmanagedType.LPWStr)] string FilePath, // LPCWSTR
IntPtr IsExternalFile, // BOOL* optional, out
IntPtr Provider, // DWORD* optional, out
IntPtr ExternalFileInfo, // void* optional, out
IntPtr BufferLength // DWORD* optional, in/out
);<DllImport("WOFUTIL.dll", ExactSpelling:=True)>
Public Shared Function WofIsExternalFile(
<MarshalAs(UnmanagedType.LPWStr)> FilePath As String, ' LPCWSTR
IsExternalFile As IntPtr, ' BOOL* optional, out
Provider As IntPtr, ' DWORD* optional, out
ExternalFileInfo As IntPtr, ' void* optional, out
BufferLength As IntPtr ' DWORD* optional, in/out
) As Integer
End Function' FilePath : LPCWSTR
' IsExternalFile : BOOL* optional, out
' Provider : DWORD* optional, out
' ExternalFileInfo : void* optional, out
' BufferLength : DWORD* optional, in/out
Declare PtrSafe Function WofIsExternalFile Lib "wofutil" ( _
ByVal FilePath As LongPtr, _
ByVal IsExternalFile As LongPtr, _
ByVal Provider As LongPtr, _
ByVal ExternalFileInfo As LongPtr, _
ByVal BufferLength As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
WofIsExternalFile = ctypes.windll.wofutil.WofIsExternalFile
WofIsExternalFile.restype = ctypes.c_int
WofIsExternalFile.argtypes = [
wintypes.LPCWSTR, # FilePath : LPCWSTR
ctypes.c_void_p, # IsExternalFile : BOOL* optional, out
ctypes.POINTER(wintypes.DWORD), # Provider : DWORD* optional, out
ctypes.POINTER(None), # ExternalFileInfo : void* optional, out
ctypes.POINTER(wintypes.DWORD), # BufferLength : DWORD* optional, in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('WOFUTIL.dll')
WofIsExternalFile = Fiddle::Function.new(
lib['WofIsExternalFile'],
[
Fiddle::TYPE_VOIDP, # FilePath : LPCWSTR
Fiddle::TYPE_VOIDP, # IsExternalFile : BOOL* optional, out
Fiddle::TYPE_VOIDP, # Provider : DWORD* optional, out
Fiddle::TYPE_VOIDP, # ExternalFileInfo : void* optional, out
Fiddle::TYPE_VOIDP, # BufferLength : DWORD* optional, in/out
],
Fiddle::TYPE_INT)#[link(name = "wofutil")]
extern "system" {
fn WofIsExternalFile(
FilePath: *const u16, // LPCWSTR
IsExternalFile: *mut i32, // BOOL* optional, out
Provider: *mut u32, // DWORD* optional, out
ExternalFileInfo: *mut (), // void* optional, out
BufferLength: *mut u32 // DWORD* optional, in/out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("WOFUTIL.dll")]
public static extern int WofIsExternalFile([MarshalAs(UnmanagedType.LPWStr)] string FilePath, IntPtr IsExternalFile, IntPtr Provider, IntPtr ExternalFileInfo, IntPtr BufferLength);
"@
$api = Add-Type -MemberDefinition $sig -Name 'WOFUTIL_WofIsExternalFile' -Namespace Win32 -PassThru
# $api::WofIsExternalFile(FilePath, IsExternalFile, Provider, ExternalFileInfo, BufferLength)#uselib "WOFUTIL.dll"
#func global WofIsExternalFile "WofIsExternalFile" sptr, sptr, sptr, sptr, sptr
; WofIsExternalFile FilePath, varptr(IsExternalFile), varptr(Provider), ExternalFileInfo, varptr(BufferLength) ; 戻り値は stat
; FilePath : LPCWSTR -> "sptr"
; IsExternalFile : BOOL* optional, out -> "sptr"
; Provider : DWORD* optional, out -> "sptr"
; ExternalFileInfo : void* optional, out -> "sptr"
; BufferLength : DWORD* optional, in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "WOFUTIL.dll" #cfunc global WofIsExternalFile "WofIsExternalFile" wstr, var, var, sptr, var ; res = WofIsExternalFile(FilePath, IsExternalFile, Provider, ExternalFileInfo, BufferLength) ; FilePath : LPCWSTR -> "wstr" ; IsExternalFile : BOOL* optional, out -> "var" ; Provider : DWORD* optional, out -> "var" ; ExternalFileInfo : void* optional, out -> "sptr" ; BufferLength : DWORD* optional, in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "WOFUTIL.dll" #cfunc global WofIsExternalFile "WofIsExternalFile" wstr, sptr, sptr, sptr, sptr ; res = WofIsExternalFile(FilePath, varptr(IsExternalFile), varptr(Provider), ExternalFileInfo, varptr(BufferLength)) ; FilePath : LPCWSTR -> "wstr" ; IsExternalFile : BOOL* optional, out -> "sptr" ; Provider : DWORD* optional, out -> "sptr" ; ExternalFileInfo : void* optional, out -> "sptr" ; BufferLength : DWORD* optional, in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HRESULT WofIsExternalFile(LPCWSTR FilePath, BOOL* IsExternalFile, DWORD* Provider, void* ExternalFileInfo, DWORD* BufferLength) #uselib "WOFUTIL.dll" #cfunc global WofIsExternalFile "WofIsExternalFile" wstr, var, var, intptr, var ; res = WofIsExternalFile(FilePath, IsExternalFile, Provider, ExternalFileInfo, BufferLength) ; FilePath : LPCWSTR -> "wstr" ; IsExternalFile : BOOL* optional, out -> "var" ; Provider : DWORD* optional, out -> "var" ; ExternalFileInfo : void* optional, out -> "intptr" ; BufferLength : DWORD* optional, in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HRESULT WofIsExternalFile(LPCWSTR FilePath, BOOL* IsExternalFile, DWORD* Provider, void* ExternalFileInfo, DWORD* BufferLength) #uselib "WOFUTIL.dll" #cfunc global WofIsExternalFile "WofIsExternalFile" wstr, intptr, intptr, intptr, intptr ; res = WofIsExternalFile(FilePath, varptr(IsExternalFile), varptr(Provider), ExternalFileInfo, varptr(BufferLength)) ; FilePath : LPCWSTR -> "wstr" ; IsExternalFile : BOOL* optional, out -> "intptr" ; Provider : DWORD* optional, out -> "intptr" ; ExternalFileInfo : void* optional, out -> "intptr" ; BufferLength : DWORD* optional, in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
wofutil = windows.NewLazySystemDLL("WOFUTIL.dll")
procWofIsExternalFile = wofutil.NewProc("WofIsExternalFile")
)
// FilePath (LPCWSTR), IsExternalFile (BOOL* optional, out), Provider (DWORD* optional, out), ExternalFileInfo (void* optional, out), BufferLength (DWORD* optional, in/out)
r1, _, err := procWofIsExternalFile.Call(
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(FilePath))),
uintptr(IsExternalFile),
uintptr(Provider),
uintptr(ExternalFileInfo),
uintptr(BufferLength),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction WofIsExternalFile(
FilePath: PWideChar; // LPCWSTR
IsExternalFile: Pointer; // BOOL* optional, out
Provider: Pointer; // DWORD* optional, out
ExternalFileInfo: Pointer; // void* optional, out
BufferLength: Pointer // DWORD* optional, in/out
): Integer; stdcall;
external 'WOFUTIL.dll' name 'WofIsExternalFile';result := DllCall("WOFUTIL\WofIsExternalFile"
, "WStr", FilePath ; LPCWSTR
, "Ptr", IsExternalFile ; BOOL* optional, out
, "Ptr", Provider ; DWORD* optional, out
, "Ptr", ExternalFileInfo ; void* optional, out
, "Ptr", BufferLength ; DWORD* optional, in/out
, "Int") ; return: HRESULT●WofIsExternalFile(FilePath, IsExternalFile, Provider, ExternalFileInfo, BufferLength) = DLL("WOFUTIL.dll", "int WofIsExternalFile(char*, void*, void*, void*, void*)")
# 呼び出し: WofIsExternalFile(FilePath, IsExternalFile, Provider, ExternalFileInfo, BufferLength)
# FilePath : LPCWSTR -> "char*"
# IsExternalFile : BOOL* optional, out -> "void*"
# Provider : DWORD* optional, out -> "void*"
# ExternalFileInfo : void* optional, out -> "void*"
# BufferLength : DWORD* optional, in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "wofutil" fn WofIsExternalFile(
FilePath: [*c]const u16, // LPCWSTR
IsExternalFile: [*c]i32, // BOOL* optional, out
Provider: [*c]u32, // DWORD* optional, out
ExternalFileInfo: ?*anyopaque, // void* optional, out
BufferLength: [*c]u32 // DWORD* optional, in/out
) callconv(std.os.windows.WINAPI) i32;proc WofIsExternalFile(
FilePath: WideCString, # LPCWSTR
IsExternalFile: ptr int32, # BOOL* optional, out
Provider: ptr uint32, # DWORD* optional, out
ExternalFileInfo: pointer, # void* optional, out
BufferLength: ptr uint32 # DWORD* optional, in/out
): int32 {.importc: "WofIsExternalFile", stdcall, dynlib: "WOFUTIL.dll".}pragma(lib, "wofutil");
extern(Windows)
int WofIsExternalFile(
const(wchar)* FilePath, // LPCWSTR
int* IsExternalFile, // BOOL* optional, out
uint* Provider, // DWORD* optional, out
void* ExternalFileInfo, // void* optional, out
uint* BufferLength // DWORD* optional, in/out
);ccall((:WofIsExternalFile, "WOFUTIL.dll"), stdcall, Int32,
(Cwstring, Ptr{Int32}, Ptr{UInt32}, Ptr{Cvoid}, Ptr{UInt32}),
FilePath, IsExternalFile, Provider, ExternalFileInfo, BufferLength)
# FilePath : LPCWSTR -> Cwstring
# IsExternalFile : BOOL* optional, out -> Ptr{Int32}
# Provider : DWORD* optional, out -> Ptr{UInt32}
# ExternalFileInfo : void* optional, out -> Ptr{Cvoid}
# BufferLength : DWORD* optional, in/out -> Ptr{UInt32}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t WofIsExternalFile(
const uint16_t* FilePath,
int32_t* IsExternalFile,
uint32_t* Provider,
void* ExternalFileInfo,
uint32_t* BufferLength);
]]
local wofutil = ffi.load("wofutil")
-- wofutil.WofIsExternalFile(FilePath, IsExternalFile, Provider, ExternalFileInfo, BufferLength)
-- FilePath : LPCWSTR
-- IsExternalFile : BOOL* optional, out
-- Provider : DWORD* optional, out
-- ExternalFileInfo : void* optional, out
-- BufferLength : DWORD* optional, in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('WOFUTIL.dll');
const WofIsExternalFile = lib.func('__stdcall', 'WofIsExternalFile', 'int32_t', ['str16', 'int32_t *', 'uint32_t *', 'void *', 'uint32_t *']);
// WofIsExternalFile(FilePath, IsExternalFile, Provider, ExternalFileInfo, BufferLength)
// FilePath : LPCWSTR -> 'str16'
// IsExternalFile : BOOL* optional, out -> 'int32_t *'
// Provider : DWORD* optional, out -> 'uint32_t *'
// ExternalFileInfo : void* optional, out -> 'void *'
// BufferLength : DWORD* optional, in/out -> 'uint32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("WOFUTIL.dll", {
WofIsExternalFile: { parameters: ["buffer", "pointer", "pointer", "pointer", "pointer"], result: "i32" },
});
// lib.symbols.WofIsExternalFile(FilePath, IsExternalFile, Provider, ExternalFileInfo, BufferLength)
// FilePath : LPCWSTR -> "buffer"
// IsExternalFile : BOOL* optional, out -> "pointer"
// Provider : DWORD* optional, out -> "pointer"
// ExternalFileInfo : void* optional, out -> "pointer"
// BufferLength : DWORD* optional, in/out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t WofIsExternalFile(
const uint16_t* FilePath,
int32_t* IsExternalFile,
uint32_t* Provider,
void* ExternalFileInfo,
uint32_t* BufferLength);
C, "WOFUTIL.dll");
// $ffi->WofIsExternalFile(FilePath, IsExternalFile, Provider, ExternalFileInfo, BufferLength);
// FilePath : LPCWSTR
// IsExternalFile : BOOL* optional, out
// Provider : DWORD* optional, out
// ExternalFileInfo : void* optional, out
// BufferLength : DWORD* optional, 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 Wofutil extends StdCallLibrary {
Wofutil INSTANCE = Native.load("wofutil", Wofutil.class);
int WofIsExternalFile(
WString FilePath, // LPCWSTR
IntByReference IsExternalFile, // BOOL* optional, out
IntByReference Provider, // DWORD* optional, out
Pointer ExternalFileInfo, // void* optional, out
IntByReference BufferLength // DWORD* optional, in/out
);
}@[Link("wofutil")]
lib LibWOFUTIL
fun WofIsExternalFile = WofIsExternalFile(
FilePath : UInt16*, # LPCWSTR
IsExternalFile : Int32*, # BOOL* optional, out
Provider : UInt32*, # DWORD* optional, out
ExternalFileInfo : Void*, # void* optional, out
BufferLength : UInt32* # DWORD* optional, in/out
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef WofIsExternalFileNative = Int32 Function(Pointer<Utf16>, Pointer<Int32>, Pointer<Uint32>, Pointer<Void>, Pointer<Uint32>);
typedef WofIsExternalFileDart = int Function(Pointer<Utf16>, Pointer<Int32>, Pointer<Uint32>, Pointer<Void>, Pointer<Uint32>);
final WofIsExternalFile = DynamicLibrary.open('WOFUTIL.dll')
.lookupFunction<WofIsExternalFileNative, WofIsExternalFileDart>('WofIsExternalFile');
// FilePath : LPCWSTR -> Pointer<Utf16>
// IsExternalFile : BOOL* optional, out -> Pointer<Int32>
// Provider : DWORD* optional, out -> Pointer<Uint32>
// ExternalFileInfo : void* optional, out -> Pointer<Void>
// BufferLength : DWORD* optional, in/out -> Pointer<Uint32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function WofIsExternalFile(
FilePath: PWideChar; // LPCWSTR
IsExternalFile: Pointer; // BOOL* optional, out
Provider: Pointer; // DWORD* optional, out
ExternalFileInfo: Pointer; // void* optional, out
BufferLength: Pointer // DWORD* optional, in/out
): Integer; stdcall;
external 'WOFUTIL.dll' name 'WofIsExternalFile';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "WofIsExternalFile"
c_WofIsExternalFile :: CWString -> Ptr CInt -> Ptr Word32 -> Ptr () -> Ptr Word32 -> IO Int32
-- FilePath : LPCWSTR -> CWString
-- IsExternalFile : BOOL* optional, out -> Ptr CInt
-- Provider : DWORD* optional, out -> Ptr Word32
-- ExternalFileInfo : void* optional, out -> Ptr ()
-- BufferLength : DWORD* optional, in/out -> Ptr Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let wofisexternalfile =
foreign "WofIsExternalFile"
((ptr uint16_t) @-> (ptr int32_t) @-> (ptr uint32_t) @-> (ptr void) @-> (ptr uint32_t) @-> returning int32_t)
(* FilePath : LPCWSTR -> (ptr uint16_t) *)
(* IsExternalFile : BOOL* optional, out -> (ptr int32_t) *)
(* Provider : DWORD* optional, out -> (ptr uint32_t) *)
(* ExternalFileInfo : void* optional, out -> (ptr void) *)
(* BufferLength : DWORD* optional, in/out -> (ptr uint32_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library wofutil (t "WOFUTIL.dll"))
(cffi:use-foreign-library wofutil)
(cffi:defcfun ("WofIsExternalFile" wof-is-external-file :convention :stdcall) :int32
(file-path (:string :encoding :utf-16le)) ; LPCWSTR
(is-external-file :pointer) ; BOOL* optional, out
(provider :pointer) ; DWORD* optional, out
(external-file-info :pointer) ; void* optional, out
(buffer-length :pointer)) ; DWORD* optional, in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $WofIsExternalFile = Win32::API::More->new('WOFUTIL',
'int WofIsExternalFile(LPCWSTR FilePath, LPVOID IsExternalFile, LPVOID Provider, LPVOID ExternalFileInfo, LPVOID BufferLength)');
# my $ret = $WofIsExternalFile->Call($FilePath, $IsExternalFile, $Provider, $ExternalFileInfo, $BufferLength);
# FilePath : LPCWSTR -> LPCWSTR
# IsExternalFile : BOOL* optional, out -> LPVOID
# Provider : DWORD* optional, out -> LPVOID
# ExternalFileInfo : void* optional, out -> LPVOID
# BufferLength : DWORD* optional, in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。