ホーム › Storage.InstallableFileSystems › FilterDetach
FilterDetach
関数ボリュームからミニフィルターインスタンスをデタッチする。
シグネチャ
// FLTLIB.dll
#include <windows.h>
HRESULT FilterDetach(
LPCWSTR lpFilterName,
LPCWSTR lpVolumeName,
LPCWSTR lpInstanceName // optional
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| lpFilterName | LPCWSTR | in | デタッチするミニフィルターのサービス名を指す。 |
| lpVolumeName | LPCWSTR | in | デタッチ対象のボリューム名を指す。 |
| lpInstanceName | LPCWSTR | inoptional | デタッチするインスタンス名を指す。NULL可。 |
戻り値の型: HRESULT
各言語での呼び出し定義
// FLTLIB.dll
#include <windows.h>
HRESULT FilterDetach(
LPCWSTR lpFilterName,
LPCWSTR lpVolumeName,
LPCWSTR lpInstanceName // optional
);[DllImport("FLTLIB.dll", ExactSpelling = true)]
static extern int FilterDetach(
[MarshalAs(UnmanagedType.LPWStr)] string lpFilterName, // LPCWSTR
[MarshalAs(UnmanagedType.LPWStr)] string lpVolumeName, // LPCWSTR
[MarshalAs(UnmanagedType.LPWStr)] string lpInstanceName // LPCWSTR optional
);<DllImport("FLTLIB.dll", ExactSpelling:=True)>
Public Shared Function FilterDetach(
<MarshalAs(UnmanagedType.LPWStr)> lpFilterName As String, ' LPCWSTR
<MarshalAs(UnmanagedType.LPWStr)> lpVolumeName As String, ' LPCWSTR
<MarshalAs(UnmanagedType.LPWStr)> lpInstanceName As String ' LPCWSTR optional
) As Integer
End Function' lpFilterName : LPCWSTR
' lpVolumeName : LPCWSTR
' lpInstanceName : LPCWSTR optional
Declare PtrSafe Function FilterDetach Lib "fltlib" ( _
ByVal lpFilterName As LongPtr, _
ByVal lpVolumeName As LongPtr, _
ByVal lpInstanceName As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
FilterDetach = ctypes.windll.fltlib.FilterDetach
FilterDetach.restype = ctypes.c_int
FilterDetach.argtypes = [
wintypes.LPCWSTR, # lpFilterName : LPCWSTR
wintypes.LPCWSTR, # lpVolumeName : LPCWSTR
wintypes.LPCWSTR, # lpInstanceName : LPCWSTR optional
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('FLTLIB.dll')
FilterDetach = Fiddle::Function.new(
lib['FilterDetach'],
[
Fiddle::TYPE_VOIDP, # lpFilterName : LPCWSTR
Fiddle::TYPE_VOIDP, # lpVolumeName : LPCWSTR
Fiddle::TYPE_VOIDP, # lpInstanceName : LPCWSTR optional
],
Fiddle::TYPE_INT)#[link(name = "fltlib")]
extern "system" {
fn FilterDetach(
lpFilterName: *const u16, // LPCWSTR
lpVolumeName: *const u16, // LPCWSTR
lpInstanceName: *const u16 // LPCWSTR optional
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("FLTLIB.dll")]
public static extern int FilterDetach([MarshalAs(UnmanagedType.LPWStr)] string lpFilterName, [MarshalAs(UnmanagedType.LPWStr)] string lpVolumeName, [MarshalAs(UnmanagedType.LPWStr)] string lpInstanceName);
"@
$api = Add-Type -MemberDefinition $sig -Name 'FLTLIB_FilterDetach' -Namespace Win32 -PassThru
# $api::FilterDetach(lpFilterName, lpVolumeName, lpInstanceName)#uselib "FLTLIB.dll"
#func global FilterDetach "FilterDetach" sptr, sptr, sptr
; FilterDetach lpFilterName, lpVolumeName, lpInstanceName ; 戻り値は stat
; lpFilterName : LPCWSTR -> "sptr"
; lpVolumeName : LPCWSTR -> "sptr"
; lpInstanceName : LPCWSTR optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "FLTLIB.dll"
#cfunc global FilterDetach "FilterDetach" wstr, wstr, wstr
; res = FilterDetach(lpFilterName, lpVolumeName, lpInstanceName)
; lpFilterName : LPCWSTR -> "wstr"
; lpVolumeName : LPCWSTR -> "wstr"
; lpInstanceName : LPCWSTR optional -> "wstr"; HRESULT FilterDetach(LPCWSTR lpFilterName, LPCWSTR lpVolumeName, LPCWSTR lpInstanceName)
#uselib "FLTLIB.dll"
#cfunc global FilterDetach "FilterDetach" wstr, wstr, wstr
; res = FilterDetach(lpFilterName, lpVolumeName, lpInstanceName)
; lpFilterName : LPCWSTR -> "wstr"
; lpVolumeName : LPCWSTR -> "wstr"
; lpInstanceName : LPCWSTR optional -> "wstr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
fltlib = windows.NewLazySystemDLL("FLTLIB.dll")
procFilterDetach = fltlib.NewProc("FilterDetach")
)
// lpFilterName (LPCWSTR), lpVolumeName (LPCWSTR), lpInstanceName (LPCWSTR optional)
r1, _, err := procFilterDetach.Call(
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(lpFilterName))),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(lpVolumeName))),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(lpInstanceName))),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction FilterDetach(
lpFilterName: PWideChar; // LPCWSTR
lpVolumeName: PWideChar; // LPCWSTR
lpInstanceName: PWideChar // LPCWSTR optional
): Integer; stdcall;
external 'FLTLIB.dll' name 'FilterDetach';result := DllCall("FLTLIB\FilterDetach"
, "WStr", lpFilterName ; LPCWSTR
, "WStr", lpVolumeName ; LPCWSTR
, "WStr", lpInstanceName ; LPCWSTR optional
, "Int") ; return: HRESULT●FilterDetach(lpFilterName, lpVolumeName, lpInstanceName) = DLL("FLTLIB.dll", "int FilterDetach(char*, char*, char*)")
# 呼び出し: FilterDetach(lpFilterName, lpVolumeName, lpInstanceName)
# lpFilterName : LPCWSTR -> "char*"
# lpVolumeName : LPCWSTR -> "char*"
# lpInstanceName : LPCWSTR optional -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "fltlib" fn FilterDetach(
lpFilterName: [*c]const u16, // LPCWSTR
lpVolumeName: [*c]const u16, // LPCWSTR
lpInstanceName: [*c]const u16 // LPCWSTR optional
) callconv(std.os.windows.WINAPI) i32;proc FilterDetach(
lpFilterName: WideCString, # LPCWSTR
lpVolumeName: WideCString, # LPCWSTR
lpInstanceName: WideCString # LPCWSTR optional
): int32 {.importc: "FilterDetach", stdcall, dynlib: "FLTLIB.dll".}pragma(lib, "fltlib");
extern(Windows)
int FilterDetach(
const(wchar)* lpFilterName, // LPCWSTR
const(wchar)* lpVolumeName, // LPCWSTR
const(wchar)* lpInstanceName // LPCWSTR optional
);ccall((:FilterDetach, "FLTLIB.dll"), stdcall, Int32,
(Cwstring, Cwstring, Cwstring),
lpFilterName, lpVolumeName, lpInstanceName)
# lpFilterName : LPCWSTR -> Cwstring
# lpVolumeName : LPCWSTR -> Cwstring
# lpInstanceName : LPCWSTR optional -> Cwstring
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t FilterDetach(
const uint16_t* lpFilterName,
const uint16_t* lpVolumeName,
const uint16_t* lpInstanceName);
]]
local fltlib = ffi.load("fltlib")
-- fltlib.FilterDetach(lpFilterName, lpVolumeName, lpInstanceName)
-- lpFilterName : LPCWSTR
-- lpVolumeName : LPCWSTR
-- lpInstanceName : LPCWSTR optional
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('FLTLIB.dll');
const FilterDetach = lib.func('__stdcall', 'FilterDetach', 'int32_t', ['str16', 'str16', 'str16']);
// FilterDetach(lpFilterName, lpVolumeName, lpInstanceName)
// lpFilterName : LPCWSTR -> 'str16'
// lpVolumeName : LPCWSTR -> 'str16'
// lpInstanceName : LPCWSTR optional -> 'str16'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("FLTLIB.dll", {
FilterDetach: { parameters: ["buffer", "buffer", "buffer"], result: "i32" },
});
// lib.symbols.FilterDetach(lpFilterName, lpVolumeName, lpInstanceName)
// lpFilterName : LPCWSTR -> "buffer"
// lpVolumeName : LPCWSTR -> "buffer"
// lpInstanceName : LPCWSTR optional -> "buffer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t FilterDetach(
const uint16_t* lpFilterName,
const uint16_t* lpVolumeName,
const uint16_t* lpInstanceName);
C, "FLTLIB.dll");
// $ffi->FilterDetach(lpFilterName, lpVolumeName, lpInstanceName);
// lpFilterName : LPCWSTR
// lpVolumeName : LPCWSTR
// lpInstanceName : LPCWSTR optional
// 構造体/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 Fltlib extends StdCallLibrary {
Fltlib INSTANCE = Native.load("fltlib", Fltlib.class);
int FilterDetach(
WString lpFilterName, // LPCWSTR
WString lpVolumeName, // LPCWSTR
WString lpInstanceName // LPCWSTR optional
);
}@[Link("fltlib")]
lib LibFLTLIB
fun FilterDetach = FilterDetach(
lpFilterName : UInt16*, # LPCWSTR
lpVolumeName : UInt16*, # LPCWSTR
lpInstanceName : UInt16* # LPCWSTR optional
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef FilterDetachNative = Int32 Function(Pointer<Utf16>, Pointer<Utf16>, Pointer<Utf16>);
typedef FilterDetachDart = int Function(Pointer<Utf16>, Pointer<Utf16>, Pointer<Utf16>);
final FilterDetach = DynamicLibrary.open('FLTLIB.dll')
.lookupFunction<FilterDetachNative, FilterDetachDart>('FilterDetach');
// lpFilterName : LPCWSTR -> Pointer<Utf16>
// lpVolumeName : LPCWSTR -> Pointer<Utf16>
// lpInstanceName : LPCWSTR optional -> Pointer<Utf16>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function FilterDetach(
lpFilterName: PWideChar; // LPCWSTR
lpVolumeName: PWideChar; // LPCWSTR
lpInstanceName: PWideChar // LPCWSTR optional
): Integer; stdcall;
external 'FLTLIB.dll' name 'FilterDetach';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "FilterDetach"
c_FilterDetach :: CWString -> CWString -> CWString -> IO Int32
-- lpFilterName : LPCWSTR -> CWString
-- lpVolumeName : LPCWSTR -> CWString
-- lpInstanceName : LPCWSTR optional -> CWString
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let filterdetach =
foreign "FilterDetach"
((ptr uint16_t) @-> (ptr uint16_t) @-> (ptr uint16_t) @-> returning int32_t)
(* lpFilterName : LPCWSTR -> (ptr uint16_t) *)
(* lpVolumeName : LPCWSTR -> (ptr uint16_t) *)
(* lpInstanceName : LPCWSTR optional -> (ptr uint16_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library fltlib (t "FLTLIB.dll"))
(cffi:use-foreign-library fltlib)
(cffi:defcfun ("FilterDetach" filter-detach :convention :stdcall) :int32
(lp-filter-name (:string :encoding :utf-16le)) ; LPCWSTR
(lp-volume-name (:string :encoding :utf-16le)) ; LPCWSTR
(lp-instance-name (:string :encoding :utf-16le))) ; LPCWSTR optional
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $FilterDetach = Win32::API::More->new('FLTLIB',
'int FilterDetach(LPCWSTR lpFilterName, LPCWSTR lpVolumeName, LPCWSTR lpInstanceName)');
# my $ret = $FilterDetach->Call($lpFilterName, $lpVolumeName, $lpInstanceName);
# lpFilterName : LPCWSTR -> LPCWSTR
# lpVolumeName : LPCWSTR -> LPCWSTR
# lpInstanceName : LPCWSTR optional -> LPCWSTR
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。