June, 2007

  • The Old New Thing

    Points are earned by programs, not by shortcuts


    The first subtlety of the basic principle that determines which programs show up in the Start menu is something you may not have noticed when I stated it:

    Each time you launch a program, it "earns a point", and the longer you don't launch a program, the more points it loses.

    Notice that the rule talks about programs, not shortcuts.

    The "points" for a program are tallied from all the shortcuts that exist on the All Programs section of the Start menu. Many programs install multiple shortcuts, say one to the root of the All Programs menu and another to a deep folder. It doesn't matter how many shortcuts you have; if they all point to the same program, then it is that program that earns the points when you use any of the shortcuts.

    One the Start menu decides that a program has earned enough points to make it to the front page, it then has to choose which shortcut to use to represent that program. This is an easy decision if there's only one shortcut. If there are multiple shortcuts to the same program, then the most-frequently-used shortcut is selected as the one to appear on the front page of the Start menu.

    If you paid really close attention, you may have noticed a subtlety to this subtlety. We'll take that up next time.

    Please hold off your questions until the (two-week!) series is complete, because I suspect a later entry will answer them. (This series is an expansion upon the TechNet column on the same topic. If you've read the TechNet article, then a lot of this series will be review.)*


    *I wrote this last time, but that didn't stop people from asking questions anyway. I don't expect it'll work today either, but who knows, maybe you'll surprise me.

  • The Old New Thing

    Even advanced users liked the Windows XP Start menu


    In addition to testing out the Windows XP Start menu on beginners, we asked advanced users (including lots of system administrators) what they thought of it, and the response was still positive. This was kind of surprising, for advanced users tend to be resistant to change.

    In fact, system administrators like the new Start menu so much that they asked for a special "server administrators" version of the new Start menu. Explorer decides whether you get the "normal user" version or the "server administrator" version of the Start menu based on your account permissions at the time you log on for the first time.

    If your account is a member of the Administrators group when you first log onto one of the Server editions of Windows Server 2003, then Explorer sets up your defaults to be more suitable for server administration. The default pin list contains server management utilities (I forget exactly which ones, but I think "Manage Your Server" is in there somewhere), Explorer defaults to Details mode, and showing the full path in the address bar. There may be some other minor changes; I forget exactly.

  • The Old New Thing

    What determines which programs show up on the front page of the Windows XP Start menu?


    The principle is that programs you've run most often recently are the ones that show up on the front page of the Start menu. At least, that's what we started with, but it turns out that some fine-tuning was needed in order to get the experience to be more "natural".

    The basic rule is that each time you launch a program, it "earns a point", and the longer you don't launch a program, the more points it loses. The Start menu then shows the programs that have the most points. That's about all I'm going to say about the mechanics of point-winning for a variety of reasons.

    • The details of the method by which the programs on the Start menu are selected are still patent-pending.†
    • The details are also extraordinarily boring. I get drowsy every time I have to explain them.
    • Exposing the details would just encourage people to "game the system" in order to improve the placement of their programs on the Start menu.
    • Formally documenting the details would implicitly grant permission for people to rely on those details. This would prevent the Start menu designers from making adjustments to the rules (for example, to combat people who "game the system") or to scrap the process entirely and replace it with a whole new method.
    • It's not this part of the Start menu selection algorithm that puzzles people.

    After the basic rule is applied, the fine-tuning and detail-following kick in. Those are the parts that are puzzling to most people. The next several entries will go into many of the subtleties and fine-tuning behind the Start menu's list of frequently-used programs.

    Now, you may wonder about all these subtleties and whether they're really necessary, but it is these little fine-tuning steps that make the final result more useful and feel natural.

    Please hold off your questions until the (two-week!) series is complete, because I suspect a later entry will answer them. (This series is an expansion upon the TechNet column on the same topic. If you've read the TechNet article, then a lot of this series will be review.)

    Pre-emptive snarky comment

    †"Software patents suck!" It's irrelevant what your or my opinion of software patents is. So long as they are legal, they will exist, and you and I will just have to deal with it. If you want a change, write to your congressman. Support candidates whose position on software patents is compatible with yours. Complaining to me accomplishes nothing.‡ It's sad that I have to write this, but any time somebody writes the word "patent" the comments degenerate into flamology about patents. I have a few future entries about patents; the response to this article will determine whether they stay on the schedule or quietly vanish like the stories about Bob.

    ‡Well, it does accomplish something: It gives me another reason to stop blogging.*

    *Along with the people who keep bugging me about using daggers instead of asterisks. Hint: Asterisks already mean something in computer programming.

  • The Old New Thing

    It's official: The logo for the London 2012 Olympic Games is hideously ugly


    Yesterday, the organizers of the London 2012 Olympic Games unveiled their official logo, and it's officially hideous. They paid £400,000 for that? As one of my friends put it, it looks like a bunch of old people tried to imagine something that would appeal to young people. Unfortunately, they forgot that today's young people don't live in the 1980's.

  • The Old New Thing

    The meaning of a red traffic light is open to interpretation


    It seems a sure-fire way to get a lot of good comments is to write about traffic lights or crazy driving, so I'm going to combine the two and write about crazy driving at traffic lights. Then my comments will set a new record.

    My friend The Knitty Professor told me about the time the sister of one of her friends came to visit from another country. The sister was driving through the streets of Boston with my friend among the passengers, and she drove straight through a red light.

    After my friend checked that she was still alive, she pointed out politely that the traffic light they had just driven through was in fact red.

    "That's okay," the sister replied. "I'll stop at the next one."

    Update: See a comment from the Knitty Professor herself for additional clarification.

  • The Old New Thing

    Email tip: Lay off the massive email signatures


    All too often I see email like this:

    From: X

    Is there a way to turn off Q?


    Support Professional
    Microsoft Product Support Services
    Tel: +123 456 7890 Extension 1234

    Email: X@microsoft.com

    In case I am unavailable and you need urgent assistance, you can contact the following people:

    My Backup: Y, Phone: +123 456 7890 Extension 1235 or Email: Y@microsoft.com

    My Manager: Z, Phone: +123 456 7890 Extension 1236 or Email: Z@microsoft.com

    Note: If you are a customer of Microsoft, Please refer to the terms and conditions which cover the provision of support and consulting services to you/your organization. If you are not a corresponding in the course of, or in connection with a Microsoft contract or program with its own terms and conditions, Please note that no liability is accepted by Microsoft for the contents of this email.

    Not only is your email signature is longer than your message, it's also more colorful and makes greater use of boldface, so the reader's eye is going to be attracted to the signature and miss your question entirely. (This is actually a rather subdued version. I've seen much worse, with animated images in the signature.)

    Don't let your message get lost in the medium. The email signature should not draw attention away from your message. What's more, it shouldn't convey information that the reader doesn't need to know. First of all, we already know your name and email address since it's in the message header. And since this message was sent internally, we can easily look up your job title, division, telephone number, and manager's name, and the huge disclaimer at the bottom is completely unnecessary since the message is internal and wasn't sent to any of your support customers.

    The only information in the signature that we didn't already know (or couldn't already find out) is your backup, and I suspect this question could have gotten by without even that.


    Some time ago, I had a hobby of collecting hideous email signatures and organized nearly 200 of them into an online "email signature museum". If things get slow, I could trot those out.

  • The Old New Thing

    How do I inflate a bicycle tire with a potato?


    I see this all the time.

    People have a problem and have already decided what technology they're going to use to solve it, and then they hit a roadblock: The technology they picked is unsuited to the problem!

    How do I put my laptop into standby mode from VBScript?
    How do I change the user's mouse acceleration from a batch file? I changed the registry values but it doesn't take effect immediately.

    The functionality you seek is implemented in native code via Win32. At the end of the day, the solution involves calling SetSystemPowerState or SystemParametersInfo(SPI_SETMOUSE), since those are the functions that actually do the work.

    There's no law that forbids writing programs in C or C++, particularly since that's the target language for the native bits of Win32. Go ahead, write that program, and then call it from your batch file.

    Now, it's possible that you can get somebody else to play middle-man for you. For example, if you wanted to shut down the computer, you can get the shutdown.exe program to help out. And if you had chosen wisely, the technology you already decided upon may wrap the Win32 functionality inside a helper function or class, or it may provide a way of calling into native Win32 code. For example, your Visual Basic program could just call SetSystemPowerState via a platform invoke:

    Public Shared Function SetSystemPowerState(_
          fSuspend As Boolean, _
          fForce As Boolean) As Boolean
    SetSystemPowerState(True, False)

    (Note: I don't speak Visual Basic, so I may have gotten the details wrong, but I hope you get the idea.)

  • The Old New Thing

    There's no point improving the implementation of a bad idea


    IsBadXxxPtr is a bad idea and you shouldn't call it. In the comments, many people proposed changes to the function to improve the implementation. But what's the point? IsBadXxxPtr is just a bad idea. There's no point improving the implementation of a bad idea.

    On the other hand, some people suggested making it clear that IsBadXxxPtr is a bad idea by making it worse. While this is tempting in a "I'm forcing you to do the right thing" sense, it carries with it serious compatibility problems.

    There's a lot of code that uses IsBadXxxPtr even though it's a bad idea, and making IsBadXxxPtr worse would risk breaking those programs that managed to get away with it up until now. The danger of this is that people would upgrade to the next version of Windows and their program would stop working. Who do you think the blame will be placed on?

    Sure, you might tell these people, "That's because it's a bug in your program. Go contact the vendor for an update." Of course, that's assuming you can prove that the reason why the program stopped working was this IsBadXxxPtr stuff. How can you tell that that was the problem? Maybe it was caused by some other problem, possibly even a bug in Windows itself. Or is your answer just going to be "Any program that crashes must be crashing due to misuse of IsBadXxxPtr?"

    And, as I've noted before, contacting the vendor may not be enough. Most large corporations have programs that run their day-to-day operations. Some of them may have been written by a consultant ten years ago. Even if they have the source code, they may not have the expertise, resources, or simply inclination go to in and fix it. This happens more often than you think. To these customers, the behavior change is simply a regression.

    Even if you have the source code and expertise, fixing the problem may not be as simple as it looks. You may have designed your program poorly and relied on IsBadXxxPtr to cover for your failings. For example, you may have decided that "The lParam to this message is a pointer to a CUSTOMER structure, or it could just be the customer ID number. I'll use IsBadReadPtr, and if the pointer is bad, then the value must be the customer ID number." Or you may have changed the definition of a function parameter and now need to detect whether your caller is calling the "old function" or the "new one". Or it could simply be that once you remove the call to IsBadXxxPtr, your program crashes constantly because the IsBadXxxPtr was covering up for a huge number of other programming errors (such as uninitialized variables).

    "But what if I'm just using it for debugging purposes?" For debugging purposes, allow me to propose the following drop-in replacement functions:

    inline BOOL IsBadReadPtr2(CONST VOID *p, UINT_PTR cb)
      memcmp(p, p, cb);
      return FALSE;
    inline BOOL IsBadWritePtr2(LPVOID p, UINT_PTR cb)
      memmove(p, p, cb);
      return FALSE;

    It's very simple: To see if a pointer is bad for reading, just read it (and similarly writing). If the pointer is bad, the read (or write) will raise an exception, and then you can investigate the bad pointer at the point it is found. We read from the memory by comparing it to itself and write to the memory by copying it to itself. These have no effect but they do force the memory to be read or written. Of course, this trick assumes that the compiler didn't optimize out the otherwise pointless "compare memory to itself" and "copy memory to itself" operations. (Note also that the replacement IsBadWritePtr2 is not thread-safe, since another thread might be modifying the memory while we're copying it. But then again, the original IsBadWritePtr wasn't thread-safe either, so there's no loss of amenity there.)

    (As an aside: I've seen people try to write replacements for IsBadXxxPtr and end up introducing a bug along the way. There are many corner cases in this seemingly-simple family of functions.)

  • The Old New Thing

    What is the international sign for "you left something on the roof of your car"?


    Occasionally, I'll spot a car with something on its roof, the driver clearly having put it there and forgotten about it. I have just a few seconds to catch the driver's attention and make some sort of explanatory gesture. What is the international sign for "You left something on your roof"?

  • The Old New Thing

    Why does a new user get stuff on their Start menu right off the bat?


    In the initial designs for the Start menu, the list of most-frequently-used programs on the Start menu would be completely empty the first time you opened it. This was perfectly logical, since you hadn't run any programs at all yet, so nothing was frequently-used because nothing had been used at all! Perfectly logical and completely stupid-looking.

    Imagine the disappointment of people who just bought a computer. They unpack it, plug everything in, turn it on, everything looks great. Then they open the Start menu to start using their computer and they get... a blank white space. "Ha-ha! This computer can't do anything! You should have bought a Mac!"

    (In usability-speak, this is known as "the cliff": You're setting up a new computer, everything looks like it's going great, and then... you're staring at a blank screen and have no idea what to do next. The learning curve has turned into a precipice.)

    The original design attempted to make this initially-blank Start menu less stark by adding text that said, roughly, "Hey, sure, this space is blank right now, but as you run programs, they will show up here, trust me."

    Great work there. Now it's not stupid any more. Now it's stupid and ugly.

    It took a few months to figure out how to solve this problem, and ultimately we decided upon what you see in Windows XP: For brand new users, we create some "artificial points" so that the initial Start menu has a sampling of fun programs on it. The number of artificial points is carefully chosen so that they are enough points to get the programs onto the Start menu's front page, but not so many points that they overwhelm the "real" points earned by programs users run themselves. (I believe the values were chosen so that a user needs to run a program only twice to get it onto the front page on the first day.)

    Note that these "artificial points" are not given if the user was upgraded from Windows 2000. In that case, the points that the Windows 2000 Start menu used for Intellimenus were used to seed the Windows XP point system. In that way, the front page of the Start menu for an upgraded uses already reflects the programs that the user ran most often on Windows 2000.

    In the initial release of Windows XP, the "artificial points" were assigned so that the first three of the six slots on the most-frequently-used programs list were chosen by Windows and the last three by the computer manufacturer. If your copy of Windows XP was purchased at retail instead of preinstalled by the computer manufacturer, or if the computer manufacturer declined to take advantage of the three slots offered to it (something that never happened in practice), then Windows took two of the three slots that had been offered to the computer manufacturer, leaving the last slot blank. That way, the very first program you ran showed up on your Start menu immediately.

    In Windows XP Service Pack 1, the assignment of the six slots changed slightly. Two of the slots were assigned by Windows, one by the United States Department of Justice, and the last three by the computer manufacturer. (Again, if you bought your copy of Windows XP at retail, then two of the computer manufacturer slots were assigned by Windows and the last was left blank.)

Page 1 of 5 (41 items) 12345