The Old New Thing

Practical development throughout the evolution of Windows.

Latest posts

Nov 27, 2013
Post comments count 0
Post likes count 1

The case of the DLL that refuses to load

Raymond Chen

A customer reported that they had a problem that occurred only on some machines but not others. Their application called and the call succeeded on some machines, but failed on others with error ("The specified module could not be found"). The path was a fully-qualified path to a file that was confirmed to exist and be readable. If the command was used in the debugger to break when the DLL loads, the breakpoint does fire, but a breakpoint on Contoso's is never hit. "I think this means that the problem is not that Contoso failed to initialize, but what does it mean?" If you get a break from but no brea...

Nov 26, 2013
Post comments count 0
Post likes count 1

Why did Raymond bring a knitting bag to every meeting?

Raymond Chen

I stopped knitting a few years ago, but back when I knitted regularly, I tended to bring my knitting bag with me everywhere I went. There are a lot of idle minutes in your typical day. Waiting for the bus, waiting in line for the ATM, waiting for a meeting to start. There's not enough time in those idle minutes to do anything substantial, but it's enough time to sneak in a little bit of knitting. But there's another reason I brought a knitting bag to every meeting. Nothing says "I don't care about this meeting" like knitting.

Nov 25, 2013
Post comments count 0
Post likes count 1

My friend lived in an apartment inside a museum

Raymond Chen

One evening, I had a series of three dreams. In each one, I visited an unusual home. In the second dream, I visited the home of a friend of mine. She lived in a modern luxury apartment inside an art museum. It was a little tricky, because you could visit her only during museum hours. If you stayed past closing time, then you were locked inside the museum, and you were spending the night whether you liked it or not. On the other hand, it meant that you could go out an view the art to your heart's content without any crowds. And no, the museum did not come to life. You just got free run of a museum for the nigh...

Nov 25, 2013
Post comments count 0
Post likes count 0

Extracting GPS coordinates from a photo and plotting it on a map

Raymond Chen

Today's Little Program extracts GPS coordinates from a photo and plots it on a map. Remember, Little Programs do little to no error checking, because that's how they roll. We start with a simple function that takes a latitude and longitude and opens a Web page that highlights that coordinate. In a real program, you probably would do something more interesting with the coordinates, but I'm opening a Web page just to do something. The class is an incredibly lame wrapper around for RAII purposes. The function is where the real work happens. GPS latitude and longitude are encoded in the shell property sy...

Nov 22, 2013
Post comments count 0
Post likes count 1

How do I get the effect of CW_USEDEFAULT positioning on a window I've already created?

Raymond Chen

A customer wanted to know how to get the effect of positioning on a window that already exists. In particular, they wanted to be able to reposition a dialog box to get the cascade effect, but since you can't actually pass in a dialog template, the repositioning has to be done after the fact. (Presumably in the handler, which runs before the dialog is visible, so that there is no visible flicker.) The solution here is simple: Create a temporary invisible window with as its position and the same height and width as your dialog box. See where the window manager puts that temporary window and move your dialog...

Nov 21, 2013
Post comments count 0
Post likes count 1

How do I get the path to the default user's profile?

Raymond Chen

A customer wanted to know how to get the path to the default user's profile. On older versions of Windows, the default location of the default user's profile was . Then it moved to . Now it's in . And the location may have been customized, so in principle it could be anywhere. The function to get the default user profile's directory is is the deviously-named . But the reason I'm writing this article is not to call your attention to the function, but rather to something in the function documentation. The documentation for the function includes the strings and , so all somebody had to do was type either of ...

Nov 20, 2013
Post comments count 0
Post likes count 1

Why don't all of my documents show up when I arrange my Documents library by Name?

Raymond Chen

A customer reported that when they opened their Documents library on Windows 7, some files were missing if they selected Arrange by: Name or Arrange by: Author or in fact any arrangement other than Arrange by: Folder. What's going on? When you arrange the Documents library by anything other than Folder, the Documents library uses the content indexer to obtain results quickly, rather than kicking off a recursive disk search (ugh). (The Folder arrangement does not require a recursive search, so it can use the traditional / loop to get the results. A member of the search indexer team suggested that a common ...

Nov 19, 2013
Post comments count 0
Post likes count 2

Why is the Program Files directory called Program Files instead of just Programs?

Raymond Chen

Some people suggest that one thing Microsoft Research could do with that time machine they're working on is to go back in time and change the name of the Program Files directory to simply Programs. No, it really should be Program Files. Program Files are not the same as Programs. Programs are things like Calc, Notepad, Excel, Photoshop. They are things you run. Program Files are things like and . They are files that make programs run. If the directory were named Programs, then people who wanted to run a program would start digging into that directory and seeing a page full of weird DLL names and wonder "W...

Nov 18, 2013
Post comments count 0
Post likes count 1

My friend lived in a tiny house with an enormous garage

Raymond Chen

One evening, I had a series of three dreams. In each one, I visited an unusual home. In the first dream, I visited the home of a friend of mine. But instead of living in his condominium in the city, he lived in a house built into the side of a cliff. The house commanded a breathtaking view of the valley below, but the living quarters weren't very large. This was to his liking. "Moving in didn't take long." The top floor was a single room the size of a typical bedroom. The bottom floor was half that size. There was a six-inch-square mesh of wire covering the downstairs walls. "That lets the dog roam freely down...