ホーム › Devices.DeviceAndDriverInstallation › DiShowUpdateDevice
DiShowUpdateDevice
関数デバイスドライバーの更新ウィザードを表示する。
シグネチャ
// newdev.dll
#include <windows.h>
BOOL DiShowUpdateDevice(
HWND hwndParent, // optional
HDEVINFO DeviceInfoSet,
SP_DEVINFO_DATA* DeviceInfoData,
DWORD Flags,
BOOL* NeedReboot // optional
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| hwndParent | HWND | inoptional | ドライバー更新ウィザードの親となるウィンドウハンドル。 |
| DeviceInfoSet | HDEVINFO | in | 対象デバイスを含むデバイス情報セットのハンドル(HDEVINFO)。 |
| DeviceInfoData | SP_DEVINFO_DATA* | in | 更新対象デバイスを示すSP_DEVINFO_DATA構造体へのポインタ。 |
| Flags | DWORD | in | 予約済みフラグ。常に0を指定する。 |
| NeedReboot | BOOL* | outoptional | 再起動が必要かどうかの真偽値を受け取る出力先ポインタ。NULL可。 |
戻り値の型: BOOL
各言語での呼び出し定義
// newdev.dll
#include <windows.h>
BOOL DiShowUpdateDevice(
HWND hwndParent, // optional
HDEVINFO DeviceInfoSet,
SP_DEVINFO_DATA* DeviceInfoData,
DWORD Flags,
BOOL* NeedReboot // optional
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("newdev.dll", SetLastError = true, ExactSpelling = true)]
static extern bool DiShowUpdateDevice(
IntPtr hwndParent, // HWND optional
IntPtr DeviceInfoSet, // HDEVINFO
IntPtr DeviceInfoData, // SP_DEVINFO_DATA*
uint Flags, // DWORD
IntPtr NeedReboot // BOOL* optional, out
);<DllImport("newdev.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function DiShowUpdateDevice(
hwndParent As IntPtr, ' HWND optional
DeviceInfoSet As IntPtr, ' HDEVINFO
DeviceInfoData As IntPtr, ' SP_DEVINFO_DATA*
Flags As UInteger, ' DWORD
NeedReboot As IntPtr ' BOOL* optional, out
) As <MarshalAs(UnmanagedType.Bool)> Boolean
End Function' hwndParent : HWND optional
' DeviceInfoSet : HDEVINFO
' DeviceInfoData : SP_DEVINFO_DATA*
' Flags : DWORD
' NeedReboot : BOOL* optional, out
Declare PtrSafe Function DiShowUpdateDevice Lib "newdev" ( _
ByVal hwndParent As LongPtr, _
ByVal DeviceInfoSet As LongPtr, _
ByVal DeviceInfoData As LongPtr, _
ByVal Flags As Long, _
ByVal NeedReboot As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
DiShowUpdateDevice = ctypes.windll.newdev.DiShowUpdateDevice
DiShowUpdateDevice.restype = wintypes.BOOL
DiShowUpdateDevice.argtypes = [
wintypes.HANDLE, # hwndParent : HWND optional
ctypes.c_ssize_t, # DeviceInfoSet : HDEVINFO
ctypes.c_void_p, # DeviceInfoData : SP_DEVINFO_DATA*
wintypes.DWORD, # Flags : DWORD
ctypes.c_void_p, # NeedReboot : BOOL* optional, out
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('newdev.dll')
DiShowUpdateDevice = Fiddle::Function.new(
lib['DiShowUpdateDevice'],
[
Fiddle::TYPE_VOIDP, # hwndParent : HWND optional
Fiddle::TYPE_INTPTR_T, # DeviceInfoSet : HDEVINFO
Fiddle::TYPE_VOIDP, # DeviceInfoData : SP_DEVINFO_DATA*
-Fiddle::TYPE_INT, # Flags : DWORD
Fiddle::TYPE_VOIDP, # NeedReboot : BOOL* optional, out
],
Fiddle::TYPE_INT)#[link(name = "newdev")]
extern "system" {
fn DiShowUpdateDevice(
hwndParent: *mut core::ffi::c_void, // HWND optional
DeviceInfoSet: isize, // HDEVINFO
DeviceInfoData: *mut SP_DEVINFO_DATA, // SP_DEVINFO_DATA*
Flags: u32, // DWORD
NeedReboot: *mut i32 // BOOL* optional, out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("newdev.dll", SetLastError = true)]
public static extern bool DiShowUpdateDevice(IntPtr hwndParent, IntPtr DeviceInfoSet, IntPtr DeviceInfoData, uint Flags, IntPtr NeedReboot);
"@
$api = Add-Type -MemberDefinition $sig -Name 'newdev_DiShowUpdateDevice' -Namespace Win32 -PassThru
# $api::DiShowUpdateDevice(hwndParent, DeviceInfoSet, DeviceInfoData, Flags, NeedReboot)#uselib "newdev.dll"
#func global DiShowUpdateDevice "DiShowUpdateDevice" sptr, sptr, sptr, sptr, sptr
; DiShowUpdateDevice hwndParent, DeviceInfoSet, varptr(DeviceInfoData), Flags, varptr(NeedReboot) ; 戻り値は stat
; hwndParent : HWND optional -> "sptr"
; DeviceInfoSet : HDEVINFO -> "sptr"
; DeviceInfoData : SP_DEVINFO_DATA* -> "sptr"
; Flags : DWORD -> "sptr"
; NeedReboot : BOOL* optional, out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "newdev.dll" #cfunc global DiShowUpdateDevice "DiShowUpdateDevice" sptr, sptr, var, int, var ; res = DiShowUpdateDevice(hwndParent, DeviceInfoSet, DeviceInfoData, Flags, NeedReboot) ; hwndParent : HWND optional -> "sptr" ; DeviceInfoSet : HDEVINFO -> "sptr" ; DeviceInfoData : SP_DEVINFO_DATA* -> "var" ; Flags : DWORD -> "int" ; NeedReboot : BOOL* optional, out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "newdev.dll" #cfunc global DiShowUpdateDevice "DiShowUpdateDevice" sptr, sptr, sptr, int, sptr ; res = DiShowUpdateDevice(hwndParent, DeviceInfoSet, varptr(DeviceInfoData), Flags, varptr(NeedReboot)) ; hwndParent : HWND optional -> "sptr" ; DeviceInfoSet : HDEVINFO -> "sptr" ; DeviceInfoData : SP_DEVINFO_DATA* -> "sptr" ; Flags : DWORD -> "int" ; NeedReboot : BOOL* optional, out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; BOOL DiShowUpdateDevice(HWND hwndParent, HDEVINFO DeviceInfoSet, SP_DEVINFO_DATA* DeviceInfoData, DWORD Flags, BOOL* NeedReboot) #uselib "newdev.dll" #cfunc global DiShowUpdateDevice "DiShowUpdateDevice" intptr, intptr, var, int, var ; res = DiShowUpdateDevice(hwndParent, DeviceInfoSet, DeviceInfoData, Flags, NeedReboot) ; hwndParent : HWND optional -> "intptr" ; DeviceInfoSet : HDEVINFO -> "intptr" ; DeviceInfoData : SP_DEVINFO_DATA* -> "var" ; Flags : DWORD -> "int" ; NeedReboot : BOOL* optional, out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; BOOL DiShowUpdateDevice(HWND hwndParent, HDEVINFO DeviceInfoSet, SP_DEVINFO_DATA* DeviceInfoData, DWORD Flags, BOOL* NeedReboot) #uselib "newdev.dll" #cfunc global DiShowUpdateDevice "DiShowUpdateDevice" intptr, intptr, intptr, int, intptr ; res = DiShowUpdateDevice(hwndParent, DeviceInfoSet, varptr(DeviceInfoData), Flags, varptr(NeedReboot)) ; hwndParent : HWND optional -> "intptr" ; DeviceInfoSet : HDEVINFO -> "intptr" ; DeviceInfoData : SP_DEVINFO_DATA* -> "intptr" ; Flags : DWORD -> "int" ; NeedReboot : BOOL* optional, out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
newdev = windows.NewLazySystemDLL("newdev.dll")
procDiShowUpdateDevice = newdev.NewProc("DiShowUpdateDevice")
)
// hwndParent (HWND optional), DeviceInfoSet (HDEVINFO), DeviceInfoData (SP_DEVINFO_DATA*), Flags (DWORD), NeedReboot (BOOL* optional, out)
r1, _, err := procDiShowUpdateDevice.Call(
uintptr(hwndParent),
uintptr(DeviceInfoSet),
uintptr(DeviceInfoData),
uintptr(Flags),
uintptr(NeedReboot),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction DiShowUpdateDevice(
hwndParent: THandle; // HWND optional
DeviceInfoSet: NativeInt; // HDEVINFO
DeviceInfoData: Pointer; // SP_DEVINFO_DATA*
Flags: DWORD; // DWORD
NeedReboot: Pointer // BOOL* optional, out
): BOOL; stdcall;
external 'newdev.dll' name 'DiShowUpdateDevice';result := DllCall("newdev\DiShowUpdateDevice"
, "Ptr", hwndParent ; HWND optional
, "Ptr", DeviceInfoSet ; HDEVINFO
, "Ptr", DeviceInfoData ; SP_DEVINFO_DATA*
, "UInt", Flags ; DWORD
, "Ptr", NeedReboot ; BOOL* optional, out
, "Int") ; return: BOOL●DiShowUpdateDevice(hwndParent, DeviceInfoSet, DeviceInfoData, Flags, NeedReboot) = DLL("newdev.dll", "bool DiShowUpdateDevice(void*, int, void*, dword, void*)")
# 呼び出し: DiShowUpdateDevice(hwndParent, DeviceInfoSet, DeviceInfoData, Flags, NeedReboot)
# hwndParent : HWND optional -> "void*"
# DeviceInfoSet : HDEVINFO -> "int"
# DeviceInfoData : SP_DEVINFO_DATA* -> "void*"
# Flags : DWORD -> "dword"
# NeedReboot : BOOL* optional, out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "newdev" fn DiShowUpdateDevice(
hwndParent: ?*anyopaque, // HWND optional
DeviceInfoSet: isize, // HDEVINFO
DeviceInfoData: [*c]SP_DEVINFO_DATA, // SP_DEVINFO_DATA*
Flags: u32, // DWORD
NeedReboot: [*c]i32 // BOOL* optional, out
) callconv(std.os.windows.WINAPI) i32;proc DiShowUpdateDevice(
hwndParent: pointer, # HWND optional
DeviceInfoSet: int, # HDEVINFO
DeviceInfoData: ptr SP_DEVINFO_DATA, # SP_DEVINFO_DATA*
Flags: uint32, # DWORD
NeedReboot: ptr int32 # BOOL* optional, out
): int32 {.importc: "DiShowUpdateDevice", stdcall, dynlib: "newdev.dll".}pragma(lib, "newdev");
extern(Windows)
int DiShowUpdateDevice(
void* hwndParent, // HWND optional
ptrdiff_t DeviceInfoSet, // HDEVINFO
SP_DEVINFO_DATA* DeviceInfoData, // SP_DEVINFO_DATA*
uint Flags, // DWORD
int* NeedReboot // BOOL* optional, out
);ccall((:DiShowUpdateDevice, "newdev.dll"), stdcall, Int32,
(Ptr{Cvoid}, Int, Ptr{SP_DEVINFO_DATA}, UInt32, Ptr{Int32}),
hwndParent, DeviceInfoSet, DeviceInfoData, Flags, NeedReboot)
# hwndParent : HWND optional -> Ptr{Cvoid}
# DeviceInfoSet : HDEVINFO -> Int
# DeviceInfoData : SP_DEVINFO_DATA* -> Ptr{SP_DEVINFO_DATA}
# Flags : DWORD -> UInt32
# NeedReboot : BOOL* optional, out -> Ptr{Int32}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t DiShowUpdateDevice(
void* hwndParent,
intptr_t DeviceInfoSet,
void* DeviceInfoData,
uint32_t Flags,
int32_t* NeedReboot);
]]
local newdev = ffi.load("newdev")
-- newdev.DiShowUpdateDevice(hwndParent, DeviceInfoSet, DeviceInfoData, Flags, NeedReboot)
-- hwndParent : HWND optional
-- DeviceInfoSet : HDEVINFO
-- DeviceInfoData : SP_DEVINFO_DATA*
-- Flags : DWORD
-- NeedReboot : BOOL* optional, out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('newdev.dll');
const DiShowUpdateDevice = lib.func('__stdcall', 'DiShowUpdateDevice', 'int32_t', ['void *', 'intptr_t', 'void *', 'uint32_t', 'int32_t *']);
// DiShowUpdateDevice(hwndParent, DeviceInfoSet, DeviceInfoData, Flags, NeedReboot)
// hwndParent : HWND optional -> 'void *'
// DeviceInfoSet : HDEVINFO -> 'intptr_t'
// DeviceInfoData : SP_DEVINFO_DATA* -> 'void *'
// Flags : DWORD -> 'uint32_t'
// NeedReboot : BOOL* optional, out -> 'int32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("newdev.dll", {
DiShowUpdateDevice: { parameters: ["pointer", "isize", "pointer", "u32", "pointer"], result: "i32" },
});
// lib.symbols.DiShowUpdateDevice(hwndParent, DeviceInfoSet, DeviceInfoData, Flags, NeedReboot)
// hwndParent : HWND optional -> "pointer"
// DeviceInfoSet : HDEVINFO -> "isize"
// DeviceInfoData : SP_DEVINFO_DATA* -> "pointer"
// Flags : DWORD -> "u32"
// NeedReboot : BOOL* optional, out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t DiShowUpdateDevice(
void* hwndParent,
intptr_t DeviceInfoSet,
void* DeviceInfoData,
uint32_t Flags,
int32_t* NeedReboot);
C, "newdev.dll");
// $ffi->DiShowUpdateDevice(hwndParent, DeviceInfoSet, DeviceInfoData, Flags, NeedReboot);
// hwndParent : HWND optional
// DeviceInfoSet : HDEVINFO
// DeviceInfoData : SP_DEVINFO_DATA*
// Flags : DWORD
// NeedReboot : BOOL* optional, out
// 構造体/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 Newdev extends StdCallLibrary {
Newdev INSTANCE = Native.load("newdev", Newdev.class);
boolean DiShowUpdateDevice(
Pointer hwndParent, // HWND optional
long DeviceInfoSet, // HDEVINFO
Pointer DeviceInfoData, // SP_DEVINFO_DATA*
int Flags, // DWORD
IntByReference NeedReboot // BOOL* optional, out
);
}@[Link("newdev")]
lib Libnewdev
fun DiShowUpdateDevice = DiShowUpdateDevice(
hwndParent : Void*, # HWND optional
DeviceInfoSet : LibC::SSizeT, # HDEVINFO
DeviceInfoData : SP_DEVINFO_DATA*, # SP_DEVINFO_DATA*
Flags : UInt32, # DWORD
NeedReboot : Int32* # BOOL* optional, out
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef DiShowUpdateDeviceNative = Int32 Function(Pointer<Void>, IntPtr, Pointer<Void>, Uint32, Pointer<Int32>);
typedef DiShowUpdateDeviceDart = int Function(Pointer<Void>, int, Pointer<Void>, int, Pointer<Int32>);
final DiShowUpdateDevice = DynamicLibrary.open('newdev.dll')
.lookupFunction<DiShowUpdateDeviceNative, DiShowUpdateDeviceDart>('DiShowUpdateDevice');
// hwndParent : HWND optional -> Pointer<Void>
// DeviceInfoSet : HDEVINFO -> IntPtr
// DeviceInfoData : SP_DEVINFO_DATA* -> Pointer<Void>
// Flags : DWORD -> Uint32
// NeedReboot : BOOL* optional, out -> Pointer<Int32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function DiShowUpdateDevice(
hwndParent: THandle; // HWND optional
DeviceInfoSet: NativeInt; // HDEVINFO
DeviceInfoData: Pointer; // SP_DEVINFO_DATA*
Flags: DWORD; // DWORD
NeedReboot: Pointer // BOOL* optional, out
): BOOL; stdcall;
external 'newdev.dll' name 'DiShowUpdateDevice';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "DiShowUpdateDevice"
c_DiShowUpdateDevice :: Ptr () -> CIntPtr -> Ptr () -> Word32 -> Ptr CInt -> IO CInt
-- hwndParent : HWND optional -> Ptr ()
-- DeviceInfoSet : HDEVINFO -> CIntPtr
-- DeviceInfoData : SP_DEVINFO_DATA* -> Ptr ()
-- Flags : DWORD -> Word32
-- NeedReboot : BOOL* optional, out -> Ptr CInt
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let dishowupdatedevice =
foreign "DiShowUpdateDevice"
((ptr void) @-> intptr_t @-> (ptr void) @-> uint32_t @-> (ptr int32_t) @-> returning int32_t)
(* hwndParent : HWND optional -> (ptr void) *)
(* DeviceInfoSet : HDEVINFO -> intptr_t *)
(* DeviceInfoData : SP_DEVINFO_DATA* -> (ptr void) *)
(* Flags : DWORD -> uint32_t *)
(* NeedReboot : BOOL* optional, out -> (ptr int32_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library newdev (t "newdev.dll"))
(cffi:use-foreign-library newdev)
(cffi:defcfun ("DiShowUpdateDevice" di-show-update-device :convention :stdcall) :int32
(hwnd-parent :pointer) ; HWND optional
(device-info-set :int64) ; HDEVINFO
(device-info-data :pointer) ; SP_DEVINFO_DATA*
(flags :uint32) ; DWORD
(need-reboot :pointer)) ; BOOL* optional, out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $DiShowUpdateDevice = Win32::API::More->new('newdev',
'BOOL DiShowUpdateDevice(HANDLE hwndParent, LPARAM DeviceInfoSet, LPVOID DeviceInfoData, DWORD Flags, LPVOID NeedReboot)');
# my $ret = $DiShowUpdateDevice->Call($hwndParent, $DeviceInfoSet, $DeviceInfoData, $Flags, $NeedReboot);
# hwndParent : HWND optional -> HANDLE
# DeviceInfoSet : HDEVINFO -> LPARAM
# DeviceInfoData : SP_DEVINFO_DATA* -> LPVOID
# Flags : DWORD -> DWORD
# NeedReboot : BOOL* optional, out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
使用する型