Showing tag results for Code

Mar 14, 2012
Post comments count0
Post likes count0

How do I get mouse messages faster than WM_MOUSEMOVE?

Raymond Chen
Raymond Chen

We saw some time ago that the rate at which you receive messages is entirely up to how fast your program calls . But what if your program is calling as fast as it can, and it's still not fast enough? You can use the function to ask the window manager, "Hey, can you tell me about the mouse messages I missed?" I can think of two cases where yo...

Code
Mar 2, 2012
Post comments count0
Post likes count0

This isn't Highlights magazine: Sort keys and why they change

Raymond Chen
Raymond Chen

Some time ago, Ry Jones gave some examples of Quotable Raymond, including the following: How to make a good doc bug report: 1. Don't embed pictures. ... This isn't Highlights magazine. What Ry didn't realize is that his "..." totally misrepresented the message. There were actually two separate items, but he combined them into one and rep...

Code
Mar 1, 2012
Post comments count0
Post likes count0

How do I make it so that users can copy static text on a dialog box to the clipboard easily?

Raymond Chen
Raymond Chen

Given that you have a Win32 dialog box with static text in an control, how do you make it so that users can easily copy that text to the clipboard? The traditional solution is to create a borderless read-only edit control (which draws as static text by default). Add it to the tab order by setting the style, and maybe even give it a keyboard a...

Code
Feb 22, 2012
Post comments count0
Post likes count0

Instead of creating something and then trying to hide it, simply don't create it in the first place

Raymond Chen
Raymond Chen

A customer had a question, which was sort of I bet somebody got a really nice bonus for that feature in reverse. A customer is asking if there is a way to programmatically control the icons in the notification area. Specifically, they want the setting for their notification icon to be "Only show notifications" rather than "Show icon and notifi...

Code
Feb 20, 2012
Post comments count0
Post likes count0

What's the difference between Text Document, Text Document – MS-DOS Format, and Unicode Text Document?

Raymond Chen
Raymond Chen

Alasdair King asks why Wordpad has three formats, Text Document, Text Document - MS-DOS Format, and Unicode Text Document. "Isn't at least one redundant?" Recall that in Windows, three code pages have special status. Three text file formats. Three encodings. Hm... I wonder... As you might have guessed by now, the three text file formats c...

Code
Feb 17, 2012
Post comments count0
Post likes count0

How do I find out which process has a file open?

Raymond Chen
Raymond Chen

Classically, there was no way to find out which process has a file open. A file object has a reference count, and when the reference count drops to zero, the file is closed. But there's nobody keeping track of which processes own how many references. (And that's ignoring the case that the reference is not coming from a process in the first place; ...

Code
Feb 15, 2012
Post comments count0
Post likes count0

When does an icon handler shell extension get unloaded?

Raymond Chen
Raymond Chen

A customer had a question about the function. They used the function to obtain the icon for a file, and they discovered that when they asked for the icon of a particular type of file, the shell extension for the associated application was loaded. But unfortunately the third party shell extension is not getting unloaded, maybe because of a bug. Ca...

Code
Feb 10, 2012
Post comments count0
Post likes count1

Fancy use of exception handling in FormatMessage leads to repeated "discovery" of security flaw

Raymond Chen
Raymond Chen

Every so often, somebody "discovers" an alleged security vulnerability in the function. You can try it yourself: If you run this program under the debugger and you tell it to break on all exceptions, then you will find that it breaks on an access violation trying to write to an invalid address. Did you just find a buffer overflow security v...

Code
Feb 9, 2012
Post comments count0
Post likes count0

What is the effect of memory-mapped file access on GetLastError()?

Raymond Chen
Raymond Chen

A customer was using memory-mapped files and was looking for information as to whether access to the memory-mapped data modifies the value returned by . A member of the kernel team replied, "No, memory-mapped I/O does not ever change the value returned by ." That answer is simultaneously correct and wrong, a case of looking at the world through...

Code
Feb 8, 2012
Post comments count0
Post likes count0

The path-searching algorithm is not a backtracking algorithm

Raymond Chen
Raymond Chen

Suppose your PATH environment variable looks like this: Suppose that you call intending to load the library at . If the network server is down, the call will fail. Why doesn't it just skip the bad directory in the PATH and continue searching? Suppose the function skipped the bad network directory and kept searching. Suppose that the code w...

Code