The Old New Thing

Practical development throughout the evolution of Windows.

Latest posts

How can I get information about the items in the Recycle Bin?
Aug 30, 2011
Post comments count 0
Post likes count 0

How can I get information about the items in the Recycle Bin?

Raymond Chen
Raymond Chen

For some reason, a lot of people are interested in programmatic access to the contents of the Recycle Bin. They never explain why they care, so it's possible that they are looking at their problem the wrong way. For example, one reason for asking, "How do I purge an item from the Recycle Bin given a path?" is that some operation in their program results in the files going into the Recycle Bin and they want them to be deleted entirely. The correct solution is to clear the flag when deleting the items in the first place. Moving to the Recycle Bin and then purging is the wrong solution because your search-and-de...

Why can't I use PSGUID_STORAGE like a GUID?
Aug 29, 2011
Post comments count 0
Post likes count 0

Why can't I use PSGUID_STORAGE like a GUID?

Raymond Chen
Raymond Chen

The header file defines a GUID called , but a customer was having trouble using it. The strange compiler error the customer referred to is the following: "I don't see what the compiler is complaining about. The parentheses appear to be properly matched before the left brace." Remember, what you see is not necessarily what the compiler sees. Let's take another look at this mysterious GUID: Well there's your problem. After the preprocessor does its substitution, the line becomes and that's not legal C/C++. (Though with a little tweaking, you can get GCC to accept it.) The symbols is intended to be...

Random musings on the introduction of long file names on FAT
Aug 26, 2011
Post comments count 0
Post likes count 0

Random musings on the introduction of long file names on FAT

Raymond Chen
Raymond Chen

Tom Keddie thinks that the format of long file names on FAT deserves an article. Fortunately, I don't have to write it; somebody else already did. So go read that article first. I'm just going to add some remarks and stories. Hi, welcome back. Coming up with the technique of setting Read-only, System, Hidden, and Volume attributes to hide LFN entries took a bit of trial and error. The volume label was the most important part, since that was enough to get 90% of programs which did low-level disk access to lay off those directory entries. The other bits were added to push the success rate ever so close to 100%...

Stupid command-line trick: Counting the number of lines in stdin
Aug 25, 2011
Post comments count 0
Post likes count 0

Stupid command-line trick: Counting the number of lines in stdin

Raymond Chen
Raymond Chen

On unix, you can use to count the number of lines in stdin. Windows doesn't come with , but there's a sneaky way to count the number of lines anyway: It is a special quirk of the command that the null string is treated as never matching. The flag reverses the sense of the test, so now it matches everything. And the flag returns the count. It's pretty convoluted, but it does work. (Remember, I provide the occasional tip on batch file programming as a public service to those forced to endure it, not as an endorsement of batch file programming.) Now come da history: Why does the command say that a nul...

Magic dirt, the fate of former professional athletes, and other sports randomness
Aug 24, 2011
Post comments count 0
Post likes count 0

Magic dirt, the fate of former professional athletes, and other sports randomness

Raymond Chen
Raymond Chen

A sports-related (mostly baseball) link dump.

What do SizeOfStackReserve and SizeOfStackCommit mean for a DLL?
Aug 24, 2011
Post comments count 0
Post likes count 0

What do SizeOfStackReserve and SizeOfStackCommit mean for a DLL?

Raymond Chen
Raymond Chen

Nothing. Those fields in the structure are meaningful only when they appear in the EXE. The values provided in DLLs are ignored. and fall into the same category. In general, flags and fields which control process settings have no effect when declared in a DLL. We've seen a few examples already, like the flag or the markers which indicate the default layout direction.

Why doesn't the Open Files list in the Shared Folders snap-in show all my open files?
Aug 23, 2011
Post comments count 0
Post likes count 0

Why doesn't the Open Files list in the Shared Folders snap-in show all my open files?

Raymond Chen
Raymond Chen

A customer wanted a way to determine which users were using specific files on their server. They fired up the Shared Folders MMC snap-in and went to the Open Files list. They found that the results were inconsistent. Some file types like and did show up in the list when they were open, but other file types like did not. The customer asked for an explanation of the inconsistency and for a list of which file types work and which ones don't. The customer is confusing two senses of the term open file. From the file system point of view, an open file is one that has an outstanding handle reference. This is differ...

You don't make something easier to find by hiding it even more deeply
Aug 22, 2011
Post comments count 0
Post likes count 0

You don't make something easier to find by hiding it even more deeply

Raymond Chen
Raymond Chen

Commenter rolfhub suggested that, to help people recover from accidentally going into Tiny Footprint Mode, the Task Manager could display a right-click context menu with an entry to return to normal mode. My initial reaction to this was Huh? Who right-clicks on nothing? Tiny Footprint Mode is itself already a bad secret hidden setting. Having the exit from the mode be a right-click menu on a blank space is a double-secret hidden setting. If I had dictatorial control over all aspects of the shell, I would put a Restore button  in the upper right corner to let people return to normal mode.

Why are the alignment requirements for SLIST_ENTRY so different on 64-bit Windows?
Aug 19, 2011
Post comments count 0
Post likes count 0

Why are the alignment requirements for SLIST_ENTRY so different on 64-bit Windows?

Raymond Chen
Raymond Chen

The function stipulates that all list items must be aligned on a boundary. For 32-bit Windows, is 8, but the structure itself does not have a attribute. Even more confusingly, the documentation for says that the 64-bit structure needs to be 16-byte aligned but says nothing about the 32-bit structure. So what are the memory alignment requirements for a 32-bit , 8 or 4? It's 8. No, 4. No wait, it's both. Officially, the alignment requirement is 8. Earlier versions of the header file did not stipulate 8-byte alignment, and changing the declaration would have resulted in existing structures which ...