The Old New Thing

How do I access a file without updating its last-access time?

The first problem with discussing file last-access time is agreeing what you mean by a file's last-access time. The file system folks have one definition of the file last-access time, namely the time the file was most recently opened and either read from or written to. This is the value retrieved by functions like , , and . The problem ...

During process termination, slim reader/writer locks are now also electrified

Some time ago I mentioned that during process termination, the gates are now electrified: If you attempt to enter a critical section that is owned by a thread that was terminated by an earlier phase of process termination, the entire process is forcibly terminated. Windows Vista introduced a new lightweight synchronization pseudo-object ...

Do not access the disk in your IContextMenu handler, no really, don't do it

We saw some time ago that the number one cause of crashes in Explorer is malware. It so happens that the number one cause of hangs in Explorer is disk access from context menu handlers (a special case of the more general principle, you can't open the file until the user tells you to open it). That's why I was amused by Memet's claim ...

Sending a window a WM_DESTROY message is like prank calling somebody pretending to be the police

A customer was trying to track down a memory leak in their program. Their leak tracking tool produced the stacks which allocated memory that was never freed, and they all seemed to come from , which is a DLL that comes with Windows. The customer naturally contacted Microsoft to report what appeared to be a memory leak in Windows. I was one ...

Why does my asynchronous I/O complete synchronously?

A customer was creating a large file and found that, even though the file was opened with and the call was being made with an structure, the I/O was nevertheless completing synchronously. Knowledge Base article 156932 covers some cases in which asynchronous I/O will be converted to synchronous I/O. And in this case, it was scenario number...

Why does my single-byte write take forever?

A customer found that a single-byte write was taking several seconds, even though the write was to a file on the local hard drive that was fully spun-up. Here's the pseudocode: The customer experimented with using asynchronous I/O, but it didn't help. The write still took a long time. Even using (and writing full sectors, naturally) didn...

The clipboard viewer linked list is no longer the responsibility of applications to maintain, unless they want to

Commenter Nice Clipboard Manager (with drop->clipboard) wonders why Windows still uses a linked list to inform programs about clipboard modifications. If any clipboard viewer fails to maintain the chain, then some windows won't get informed of the change, and if a clipboard viewer creates a loop in the chain, an infinite loop results. ...