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

K32QueryWorkingSet

関数
指定プロセスのワーキングセット情報を取得する。
DLLKERNEL32.dll呼出規約winapi

シグネチャ

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

BOOL K32QueryWorkingSet(
    HANDLE hProcess,
    void* pv,
    DWORD cb
);

パラメーター

名前方向
hProcessHANDLEin
pvvoid*out
cbDWORDin

戻り値の型: BOOL

各言語での呼び出し定義

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

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

K32QueryWorkingSet = ctypes.windll.kernel32.K32QueryWorkingSet
K32QueryWorkingSet.restype = wintypes.BOOL
K32QueryWorkingSet.argtypes = [
    wintypes.HANDLE,  # hProcess : HANDLE
    ctypes.POINTER(None),  # pv : void* out
    wintypes.DWORD,  # cb : DWORD
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('KERNEL32.dll')
K32QueryWorkingSet = Fiddle::Function.new(
  lib['K32QueryWorkingSet'],
  [
    Fiddle::TYPE_VOIDP,  # hProcess : HANDLE
    Fiddle::TYPE_VOIDP,  # pv : void* out
    -Fiddle::TYPE_INT,  # cb : DWORD
  ],
  Fiddle::TYPE_INT)
#[link(name = "kernel32")]
extern "system" {
    fn K32QueryWorkingSet(
        hProcess: *mut core::ffi::c_void,  // HANDLE
        pv: *mut (),  // void* out
        cb: u32  // DWORD
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("KERNEL32.dll")]
public static extern bool K32QueryWorkingSet(IntPtr hProcess, IntPtr pv, uint cb);
"@
$api = Add-Type -MemberDefinition $sig -Name 'KERNEL32_K32QueryWorkingSet' -Namespace Win32 -PassThru
# $api::K32QueryWorkingSet(hProcess, pv, cb)
#uselib "KERNEL32.dll"
#func global K32QueryWorkingSet "K32QueryWorkingSet" sptr, sptr, sptr
; K32QueryWorkingSet hProcess, pv, cb   ; 戻り値は stat
; hProcess : HANDLE -> "sptr"
; pv : void* out -> "sptr"
; cb : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "KERNEL32.dll"
#cfunc global K32QueryWorkingSet "K32QueryWorkingSet" sptr, sptr, int
; res = K32QueryWorkingSet(hProcess, pv, cb)
; hProcess : HANDLE -> "sptr"
; pv : void* out -> "sptr"
; cb : DWORD -> "int"
; BOOL K32QueryWorkingSet(HANDLE hProcess, void* pv, DWORD cb)
#uselib "KERNEL32.dll"
#cfunc global K32QueryWorkingSet "K32QueryWorkingSet" intptr, intptr, int
; res = K32QueryWorkingSet(hProcess, pv, cb)
; hProcess : HANDLE -> "intptr"
; pv : void* out -> "intptr"
; cb : DWORD -> "int"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	kernel32 = windows.NewLazySystemDLL("KERNEL32.dll")
	procK32QueryWorkingSet = kernel32.NewProc("K32QueryWorkingSet")
)

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