ホーム › System.WindowsProgramming › NeedReboot
NeedReboot
関数インストールに再起動が必要かを判定する。
シグネチャ
// ADVPACK.dll
#include <windows.h>
BOOL NeedReboot(
DWORD dwRebootCheck
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| dwRebootCheck | DWORD | in | RunSetupCommand等が返した再起動チェック識別子。再起動が必要か判定するために渡す。 |
戻り値の型: BOOL
各言語での呼び出し定義
// ADVPACK.dll
#include <windows.h>
BOOL NeedReboot(
DWORD dwRebootCheck
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("ADVPACK.dll", ExactSpelling = true)]
static extern bool NeedReboot(
uint dwRebootCheck // DWORD
);<DllImport("ADVPACK.dll", ExactSpelling:=True)>
Public Shared Function NeedReboot(
dwRebootCheck As UInteger ' DWORD
) As <MarshalAs(UnmanagedType.Bool)> Boolean
End Function' dwRebootCheck : DWORD
Declare PtrSafe Function NeedReboot Lib "advpack" ( _
ByVal dwRebootCheck As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
NeedReboot = ctypes.windll.advpack.NeedReboot
NeedReboot.restype = wintypes.BOOL
NeedReboot.argtypes = [
wintypes.DWORD, # dwRebootCheck : DWORD
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('ADVPACK.dll')
NeedReboot = Fiddle::Function.new(
lib['NeedReboot'],
[
-Fiddle::TYPE_INT, # dwRebootCheck : DWORD
],
Fiddle::TYPE_INT)#[link(name = "advpack")]
extern "system" {
fn NeedReboot(
dwRebootCheck: u32 // DWORD
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("ADVPACK.dll")]
public static extern bool NeedReboot(uint dwRebootCheck);
"@
$api = Add-Type -MemberDefinition $sig -Name 'ADVPACK_NeedReboot' -Namespace Win32 -PassThru
# $api::NeedReboot(dwRebootCheck)#uselib "ADVPACK.dll"
#func global NeedReboot "NeedReboot" sptr
; NeedReboot dwRebootCheck ; 戻り値は stat
; dwRebootCheck : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "ADVPACK.dll"
#cfunc global NeedReboot "NeedReboot" int
; res = NeedReboot(dwRebootCheck)
; dwRebootCheck : DWORD -> "int"; BOOL NeedReboot(DWORD dwRebootCheck)
#uselib "ADVPACK.dll"
#cfunc global NeedReboot "NeedReboot" int
; res = NeedReboot(dwRebootCheck)
; dwRebootCheck : DWORD -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
advpack = windows.NewLazySystemDLL("ADVPACK.dll")
procNeedReboot = advpack.NewProc("NeedReboot")
)
// dwRebootCheck (DWORD)
r1, _, err := procNeedReboot.Call(
uintptr(dwRebootCheck),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction NeedReboot(
dwRebootCheck: DWORD // DWORD
): BOOL; stdcall;
external 'ADVPACK.dll' name 'NeedReboot';result := DllCall("ADVPACK\NeedReboot"
, "UInt", dwRebootCheck ; DWORD
, "Int") ; return: BOOL●NeedReboot(dwRebootCheck) = DLL("ADVPACK.dll", "bool NeedReboot(dword)")
# 呼び出し: NeedReboot(dwRebootCheck)
# dwRebootCheck : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "advpack" fn NeedReboot(
dwRebootCheck: u32 // DWORD
) callconv(std.os.windows.WINAPI) i32;proc NeedReboot(
dwRebootCheck: uint32 # DWORD
): int32 {.importc: "NeedReboot", stdcall, dynlib: "ADVPACK.dll".}pragma(lib, "advpack");
extern(Windows)
int NeedReboot(
uint dwRebootCheck // DWORD
);ccall((:NeedReboot, "ADVPACK.dll"), stdcall, Int32,
(UInt32,),
dwRebootCheck)
# dwRebootCheck : DWORD -> UInt32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t NeedReboot(
uint32_t dwRebootCheck);
]]
local advpack = ffi.load("advpack")
-- advpack.NeedReboot(dwRebootCheck)
-- dwRebootCheck : DWORD
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('ADVPACK.dll');
const NeedReboot = lib.func('__stdcall', 'NeedReboot', 'int32_t', ['uint32_t']);
// NeedReboot(dwRebootCheck)
// dwRebootCheck : DWORD -> 'uint32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("ADVPACK.dll", {
NeedReboot: { parameters: ["u32"], result: "i32" },
});
// lib.symbols.NeedReboot(dwRebootCheck)
// dwRebootCheck : DWORD -> "u32"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t NeedReboot(
uint32_t dwRebootCheck);
C, "ADVPACK.dll");
// $ffi->NeedReboot(dwRebootCheck);
// dwRebootCheck : DWORD
// 構造体/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 Advpack extends StdCallLibrary {
Advpack INSTANCE = Native.load("advpack", Advpack.class);
boolean NeedReboot(
int dwRebootCheck // DWORD
);
}@[Link("advpack")]
lib LibADVPACK
fun NeedReboot = NeedReboot(
dwRebootCheck : UInt32 # DWORD
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef NeedRebootNative = Int32 Function(Uint32);
typedef NeedRebootDart = int Function(int);
final NeedReboot = DynamicLibrary.open('ADVPACK.dll')
.lookupFunction<NeedRebootNative, NeedRebootDart>('NeedReboot');
// dwRebootCheck : DWORD -> Uint32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function NeedReboot(
dwRebootCheck: DWORD // DWORD
): BOOL; stdcall;
external 'ADVPACK.dll' name 'NeedReboot';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "NeedReboot"
c_NeedReboot :: Word32 -> IO CInt
-- dwRebootCheck : DWORD -> Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let needreboot =
foreign "NeedReboot"
(uint32_t @-> returning int32_t)
(* dwRebootCheck : DWORD -> uint32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library advpack (t "ADVPACK.dll"))
(cffi:use-foreign-library advpack)
(cffi:defcfun ("NeedReboot" need-reboot :convention :stdcall) :int32
(dw-reboot-check :uint32)) ; DWORD
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $NeedReboot = Win32::API::More->new('ADVPACK',
'BOOL NeedReboot(DWORD dwRebootCheck)');
# my $ret = $NeedReboot->Call($dwRebootCheck);
# dwRebootCheck : DWORD -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。