ホーム › System.ClrHosting › CorExitProcess
CorExitProcess
関数CLRをシャットダウンして現在のプロセスを終了する。
シグネチャ
// MSCorEE.dll
#include <windows.h>
void CorExitProcess(
INT exitCode
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| exitCode | INT | in | プロセスを終了する際の終了コード。 |
戻り値の型: void
各言語での呼び出し定義
// MSCorEE.dll
#include <windows.h>
void CorExitProcess(
INT exitCode
);[DllImport("MSCorEE.dll", ExactSpelling = true)]
static extern void CorExitProcess(
int exitCode // INT
);<DllImport("MSCorEE.dll", ExactSpelling:=True)>
Public Shared Sub CorExitProcess(
exitCode As Integer ' INT
)
End Sub' exitCode : INT
Declare PtrSafe Sub CorExitProcess Lib "mscoree" ( _
ByVal exitCode As Long)
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
CorExitProcess = ctypes.windll.mscoree.CorExitProcess
CorExitProcess.restype = None
CorExitProcess.argtypes = [
ctypes.c_int, # exitCode : INT
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('MSCorEE.dll')
CorExitProcess = Fiddle::Function.new(
lib['CorExitProcess'],
[
Fiddle::TYPE_INT, # exitCode : INT
],
Fiddle::TYPE_VOID)#[link(name = "mscoree")]
extern "system" {
fn CorExitProcess(
exitCode: i32 // INT
);
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("MSCorEE.dll")]
public static extern void CorExitProcess(int exitCode);
"@
$api = Add-Type -MemberDefinition $sig -Name 'MSCorEE_CorExitProcess' -Namespace Win32 -PassThru
# $api::CorExitProcess(exitCode)#uselib "MSCorEE.dll"
#func global CorExitProcess "CorExitProcess" sptr
; CorExitProcess exitCode
; exitCode : INT -> "sptr"#uselib "MSCorEE.dll"
#func global CorExitProcess "CorExitProcess" int
; CorExitProcess exitCode
; exitCode : INT -> "int"; void CorExitProcess(INT exitCode)
#uselib "MSCorEE.dll"
#func global CorExitProcess "CorExitProcess" int
; CorExitProcess exitCode
; exitCode : INT -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
mscoree = windows.NewLazySystemDLL("MSCorEE.dll")
procCorExitProcess = mscoree.NewProc("CorExitProcess")
)
// exitCode (INT)
r1, _, err := procCorExitProcess.Call(
uintptr(exitCode),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // voidprocedure CorExitProcess(
exitCode: Integer // INT
); stdcall;
external 'MSCorEE.dll' name 'CorExitProcess';result := DllCall("MSCorEE\CorExitProcess"
, "Int", exitCode ; INT
, "Int") ; return: void●CorExitProcess(exitCode) = DLL("MSCorEE.dll", "int CorExitProcess(int)")
# 呼び出し: CorExitProcess(exitCode)
# exitCode : INT -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "mscoree" fn CorExitProcess(
exitCode: i32 // INT
) callconv(std.os.windows.WINAPI) void;proc CorExitProcess(
exitCode: int32 # INT
) {.importc: "CorExitProcess", stdcall, dynlib: "MSCorEE.dll".}pragma(lib, "mscoree");
extern(Windows)
void CorExitProcess(
int exitCode // INT
);ccall((:CorExitProcess, "MSCorEE.dll"), stdcall, Cvoid,
(Int32,),
exitCode)
# exitCode : INT -> Int32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
void CorExitProcess(
int32_t exitCode);
]]
local mscoree = ffi.load("mscoree")
-- mscoree.CorExitProcess(exitCode)
-- exitCode : INT
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('MSCorEE.dll');
const CorExitProcess = lib.func('__stdcall', 'CorExitProcess', 'void', ['int32_t']);
// CorExitProcess(exitCode)
// exitCode : INT -> 'int32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("MSCorEE.dll", {
CorExitProcess: { parameters: ["i32"], result: "void" },
});
// lib.symbols.CorExitProcess(exitCode)
// exitCode : INT -> "i32"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
void CorExitProcess(
int32_t exitCode);
C, "MSCorEE.dll");
// $ffi->CorExitProcess(exitCode);
// exitCode : INT
// 構造体/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 Mscoree extends StdCallLibrary {
Mscoree INSTANCE = Native.load("mscoree", Mscoree.class);
void CorExitProcess(
int exitCode // INT
);
}@[Link("mscoree")]
lib LibMSCorEE
fun CorExitProcess = CorExitProcess(
exitCode : Int32 # INT
) : Void
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef CorExitProcessNative = Void Function(Int32);
typedef CorExitProcessDart = void Function(int);
final CorExitProcess = DynamicLibrary.open('MSCorEE.dll')
.lookupFunction<CorExitProcessNative, CorExitProcessDart>('CorExitProcess');
// exitCode : INT -> Int32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
procedure CorExitProcess(
exitCode: Integer // INT
); stdcall;
external 'MSCorEE.dll' name 'CorExitProcess';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "CorExitProcess"
c_CorExitProcess :: Int32 -> IO ()
-- exitCode : INT -> Int32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let corexitprocess =
foreign "CorExitProcess"
(int32_t @-> returning void)
(* exitCode : INT -> int32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library mscoree (t "MSCorEE.dll"))
(cffi:use-foreign-library mscoree)
(cffi:defcfun ("CorExitProcess" cor-exit-process :convention :stdcall) :void
(exit-code :int32)) ; INT
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $CorExitProcess = Win32::API::More->new('MSCorEE',
'void CorExitProcess(int exitCode)');
# my $ret = $CorExitProcess->Call($exitCode);
# exitCode : INT -> int
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。