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