Path: news.mitre.org!blanket.mitre.org!agate!howland.erols.net!newsfeed.direct.ca!newshub1.home.com!news.home.com!zdc!szdc!super.zippo.com!newsp.zippo.com!news2 From: "Axel Rietschin" Newsgroups: comp.os.ms-windows.programmer.misc,comp.os.ms-windows.programmer.nt.kernel-mode,comp.os.ms-windows.programmer.win32,comp.windows,comp.windows.ms.programmer Subject: Re: Disk Cache Control Date: Fri, 7 Nov 1997 06:02:44 +0100 Organization: Zippo News Service [http://www.zippo.com] Lines: 48 Message-ID: <63u75r$bsb@news2.zippo.com> References: <199711060938.DAA00864@dfw-ix5.ix.netcom.com> <3461FF01.3DA7@cerberus-sys.com> NNTP-Posting-Host: p-122.newsdawg.com X-Newsreader: Microsoft Outlook Express 4.71.1712.3 X-MimeOLE: Produced By Microsoft MimeOLE V4.71.1712.3 Xref: news.mitre.org comp.os.ms-windows.programmer.misc:132946 comp.os.ms-windows.programmer.nt.kernel-mode:4735 comp.os.ms-windows.programmer.win32:90979 Albert P. Belle Isle wrote in message <3461FF01.3DA7@cerberus-sys.com>... >Lance Larsen wrote: >> >> Does anyone know how I can programmatically control the Windows (95/NT) disk >> caching to force a cache commit? C++ or BASIC code fragments would be greatly >> appreciated. >> >> Please include the following string in your reply so I can find it: >> 4583575C38CE4000E8 > >FlushFileBuffers( file-handle ) > >[standard Win32 API call to flush VCACHE] > and here is your code fragment: #include int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { char szStrings[2048], *p = szStrings; GetLogicalDriveStrings (sizeof szStrings, szStrings); while (*p) { if (*p > 'B' || *p > 'b') { UINT nDriveType = GetDriveType (p); if (nDriveType >= DRIVE_REMOVABLE && nDriveType != DRIVE_CDROM) { char szDev[40]; HANDLE hDevice; wsprintf (szDev, "\\\\.\\%c:", *p); if (INVALID_HANDLE_VALUE != (hDevice = CreateFile (szDev, GENERIC_WRITE, FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL))) { FlushFileBuffers (hDevice); CloseHandle (hDevice); } } } p += strlen (p) + 1; } return (0); } Axel Rietschin