The Old New Thing

Practical development throughout the evolution of Windows.

Latest posts

Sep 5, 2011
Post comments count 0
Post likes count 0

Thanks for letting me know what my ideal career and company are

Raymond Chen

When it's performance review season, all of a sudden you start getting mail about career management. What a coincidence. There are a variety of career management tools available, some mandatory, some optional. I gave one of the optional ones a shot, since it claimed to help me "manage my career and professional development", and as I already noted, I appear to have been promoted by mistake all these years, so maybe I should figure out how to get promoted for real. This particular tool sends me to the Web site of an external company that was contracted by Microsoft to provide career guidance services. I went thr...

Sep 2, 2011
Post comments count 0
Post likes count 1

What's the story with the parameters to the WM_INPUT_DEVICE_CHANGE message?

Raymond Chen

A customer found these strange macros in winuser.h: According to the documentation for the message, the is the operation code and the is a handle to the device that changed. Given that definition, the correct macro would be . What's up with the bogus macro? The macro was incorrectly defined in Windows Vista. In the Windows 7 version of the Platform SDK, the correct macro was added, but in order to avoid introducing a breaking change to existing code, the old broken macro remains in place in order to retain bug-for-bug compatibility with existing code. Even though the macro didn't work, ...

Sep 1, 2011
Post comments count 0
Post likes count 1

Invoking commands on items in the Recycle Bin

Raymond Chen

Our old friend, the IContextMenu.

Aug 31, 2011
Post comments count 0
Post likes count 1

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

Raymond Chen

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

Aug 30, 2011
Post comments count 0
Post likes count 1

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

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

Aug 29, 2011
Post comments count 0
Post likes count 1

Why can't I use PSGUID_STORAGE like a GUID?

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

Aug 26, 2011
Post comments count 0
Post likes count 1

Random musings on the introduction of long file names on FAT

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

Aug 25, 2011
Post comments count 0
Post likes count 1

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

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

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

A sports-related (mostly baseball) link dump.