The Old New Thing
Practical development throughout the evolution of Windows.
Latest posts

Invoking commands on items in the Recycle Bin

Our old friend, the IContextMenu.

Modernizing our simple program that retrieves information about the items in the Recycle Bin

Last time, we wrote a simple program to print various properties of the items in the Recycle Bin, and we did so in the classical style, using item ID lists and s. One thing you may have noticed is that a lot of functions take the combination of an and a . In the shell namespace, operations on items usually happen by means of the pair (folder, child), and one of the common mistakes made by beginners is failing to keep track of the pairing and passing child pidls to the wrong parent folder. Even if you're not a beginner and are good at keeping track of which child pidls correspond to which parent folders, it's...

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

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?

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

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

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

A sports-related (mostly baseball) link dump.

What do SizeOfStackReserve and SizeOfStackCommit mean for a DLL?

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?

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...