Home | Blog | Software | Reviews and Features | Forum | Help | Donate | About us
topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • December 11, 2016, 03:58:29 AM
  • Proudly celebrating 10 years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: Flush system cache using AHK (NtSetSystemInformation API)  (Read 4199 times)

strictlyfocused02

  • Participant
  • Joined in 2010
  • *
  • default avatar
  • Posts: 10
    • View Profile
    • Donate to Member
Flush system cache using AHK (NtSetSystemInformation API)
« on: June 07, 2010, 02:20:32 PM »
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.
« Last Edit: June 07, 2010, 02:33:14 PM by strictlyfocused02 »

strictlyfocused02

  • Participant
  • Joined in 2010
  • *
  • default avatar
  • Posts: 10
    • View Profile
    • Donate to Member
Re: Flush system cache using AHK (NtSetSystemInformation API)
« Reply #1 on: June 14, 2010, 01:30:59 PM »
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
« Last Edit: June 14, 2010, 02:00:14 PM by strictlyfocused02 »