ホーム › Devices.Enumeration.Pnp › SwDeviceSetLifetime
SwDeviceSetLifetime
関数ソフトウェアデバイスの存続期間を設定する。
シグネチャ
// CFGMGR32.dll
#include <windows.h>
HRESULT SwDeviceSetLifetime(
HSWDEVICE hSwDevice,
SW_DEVICE_LIFETIME Lifetime
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hSwDevice | HSWDEVICE | in |
| Lifetime | SW_DEVICE_LIFETIME | in |
戻り値の型: HRESULT
各言語での呼び出し定義
// CFGMGR32.dll
#include <windows.h>
HRESULT SwDeviceSetLifetime(
HSWDEVICE hSwDevice,
SW_DEVICE_LIFETIME Lifetime
);[DllImport("CFGMGR32.dll", ExactSpelling = true)]
static extern int SwDeviceSetLifetime(
IntPtr hSwDevice, // HSWDEVICE
int Lifetime // SW_DEVICE_LIFETIME
);<DllImport("CFGMGR32.dll", ExactSpelling:=True)>
Public Shared Function SwDeviceSetLifetime(
hSwDevice As IntPtr, ' HSWDEVICE
Lifetime As Integer ' SW_DEVICE_LIFETIME
) As Integer
End Function' hSwDevice : HSWDEVICE
' Lifetime : SW_DEVICE_LIFETIME
Declare PtrSafe Function SwDeviceSetLifetime Lib "cfgmgr32" ( _
ByVal hSwDevice As LongPtr, _
ByVal Lifetime As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
SwDeviceSetLifetime = ctypes.windll.cfgmgr32.SwDeviceSetLifetime
SwDeviceSetLifetime.restype = ctypes.c_int
SwDeviceSetLifetime.argtypes = [
wintypes.HANDLE, # hSwDevice : HSWDEVICE
ctypes.c_int, # Lifetime : SW_DEVICE_LIFETIME
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('CFGMGR32.dll')
SwDeviceSetLifetime = Fiddle::Function.new(
lib['SwDeviceSetLifetime'],
[
Fiddle::TYPE_VOIDP, # hSwDevice : HSWDEVICE
Fiddle::TYPE_INT, # Lifetime : SW_DEVICE_LIFETIME
],
Fiddle::TYPE_INT)#[link(name = "cfgmgr32")]
extern "system" {
fn SwDeviceSetLifetime(
hSwDevice: *mut core::ffi::c_void, // HSWDEVICE
Lifetime: i32 // SW_DEVICE_LIFETIME
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("CFGMGR32.dll")]
public static extern int SwDeviceSetLifetime(IntPtr hSwDevice, int Lifetime);
"@
$api = Add-Type -MemberDefinition $sig -Name 'CFGMGR32_SwDeviceSetLifetime' -Namespace Win32 -PassThru
# $api::SwDeviceSetLifetime(hSwDevice, Lifetime)#uselib "CFGMGR32.dll"
#func global SwDeviceSetLifetime "SwDeviceSetLifetime" sptr, sptr
; SwDeviceSetLifetime hSwDevice, Lifetime ; 戻り値は stat
; hSwDevice : HSWDEVICE -> "sptr"
; Lifetime : SW_DEVICE_LIFETIME -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "CFGMGR32.dll"
#cfunc global SwDeviceSetLifetime "SwDeviceSetLifetime" sptr, int
; res = SwDeviceSetLifetime(hSwDevice, Lifetime)
; hSwDevice : HSWDEVICE -> "sptr"
; Lifetime : SW_DEVICE_LIFETIME -> "int"; HRESULT SwDeviceSetLifetime(HSWDEVICE hSwDevice, SW_DEVICE_LIFETIME Lifetime)
#uselib "CFGMGR32.dll"
#cfunc global SwDeviceSetLifetime "SwDeviceSetLifetime" intptr, int
; res = SwDeviceSetLifetime(hSwDevice, Lifetime)
; hSwDevice : HSWDEVICE -> "intptr"
; Lifetime : SW_DEVICE_LIFETIME -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
cfgmgr32 = windows.NewLazySystemDLL("CFGMGR32.dll")
procSwDeviceSetLifetime = cfgmgr32.NewProc("SwDeviceSetLifetime")
)
// hSwDevice (HSWDEVICE), Lifetime (SW_DEVICE_LIFETIME)
r1, _, err := procSwDeviceSetLifetime.Call(
uintptr(hSwDevice),
uintptr(Lifetime),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction SwDeviceSetLifetime(
hSwDevice: THandle; // HSWDEVICE
Lifetime: Integer // SW_DEVICE_LIFETIME
): Integer; stdcall;
external 'CFGMGR32.dll' name 'SwDeviceSetLifetime';result := DllCall("CFGMGR32\SwDeviceSetLifetime"
, "Ptr", hSwDevice ; HSWDEVICE
, "Int", Lifetime ; SW_DEVICE_LIFETIME
, "Int") ; return: HRESULT●SwDeviceSetLifetime(hSwDevice, Lifetime) = DLL("CFGMGR32.dll", "int SwDeviceSetLifetime(void*, int)")
# 呼び出し: SwDeviceSetLifetime(hSwDevice, Lifetime)
# hSwDevice : HSWDEVICE -> "void*"
# Lifetime : SW_DEVICE_LIFETIME -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。