ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

DonationCoder.com Software > Post New Requests Here

Flush system cache using AHK (NtSetSystemInformation API)

(1/1)

strictlyfocused02:
Im trying to write a function that when called will perform the same actions as Microsoft's CacheSet tool to flush the system cache.

Here is my non-working attempt:


--- ---p := ClearCache()

If not p
   MsgBox, Success
If p
   MsgBox, Fail`n%p%

ClearCache()
{
   k := DllCall("ntdll.dll\NtSetSystemInformation", "Str", SYSTEM_CACHE_INFORMATION, "UInt", -1, "UInt", -1)
   If not k
      k := DllCall("Kernel32.dll\GetLastError")
   Return k
}
P.S. - I dont know how much help it will be but just in case, HERE is a topic I started on the AHK forums that never amounted to much ...
P.P.S - It was recommended to me to also post the CacheSet source ... Here ... Line 257 is the start of the function Im interested in.

strictlyfocused02:
Mouser in the IRC channel was kind enough to help me out to get this far, but our collective knowledge wasnt qutie enough to finish the function.  Heres where Im at:

--- ---p := ClearCache()

ClearCache()
{
   VarSetCapacity(Var, 36)
   NumPut(-1, Var, 12, "ULong")
   NumPut(-1, Var, 16, "ULong")
   DllCall("ntdll.dll\NtSetSystemInformation", "UInt", 0x15, "UInt", &Var, "UInt", 36)
   Return
}
Anyone able to point me in the right direction?

Edit - BTW, mouser found and shared THIS with me showing the structure for what were working with here

Navigation

[0] Message Index

Go to full version