Win32 API 日本語リファレンス
ホームDevices.DeviceAndDriverInstallation › SetupPromptReboot

SetupPromptReboot

関数
ファイルキューの操作完了後に再起動の要否を確認し促す。
DLLSETUPAPI.dll呼出規約winapiSetLastErrorあり対応OSWindows XP 以降

シグネチャ

// SETUPAPI.dll
#include <windows.h>

INT SetupPromptReboot(
    void* FileQueue,   // optional
    HWND Owner,   // optional
    BOOL ScanOnly
);

パラメーター

名前方向説明
FileQueuevoid*inoptional再起動要否を判定するファイルキューのハンドル。NULL可。
OwnerHWNDinoptionalプロンプトダイアログの親ウィンドウハンドル。NULL可。
ScanOnlyBOOLinTRUEなら再起動要否の判定のみ行いプロンプトを表示しない。

戻り値の型: INT

各言語での呼び出し定義

// SETUPAPI.dll
#include <windows.h>

INT SetupPromptReboot(
    void* FileQueue,   // optional
    HWND Owner,   // optional
    BOOL ScanOnly
);
[DllImport("SETUPAPI.dll", SetLastError = true, ExactSpelling = true)]
static extern int SetupPromptReboot(
    IntPtr FileQueue,   // void* optional
    IntPtr Owner,   // HWND optional
    bool ScanOnly   // BOOL
);
<DllImport("SETUPAPI.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function SetupPromptReboot(
    FileQueue As IntPtr,   ' void* optional
    Owner As IntPtr,   ' HWND optional
    ScanOnly As Boolean   ' BOOL
) As Integer
End Function
' FileQueue : void* optional
' Owner : HWND optional
' ScanOnly : BOOL
Declare PtrSafe Function SetupPromptReboot Lib "setupapi" ( _
    ByVal FileQueue As LongPtr, _
    ByVal Owner As LongPtr, _
    ByVal ScanOnly As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

SetupPromptReboot = ctypes.windll.setupapi.SetupPromptReboot
SetupPromptReboot.restype = ctypes.c_int
SetupPromptReboot.argtypes = [
    ctypes.POINTER(None),  # FileQueue : void* optional
    wintypes.HANDLE,  # Owner : HWND optional
    wintypes.BOOL,  # ScanOnly : BOOL
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('SETUPAPI.dll')
SetupPromptReboot = Fiddle::Function.new(
  lib['SetupPromptReboot'],
  [
    Fiddle::TYPE_VOIDP,  # FileQueue : void* optional
    Fiddle::TYPE_VOIDP,  # Owner : HWND optional
    Fiddle::TYPE_INT,  # ScanOnly : BOOL
  ],
  Fiddle::TYPE_INT)
#[link(name = "setupapi")]
extern "system" {
    fn SetupPromptReboot(
        FileQueue: *mut (),  // void* optional
        Owner: *mut core::ffi::c_void,  // HWND optional
        ScanOnly: i32  // BOOL
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("SETUPAPI.dll", SetLastError = true)]
public static extern int SetupPromptReboot(IntPtr FileQueue, IntPtr Owner, bool ScanOnly);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SETUPAPI_SetupPromptReboot' -Namespace Win32 -PassThru
# $api::SetupPromptReboot(FileQueue, Owner, ScanOnly)
#uselib "SETUPAPI.dll"
#func global SetupPromptReboot "SetupPromptReboot" sptr, sptr, sptr
; SetupPromptReboot FileQueue, Owner, ScanOnly   ; 戻り値は stat
; FileQueue : void* optional -> "sptr"
; Owner : HWND optional -> "sptr"
; ScanOnly : BOOL -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "SETUPAPI.dll"
#cfunc global SetupPromptReboot "SetupPromptReboot" sptr, sptr, int
; res = SetupPromptReboot(FileQueue, Owner, ScanOnly)
; FileQueue : void* optional -> "sptr"
; Owner : HWND optional -> "sptr"
; ScanOnly : BOOL -> "int"
; INT SetupPromptReboot(void* FileQueue, HWND Owner, BOOL ScanOnly)
#uselib "SETUPAPI.dll"
#cfunc global SetupPromptReboot "SetupPromptReboot" intptr, intptr, int
; res = SetupPromptReboot(FileQueue, Owner, ScanOnly)
; FileQueue : void* optional -> "intptr"
; Owner : HWND optional -> "intptr"
; ScanOnly : BOOL -> "int"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	setupapi = windows.NewLazySystemDLL("SETUPAPI.dll")
	procSetupPromptReboot = setupapi.NewProc("SetupPromptReboot")
)

// FileQueue (void* optional), Owner (HWND optional), ScanOnly (BOOL)
r1, _, err := procSetupPromptReboot.Call(
	uintptr(FileQueue),
	uintptr(Owner),
	uintptr(ScanOnly),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // INT
function SetupPromptReboot(
  FileQueue: Pointer;   // void* optional
  Owner: THandle;   // HWND optional
  ScanOnly: BOOL   // BOOL
): Integer; stdcall;
  external 'SETUPAPI.dll' name 'SetupPromptReboot';
result := DllCall("SETUPAPI\SetupPromptReboot"
    , "Ptr", FileQueue   ; void* optional
    , "Ptr", Owner   ; HWND optional
    , "Int", ScanOnly   ; BOOL
    , "Int")   ; return: INT
●SetupPromptReboot(FileQueue, Owner, ScanOnly) = DLL("SETUPAPI.dll", "int SetupPromptReboot(void*, void*, bool)")
# 呼び出し: SetupPromptReboot(FileQueue, Owner, ScanOnly)
# FileQueue : void* optional -> "void*"
# Owner : HWND optional -> "void*"
# ScanOnly : BOOL -> "bool"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

extern "setupapi" fn SetupPromptReboot(
    FileQueue: ?*anyopaque, // void* optional
    Owner: ?*anyopaque, // HWND optional
    ScanOnly: i32 // BOOL
) callconv(std.os.windows.WINAPI) i32;
proc SetupPromptReboot(
    FileQueue: pointer,  # void* optional
    Owner: pointer,  # HWND optional
    ScanOnly: int32  # BOOL
): int32 {.importc: "SetupPromptReboot", stdcall, dynlib: "SETUPAPI.dll".}
pragma(lib, "setupapi");
extern(Windows)
int SetupPromptReboot(
    void* FileQueue,   // void* optional
    void* Owner,   // HWND optional
    int ScanOnly   // BOOL
);
ccall((:SetupPromptReboot, "SETUPAPI.dll"), stdcall, Int32,
      (Ptr{Cvoid}, Ptr{Cvoid}, Int32),
      FileQueue, Owner, ScanOnly)
# FileQueue : void* optional -> Ptr{Cvoid}
# Owner : HWND optional -> Ptr{Cvoid}
# ScanOnly : BOOL -> Int32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t SetupPromptReboot(
    void* FileQueue,
    void* Owner,
    int32_t ScanOnly);
]]
local setupapi = ffi.load("setupapi")
-- setupapi.SetupPromptReboot(FileQueue, Owner, ScanOnly)
-- FileQueue : void* optional
-- Owner : HWND optional
-- ScanOnly : BOOL
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('SETUPAPI.dll');
const SetupPromptReboot = lib.func('__stdcall', 'SetupPromptReboot', 'int32_t', ['void *', 'void *', 'int32_t']);
// SetupPromptReboot(FileQueue, Owner, ScanOnly)
// FileQueue : void* optional -> 'void *'
// Owner : HWND optional -> 'void *'
// ScanOnly : BOOL -> 'int32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("SETUPAPI.dll", {
  SetupPromptReboot: { parameters: ["pointer", "pointer", "i32"], result: "i32" },
});
// lib.symbols.SetupPromptReboot(FileQueue, Owner, ScanOnly)
// FileQueue : void* optional -> "pointer"
// Owner : HWND optional -> "pointer"
// ScanOnly : BOOL -> "i32"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t SetupPromptReboot(
    void* FileQueue,
    void* Owner,
    int32_t ScanOnly);
C, "SETUPAPI.dll");
// $ffi->SetupPromptReboot(FileQueue, Owner, ScanOnly);
// FileQueue : void* optional
// Owner : HWND optional
// ScanOnly : BOOL
// 構造体/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);
    int SetupPromptReboot(
        Pointer FileQueue,   // void* optional
        Pointer Owner,   // HWND optional
        boolean ScanOnly   // BOOL
    );
}
@[Link("setupapi")]
lib LibSETUPAPI
  fun SetupPromptReboot = SetupPromptReboot(
    FileQueue : Void*,   # void* optional
    Owner : Void*,   # HWND optional
    ScanOnly : Int32   # BOOL
  ) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef SetupPromptRebootNative = Int32 Function(Pointer<Void>, Pointer<Void>, Int32);
typedef SetupPromptRebootDart = int Function(Pointer<Void>, Pointer<Void>, int);
final SetupPromptReboot = DynamicLibrary.open('SETUPAPI.dll')
    .lookupFunction<SetupPromptRebootNative, SetupPromptRebootDart>('SetupPromptReboot');
// FileQueue : void* optional -> Pointer<Void>
// Owner : HWND optional -> Pointer<Void>
// ScanOnly : BOOL -> Int32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function SetupPromptReboot(
  FileQueue: Pointer;   // void* optional
  Owner: THandle;   // HWND optional
  ScanOnly: BOOL   // BOOL
): Integer; stdcall;
  external 'SETUPAPI.dll' name 'SetupPromptReboot';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "SetupPromptReboot"
  c_SetupPromptReboot :: Ptr () -> Ptr () -> CInt -> IO Int32
-- FileQueue : void* optional -> Ptr ()
-- Owner : HWND optional -> Ptr ()
-- ScanOnly : BOOL -> CInt
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let setuppromptreboot =
  foreign "SetupPromptReboot"
    ((ptr void) @-> (ptr void) @-> int32_t @-> returning int32_t)
(* FileQueue : void* optional -> (ptr void) *)
(* Owner : HWND optional -> (ptr void) *)
(* ScanOnly : BOOL -> int32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library setupapi (t "SETUPAPI.dll"))
(cffi:use-foreign-library setupapi)

(cffi:defcfun ("SetupPromptReboot" setup-prompt-reboot :convention :stdcall) :int32
  (file-queue :pointer)   ; void* optional
  (owner :pointer)   ; HWND optional
  (scan-only :int32))   ; BOOL
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $SetupPromptReboot = Win32::API::More->new('SETUPAPI',
    'int SetupPromptReboot(LPVOID FileQueue, HANDLE Owner, BOOL ScanOnly)');
# my $ret = $SetupPromptReboot->Call($FileQueue, $Owner, $ScanOnly);
# FileQueue : void* optional -> LPVOID
# Owner : HWND optional -> HANDLE
# ScanOnly : BOOL -> BOOL
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。