Showing results for November 2004 - The Old New Thing

Nov 30, 2004
0
0

What’s the difference between GetKeyState and GetAsyncKeyState?

Raymond Chen
Raymond Chen

I've seen some confusion over the difference between the function and the function. returns the virtual key state. In other words, reports the state of the keyboard based on the messages you have retrieved from your input queue. This is not the same as the physical keyboard state: When should you use and when should you use ? For ...

Code
Nov 29, 2004
0
0

Why doesn’t the RunAs program accept a password on the command line?

Raymond Chen
Raymond Chen

The RunAs program demands that you type the password manually. Why doesn't it accept a password on the command line? This was a conscious decision. If it were possible to pass the password on the command line, people would start embedding passwords into batch files and logon scripts, which is laughably insecure. In other words, the feature is ...

Other
Nov 26, 2004
0
0

Simple things you can do with the ShellExecuteEx function

Raymond Chen
Raymond Chen

Here's a tiny little program: #include <windows.h> #include <shellapi.h> int __cdecl main(int argc, char **argv) { if (argc == 3) { SHELLEXECUTEINFO sei = { sizeof(sei) }; sei.fMask = SEE_MASK_FLAG_DDEWAIT; sei.nShow = SW_SHOWNORMAL; // added 27 Nov sei.lpVerb = argv[1]; sei.lpFile = argv[2]; ShellExecuteEx...

Code
Nov 24, 2004
0
0

Why can’t you drop directly onto a taskbar button?

Raymond Chen
Raymond Chen

If you drag a object and drop it onto a taskbar button, you get an error message that says, You cannot drop an item onto a button on the taskbar. However, if you drag the item over a button without releasing the mouse button, the window will open after a moment, allowing you to drop the item inside the window. Why doesn't the taskbar let y...

Other
Nov 23, 2004
0
0

Why do folders like “My Pictures” come back after I delete them?

Raymond Chen
Raymond Chen

Some people are offended by the special folders like "My Pictures" and "My Music" and delete them, only to find them being re-created. What's going on? Windows itself is okay with you deleting those folders. Some corporations, for example, remove those folders from their employees' machines because they don't want the employees looking at picture...

Code
Nov 22, 2004
0
0

When people ask for security holes as features: World-writable files

Raymond Chen
Raymond Chen

If I had a nickel each time somebody asked for a feature that was a security hole... I'd have a lot of nickels. For example, "I want a file that all users can write to. My program will use it as a common database of goodies." This is a security hole. For a start, there's an obvious denial of service attack by having a user open the file in ...

HistoryWhen people ask for security holes as features
Nov 19, 2004
0
0

The various ways of sending a message

Raymond Chen
Raymond Chen

There are several variations on the SendMessage function, but some are special cases of others. The simplest version is SendMessage itself, which sends a message and waits indefinitely for the response. The next level up is SendMessageTimeout which sends a message and waits for the response or until a certain amount of time has elapsed. Send...

Code
Nov 18, 2004
0
0

Am I sorry or not?

Raymond Chen
Raymond Chen

One of the consequences of the New Internet World Order is that it is very easy to set up a web site like www.sorryeverybody.com and equally easy to set up a response like www.notsorryeverybody.com. This state of affairs clearly calls out for some sort of competition between the two. At dinner last night, someone suggested that there should be a ...

Nov 18, 2004
0
0

If a program and a folder have the same name, the shell prefers the program

Raymond Chen
Raymond Chen

If you have both a folder named, say, and a program named and you type into the Start.Run dialog, you get the program and not the folder. Why is that? Because it is common to have where there is a setup program in the root, as well as a setup folder containing files needed by the setup program. Before Windows 95, you couldn't open...

History