The Old New Thing

Practical development throughout the evolution of Windows.

Latest posts

What happens when applications try to copy text by sending Ctrl+C
Jun 23, 2011
Post comments count 0
Post likes count 0

What happens when applications try to copy text by sending Ctrl+C

Raymond Chen
Raymond Chen

I'm stealing this story from one of my colleagues. I remember one app from a long time ago that had a feature where you could hit a global short cut key (or something like that) to launch the dictionary. It was also smart in that it would detect the current selected text and immediately search the dictionary for that term. One day I was running a Perl script that took several hours to run. It was nearly done and for whatever I decided to launch the dictionary. It sent a Ctrl+C to my Perl script and killed it. And that's why you don't send Ctrl+C to arbitrary applications. Active Accessibility gives you ...

How do I compress files (via NTFS compression) from the command line?
Jun 22, 2011
Post comments count 0
Post likes count 0

How do I compress files (via NTFS compression) from the command line?

Raymond Chen
Raymond Chen

A customer wanted to know whether there was a way to compress files and directories (in the sense of NTFS compression) from a script or from the command line. They knew about the Properties dialog, but they wanted something scriptable. The command-line tool for this is . Type for usage information. The customer liaison was grateful for this information. Thanks for the prompt response, and yes, this will meet our customer's need to compress specific files such as *.docx under a particular directory and all its subdirectories. Um, *.docx files are already compressed. Compressing them again gains you nothing. ...

How to get Windows Media Player to single-step a video
Jun 21, 2011
Post comments count 0
Post likes count 0

How to get Windows Media Player to single-step a video

Raymond Chen
Raymond Chen

I always forget how to do this, so I'm going to write it down so I can look it up later. When a video is playing, right-click the volume control slider and select Enhancements, then Play speed settings. (Actually, it also works if you right-click the speaker icon, the Stop button, the Replay button, or the Shuffle button, but the volume control slider is the biggest target.) On the Play speed settings dialog, the single-step controls are at the bottom; they look like triangles. Update: There's an even easier way.

See you in Building 109, Conference Room A
Jun 21, 2011
Post comments count 0
Post likes count 0

See you in Building 109, Conference Room A

Raymond Chen
Raymond Chen

We saw some time ago that if somebody invites you to a meeting in Building 7, they are inviting you off campus to take a break from work. If somebody invites you to a meeting in Building 109, Conference Room A, they are inviting you to join them at the Azteca Mexican restaurant next door. Update: One of the members of the "Building 109 Conference Room A" mailing list informed me that Building 109 Conference Room A is specifically the bar at the Azteca restaurant. Update 2: Building 109 Conference Room A has its own mailing list!

In Windows, the directory is the application bundle
Jun 20, 2011
Post comments count 0
Post likes count 1

In Windows, the directory is the application bundle

Raymond Chen
Raymond Chen

Aaargh! wonders why Windows doesn't just steal the concept of bundles from Apple and package up each application with all its libraries and everything else it needs into a single directory. This is such a great idea, it's been around since the early 1990's. It's just that Windows didn't give it a cute named like bundle. It just gave it the boring name directory. In other words, it's a victim of bad marketing. Maybe we should have given it a cute name like... elfgrass. The first directory searched by the function is the directory containing the application. If you put all your supporting libraries in the same...

How do I make a window remain visible even when the user selects Show Desktop?
Jun 17, 2011
Post comments count 0
Post likes count 0

How do I make a window remain visible even when the user selects Show Desktop?

Raymond Chen
Raymond Chen

A customer had this question: I'd like to know how to get a window to remain visible, even when the user has selected Show Desktop. Right now, when the user picks Show Desktop, the desktop appears and covers my window. Um, yeah, because that's the whole point of Show Desktop: To show the desktop and get rid of all those windows that are in the way. Windows like yours. We're sorry that Windows was unprepared for a program as awesome as yours, because there's no way to mark your window as even if the user says to show the desktop instead of this window, override the user's command and show the window anyway. (...

How do I create a right-aligned toolbar button?
Jun 16, 2011
Post comments count 0
Post likes count 0

How do I create a right-aligned toolbar button?

Raymond Chen
Raymond Chen

I didn't think this was all that common a request, but it came in twice from two different customers, so I guess there are still people creating toolbars, and creating them with right-aligned buttons (even though it violates Windows user interface guidelines, though I can't find a citation right now). You may have noticed that the toolbar common control doesn't provide a facility for creating right-aligned buttons. Partly because it's a violation of the guidelines anyway, but mostly because the default state of every feature is "not implemented." Adding a feature requires work, and since there is only a finite ...

How do I convert a UTF-8 string to UTF-16 while rejecting illegal sequences?
Jun 15, 2011
Post comments count 0
Post likes count 0

How do I convert a UTF-8 string to UTF-16 while rejecting illegal sequences?

Raymond Chen
Raymond Chen

By default, when you ask to convert a UTF-8 string to UTF-16 that contains illegal sequences (such as overlong sequences), it will try to muddle through as best as it can. If you want it to treat illegal sequences as an error, pass the flag. The MSDN documentation on this subject is, to be honest, kind of hard to follow and even includes a double-negative: "The function does not drop illegal code points if the application does not set this flag." Not only is this confusing, it doesn't even say what happens to illegal code points when you omit this flag; all it says is what it doesn't do, namely that it doesn'...

Sufficiently advanced magic is indistinguishable from technology
Jun 14, 2011
Post comments count 0
Post likes count 0

Sufficiently advanced magic is indistinguishable from technology

Raymond Chen
Raymond Chen

An informal tradition in a former group was that whenever somebody bought a new car, we all went out to lunch to celebrate, but the person with the new car had to be one of the drivers. During one of our new-car trips, the proud owner of the new car showed off its fancy features. "Check this out, this car has a voice-controlled radio: Radio, On." The car radio turned on. "Radio, Select KUOW." The radio changed its station. "Radio, louder." The volume went up. But this wasn't a demonstration of voice-recognition technology. It was a magic trick. You see, the car has radio controls built into the back of th...