Win32 API 日本語リファレンス
ホームSystem.JobObjects › SetInformationJobObject

SetInformationJobObject

関数
ジョブオブジェクトに制限や情報を設定する。
DLLKERNEL32.dll呼出規約winapiSetLastErrorあり対応OSWindows XP 以降

シグネチャ

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

BOOL SetInformationJobObject(
    HANDLE hJob,
    JOBOBJECTINFOCLASS JobObjectInformationClass,
    void* lpJobObjectInformation,
    DWORD cbJobObjectInformationLength
);

パラメーター

名前方向
hJobHANDLEin
JobObjectInformationClassJOBOBJECTINFOCLASSin
lpJobObjectInformationvoid*in
cbJobObjectInformationLengthDWORDin

戻り値の型: BOOL

各言語での呼び出し定義

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

BOOL SetInformationJobObject(
    HANDLE hJob,
    JOBOBJECTINFOCLASS JobObjectInformationClass,
    void* lpJobObjectInformation,
    DWORD cbJobObjectInformationLength
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("KERNEL32.dll", SetLastError = true, ExactSpelling = true)]
static extern bool SetInformationJobObject(
    IntPtr hJob,   // HANDLE
    int JobObjectInformationClass,   // JOBOBJECTINFOCLASS
    IntPtr lpJobObjectInformation,   // void*
    uint cbJobObjectInformationLength   // DWORD
);
<DllImport("KERNEL32.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function SetInformationJobObject(
    hJob As IntPtr,   ' HANDLE
    JobObjectInformationClass As Integer,   ' JOBOBJECTINFOCLASS
    lpJobObjectInformation As IntPtr,   ' void*
    cbJobObjectInformationLength As UInteger   ' DWORD
) As Boolean
End Function
' hJob : HANDLE
' JobObjectInformationClass : JOBOBJECTINFOCLASS
' lpJobObjectInformation : void*
' cbJobObjectInformationLength : DWORD
Declare PtrSafe Function SetInformationJobObject Lib "kernel32" ( _
    ByVal hJob As LongPtr, _
    ByVal JobObjectInformationClass As Long, _
    ByVal lpJobObjectInformation As LongPtr, _
    ByVal cbJobObjectInformationLength As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

SetInformationJobObject = ctypes.windll.kernel32.SetInformationJobObject
SetInformationJobObject.restype = wintypes.BOOL
SetInformationJobObject.argtypes = [
    wintypes.HANDLE,  # hJob : HANDLE
    ctypes.c_int,  # JobObjectInformationClass : JOBOBJECTINFOCLASS
    ctypes.POINTER(None),  # lpJobObjectInformation : void*
    wintypes.DWORD,  # cbJobObjectInformationLength : DWORD
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('KERNEL32.dll')
SetInformationJobObject = Fiddle::Function.new(
  lib['SetInformationJobObject'],
  [
    Fiddle::TYPE_VOIDP,  # hJob : HANDLE
    Fiddle::TYPE_INT,  # JobObjectInformationClass : JOBOBJECTINFOCLASS
    Fiddle::TYPE_VOIDP,  # lpJobObjectInformation : void*
    -Fiddle::TYPE_INT,  # cbJobObjectInformationLength : DWORD
  ],
  Fiddle::TYPE_INT)
#[link(name = "kernel32")]
extern "system" {
    fn SetInformationJobObject(
        hJob: *mut core::ffi::c_void,  // HANDLE
        JobObjectInformationClass: i32,  // JOBOBJECTINFOCLASS
        lpJobObjectInformation: *mut (),  // void*
        cbJobObjectInformationLength: u32  // DWORD
    ) -> 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 SetInformationJobObject(IntPtr hJob, int JobObjectInformationClass, IntPtr lpJobObjectInformation, uint cbJobObjectInformationLength);
"@
$api = Add-Type -MemberDefinition $sig -Name 'KERNEL32_SetInformationJobObject' -Namespace Win32 -PassThru
# $api::SetInformationJobObject(hJob, JobObjectInformationClass, lpJobObjectInformation, cbJobObjectInformationLength)
#uselib "KERNEL32.dll"
#func global SetInformationJobObject "SetInformationJobObject" sptr, sptr, sptr, sptr
; SetInformationJobObject hJob, JobObjectInformationClass, lpJobObjectInformation, cbJobObjectInformationLength   ; 戻り値は stat
; hJob : HANDLE -> "sptr"
; JobObjectInformationClass : JOBOBJECTINFOCLASS -> "sptr"
; lpJobObjectInformation : void* -> "sptr"
; cbJobObjectInformationLength : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "KERNEL32.dll"
#cfunc global SetInformationJobObject "SetInformationJobObject" sptr, int, sptr, int
; res = SetInformationJobObject(hJob, JobObjectInformationClass, lpJobObjectInformation, cbJobObjectInformationLength)
; hJob : HANDLE -> "sptr"
; JobObjectInformationClass : JOBOBJECTINFOCLASS -> "int"
; lpJobObjectInformation : void* -> "sptr"
; cbJobObjectInformationLength : DWORD -> "int"
; BOOL SetInformationJobObject(HANDLE hJob, JOBOBJECTINFOCLASS JobObjectInformationClass, void* lpJobObjectInformation, DWORD cbJobObjectInformationLength)
#uselib "KERNEL32.dll"
#cfunc global SetInformationJobObject "SetInformationJobObject" intptr, int, intptr, int
; res = SetInformationJobObject(hJob, JobObjectInformationClass, lpJobObjectInformation, cbJobObjectInformationLength)
; hJob : HANDLE -> "intptr"
; JobObjectInformationClass : JOBOBJECTINFOCLASS -> "int"
; lpJobObjectInformation : void* -> "intptr"
; cbJobObjectInformationLength : DWORD -> "int"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	kernel32 = windows.NewLazySystemDLL("KERNEL32.dll")
	procSetInformationJobObject = kernel32.NewProc("SetInformationJobObject")
)

// hJob (HANDLE), JobObjectInformationClass (JOBOBJECTINFOCLASS), lpJobObjectInformation (void*), cbJobObjectInformationLength (DWORD)
r1, _, err := procSetInformationJobObject.Call(
	uintptr(hJob),
	uintptr(JobObjectInformationClass),
	uintptr(lpJobObjectInformation),
	uintptr(cbJobObjectInformationLength),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function SetInformationJobObject(
  hJob: THandle;   // HANDLE
  JobObjectInformationClass: Integer;   // JOBOBJECTINFOCLASS
  lpJobObjectInformation: Pointer;   // void*
  cbJobObjectInformationLength: DWORD   // DWORD
): BOOL; stdcall;
  external 'KERNEL32.dll' name 'SetInformationJobObject';
result := DllCall("KERNEL32\SetInformationJobObject"
    , "Ptr", hJob   ; HANDLE
    , "Int", JobObjectInformationClass   ; JOBOBJECTINFOCLASS
    , "Ptr", lpJobObjectInformation   ; void*
    , "UInt", cbJobObjectInformationLength   ; DWORD
    , "Int")   ; return: BOOL
●SetInformationJobObject(hJob, JobObjectInformationClass, lpJobObjectInformation, cbJobObjectInformationLength) = DLL("KERNEL32.dll", "bool SetInformationJobObject(void*, int, void*, dword)")
# 呼び出し: SetInformationJobObject(hJob, JobObjectInformationClass, lpJobObjectInformation, cbJobObjectInformationLength)
# hJob : HANDLE -> "void*"
# JobObjectInformationClass : JOBOBJECTINFOCLASS -> "int"
# lpJobObjectInformation : void* -> "void*"
# cbJobObjectInformationLength : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。