The Old New Thing

Practical development throughout the evolution of Windows.

Latest posts

Taxes: Detecting session state changes, such as a locked workstation
Jan 4, 2006
Post comments count 0
Post likes count 0

Taxes: Detecting session state changes, such as a locked workstation

Raymond Chen
Raymond Chen

Another developer tax is playing friendly with Fast User Switching and Terminal Services. When the workstation is locked or disconnected, you should turn off non-essential timers, minimize background activities, and generally send your program into a quiet state. If you already used the technique of painting only when your window is visible on the screen, then you get all of this for free, since a locked workstation and a disconnected session do not generate paint messages. If you have other activities that you need to scale back or shut down when the user has locked the workstation or disconnected, you can r...

Taxes: Remote Desktop Connection and painting
Jan 3, 2006
Post comments count 0
Post likes count 0

Taxes: Remote Desktop Connection and painting

Raymond Chen
Raymond Chen

An increasingly important developer tax is supporting Remote Desktop Connection properly. When the user is connected via a Remote Desktop Connection, video operations are transferred over the network connection to the client for display. Since networks have high latency and nowhere near the bandwidth of a local PCI or AGP bus, you need to adapt to the changing cost of drawing to the screen. If you draw a line on the screen, the "draw line" command is sent over the network to the client. If you draw text, a "draw text" command is sent (along with the text to draw). So far so good. But if you copy a bitmap to th...

The world's slowest RET instruction
Jan 3, 2006
Post comments count 0
Post likes count 0

The world's slowest RET instruction

Raymond Chen
Raymond Chen

Occasionally, somebody will ask I'm debugging a hang, and I see that many threads are stuck at a RET instruction. When I try to trace one instruction from that thread, the trace breakpoint never fires. It's as if the RET instruction itself is wedged! I've found the world's slowest RET instruction. (A common variation on this theme is that the thread in question is consuming 100% CPU... on a RET instruction?) Because what you see in that RET instruction is a thread that is executing in kernel mode. The kernel parked the user-mode side of the thread at a RET instruction, poised to execute once the kernel-mode s...

2005 end-of-year link blowout sale
Jan 3, 2006
Post comments count 0
Post likes count 0

2005 end-of-year link blowout sale

Raymond Chen
Raymond Chen

A quick list of links amassed over the past year. Not quite worth a posting on their own, but together they might mean something. [While Raymond was on vacation, the autopilot stopped working due to a power outage. This entry has been backdated.]

On the abuse of properties
Jan 3, 2006
Post comments count 0
Post likes count 0

On the abuse of properties

Raymond Chen
Raymond Chen

One thing that I see occasionally is the abuse of property syntax. IDispatch and CLR objects (and C++ objects if you want to avail yourself of a Microsoft-specific extension) support "properties", which syntactically look like fields but internally are treated as a pair of methods ("get" and "put"). An important principle is that given an object and a property , the lines should be effectively nops. (Mind you, they might be really inefficient nops.) My favorite (or perhaps most hated) example of violating this principle is an object I saw many years ago that had a "print" property, which if set to true, c...

There's more to calling a function than just getting the types to match
Jan 3, 2006
Post comments count 0
Post likes count 0

There's more to calling a function than just getting the types to match

Raymond Chen
Raymond Chen

Here's a classic novice error. You want to call a function, say GetBinaryType. What should you write for those question marks? Well, the prototype says that the second parameter is an LPDWORD, so let's pass it one. Hm, but that crashes. Well, maybe we can pass it an LPDWORD this way: Hm, that still crashes. Oh wait, it's because of the uninitialized variable. No, that still crashes. Hang on, I know where I can get an LPDWORD. This code finally works! Okay, on to the next problem... Of course, the seasoned programmer still shakes his head. Just because the function prototype says that the para...

If one certification is good, more must be better
Jan 3, 2006
Post comments count 0
Post likes count 0

If one certification is good, more must be better

Raymond Chen
Raymond Chen

In the discussion of driver signing, commenter ATZ Man suggested: Further, Microsoft should allow orgs that are peers of WHQL [to] certify drivers and allow drivers to obtain certs from any such org or set of such orgs as they choose. Over time users would know which orgs were on the ball and which had agendas. Would they? Let's take a real-world case where there are multiple certifying authorities, to see whether what this commenter predicts actually has come to pass. The United States has several bicycle helmet standards which a manufacturer can choose to meet. At a minimum, it must meet the requireme...

Why did the Windows 95 CD have extra fun stuff?
Jan 3, 2006
Post comments count 0
Post likes count 0

Why did the Windows 95 CD have extra fun stuff?

Raymond Chen
Raymond Chen

Why did the Windows 95 CD have extra fun stuff, like the Good Times and Buddy Holly music videos, the Rob Roy trailer, and the cartoons by Bill Plympton? Because it was fun! Why does one have to justify having fun? In addition to the multimedia fun, there was also video game fun, with the addition of Pinball and the mercifully-forgotten hovercraft game Hover! (Some of us thought it was so awful, we secretly called it Hoover!) [While Raymond was on vacation, the autopilot stopped working due to a power outage. This entry has been backdated.]

On the “Days without a pony” web page
Dec 23, 2005
Post comments count 0
Post likes count 0

On the “Days without a pony” web page

Raymond Chen
Raymond Chen

Reader Mark Eichin was curious about the "Days with a pony" web page. Here's what it would look (suitably redacted) if it were still operating: December 23, 2005: Still no pony From: Raymond Chen To: Xxxx Xxxxxx Subject: Laptop order Date: Mon, 27 Mar 2000 09:47:19 -0800 I want a pony and a train set and an NEC Versa SX laptop (NECVS4E0E7A). Maybe you can help. Did I mention the pony? From: Order Management To: Raymond Chen Subject: Order Confirmation Date: Fri, 31 Mar 2000 14:28:19 -0800 Your order has been confirmed. Please contact your Central Sales Representative if you have any questions...