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

FilterUnload

関数
指定したミニフィルタードライバーをアンロードする。
DLLFLTLIB.dll呼出規約winapi

シグネチャ

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

HRESULT FilterUnload(
    LPCWSTR lpFilterName
);

パラメーター

名前方向説明
lpFilterNameLPCWSTRinアンロードする読み込み済みミニフィルタードライバーのサービス名を指す。

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT FilterUnload(
    LPCWSTR lpFilterName
);
[DllImport("FLTLIB.dll", ExactSpelling = true)]
static extern int FilterUnload(
    [MarshalAs(UnmanagedType.LPWStr)] string lpFilterName   // LPCWSTR
);
<DllImport("FLTLIB.dll", ExactSpelling:=True)>
Public Shared Function FilterUnload(
    <MarshalAs(UnmanagedType.LPWStr)> lpFilterName As String   ' LPCWSTR
) As Integer
End Function
' lpFilterName : LPCWSTR
Declare PtrSafe Function FilterUnload Lib "fltlib" ( _
    ByVal lpFilterName As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

FilterUnload = ctypes.windll.fltlib.FilterUnload
FilterUnload.restype = ctypes.c_int
FilterUnload.argtypes = [
    wintypes.LPCWSTR,  # lpFilterName : LPCWSTR
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('FLTLIB.dll')
FilterUnload = Fiddle::Function.new(
  lib['FilterUnload'],
  [
    Fiddle::TYPE_VOIDP,  # lpFilterName : LPCWSTR
  ],
  Fiddle::TYPE_INT)
#[link(name = "fltlib")]
extern "system" {
    fn FilterUnload(
        lpFilterName: *const u16  // LPCWSTR
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("FLTLIB.dll")]
public static extern int FilterUnload([MarshalAs(UnmanagedType.LPWStr)] string lpFilterName);
"@
$api = Add-Type -MemberDefinition $sig -Name 'FLTLIB_FilterUnload' -Namespace Win32 -PassThru
# $api::FilterUnload(lpFilterName)
#uselib "FLTLIB.dll"
#func global FilterUnload "FilterUnload" sptr
; FilterUnload lpFilterName   ; 戻り値は stat
; lpFilterName : LPCWSTR -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "FLTLIB.dll"
#cfunc global FilterUnload "FilterUnload" wstr
; res = FilterUnload(lpFilterName)
; lpFilterName : LPCWSTR -> "wstr"
; HRESULT FilterUnload(LPCWSTR lpFilterName)
#uselib "FLTLIB.dll"
#cfunc global FilterUnload "FilterUnload" wstr
; res = FilterUnload(lpFilterName)
; lpFilterName : LPCWSTR -> "wstr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	fltlib = windows.NewLazySystemDLL("FLTLIB.dll")
	procFilterUnload = fltlib.NewProc("FilterUnload")
)

// lpFilterName (LPCWSTR)
r1, _, err := procFilterUnload.Call(
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(lpFilterName))),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function FilterUnload(
  lpFilterName: PWideChar   // LPCWSTR
): Integer; stdcall;
  external 'FLTLIB.dll' name 'FilterUnload';
result := DllCall("FLTLIB\FilterUnload"
    , "WStr", lpFilterName   ; LPCWSTR
    , "Int")   ; return: HRESULT
●FilterUnload(lpFilterName) = DLL("FLTLIB.dll", "int FilterUnload(char*)")
# 呼び出し: FilterUnload(lpFilterName)
# lpFilterName : LPCWSTR -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

extern "fltlib" fn FilterUnload(
    lpFilterName: [*c]const u16 // LPCWSTR
) callconv(std.os.windows.WINAPI) i32;
proc FilterUnload(
    lpFilterName: WideCString  # LPCWSTR
): int32 {.importc: "FilterUnload", stdcall, dynlib: "FLTLIB.dll".}
pragma(lib, "fltlib");
extern(Windows)
int FilterUnload(
    const(wchar)* lpFilterName   // LPCWSTR
);
ccall((:FilterUnload, "FLTLIB.dll"), stdcall, Int32,
      (Cwstring,),
      lpFilterName)
# lpFilterName : LPCWSTR -> Cwstring
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t FilterUnload(
    const uint16_t* lpFilterName);
]]
local fltlib = ffi.load("fltlib")
-- fltlib.FilterUnload(lpFilterName)
-- lpFilterName : LPCWSTR
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('FLTLIB.dll');
const FilterUnload = lib.func('__stdcall', 'FilterUnload', 'int32_t', ['str16']);
// FilterUnload(lpFilterName)
// lpFilterName : LPCWSTR -> 'str16'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("FLTLIB.dll", {
  FilterUnload: { parameters: ["buffer"], result: "i32" },
});
// lib.symbols.FilterUnload(lpFilterName)
// lpFilterName : LPCWSTR -> "buffer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t FilterUnload(
    const uint16_t* lpFilterName);
C, "FLTLIB.dll");
// $ffi->FilterUnload(lpFilterName);
// lpFilterName : LPCWSTR
// 構造体/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 FilterUnload(
        WString lpFilterName   // LPCWSTR
    );
}
@[Link("fltlib")]
lib LibFLTLIB
  fun FilterUnload = FilterUnload(
    lpFilterName : UInt16*   # LPCWSTR
  ) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef FilterUnloadNative = Int32 Function(Pointer<Utf16>);
typedef FilterUnloadDart = int Function(Pointer<Utf16>);
final FilterUnload = DynamicLibrary.open('FLTLIB.dll')
    .lookupFunction<FilterUnloadNative, FilterUnloadDart>('FilterUnload');
// lpFilterName : LPCWSTR -> Pointer<Utf16>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function FilterUnload(
  lpFilterName: PWideChar   // LPCWSTR
): Integer; stdcall;
  external 'FLTLIB.dll' name 'FilterUnload';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "FilterUnload"
  c_FilterUnload :: CWString -> IO Int32
-- lpFilterName : LPCWSTR -> CWString
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let filterunload =
  foreign "FilterUnload"
    ((ptr uint16_t) @-> returning int32_t)
(* lpFilterName : LPCWSTR -> (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 ("FilterUnload" filter-unload :convention :stdcall) :int32
  (lp-filter-name (:string :encoding :utf-16le)))   ; LPCWSTR
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $FilterUnload = Win32::API::More->new('FLTLIB',
    'int FilterUnload(LPCWSTR lpFilterName)');
# my $ret = $FilterUnload->Call($lpFilterName);
# lpFilterName : LPCWSTR -> LPCWSTR
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。