June, 2004

  • The Old New Thing

    Why does the Links folder keep re-creating itself?


    Those of you who dislike the Links folder have probably tried to delete it, only to discover that it keeps coming back. Why is that?

    This is Internet Explorer trying to do some auto-repair. It noticed that the Links folder is missing, so it figures, "Gosh, it must be corrupted! I'd better fix the problem by creating a replacement."

    People complain that computers can't perform self-repair, and then when the software tries to perform self-repair, they get mad. "But I wanted it to stay broken." You can't win.

    The way to indicate, "Yes, I know about the Links folder, but I don't want to use it" is to hide it.

    This is extraordinarily similar to a problem some people have with Device Manager. They don't want Windows to use a particular device, so they delete it. And then it gets re-detected and added back.

    Because when you delete the device, you're saying, "Forget everything you know about this device." Then when it gets re-detected, Windows says, "Gosh, here's a device I've never seen before! The user must have bought it recently. Let me add it to the device tree so the user can use it."

    In other words, Windows behaves the way it does because the alternative is even worse: You buy a device, plug it in, and nothing happens.

    If you have a device that you don't want Windows to use, go into the Device Manager and Disable it rather than deleting it. This means, "Yes, I know about this device, but I don't want to use it."

  • The Old New Thing

    Fees disguised as taxes


    It has become customary in the telecommunications industry to quote a low price and then add half as much to it in "fees".

    Regulatory Programs Fee. It sure sounds like a government tax.

    It isn't.

    There's been a new round of official-sounding line items on telephone bills, which are really just ways for telephone companies to raise rates while still being able to quote a low price.

    The issue was raised as a shareholder proposal in Verizon's 2004 proxy statement. The proposal starts out sounding very much like a crackpot (perhaps because the proposer is a crackpot), and the logic is rather twisted, but the underlying theme is still there: Price hikes disguised as official-sounding fees.

    How I long for the European rule that the quoted price must accurately represent the actual amount of money you will pay, including taxes and fees. None of this "quote a low price and then add a ton of mandatory surcharges" nonsense.

  • The Old New Thing

    The difference between thread-safety and re-entrancy


    An operation is "thread-safe" if it can be performed from multiple threads safely, even if the calls happen simultaneously on multiple threads.

    An operation is re-entrant if it can be performed while the operation is already in progress (perhaps in another context). This is a stronger concept than thread-safety, because the second attempt to perform the operation can even come from within the same thread.

    Consider the following function:

    int length = 0;
    char *s = NULL;
    // Note: Since strings end with a 0, if we want to
    // add a 0, we encode it as "\0", and encode a
    // backslash as "\\".
    // WARNING! This code is buggy - do not use!
    void AddToString(int ch)
      // +1 for the character we're about to add
      // +1 for the null terminator
      char *newString = realloc(s, (length+1) * sizeof(char));
      if (newString) {
        if (ch == '\0' || ch == '\\') {
          AddToString('\\'); // escape prefix
        newString[length++] = ch;
        newString[length] = '\0';
        s = newString;

    This function is thread-safe because the critical section prevents two threads from attempting to add to the string simultaneously. However, it is not re-entrant.

    The internal call to AddToString occurs while the data structures are unstable. At the point of the call, execution re-enters the start of the function AddToString, but this time the attempt to realloc the memory will use a pointer (s) that is no longer valid. (It was invalidated by the call to realloc performed by the caller.)

  • The Old New Thing

    You can already see the bug report that led to this dialog box


    It's like stupid warning labels on consumer products: Once you read the warning label, you can already imagine the lawsuit that required the warning label to be written in the first place.

    Use that same imagination to interpret this Windows XP SP2 setup error message.

    [Dumb typo in title fixed 7:43am.]

  • The Old New Thing

    When does SHLoadInProc unload a DLL?


    The SHLoadInProc function instructs Explorer to create an instance of a particular CLSID. This causes the DLL responsible for that CLSID to be loaded.

    But when is it unloaded?

    This is one of those puzzles you should be able to figure out by thinking about it.

    Consider: The object is created by calling CoCreateInstance and then immediately releasing the returned object. That's all. Explorer pays no attention to your DLL from then on.

    With this hint, maybe now you can answer the question: When is it unloaded?

    Still don't know? Here's another hint: The issue is no longer a shell issue. Now it's a COM issue.

    When is any DLL loaded via CoCreateInstance unloaded?

    Answer: The DLL is periodically asked whether it is safe to unload. Once the DLL response in the affirmative (via S_OK), COM will unload it.

  • The Old New Thing

    Ringside seats at Fruit Fly Fight Club


    The first rule of Fruit Fly Fight Club: Flies can't talk about Fruit Fly Fight Club. Because they can't talk at all. At least not to humans.

    Researchers at Harvard Medical School took a break from studying lobster fighting and shifted their focus to fruit fly fights, and even mutant fruit fly fights.

    (Via The Annals of Improbable Research.)

    Fruit flies are strange creatures. Or perhaps it's that fruit fly researchers are strange creatures.

    One of my cousins was a fruit fly researcher. She took fruit fly testicles and squashed them and then studied them under a microscope, looking for... something... I forget. I think just finding the fruit fly testicles in the first place was accomplishment enough.

    Fruit fly researchers like to give their discoveries strange names. Typically, a gene is named after what results when you disable it. For example, a gene without which fruit flies die in two days is named Kenny, after the South Park character.

    My favorite: The gene without which fruit flies get drunk really easily is called cheap date. (That last page has several more funny gene names.)

    Yes, that's right. Fruit flies get drunk. There's a fruit fly drunk-o-meter, though I forget how it works. But one amusing aspect of fruit fly drunkenness is that just before they finally pass out, there's a big burst of activity.

    Strange gene naming has spread beyond the fruit fly world. There is a human gene named sonic hedgehog after the Sega video game character. (It's related to the fruit fly gene "hedgehog", so named because disabling it causes the fly to develop into a ball with spikes.)

  • The Old New Thing

    Suggestion box


    Post suggestions for future topics here instead of posting off-topic comments. Note that the suggestion box is emptied and read periodically so don't be surprised if your suggestion vanishes. (Note also that I am under no obligation to accept any suggestion.)

    Topics I are more inclined to cover:

    • Windows history (particularly the Windows 95 era).
    • Windows user interface programming in Win32, and shell programming in particular.
    • General programming topics (selectively).
    • Issues of general interest.
    • My personal hobbies.

    Topics I am not inclined to cover:

    • The blog software itself.  You can send feedback about .Text to its author, Scott Watermasysk.
    • Internet Explorer. You can try IE folks like Tony Schreiner, jeffdav, and Dave Massy.
    • Visual Studio.  You can try one of the Visual Studio blogs.
    • Non-software Microsoft topics, such as product support policies, marketing tactics, and hiring policy.
    • Microsoft software that isn't Windows. (Exchange, Office, ...)
    • Windows topics outside user interface programming. (Plug and Play, Terminal Services, Windows Messenger, Outlook Express, SQL, IIS, remoting, SOA...)
    • User interface programming in anything other than Win32. (Because I know nothing about it.)
    • Debugging a specific problem. (Not of general interest.)
    • Legal issues.
    • Predictions for the future. (What's the title of this blog again?)
  • The Old New Thing

    Hong Kong crocodile caught at last.


    After over half a year of eluding experts, the Hong Kong crocodile was caught at last. What amused me was that the article said that the creature had eluded an expert crocodile hunter from Australia named... John Lever? (Curiously, in this article, he is given credit for capturing the croc.)

    Not the self-proclaimed Crocodile Hunter Steve Irwin? Where's his PR department when he needs them?

  • The Old New Thing

    Monitor giving you a headache? Check the refresh rate.


    Some people are more sensitive to lower monitor refresh rates than others. Go to the display control panel and click to the Settings tab. From there, click the Advanced button and go to the Monitor tab. From there, you can adjust your screen refresh rate.

    As a rule of thumb, higher refresh rates are less likely to cause eyestrain.

    If you pick a refresh rate and your monitor goes all blooey, don't panic. Just wait fifteen seconds and the system will switch back to the original settings. (If you have a Plug and Play monitor, it's supposed to report the refresh rates it supports, but sometimes that doesn't work.)

    Note that not all refresh rates are available at all screen resolutions, so if you want to crank the rate higher, you may have to sacrifice resolution.

  • The Old New Thing

    At least it's easier than learning Finnish


    Finnish Radio station YLE offers weekly news summaries in classical Latin. Because practically nobody outside Finland would understand the news in Finnish...

    In my random travels around the Internet, I stumbled across this article on the subject of teaching Finnish to foreigners: Finnish's status as an official EU language has created demand for interpreters. Finns have long accepted that they will have to learn the languages of others, considering the language's comparatively minor exposure on the world stage. But now, others will have to learn Finnish!

    I occasionally toy with the idea of learning Finnish myself but each time conclude that it would be too much work. Though I do have as a long-term goal to learn the major modern Germanic languages. In probable order of study: English, German, Swedish, Norwegian, Dutch, Afrikaans, and Icelandic.

    (Hey, I left out Danish.)

Page 1 of 5 (45 items) 12345