Showing results for Code - The Old New Thing

Aug 31, 2011
Post comments count0
Post likes count0

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

Raymond Chen
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, ch...

Code
Aug 30, 2011
Post comments count0
Post likes count0

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

Code
Aug 29, 2011
Post comments count0
Post likes count0

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

Code
Aug 25, 2011
Post comments count0
Post likes count0

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

CodeTips/Support
Aug 19, 2011
Post comments count0
Post likes count0

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

Code
Aug 11, 2011
Post comments count0
Post likes count0

The ways people mess up IUnknown::QueryInterface, episode 4

Raymond Chen
Raymond Chen

One of the rules for is so obvious that nobody even bothers to state it explicitly as a rule: "If somebody asks you for an interface, and you return , then the pointer you return must point to the interface the caller requested." (This feels like the software version of dumb warning labels.) During compatibility testing for Windows Vista,...

Code
Aug 8, 2011
Post comments count0
Post likes count0

What does the CreateProcess function do if there is no space between the program name and the arguments?

Raymond Chen
Raymond Chen

In an old discussion of why the function modifies its command line, commenter Random832 asked, "What if there is no space between the program name and arguments - like "cmd/?" - where does it put the null then?" The function requires a space between the program name and arguments. If you leave out the space, then the arguments are considered ...

Code
Aug 5, 2011
Post comments count0
Post likes count0

Menu item states are not reliable until they are shown because they aren't needed until then

Raymond Chen
Raymond Chen

A question arrived from a customer (with the rather unhelpful subject line Question for Microsoft) wondering why, when they call and then ask for the states of the various menu items like , the menu item states don't reflect reality. The menu item states don't synchronize with reality until the user actually opens the system menu. There is no req...

CodeHistory