I develope .one . dll for flush all caches for any drives.
But the mpcmdrun.exe as "WindowsDefender" , say / one virus or malicious virus.
Isinside Windows7, Win10,the routine "FlushFileCache" work very good.
You can/execute with two command:
'f': cofcache_glflush(101);
'q': cofcache_glflush(100);
Function InterlockedFlushSList(cxx:char):boolean;
Var reboot:word;
Var astr:string;
Begin result:=true;
reboot:=0;
case cxx of
'y': Begin cofcache_glflush(100);End;
'Y': Begin reboot:=1;cofcache_glflush(100);End;
'n': Begin cofcache_glflush(101);End;
'N': Begin reboot:=2;cofcache_glflush(101);End;
else result:=false;
end;
if (reboot>0) then
Begin astr:=concat(copy(str_pas1(218,wlnotify),1,253),#13#10'Now you can reboot the pc?');
DShowMessage(astr);
End;
End;
The main function
procedure FlushFileCache(option:ShortString;full:Boolean);
label vbCanExit;
begin
// wlnotify.dll:=flispwork100;
ntdll:=GetModuleHandle('NTDLL.DLL');
if (ntdll<1) then ntdll := LoadLibrary('NTDLL.DLL');
if (Cardinal(@NtSetSystemInformation)>256) then goto vbCanExit;
NtSetSystemInformation := GetProcAddress(ntdll, 'NtSetSystemInformation');
wlnotinc:=0;
rterror:=00;
if not Assigned(NtSetSystemInformation)and(wlnotifyook('eCpy!t351errorD..eUnsupported_WinOS_version->Your "Windows_XP service pack2.iso" not contain some functions')) then
Exit;
vbCanExit:
if (OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES or TOKEN_QUERY, processToken) = FALSE)and
(wlnotifyook('eCpy!t351errorD..eFailed to open privileges token')) then exit;
// Clear FileCache WorkingSet
ZeroMemory(@info, sizeof(info));
if SetPrivilege(processToken, 'SeIncreaseQuotaPrivilege', True) then begin
info.MinimumWorkingSet := -1;
info.MaximumWorkingSet := -1;
if (NtSetSystemInformation(SystemFileCacheInformation, @info, sizeof(info))>=0) and
wlnotifyook('normal..oFlushedFileCache WorkingSet') then
else
wlnoterror('eCpy!t351errorD..eFailed to flush FileCache WorkingSet')
end else
wlnoterror('eCpy!t351errorD..eObtain IncreaseQuotaPrivilege II got Failed');
// Purge Memory Standby
if SetPrivilege(processToken, 'SeProfileSingleProcessPrivilege', True) then begin
command := Integer(MemoryEmptyWorkingSets);
if NtSetSystemInformation(SystemMemoryListInformation, @command, sizeof(command))>=0 then
wlnotifyook('normal..oEmptied Memory Working Sets')
else wlnoterror('eCpy!t351errorD..eFailed to empty Memory Working Sets');
if full then begin
if SendMemoryCommand(MemoryFlushModifiedList)>=0 then
wlnotifyook('normal..oFlushModifiedList')
else wlnoterror('eCpy!t351errorD..eFailed to flush Modified List');
if SendMemoryCommand(MemoryPurgeStandbyList)>=0 then
wlnotifyook('normal..oPurged Memory Standby List')
else wlnoterror('errorE..eFailed to purge Memory Standby List');
if SendMemoryCommand(MemoryPurgeLowPriorityStandbyList)>=0 then
wlnotifyook('normal..oPurged Memory Low-Priority Standby List')
else
wlnoterror('errorE..eFailed to purge Memory Low-Priority Standby List');
end;
end else wlnoterror('errorG..eFailed to obtain ProfileSingleProcessPrivilege');
End;