Showing tag results for Code

Oct 18, 2007
Post comments count0
Post likes count0

Win32 user interface work is inherently single-threaded

Raymond Chen
Raymond Chen

At the end of the day, there's a window handle in there. As we saw a few years ago, windows have thread affinity. You can push work to a background thread all you want, but once you send a message to the window (or do something that results in a message being sent to the window), you've given control to the UI thread. Since the shell is all abou...

Code
Oct 17, 2007
Post comments count0
Post likes count0

The wrong way to check whether the mouse buttons have been swapped

Raymond Chen
Raymond Chen

Back in the late 1990's, the window manager team received a bug that said that sometimes the mouse button state got messed up and the computer acted as if the buttons were stuck down. Further investigation revealed that it occurred only when one particular program was running, and only if the user had enabled mouse button swapping. The reason is...

Code
Oct 15, 2007
Post comments count0
Post likes count0

Why aren't shortcuts as easy as unix links?

Raymond Chen
Raymond Chen

Commenter dingo asks, "Why are shortcuts so hard to manipulate? Why can't they be as easy as unix links?" Well, if you want something like unix links, then you can just create a hard link. Creating them is about the same difficulty ( vs ) and manipulating them is the same since you don't actually manipulate a hard link. You just use it like a regu...

Code
Oct 8, 2007
Post comments count0
Post likes count1

Which windows appear in the Alt+Tab list?

Raymond Chen
Raymond Chen

Commenter Phil Quirk wants to know what the rules are for determining which windows appear in the Alt+Tab list. It's actually pretty simple although hardly anything you'd be able to guess on your own. Note: The details of this algorithm are an implementation detail. It can change at any time, so don't rely on it. In fact, it already changed with ...

Code
Oct 2, 2007
Post comments count0
Post likes count0

Don't assume the first person to run your program is an administrator

Raymond Chen
Raymond Chen

One "optimization" I've seen from some programs is to defer a bunch of system configuration work to the first time the program is run or the first time a feature is requested instead of doing it at install time. The problem with this is that the first person to run your program is not guaranteed to be an administrator. For example, there is one po...

Code
Sep 21, 2007
Post comments count0
Post likes count0

What's the BS_PUSHLIKE button style for?

Raymond Chen
Raymond Chen

One of the lesser-known button styles is . Makes a button (such as a check box, three-state check box, or radio button) look and act like a push button. The button looks raised when it isn't pushed or checked, and sunken when it is pushed or checked. In other words, you add this style to a check box or radio button to make it look like a push ...

Code
Sep 20, 2007
Post comments count0
Post likes count0

It rather involved being on the other side of this airtight hatchway: Elevation to administrator

Raymond Chen
Raymond Chen

Surprisingly, it is not a security vulnerability that administrators can add other users to the Administrators group. But that doesn't stop people from claiming that it is. For example, it's not uncommon for a vulnerability report to come in with the following steps: Wow, this looks bad. An unprivileged user can elevate to administrator and... ...

Code
Sep 19, 2007
Post comments count0
Post likes count0

What happens if you pass a source length greater than the actual string length?

Raymond Chen
Raymond Chen

Many functions accept a source string that consists of both a pointer and a length. And if you pass a length that is greater than the length of the string, the result depends on the function itself. Some of those functions, when given a string and a length, will stop either when the length is exhausted or a null terminator is reached whichever c...

Code
Sep 18, 2007
Post comments count0
Post likes count0

Why is my delay-rendered format being rendered too soon?

Raymond Chen
Raymond Chen

Here's a customer question: I've put data on the clipboard as delay-rendered, but I'm getting a request for my for many operations even though nobody actually looks at the files. Operations such as right-clicking a blank space on the desktop or opening the Edit menu. I don't want to render the data until the user hits Paste because generating th...

Code
Sep 14, 2007
Post comments count0
Post likes count0

The code page on the server is not necessarily the code page on the client

Raymond Chen
Raymond Chen

It's not enough to choose a code page. You have to choose the right code page. We have a system that reformats and reinstalls a network client computer each time it boots up. The client connects to the server to obtain a loader program, and the loader program then connects to the server to download the actual operating system. If anything goes wr...

Code