ホーム › Devices.DeviceAndDriverInstallation › DiShowUpdateDriver
DiShowUpdateDriver
関数指定INFを用いてデバイスドライバの更新ウィザードを表示する。
シグネチャ
// newdev.dll
#include <windows.h>
BOOL DiShowUpdateDriver(
HWND hwndParent, // optional
LPCWSTR FilePath, // optional
DWORD Flags,
BOOL* NeedReboot // optional
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hwndParent | HWND | inoptional |
| FilePath | LPCWSTR | inoptional |
| Flags | DWORD | in |
| NeedReboot | BOOL* | outoptional |
戻り値の型: BOOL
各言語での呼び出し定義
// newdev.dll
#include <windows.h>
BOOL DiShowUpdateDriver(
HWND hwndParent, // optional
LPCWSTR FilePath, // optional
DWORD Flags,
BOOL* NeedReboot // optional
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("newdev.dll", ExactSpelling = true)]
static extern bool DiShowUpdateDriver(
IntPtr hwndParent, // HWND optional
[MarshalAs(UnmanagedType.LPWStr)] string FilePath, // LPCWSTR optional
uint Flags, // DWORD
IntPtr NeedReboot // BOOL* optional, out
);<DllImport("newdev.dll", ExactSpelling:=True)>
Public Shared Function DiShowUpdateDriver(
hwndParent As IntPtr, ' HWND optional
<MarshalAs(UnmanagedType.LPWStr)> FilePath As String, ' LPCWSTR optional
Flags As UInteger, ' DWORD
NeedReboot As IntPtr ' BOOL* optional, out
) As Boolean
End Function' hwndParent : HWND optional
' FilePath : LPCWSTR optional
' Flags : DWORD
' NeedReboot : BOOL* optional, out
Declare PtrSafe Function DiShowUpdateDriver Lib "newdev" ( _
ByVal hwndParent As LongPtr, _
ByVal FilePath 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
DiShowUpdateDriver = ctypes.windll.newdev.DiShowUpdateDriver
DiShowUpdateDriver.restype = wintypes.BOOL
DiShowUpdateDriver.argtypes = [
wintypes.HANDLE, # hwndParent : HWND optional
wintypes.LPCWSTR, # FilePath : LPCWSTR optional
wintypes.DWORD, # Flags : DWORD
ctypes.c_void_p, # NeedReboot : BOOL* optional, out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('newdev.dll')
DiShowUpdateDriver = Fiddle::Function.new(
lib['DiShowUpdateDriver'],
[
Fiddle::TYPE_VOIDP, # hwndParent : HWND optional
Fiddle::TYPE_VOIDP, # FilePath : LPCWSTR optional
-Fiddle::TYPE_INT, # Flags : DWORD
Fiddle::TYPE_VOIDP, # NeedReboot : BOOL* optional, out
],
Fiddle::TYPE_INT)#[link(name = "newdev")]
extern "system" {
fn DiShowUpdateDriver(
hwndParent: *mut core::ffi::c_void, // HWND optional
FilePath: *const u16, // LPCWSTR optional
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")]
public static extern bool DiShowUpdateDriver(IntPtr hwndParent, [MarshalAs(UnmanagedType.LPWStr)] string FilePath, uint Flags, IntPtr NeedReboot);
"@
$api = Add-Type -MemberDefinition $sig -Name 'newdev_DiShowUpdateDriver' -Namespace Win32 -PassThru
# $api::DiShowUpdateDriver(hwndParent, FilePath, Flags, NeedReboot)#uselib "newdev.dll"
#func global DiShowUpdateDriver "DiShowUpdateDriver" sptr, sptr, sptr, sptr
; DiShowUpdateDriver hwndParent, FilePath, Flags, NeedReboot ; 戻り値は stat
; hwndParent : HWND optional -> "sptr"
; FilePath : LPCWSTR optional -> "sptr"
; Flags : DWORD -> "sptr"
; NeedReboot : BOOL* optional, out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "newdev.dll"
#cfunc global DiShowUpdateDriver "DiShowUpdateDriver" sptr, wstr, int, int
; res = DiShowUpdateDriver(hwndParent, FilePath, Flags, NeedReboot)
; hwndParent : HWND optional -> "sptr"
; FilePath : LPCWSTR optional -> "wstr"
; Flags : DWORD -> "int"
; NeedReboot : BOOL* optional, out -> "int"; BOOL DiShowUpdateDriver(HWND hwndParent, LPCWSTR FilePath, DWORD Flags, BOOL* NeedReboot)
#uselib "newdev.dll"
#cfunc global DiShowUpdateDriver "DiShowUpdateDriver" intptr, wstr, int, int
; res = DiShowUpdateDriver(hwndParent, FilePath, Flags, NeedReboot)
; hwndParent : HWND optional -> "intptr"
; FilePath : LPCWSTR optional -> "wstr"
; Flags : DWORD -> "int"
; NeedReboot : BOOL* optional, out -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
newdev = windows.NewLazySystemDLL("newdev.dll")
procDiShowUpdateDriver = newdev.NewProc("DiShowUpdateDriver")
)
// hwndParent (HWND optional), FilePath (LPCWSTR optional), Flags (DWORD), NeedReboot (BOOL* optional, out)
r1, _, err := procDiShowUpdateDriver.Call(
uintptr(hwndParent),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(FilePath))),
uintptr(Flags),
uintptr(NeedReboot),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction DiShowUpdateDriver(
hwndParent: THandle; // HWND optional
FilePath: PWideChar; // LPCWSTR optional
Flags: DWORD; // DWORD
NeedReboot: Pointer // BOOL* optional, out
): BOOL; stdcall;
external 'newdev.dll' name 'DiShowUpdateDriver';result := DllCall("newdev\DiShowUpdateDriver"
, "Ptr", hwndParent ; HWND optional
, "WStr", FilePath ; LPCWSTR optional
, "UInt", Flags ; DWORD
, "Ptr", NeedReboot ; BOOL* optional, out
, "Int") ; return: BOOL●DiShowUpdateDriver(hwndParent, FilePath, Flags, NeedReboot) = DLL("newdev.dll", "bool DiShowUpdateDriver(void*, char*, dword, void*)")
# 呼び出し: DiShowUpdateDriver(hwndParent, FilePath, Flags, NeedReboot)
# hwndParent : HWND optional -> "void*"
# FilePath : LPCWSTR optional -> "char*"
# Flags : DWORD -> "dword"
# NeedReboot : BOOL* optional, out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。