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