January, 2007

  • The Old New Thing

    Where did the Windows Vista wallpaper images come from?


    Windows Vista needed some new wallpapers. Where to get them? Historically, they were purchased from a professional service, which is expensive since Microsoft would need worldwide rights to reproduce (not just use) the image, and not just for a few months, but for decades. Besides, there are a lot of good amateur photographers at Microsoft who would be thrilled to have their work displayed on millions of computers all over the world.

    But why stop there? Creative Director Jenny Lam expanded the search to Flickr and contacted people who took really interesting pictures, asking them, "So, how would you like one of your photos included among the default wallpapers in Windows Vista?" The Flickr artists were excited to be a part of Windows Vista (one of them by an astonishing coincidence happened to be a beta tester), and after the lawyers had their say—because nothing is complete without lawyers getting involved—Microsoft sent the photographers on a commissioned photo shoot. Jenny tells me that these amateur photographers were great to work with. They don't have the ego problems that some professional photographers can have. (Another thing that I learned from Jenny is that photos which look great on paper do not always translate well to the screen.)

    Ultimately, Jenny studied over 50 gigabytes of low-resolution images. (Off the top of her head, she estimates that she evaluated over 10,000 images, but the math suggests it was a lot more.) About two thirds of the final wallpapers are licensed from various image libraries, with the rest split among amateur photographers recruited from Flickr, Microsoft employees who enjoy photography, and a professional photographer specifically hired for this purpose. Jenny confides that the ones from Flickr are her favorites.

    If you were wondering where those gorgeous pictures came from, the answer is many of them came from amateur photographers, regular people like you and me. (But with better taste.)

    [Update 9:15am: Long Zheng has a bit more on those wallpapers.]

  • The Old New Thing

    The undeletable Outlook folder, episode 2


    I had another undeletable Outlook folder, and all my tricks for cajoling Outlook into letting me delete it failed. I already deleted all the items in it, emptied it of offline items, deleted all the failures from my Sync Issues folder, but still I couldn't delete the folder.

    But I came up with a new trick.

    I moved the folder out of its normal location and made it a direct child of "Mailbox". As a result, it was no longer part of the list of synchronzized folders. I synchronized one more time, and then Outlook let me delete the folder.

    As I noted before, I don't know if this'll work for you, but it's another trick you can add to your bag.

    (And I still have three folders that I can't delete, despite trying both this trick and the previous one.)

  • The Old New Thing

    Email tip: Choose a subject line that is meaningful to the recipient, not to the sender


    Presumably you want the recipient to read the message. That's why you sent it. It would behoove you to select a subject line which conveys to your reader the purpose of your message. Otherwise your reader is likely to ignore it for being too vague and uninteresting.

    Here are some actual bad subject lines I've seen.

    • Customer question
    • Question about Windows XP
    • New question
    • Help needed
    • Any help will be most appreciated
    • SR#314159276358
    • A tough problem!
    • Some questions on Windows
    • Urgent: Query regarding Windows
    • Request for information - URGENT!!

    Suppose your Inbox had a hundred messages that all looked like this. Would you bother reading even one of them?

    I'm sure the subject line makes perfect sense to the person who sent the message. They have only one customer with a question, so "Question from my customer" captures the issue perfectly. But if you send this message to a list with 500 members, those other 499 people most likely will not know what your message is about based solely on the subject line.

    A good subject line would include enough information about the question so that the recipient can decide whether to read further or whether it's something they can't help with. For example, "Question about generics," or even better, "Question about covariant types in generics."

    Remember, choose a subject line that is meaningful to the person you're sending it to. It's only polite.

  • The Old New Thing

    Unusual uses for a ball-point pen: Breaking into the debugger


    Before PCI there was ISA. The pinout for ISA slots had one very convenient property: If you shorted the last two pins in an open ISA slot, you generated an NMI. (This trick is alluded to in passing in this discussion of generating crash dumps from hardware.)

    It so happened that the tip of a ball-point pen was the ideal shape for accomplishing this. You inserted the tip of the pen at the very end of an open slot (the end nearest the back of the computer) and slowly dragged it towards the front of the computer until it shorted the nearest pair of pins.


    If you had the Windows 95 debugger connected to the system (known as WDEB386), it caught the NMI and broke into the debugger. Doesn't matter if interrupts were disabled; you got your debugger. NMI stands for "non-maskable interrupt" and it's the "non-maskable" part that is important here, for it means that there's nothing that will prevent it from happening¹. Very handy if a device driver got itself stuck in an infinite loop. You could tell the real device driver developers from the posers by seeing who carried a ball-point pen with them. (I'll talk more about NMI in a future entry.)

    I was reminded of this little hardware trivia by a colleague who pointed out that his first encounter with me was me trying to break into a machine that had wedged by asking him to perform this little maneuver. Over the phone. From 1600 miles away. He was convinced it was some sort of prank.

    Bonus ISA trivia: During the transition period from ISA to PCI, motherboards supported both buses. If you looked at a computer from this era, you saw eight ISA slots and eight PCI slots... and eight brackets in the cover for the cards to mount into. How did that work? Shouldn't there be sixteen mounting brackets?

    Those PCI folks were so clever. If you looked at an ISA card from above, with the back plate of the computer facing away from you, it looked like this:  The board itself formed the vertical stroke, and the little metal mounting bracket formed the horizontal stroke. The mounting bracket on the case therefore sat slightly to the right of the ISA slot. The PCI folks made their cards a mirror image of the ISA card: If you looked at a PCI card from above, it looked like this:  The mounting bracket on the case sat to the right of the PCI slot.

    In this way, you were able to accommodate eight ISA slots and eight PCI slots with only eight mounting brackets. Each mounting bracket supported the PCI slot to its left or the ISA slot to its right.

    ¹For pedants: Yes, you could actually get a machine so badly wedged that even the NMI had no effect, but you needed the help of poorly-behaving hardware devices.

  • The Old New Thing

    EnumChildWindows already enumerates recursively


    I often see people write code that goes something like this:

    // do not use - see discussion
    void DoSomethingToWindowTree(HWND hwndRoot)
     // first do it to the window passed in
     // now do it to all the children
     EnumChildWindows(hwndRoot, DoSomethingHelper, 0);
    BOOL CALLBACK DoSomethingHelper(HWND hwnd, LPARAM lParam)
     return TRUE;

    The intent here was to perform the operation on all the windows in a window tree by operating on the root, then operating on each of the children. Operating on the children is in turn performed recursively, so that we eventually see every window in the tree.

    Except that if you actually run this function on a vaguely interesting window tree, you'll find that items get counted multiple times.

    The reason is that the EnumChildWindows function already does the recursion:

    If a child window has created child windows of its own, EnumChildWindows enumerates those windows as well.

    If you add your own recursion, then you end up counting grandchildren twice, great-grandchildren four times, and so on. The recursion is already done by EnumChildWindows; just use it.

    void DoSomethingToWindowTree(HWND hwndRoot)
     // first do it to the window passed in
     // now do it to all the descendants (children, grandchildren, etc.)
     EnumChildWindows(hwndRoot, DoSomethingHelper, 0);
    BOOL CALLBACK DoSomethingHelper(HWND hwnd, LPARAM lParam)
     return TRUE;
  • The Old New Thing

    Does Microsoft internally use MFC for writing Windows apps?


    Craig Ward figures that if he asks enough questions I might answer one of them. "Does Microsoft internally use MFC for writing Windows apps? How about VB?"

    People use whatever they decide best meets the requirements for the task at hand. That could be a batch file, a C++ program, a perl script, a web page with a bunch of JScript, use your imagination. Is the number of solutions that use MFC and VB nonzero? I don't know for sure (I'm not in the habit of taking all the programs I see and trying to figure out what language they're written in), but I'd be very surprised if somebody somewhere hasn't thrown together an MFC or VB program to do something, be it a test suite, an install script, a graphical interface over a complicated command-line tool, or something else. It's a big company. I understand that in some parts of the company they even use Macintoshes.

    I'm not going to go into details of specific projects because (3) I am not authorized to talk about it. (I gave reasons one and two two years ago.)

  • The Old New Thing

    The family technical support department: Everything is Outlook


    We're all in the same position. Since we work with computers all day, everybody in the extended family considers us the technical support department. One thing you all need to take away from your role as family technical support department is that normal people view computers completely differently from the way you and I do.

    One of my relatives calls every program Outlook.

    "I'm on the Internet checking the weather report and then Outlook keeps displaying these windows with advertisements in them."

    "I'm having trouble listening to music on Outlook."

    "How do I get Outlook to play that card game you showed me last time?"

    "I tried to save my spreadsheet and Outlook gave me this weird error message."

    Why is every program called Outlook?

    At work, this particular relative received word that the computer systems were being upgraded. The old system was a dedicated CAD system, but the new computers were PCs running CAD software and Outlook.

    "Okay, I know what CAD software is. That's what I've been doing for the past five years on the old system. Therefore, by process of elimination, everything else on the computer must be Outlook."

    When they got a home computer a year later, it didn't come with any CAD software on it. It was all Outlook.

    (One of my colleagues is in a similar position: His relatives call everything on the computer Microsoft X. It could be Microsoft Norton Utilities or Microsoft Quicken. I wouldn't be surprised if they even said Microsoft Google.)

    My colleague KC Lemson is in the unfortunate position of being the "Outlook expert" in her family, despite having not worked on Outlook for six years. It turns out that there have been a lot of versions of Outlook released since then, so her specialized knowledge is pretty badly outdated. That doesn't stop them from trying, though.

    She told me that she attended a family wedding some time ago, and heard from three separate people, "Oh, Alice [not her real name] has an Outlook question for you." The effect of this was perhaps not what those people expected, because KC spent the entire wedding trying to avoid Alice. KC explained, "If she'd just come up and asked the question herself, I probably would have been fine with it, but having such an early warning just scared me. Plus, sniff sniff, you want to be wanted for who you are and not what you know."

  • The Old New Thing

    The /MAXMEM switch doesn't set the maximum amount of memory Windows will use


    The Windows boot.ini file has a /MAXMEM switch whose name would lead you to believe that it sets the maximum amount of memory that Windows will use. But that's not what it does; the name is misleading.

    What the /MAXMEM flag really does is set the maximum physical address that Windows will scan in search of RAM. If your physical memory map contains discontiguous chunks of RAM, such as the one at the 3.5GB boundary in the sample diagram I drew a few months ago, then the amount of RAM Windows finds will be less than the /MAXMEM value you specified. For example, if there were a gap between 128MB and 256MB (said gap used by some hardware device, say), then setting /MAXMEM to 512MB would only give you 384MB of RAM. You lost 128MB of physical address space to the gap.

    What's more, Knowledge Base article Q108393 says

    Microsoft has not committed to keeping the switch in any future releases of Windows.

    In fact, Windows Vista carries through that threat. The /MAXMEM switch has no effect in Windows Vista. To try to avoid the confusion surrounding the meaning of MAXMEM, the kernel folks changed its name to TRUNCATEMEMORY. (It also specifies the physical address limit in bytes rather than megabytes.) I'm not sure the name change will really help much to dispel the confusion, though, since it still says "memory". I think they should've called it something like MAXPHYSADDR.

  • The Old New Thing

    How a bullet turns into a beep


    Here's a minor mystery:

    echo •

    That last character is U+2022. Select that line with the mouse, right-click, and select Copy to copy it to the clipboard. Now go to a command prompt and paste it and hit Enter.

    You'd expect a • to be printed, but instead you get a beep. What happened?

    Here's another clue. Run this program.

    class Mystery {
     public static void Main() {

    Hm, there's that beep again. How about this program:

    #include <stdio.h>
    #include <windows.h>
    int __cdecl main(int argc, char **argv)
     char ch;
     if (WideCharToMultiByte(CP_OEMCP, 0, L"\x2022", 1,
                             &ch,  1, NULL, NULL) == 1) {
      printf("%d\n", ch);
     return 0;

    Run this program and it prints "7".

    By now you should have figured out what's going on. In the OEM code page, the bullet character is being converted to a beep. But why is that?

    What you're seeing is MB_USEGLYPHCHARS in reverse. Michael Kaplan discussed MB_USEGLYPHCHARS a while ago. It determines whether certain characters should be treated as control characters or as printable characters when converting to Unicode. For example, it controls whether the ASCII bell character 0x07 should be converted to the Unicode bell character U+0007 or to the Unicode bullet U+2022. You need the MB_USEGLYPHCHARS flag to decide which way to go when converting to Unicode, but there is no corresponding ambiguity when converting from Unicode. When converting from Unicode, both U+0007 and U+2022 map to the ASCII bell character.

    "But converting a bullet to 0x07 is clearly wrong. I mean, who expects a printable character to turn into a control character?"

    Well, you're assuming that the code who does the conversion is going to interpret it as a control character. The code might treat it as a glyph character, like this:

    // starting with the scratch program
    PaintContent(HWND hwnd, PAINTSTRUCT *pps)
     HFONT hfPrev = SelectFont(pps->hdc, GetStockFont(OEM_FIXED_FONT));
     TextOut(pps->hdc, 0, 0, "\x07", 1);
     SelectFont(pps->hdc, hfPrev);

    Run this program and you get a happy bullet in the corner of the window. The TextOut function does not interpret control characters as control characters; it interprets them as glyphs.

    The WideCharToMultiByte function doesn't know what you're going to do with the string it produces. It converts the character and leaves you to decide what to do next. There doesn't appear to be a WC_DONTUSEGLYPHCHARS flag, so you're going to get glyph characters whether you like it or not.

    (Postscript: You can see this happening in reverse from the command prompt. Then again, since this problem is itself a reversal, I guess you could say the behavior is happening in the forward direction now... Type echo ^A where you actually type Ctrl+A where I wrote ^A. The result: A smiling face, U+263A.)

  • The Old New Thing

    If you ask an author to sign a book, you have to tell him/her what to write


    If you happen to catch me, say by stopping by my office if you happen to work at Microsoft, I'd be happy to sign your copy of my book. (There's no need to set up a formal book signing appearance in building 9; just stop by my office any time.) One of the things you don't realize as a fan waiting in line at a book signing is that when you get to the front of the line, you have to tell the author what to write.

    It's obvious once you think about it. The author doesn't know anything about you. You're just one person out of hundreds they're going to sign for today. How should they know what to write?

    So don't make the same mistake Michael Kaplan did. (I'm just teasing, Michael!) When you stop by to ask me to sign your copy of the book, give me some idea what you want me to write. I'm happy to do it, but you have to give me something to work with.

    In other book news: The publishers are working on getting the bonus chapters onto the book web site. Your patience is appreciated. And I'm seeing book reviews coming from all over, like this one from Tom Duff (who even posted the review to the book's Amazon page), and a surprise one from Martin Heller. (The surprise that Martin Heller wrote a review of my book at all, not that the review is full of surprises. I don't know if that makes sense.)

Page 1 of 4 (35 items) 1234