The Old New Thing

Practical development throughout the evolution of Windows.

Latest posts

Jul 30, 2014
Post comments count 0
Post likes count 1

If you want to be notified when your app is uninstalled, you can do that from your uninstaller

Raymond Chen

A customer had a rather strange request. "Is there a way to be notified when the user uninstalls any program from Programs and Features (formerly known as Add and Remove Programs)?" They didn't explain what they wanted to do this for, and we immediately got suspicious. It sounds like the customer is trying to do something user-hostile, like seeing that a user uninstalled a program and immediately reinstalling it. (Sort of the reverse of force-uninstalling all your competitors.) The customer failed to take into account that there are many ways of uninstalling an application that do not involve navigating to the...

Jul 29, 2014
Post comments count 0
Post likes count 1

Did the Windows 95 interface have a code name?

Raymond Chen

Commenter kinokijuf wonders whether the Windows 95 interface had a code name. Nope. We called it "the new shell" while it was under preliminary development, and when it got enabled in the builds, we just called it "the shell." (Explorer originally was named Cabinet, unrelated to the container file format of the same name. This original name lingers in the window class: CabinetWClass.)

Jul 28, 2014
Post comments count 0
Post likes count 1

Finding the shortest path to the ground while avoiding obstacles

Raymond Chen

Today's Little Program solves the following problem: Consider a two-dimensional board, tall and narrow. Into the board are nailed a number of horizontal obstacles. Place a water faucet at the top of the board and turn it on. The water will dribble down, and when it hits an obstacle, some of the water will go left and some will go right. The goal is to find the shortest path to the ground from a given starting position, counting both horizontal and vertical distance traveled. ⬤ • • • • • • • • • • &bu...

Jul 25, 2014
Post comments count 0
Post likes count 1

How do I obtain the computer manufacturer's name from C++?

Raymond Chen

Some time ago, I gave a scripting solution to the problem of obtaining the computer manufacturer and model. But what if you want to do this from C++? I could translate the script into C++, or I could just point you to Creating a WMI Application Using C++ in MSDN. In particular, one of the WMI C++ Sample Applications does exactly what you want: Example: Creating a WMI Application. The only things you need to do are

Jul 24, 2014
Post comments count 0
Post likes count 1

When I send a WM_GETFONT message to a window, why don't I get a font?

Raymond Chen

A customer reported that the message was not working. Specifically, they sent the message to a window, and they can plainly see that the window is rendering with a particular font, yet the message returns 0. Why isn't the window returning the correct font handle? The and messages are not mandatory. A window may choose to support them, or it may choose not to, or it may even choose to support one but not the other. (Though if it supports , it probably ought to support .) For example, our scroll bar program creates a custom font for the items in the list, but it does not implement the or messages. If you t...

Jul 23, 2014
Post comments count 0
Post likes count 1

When will GetSystemWindowsDirectory return something different from GetWindowsDirectory?

Raymond Chen

Most of the time, the returns the Windows directory. However, as noted in the documentation for : With Terminal Services, the Get­System­Windows­Directory function retrieves the path of the system Windows directory, while the Get­Windows­Directory function retrieves the path of a Windows directory that is private for each user. On a single-user system, Get­System­Windows­Directory is the same as Get­Windows­Directory. What's going on here, and how do I test this scenario? When Terminal Services support was being added to Windows NT 4.0 in the mid 1990's, the Termi...

Jul 22, 2014
Post comments count 0
Post likes count 1

Microspeak: Tell Mode / Ask Mode

Raymond Chen

As a product nears release, the rate of change slows down, and along the way, the ship room goes through stages known as Tell Mode and Ask Mode. In Tell Mode, any changes to the product do not require prior approval, but you are required to present your changes to the next ship room meeting and be prepared to explain and defend them. The purpose of this exercise is to get teams accustomed to the idea of having to present their changes to the ship room as a warm-up for Ask Mode. There is also the psychological aspect: If you have to present and defend your changes, you are going to be more careful about deciding ...

Jul 21, 2014
Post comments count 0
Post likes count 1

The alternate story of the time one of my colleagues debugged a line-of-business application for a package delivery service

Raymond Chen

Some people objected to the length, the structure, the metaphors, the speculation, and fabrication. So let's say they were my editors. Here's what the article might have looked like, had I taken their recommendations. (Some recommendations were to text that was also recommended cut. I applied the recommendations before cutting; the cuts are in gray.) You tell me whether you like the original or the edited version.

Jul 21, 2014
Post comments count 0
Post likes count 1

How can I get the URL to the Web page the clipboard was copied from?

Raymond Chen

When you copy content from a Web page to the clipboard and then paste it into OneNote, OneNote pastes the content but also annotates it "Pasted from ...". How does OneNote know where the content was copied from? As noted in the documentation for the HTML clipboard format, Web browsers can provide an optional property to specify the Web page the HTML was copied from. Let's write a Little Program that mimics what OneNote does, but just in plain text, because I don't want to try to parse HTML. This is much easier to do in C#, because the BCL provides most of the helper functions. First, we get the text fro...