Showing tag results for Code

Sep 19, 2011
Post comments count0
Post likes count1

The clipboard viewer linked list is no longer the responsibility of applications to maintain, unless they want to

Raymond Chen

Commenter Nice Clipboard Manager (with drop->clipboard) wonders why Windows still uses a linked list to inform programs about clipboard modifications. If any clipboard viewer fails to maintain the chain, then some windows won't get informed of the change, and if a clipboard viewer creates a loop in the chain, an infinite loop results. Well, ...

Code
Sep 16, 2011
Post comments count0
Post likes count1

Why can't I PostMessage the WM_COPYDATA message, but I can SendMessageTimeout it with a tiny timeout?

Raymond Chen

After receiving the explanation of what happens to a sent message when reaches its timeout, a customer found that the explanation raised another question: If the window manager waits until the receiving thread finishes processing the message, then why can't you post a message? "After all, with a very short timeout isn't all that different from ...

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