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

QueryInformationJobObject

関数
ジョブオブジェクトの情報を照会する。
DLLKERNEL32.dll呼出規約winapiSetLastErrorあり対応OSWindows XP 以降

シグネチャ

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

BOOL QueryInformationJobObject(
    HANDLE hJob,   // optional
    JOBOBJECTINFOCLASS JobObjectInformationClass,
    void* lpJobObjectInformation,
    DWORD cbJobObjectInformationLength,
    DWORD* lpReturnLength   // optional
);

パラメーター

名前方向
hJobHANDLEinoptional
JobObjectInformationClassJOBOBJECTINFOCLASSin
lpJobObjectInformationvoid*out
cbJobObjectInformationLengthDWORDin
lpReturnLengthDWORD*outoptional

戻り値の型: BOOL

各言語での呼び出し定義

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

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

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

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

var (
	kernel32 = windows.NewLazySystemDLL("KERNEL32.dll")
	procQueryInformationJobObject = kernel32.NewProc("QueryInformationJobObject")
)

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