ホーム › System.SystemInformation › SetSystemTimeAdjustment
SetSystemTimeAdjustment
関数システム時刻の周期的な調整値を設定する。
シグネチャ
// KERNEL32.dll
#include <windows.h>
BOOL SetSystemTimeAdjustment(
DWORD dwTimeAdjustment,
BOOL bTimeAdjustmentDisabled
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| dwTimeAdjustment | DWORD | in |
| bTimeAdjustmentDisabled | BOOL | in |
戻り値の型: BOOL
各言語での呼び出し定義
// KERNEL32.dll
#include <windows.h>
BOOL SetSystemTimeAdjustment(
DWORD dwTimeAdjustment,
BOOL bTimeAdjustmentDisabled
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("KERNEL32.dll", SetLastError = true, ExactSpelling = true)]
static extern bool SetSystemTimeAdjustment(
uint dwTimeAdjustment, // DWORD
bool bTimeAdjustmentDisabled // BOOL
);<DllImport("KERNEL32.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function SetSystemTimeAdjustment(
dwTimeAdjustment As UInteger, ' DWORD
bTimeAdjustmentDisabled As Boolean ' BOOL
) As Boolean
End Function' dwTimeAdjustment : DWORD
' bTimeAdjustmentDisabled : BOOL
Declare PtrSafe Function SetSystemTimeAdjustment Lib "kernel32" ( _
ByVal dwTimeAdjustment As Long, _
ByVal bTimeAdjustmentDisabled As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
SetSystemTimeAdjustment = ctypes.windll.kernel32.SetSystemTimeAdjustment
SetSystemTimeAdjustment.restype = wintypes.BOOL
SetSystemTimeAdjustment.argtypes = [
wintypes.DWORD, # dwTimeAdjustment : DWORD
wintypes.BOOL, # bTimeAdjustmentDisabled : BOOL
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('KERNEL32.dll')
SetSystemTimeAdjustment = Fiddle::Function.new(
lib['SetSystemTimeAdjustment'],
[
-Fiddle::TYPE_INT, # dwTimeAdjustment : DWORD
Fiddle::TYPE_INT, # bTimeAdjustmentDisabled : BOOL
],
Fiddle::TYPE_INT)#[link(name = "kernel32")]
extern "system" {
fn SetSystemTimeAdjustment(
dwTimeAdjustment: u32, // DWORD
bTimeAdjustmentDisabled: i32 // BOOL
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("KERNEL32.dll", SetLastError = true)]
public static extern bool SetSystemTimeAdjustment(uint dwTimeAdjustment, bool bTimeAdjustmentDisabled);
"@
$api = Add-Type -MemberDefinition $sig -Name 'KERNEL32_SetSystemTimeAdjustment' -Namespace Win32 -PassThru
# $api::SetSystemTimeAdjustment(dwTimeAdjustment, bTimeAdjustmentDisabled)#uselib "KERNEL32.dll"
#func global SetSystemTimeAdjustment "SetSystemTimeAdjustment" sptr, sptr
; SetSystemTimeAdjustment dwTimeAdjustment, bTimeAdjustmentDisabled ; 戻り値は stat
; dwTimeAdjustment : DWORD -> "sptr"
; bTimeAdjustmentDisabled : BOOL -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "KERNEL32.dll"
#cfunc global SetSystemTimeAdjustment "SetSystemTimeAdjustment" int, int
; res = SetSystemTimeAdjustment(dwTimeAdjustment, bTimeAdjustmentDisabled)
; dwTimeAdjustment : DWORD -> "int"
; bTimeAdjustmentDisabled : BOOL -> "int"; BOOL SetSystemTimeAdjustment(DWORD dwTimeAdjustment, BOOL bTimeAdjustmentDisabled)
#uselib "KERNEL32.dll"
#cfunc global SetSystemTimeAdjustment "SetSystemTimeAdjustment" int, int
; res = SetSystemTimeAdjustment(dwTimeAdjustment, bTimeAdjustmentDisabled)
; dwTimeAdjustment : DWORD -> "int"
; bTimeAdjustmentDisabled : BOOL -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
kernel32 = windows.NewLazySystemDLL("KERNEL32.dll")
procSetSystemTimeAdjustment = kernel32.NewProc("SetSystemTimeAdjustment")
)
// dwTimeAdjustment (DWORD), bTimeAdjustmentDisabled (BOOL)
r1, _, err := procSetSystemTimeAdjustment.Call(
uintptr(dwTimeAdjustment),
uintptr(bTimeAdjustmentDisabled),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction SetSystemTimeAdjustment(
dwTimeAdjustment: DWORD; // DWORD
bTimeAdjustmentDisabled: BOOL // BOOL
): BOOL; stdcall;
external 'KERNEL32.dll' name 'SetSystemTimeAdjustment';result := DllCall("KERNEL32\SetSystemTimeAdjustment"
, "UInt", dwTimeAdjustment ; DWORD
, "Int", bTimeAdjustmentDisabled ; BOOL
, "Int") ; return: BOOL●SetSystemTimeAdjustment(dwTimeAdjustment, bTimeAdjustmentDisabled) = DLL("KERNEL32.dll", "bool SetSystemTimeAdjustment(dword, bool)")
# 呼び出し: SetSystemTimeAdjustment(dwTimeAdjustment, bTimeAdjustmentDisabled)
# dwTimeAdjustment : DWORD -> "dword"
# bTimeAdjustmentDisabled : BOOL -> "bool"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。