Reputation: 33445
Is there a callback in Windows which will notify my application if the total amount of System RAM has changed?
Upvotes: 1
Views: 156
Reputation: 54138
You might be able to do this via WMI, if you can pick up _InstanceCreationEvent and _InstanceDeletionEvent on class Win32_PhysicalMemory.
There is sample code here (WMI is a bear to use in C or C++, sorry - C# would be easier). Just make the query you listen on use Win32_PhysicalMemory
rather than Win32_Process
here:
hres = pSvc->ExecNotificationQueryAsync(
_bstr_t("WQL"),
_bstr_t("SELECT * "
"FROM __InstanceCreationEvent WITHIN 1 "
"WHERE TargetInstance ISA 'Win32_Process'"),
WBEM_FLAG_SEND_STATUS,
NULL,
pStubSink);
You'd also need a second call like this for __InstanceDeletionEvent
detection.
Upvotes: 3