Showing tag results for Code

Sep 15, 2011
Post comments count0
Post likes count1

What happens to a sent message when SendMessageTimeout reaches its timeout?

Raymond Chen

The function tries to send a message, but gives up if the timeout elapses. What exactly happens when the timeout elapses? It depends. The first case is if the receiving thread never received the message at all. (I.e., if during the period the sender is waiting, the receiving thread never called , , or a similar message-retrieval function which d...

Code
Sep 14, 2011
Post comments count0
Post likes count1

A common control for associating extensions is well overdue

Raymond Chen

Mark complained that a common control for associating extensions is well overdue. This is a recurring theme I see in the comments: People complaining that Windows lacks some critical feature that it in fact already has. (In the case, Windows had the feature for over two years at the time the question was asked. Maybe the SDK needs a ribbon? j/k) ...

Code
Sep 12, 2011
Post comments count0
Post likes count1

Is this a really bug with CreateWindowEx or am I just confused?

Raymond Chen

Somebody sent me email pointing out strange behavior in the function if you fail a window creation by returning −1 from the message. On the other hand, returning from seems to work just fine. "So why the difference with ?" You already know enough to solve this puzzle. You just need to connect the dots. (In fact, the person who sent ...

Code
Aug 31, 2011
Post comments count0
Post likes count1

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

Code
Aug 30, 2011
Post comments count0
Post likes count1

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

Code
Aug 29, 2011
Post comments count0
Post likes count1

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

Code
Aug 25, 2011
Post comments count0
Post likes count1

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

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

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

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