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

QueryMemoryResourceNotification

関数
物理メモリリソースの現在の状態を問い合わせる。
DLLKERNEL32.dll呼出規約winapiSetLastErrorあり対応OSWindows XP 以降

シグネチャ

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

BOOL QueryMemoryResourceNotification(
    HANDLE ResourceNotificationHandle,
    BOOL* ResourceState
);

パラメーター

名前方向
ResourceNotificationHandleHANDLEin
ResourceStateBOOL*out

戻り値の型: BOOL

各言語での呼び出し定義

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

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

QueryMemoryResourceNotification = ctypes.windll.kernel32.QueryMemoryResourceNotification
QueryMemoryResourceNotification.restype = wintypes.BOOL
QueryMemoryResourceNotification.argtypes = [
    wintypes.HANDLE,  # ResourceNotificationHandle : HANDLE
    ctypes.c_void_p,  # ResourceState : BOOL* out
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))
require 'fiddle'
require 'fiddle/import'

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

var (
	kernel32 = windows.NewLazySystemDLL("KERNEL32.dll")
	procQueryMemoryResourceNotification = kernel32.NewProc("QueryMemoryResourceNotification")
)

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