July, 2008

  • The Old New Thing

    Theorize if you want, but if the problem is right there in front of you, why not go for the facts?

    • 29 Comments

    On an internal discussion list, somebody asked a question similar to this:

    My program launches a helper program. This helper program does different things based on the command line parameters, but the way I'm using it, it just prints its results to the console and exits. When I launch this program and wait for it to exit, my wait never completes. Why isn't the helper program exiting? Here's the code that I'm using to launch the helper process...

    It wasn't long before people chimed in with their suggestions.

    Have your main program call exit() at the end.
    If you're redirecting stdout, you may be forgetting to drain the pipe. Otherwise, if the program generates too much output, the pipe fills and the helper program blocks writing to it.
    Alas, that didn't help. Whether I redirect the output or not, the helper process still hangs.

    Eventually I had to step in.

    I can't believe I'm reading this discussion. It's like watching a room full of child psychologists arguing over why Billy is crying. They're all expounding on their pet theories, and none of them bothers to ask Billy, "Why are you crying?"

    Connect a debugger to the helper process. See why it's crying.

    You can sit around developing theories all you want, but since the problem is right there in front of you, the quickest way to figure out why the helper process isn't exiting is to connect a debugger and look at it to see why it's not exiting.

    This is like the software version of the black crayons story.

  • The Old New Thing

    The Microsoft Company Picnic has as a side effect a demonstration of Microsoft's rich cultural diversity

    • 9 Comments

    You hear parents scolding their kids in so many different languages.

  • The Old New Thing

    Windows could not properly load the XYZ keyboard layout

    • 14 Comments

    In my rôle as the family technical support department, I get to poke around without really knowing what I'm doing and hope to stumble across a solution. Sometimes I succeed; sometimes I fail.

    Today, I'm documenting one of my successes in the hope that it might come in handy for you, the technical support department for your family. (If not, then I guess today is not your day.)

    The boot drive on the laptop belonging to one of my relatives became corrupted, and her brother-in-law had the honor of extracting the drive, sticking it into a working computer, doing the chkdsk magic, reinstalling the software that got corrupted, and otherwise getting the machine back on its feet. (It's a good thing I wasn't the one to do it because all of the programs are in Chinese, and I can't read Chinese beyond a few dozen characters.) Anyway, the machine returned to life, mostly. The bizarro proprietary hardware (that a certain manufacturer insists on using in order to make their machines special) still doesn't have drivers, but it was happy for the most part.

    There was just one problem remaining, and it fell upon me to fix it: She couldn't type Chinese characters any more. Normally, this is done by selecting an appropriate IME, but no matter what we picked, it was as if we were always using the US-English keyboard.

    One clue was that if you deleted the IME and then re-added it, you got the error message Windows could not properly load the XYZ keyboard layout.

    Here is how I fixed it. (This was a Windows XP machine.) Maybe it will help you, maybe not.

    First, go to the Regional and Language Options control panel and set everything back to English (US):

    • On the Advanced tab, under "Select a language to match the language version of the non-Unicode programs you want to use", select "English (United States)".
    • On the Languages tab, under "Text services and input languages", click the Details button. Change your default input language to "English (United States) - US" and remove all the non-English keyboard layouts.

    Restart to make sure that nobody is using those old services.

    After the restart, go back to the Regional and Language Options control panel, go to the Languages tab, and uncheck "Install files for East Asian languages." That is the whole point of this exercise. All the other steps were just removing enough obstacles so we could do that.

    Restart to make sure nobody is using any of the East Asian fonts.

    After the restart, add the East Asian fonts back, and when you're asked whether you should use the files already on the machine, say "No." That way, they will be re-copied from the CD.

    (This step was trickier for me, because one of the hardware devices that didn't work was the DVD drive! I thought I was stuck, but then I realized that the wireless network antenna still was functional, so I went to another computer in the house, put the Windows XP CD in the drive, and shared out the CD-ROM drive. Then I went back to the first computer and told it to install the files from the second computer.)

    Once everything gets reinstalled (including the corrupted keyboard layout files), you can go back and add the Chinese IME back, and reset all those other settings back to Chinese.

    Neither I nor the owner of the laptop is very good at the other's native language (though she is far better at English than I am at Chinese), so fixing her computer is the best way I have of showing her my appreciation.

  • The Old New Thing

    A modest proposal: Getting people to stop buying SUVs

    • 91 Comments

    I developed this modest proposal many years ago, but it looks like rising gasoline prices have done the job. But in case they don't, here's my plan.

    SUVs are classified as "trucks" for the purpose of C.A.F.E. regulations, and those regulations are more lenient on gasoline efficiency for trucks. As a result, the auto industry happily built SUVs safe in the knowledge that high SUV sales wouldn't lower their overall fleet mileage and therefore not risk violating the CAFE regulations.

    On the other hand, most other highway regulations do not consider SUVs to be trucks. As a result, SUVs sit in this sweet spot where they get to pretend they're a truck when it's advantageous to be a truck (avoiding CAFE regulations) and pretend that they're a car when it's advantageous to be a car (highway regulations).

    My modest proposal was to get rid of this loophole. If you're going to let SUVs be classified as trucks for the purpose of determining whether they are subject to CAFE regulations, then classify them as trucks for the purpose of highway regulations. If you're driving an SUV on a highway that has different speed limits for cars as opposed to trucks, then you have to adhere to the truck speed limit. Because you're a truck. If you're driving an SUV on a highway which bans trucks from the leftmost lane, then you are banned from the leftmost lane. Because you're a truck.

    People who are driving a truck because they actually need it for truck-like activities (hauling lumber, pulling a boat, delivering baked goods, whatever) won't be seriously inconvenienced, since they're not going to be doing any of those car-like things anyway.

    If you really want to take this principle to its conclusion, you would even have to stop at the weigh stations to ensure that you're not over weight, and to check your log book (you keep a log book, right?) to ensure that you're not violating the laws regarding the maximum permitted number of hours behind the wheel of a truck. Because you're a truck.

    Of course, the loophole could be closed the other way, too: Alter CAFE to classify SUVs as cars. Either way works for me. Just make the CAFE regulations and highway regulations agree on who is a car and who is a truck.

    As I noted, it looks like economic forces have solved the problem on their own, but in case SUVs suffer a new surge in popularity, you've got my proposal in your back pocket, ready to spring into action.

    Yes, this modest proposal is out of order, but it seemed more timely than the planned topic (solving the problem of identity theft), which I will still get to next time, if there is a next time.

  • The Old New Thing

    MessageBoxIndirect loads the icon itself; you can't hand it a pre-loaded icon

    • 17 Comments

    Commenter 8 wants to know how to tell the MessageBoxIndirect function to use an existing HICON instead of pointing it to an icon resource.

    You can't.

    The MessageBoxIndirect loads the icon itself. You can't hand it a pre-loaded icon.

    Of course, it's hardly rocket science to write your own MessageBoxWithMyIcon function that lets you use whatever icon you want. There's no law that says all Yes/No dialogs must use the MessageBox function. Feel free to write your own.

    The MessageBox and MessageBoxIndirect functions are just convenience functions. They don't create new functionality; they don't do anything you couldn't already do yourself. You can have a template dialog box that you use for "generic" purposes and set the icon and text yourself. Or, if you're really adventuresome, you can generate a dialog template on the fly.

    The MessageBox and MessageBoxIndirect functions never aspired to be "everything anybody could ever do with a dialog box." They just provide some basic functionality that lots of people find useful. If you need more functionality, then you can always write it yourself. (There's already a function for "everything anybody could ever do with a standard Win32 dialog box": It's called, um, DialogBox.)

    Windows Vista introduces a considerably more customizable "message box"-type dialog known as a Task Dialog; you may want to give that one a try.

  • The Old New Thing

    Dr. Horrible's Sing-Along Blog, available online for a short time only

    • 21 Comments

    Get it while it's hot. Available through this weekend only, Dr. Horrible's Sing-Along Blog is a three-act Web series featuring Neil Patrick Harris as Dr. Horrible, a wannabe mad scientist evildoer who video-blogs about his plans for world domination, his application to the Evil League of Evil, his arch-enemy Captain Hammer, and his crush on the cute girl at the local laundromat.

    Oh, and it's a musical.

    Episodes one and two are available now. Episode three goes online on Saturday.

    Watch it.

    Trust me.

    Watch it.

  • The Old New Thing

    A new record for the shortest amount of time between an email message and its resend

    • 15 Comments

    As I've noted before, people didn't answer your first question for a reason, but one thing I forgot to point out is that you also need to give people a chance to answer the first time at all!

    Occasionally, I'll see somebody ask a question, and then resend the question a short time later. You also have to take into account the time of day. There was one message I recall that was sent around 4:30pm on Tuesday, and at 10am on Wednesday, it was "Resent due to no response." Now, sure, you waited nearly 18 hours before resending, but most of that time, people were at home not checking their email, and for a big chunk of that time they were even sleeping!

    I thought 90 minutes would hold up as the record, but that was mere wishful thinking. Several months ago, a new record was set. Somebody sent a question to a peer support mailing list, and then resent it a mere 27 minutes later.

    That record didn't hold up for very long, however, for the same person then sent the question a third time just 17 minutes later.

    Now, it'd be one thing if the mailing list promised responses within, say, 10 or 20 minutes of receipt, but this was to a peer-to-peer discussion group, and a peer-to-peer discussion group does not come with a service level agreement.

    Bonus chatter: In the time between writing this article and its arrival at the head of the queue, the record has been broken. Somebody sent a question, and then sent a repeat of the message with the additional plea "Please help!" eight minutes later.

  • The Old New Thing

    The best building name on the University of Washington campus

    • 8 Comments

    The best building name on the University of Washington campus is Sieg Hall, for many years home to the computer science department, and named after former university president Lee Paul Sieg.

  • The Old New Thing

    Microspeak: Well, actually management-speak

    • 30 Comments

    I hate management-speak.

    Here's an example from an internal Web site.

    The purpose of this Web site is two-fold.

    1. Create a reference source (best practices) where individuals can learn how to plan/facilitate and leverage their X activities most effectively.
    2. Establish a library of X material teams can utilize.

    Wow, let's look at the first stated purpose. It goes on for so long and uses blatant management-speak such as "facilitate" and "leverage" that by the time it's over, I forget how the sentence started. Going back and reading it again, it appears that the first item is identical to the second! It's just that the first item says it in a more confusing way.

    The second item shows evidence of management wordsmithing as well. "Utilize" instead of "use". An action verb like "establish" rather than a state verb like "to be". And those changes actually render the sentence incorrect. The purpose of the site isn't to "establish" a library; the purpose of the site is to be that library. Establishing the library is what you did when you created the site in the first place! That purpose has already been completed.

    I think the people who built this Web site just copied their annual review goals into the Web site text, forgetting that the review goal describes what you are supposed to do, not what the thing you created is supposed to do.

    Here's how I would have written it:

    This Web site is a library of X materials.
  • The Old New Thing

    News flash: Online drug sales are shady!

    • 9 Comments

    In what I'm sure is a fantastic surprise to everybody who has visited the Internet, according to a report in the New York Times, researchers at Columbia University have discovered that there are prescription drug pushers on the Internet who will sell you prescription drugs without a prescription.

    From what I can gather, they didn't actually check whether what they ordered were indeed what the sites purported the substances to be (although thanks are extended to MasterCard, Visa, American Express and PayPal for their assistance, which means that they did investigate whether the major online payment systems can be used to purchase the drugs). So who knows, maybe the sites were selling fakes. In other words, maybe the issue isn't so much one of readily-accessible prescription drugs but rather one of fraud.

Page 2 of 4 (40 items) 1234