The Old New Thing

Practical development throughout the evolution of Windows.

Latest posts

Why does the wireless connection dialog ask for your password twice?
Apr 19, 2010
Post comments count 0
Post likes count 0

Why does the wireless connection dialog ask for your password twice?

Raymond Chen
Raymond Chen

Martin wonders why the wireless networking dialog asks you to type your password twice when connecting to an existing network. Yeah, that bothers me too, and I don't know why either. But while we're on the topic of wireless networking, I thought I'd share a little program that is just as useless as my answer above. (If other people get to hijack the topic, then I want to also.) Back in the early days of Windows XP, I found that my wireless networking adapter would constantly disconnect and reconnect. I never figured out why, but I did have a theory. (Theory: The wireless zero configuration service sa...

The mysterious stock bitmap: There's no way to summon it, but it shows up in various places
Apr 16, 2010
Post comments count 0
Post likes count 0

The mysterious stock bitmap: There's no way to summon it, but it shows up in various places

Raymond Chen
Raymond Chen

A number of stock GDI objects are made available by the function, but one stock GDI object that is mysteriously missing is the stock bitmap. You can't summon the stock bitmap, but it manages to show up in various places, some of them perhaps unexpected. The stock bitmap is a monochrome 1×1 bitmap which GDI uses in various places where it has to produce a even though there really isn't any bitmap worth speaking of. In other words, it's used when GDI has to return something but would rather return nothing. When you create a memory DC, the current bitmap selected into it is the stock bitmap. When yo...

Why are there two values for NoDriveTypeAutoRun which disable Autoplay on drives of unknown type?
Apr 15, 2010
Post comments count 0
Post likes count 0

Why are there two values for NoDriveTypeAutoRun which disable Autoplay on drives of unknown type?

Raymond Chen
Raymond Chen

The Windows 2000 Resource Kit described the policy as consisting of a bitfield whose values are as follows: Hey, wait, two of the entries are the same. What's the difference between 0x1 (Disables Autoplay on drives of unknown type) and 0x80 (Disables Autoplay on drives of unknown type)? The values in the bitfield correspond to return values of the function: The value 0x1 corresponds to bit zero, which means that the function could not tell what type of drive it is. On the other hand, the value 0x80 does not correspond to any known return value of . It's reserved for future use. My guess as to ho...

When you create an object with constraints, you have to make sure everybody who uses the object understands those constraints
Apr 14, 2010
Post comments count 0
Post likes count 0

When you create an object with constraints, you have to make sure everybody who uses the object understands those constraints

Raymond Chen
Raymond Chen

Here's a question that came from a customer. This particular example involves managed code, but don't let that distract you from the point of the exercise. I am trying to create a object using the constructor that takes an as input. In my .cs file, I create the native file handle using , as shown below. Then I create the object as so: The gets created fine. But when I try to do: it fails with the error "IO operation will not work. Most likely the file will become too long or the handle was not opened to support synchronous IO operations." Gives as (). The stack trace is as below. Can so...

It's a miracle humanity has survived this far, if reaction to the inability to make or receive a telephone call is to be believed
Apr 13, 2010
Post comments count 0
Post likes count 0

It's a miracle humanity has survived this far, if reaction to the inability to make or receive a telephone call is to be believed

Raymond Chen
Raymond Chen

In one of the mailing lists devoted to chatting among people who work in a particular cluster of Microsoft office buildings, there was some discussion of the quality of mobile phone coverage in the parking garage. "I can't get a signal in any of the underground levels. This is intolerable!" — Here's an idea: Walk to ground level and make your call there. "But what if it's an emergency?" — Then run. (Or use one of the emergency phones.) Sometimes I wonder how humanity had managed to survive prior to the installation of mobile phone cell towers. Had these people been born just 30 years earlier, th...

How do I switch a window between normal and fullscreen?
Apr 12, 2010
Post comments count 0
Post likes count 1

How do I switch a window between normal and fullscreen?

Raymond Chen
Raymond Chen

Frederic Delhoume wants to know if there is a simple example of code that switches an application from windowed to fullscreen. He then included a code fragment that did some crazy things with parent windows and hiding and showing. You're making it way, way harder than it needs to be. Let's start with our scratch program and make these changes: To avoid getting into the intricacies of hotkeys and accelerators, I opted to toggle to fullscreen on a click. When the button goes up, we check whether we are currently in normal mode or fullscreen mode by sniffing at our window styles. If we are in normal mode, w...

Why can't you use WM_CTLCOLORSTATIC to change the color of a SS_BLACKRECT?
Apr 9, 2010
Post comments count 0
Post likes count 0

Why can't you use WM_CTLCOLORSTATIC to change the color of a SS_BLACKRECT?

Raymond Chen
Raymond Chen

If you specify one of the static control styles which draw a frame or rectangle the control will be drawn with the corresponding color (which, as we saw last time, isn't actually black, gray, or white). If you try to customize the color by handling the message, you'll find that it has no effect. Well, yeah, because you said you wanted a black rectangle. If you want some other color, you could set the style to then draw the solid color in your handler. Or you can just use a text static control with no text. In that case, you can respond to in the usual way. Since you specified no text, all that will be dr...

Why doesn't SS_WHITERECT actually draw a white rectangle?
Apr 8, 2010
Post comments count 0
Post likes count 0

Why doesn't SS_WHITERECT actually draw a white rectangle?

Raymond Chen
Raymond Chen

There are six styles available to the static controls which draw frames and rectangles in one of three fixed colors: But if you actually create a static control with one of these styles, you'll find that the color isn't actually black, gray, or white. So why are they called black, gray, and white? Because they used to be black, gray, and white. Knowledge Base article 125684 gives the history behind these styles. Back in the 16-bit days, these styles really did give you black, gray, and white, or at least they did if you used the default color scheme. Windows 95 shifted from using the window colors to t...

How to edit the security attributes of more than one file at a time
Apr 7, 2010
Post comments count 0
Post likes count 0

How to edit the security attributes of more than one file at a time

Raymond Chen
Raymond Chen

In Windows XP, you could select multiple files, right-click them, then select Properties. The resulting property sheet includes a Security page which lets you edit the security attributes of those files. But when you repeat this exercise on Windows Vista or Windows 7, the Security page is missing. Why doesn't Explorer let you edit the security attributes of more than one file at a time? Windows might need to display an elevation prompt if any of the files in the collection require administrator privileges in order to modify the security attributes. The security prompt needs to tell you why you are...