ホーム › Devices.DeviceAndDriverInstallation › SetupCloseInfFile
SetupCloseInfFile
関数開いているINFファイルのハンドルを閉じて解放する。
シグネチャ
// SETUPAPI.dll
#include <windows.h>
void SetupCloseInfFile(
void* InfHandle
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| InfHandle | void* | in | 閉じる対象の開いているINFハンドル。これにより関連リソースが解放される。 |
戻り値の型: void
各言語での呼び出し定義
// SETUPAPI.dll
#include <windows.h>
void SetupCloseInfFile(
void* InfHandle
);[DllImport("SETUPAPI.dll", ExactSpelling = true)]
static extern void SetupCloseInfFile(
IntPtr InfHandle // void*
);<DllImport("SETUPAPI.dll", ExactSpelling:=True)>
Public Shared Sub SetupCloseInfFile(
InfHandle As IntPtr ' void*
)
End Sub' InfHandle : void*
Declare PtrSafe Sub SetupCloseInfFile Lib "setupapi" ( _
ByVal InfHandle As LongPtr)
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
SetupCloseInfFile = ctypes.windll.setupapi.SetupCloseInfFile
SetupCloseInfFile.restype = None
SetupCloseInfFile.argtypes = [
ctypes.POINTER(None), # InfHandle : void*
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('SETUPAPI.dll')
SetupCloseInfFile = Fiddle::Function.new(
lib['SetupCloseInfFile'],
[
Fiddle::TYPE_VOIDP, # InfHandle : void*
],
Fiddle::TYPE_VOID)#[link(name = "setupapi")]
extern "system" {
fn SetupCloseInfFile(
InfHandle: *mut () // void*
);
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("SETUPAPI.dll")]
public static extern void SetupCloseInfFile(IntPtr InfHandle);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SETUPAPI_SetupCloseInfFile' -Namespace Win32 -PassThru
# $api::SetupCloseInfFile(InfHandle)#uselib "SETUPAPI.dll"
#func global SetupCloseInfFile "SetupCloseInfFile" sptr
; SetupCloseInfFile InfHandle
; InfHandle : void* -> "sptr"#uselib "SETUPAPI.dll"
#func global SetupCloseInfFile "SetupCloseInfFile" sptr
; SetupCloseInfFile InfHandle
; InfHandle : void* -> "sptr"; void SetupCloseInfFile(void* InfHandle)
#uselib "SETUPAPI.dll"
#func global SetupCloseInfFile "SetupCloseInfFile" intptr
; SetupCloseInfFile InfHandle
; InfHandle : void* -> "intptr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
setupapi = windows.NewLazySystemDLL("SETUPAPI.dll")
procSetupCloseInfFile = setupapi.NewProc("SetupCloseInfFile")
)
// InfHandle (void*)
r1, _, err := procSetupCloseInfFile.Call(
uintptr(InfHandle),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // voidprocedure SetupCloseInfFile(
InfHandle: Pointer // void*
); stdcall;
external 'SETUPAPI.dll' name 'SetupCloseInfFile';result := DllCall("SETUPAPI\SetupCloseInfFile"
, "Ptr", InfHandle ; void*
, "Int") ; return: void●SetupCloseInfFile(InfHandle) = DLL("SETUPAPI.dll", "int SetupCloseInfFile(void*)")
# 呼び出し: SetupCloseInfFile(InfHandle)
# InfHandle : void* -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "setupapi" fn SetupCloseInfFile(
InfHandle: ?*anyopaque // void*
) callconv(std.os.windows.WINAPI) void;proc SetupCloseInfFile(
InfHandle: pointer # void*
) {.importc: "SetupCloseInfFile", stdcall, dynlib: "SETUPAPI.dll".}pragma(lib, "setupapi");
extern(Windows)
void SetupCloseInfFile(
void* InfHandle // void*
);ccall((:SetupCloseInfFile, "SETUPAPI.dll"), stdcall, Cvoid,
(Ptr{Cvoid},),
InfHandle)
# InfHandle : void* -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
void SetupCloseInfFile(
void* InfHandle);
]]
local setupapi = ffi.load("setupapi")
-- setupapi.SetupCloseInfFile(InfHandle)
-- InfHandle : void*
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('SETUPAPI.dll');
const SetupCloseInfFile = lib.func('__stdcall', 'SetupCloseInfFile', 'void', ['void *']);
// SetupCloseInfFile(InfHandle)
// InfHandle : void* -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("SETUPAPI.dll", {
SetupCloseInfFile: { parameters: ["pointer"], result: "void" },
});
// lib.symbols.SetupCloseInfFile(InfHandle)
// InfHandle : void* -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
void SetupCloseInfFile(
void* InfHandle);
C, "SETUPAPI.dll");
// $ffi->SetupCloseInfFile(InfHandle);
// InfHandle : void*
// 構造体/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 Setupapi extends StdCallLibrary {
Setupapi INSTANCE = Native.load("setupapi", Setupapi.class);
void SetupCloseInfFile(
Pointer InfHandle // void*
);
}@[Link("setupapi")]
lib LibSETUPAPI
fun SetupCloseInfFile = SetupCloseInfFile(
InfHandle : Void* # void*
) : Void
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef SetupCloseInfFileNative = Void Function(Pointer<Void>);
typedef SetupCloseInfFileDart = void Function(Pointer<Void>);
final SetupCloseInfFile = DynamicLibrary.open('SETUPAPI.dll')
.lookupFunction<SetupCloseInfFileNative, SetupCloseInfFileDart>('SetupCloseInfFile');
// InfHandle : void* -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
procedure SetupCloseInfFile(
InfHandle: Pointer // void*
); stdcall;
external 'SETUPAPI.dll' name 'SetupCloseInfFile';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "SetupCloseInfFile"
c_SetupCloseInfFile :: Ptr () -> IO ()
-- InfHandle : void* -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let setupcloseinffile =
foreign "SetupCloseInfFile"
((ptr void) @-> returning void)
(* InfHandle : void* -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library setupapi (t "SETUPAPI.dll"))
(cffi:use-foreign-library setupapi)
(cffi:defcfun ("SetupCloseInfFile" setup-close-inf-file :convention :stdcall) :void
(inf-handle :pointer)) ; void*
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $SetupCloseInfFile = Win32::API::More->new('SETUPAPI',
'void SetupCloseInfFile(LPVOID InfHandle)');
# my $ret = $SetupCloseInfFile->Call($InfHandle);
# InfHandle : void* -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。