• The Old New Thing

    Fees disguised as taxes

    • 16 Comments

    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

    • 19 Comments

    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)
    {
      EnterCriticalSection(&someCriticalSection);
      // +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;
      }
      LeaveCriticalSection(&someCriticalSection);
    }
    

    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

    • 24 Comments

    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?

    • 13 Comments

    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

    • 7 Comments

    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

    • 142 Comments

    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.

    • 6 Comments

    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.

    • 46 Comments

    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

    • 38 Comments

    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.)

  • The Old New Thing

    The evolution of dialog templates - Summary

    • 4 Comments

    As promised, here's the tabular version of the evolution of dialog templates. It doesn't contain any new information, but it may give you a little glimpse into how things evolved to see the small changes highlighted against each other.

    16-bit classic 32-bit classic
    16-bit extended 32-bit extended
    Header style
    8-bit item count
    coordinates
    extended style, style
    16-bit item count
    coordinates
    help ID, extended style, style
    8-bit item count
    coordinates
    help ID, extended style, style
    16-bit item count
    coordinates
    Menu ASCIIZ or ordinal UNICODEZ or ordinal
    ASCIIZ or ordinal UNICODEZ or ordinal
    Class ASCIIZ or ordinal UNICODEZ or ordinal
    ASCIIZ or ordinal UNICODEZ or ordinal
    Caption ASCIIZ UNICODEZ
    ASCIIZ UNICODEZ
    Font
    (if DS_SETFONT)
    size
    ASCIIZ font name
    size
    UNICODEZ font name
    size, weight, italic, charset
    ASCIIZ font name
    size, weight, italic, charset
    UNICODEZ font name
    Item template alignment BYTE DWORD
    BYTE DWORD
    Item templates size, position
    16-bit ID
    style
    class, ASCIIZ text/ordinal
    8-bit extra data
    size, position
    16-bit ID
    extended style, style
    class, UNICODEZ text/ordinal
    16-bit extra data
    size, position
    32-bit ID
    help ID, extended style, style
    class, ASCIIZ text/ordinal
    16-bit extra data
    size, position
    32-bit ID
    help ID, extended style, style
    class, UNICODEZ text/ordinal
    16-bit extra data
Page 375 of 419 (4,181 items) «373374375376377»