Showing tag results for Code

Dec 10, 2003
Post comments count0
Post likes count2

What is the command line length limit?

Raymond Chen
Raymond Chen

It depends on whom you ask. The maximum command line length for the CreateProcess function is 32767 characters. This limitation comes from the UNICODE_STRING structure. CreateProcess is the core function for creating processes, so if you are talking directly to Win32, then that's the only limit you have to worry about. But if you are reaching Cr...

Code
Dec 9, 2003
Post comments count0
Post likes count1

Why you should never suspend a thread

Raymond Chen
Raymond Chen

It's almost as bad as terminating a thread. Instead of just answering a question, I'm going to ask you the questions and see if you can come up with the answers. Consider the following program, in (gasp) C#: When you run this program and hit Enter to suspend, the program hangs. But if you change the worker function to just "for(;;) {}" the ...

Code
Dec 4, 2003
Post comments count0
Post likes count0

Which access rights bits belong to whom?

Raymond Chen
Raymond Chen

Each ACE in a security descriptor contains a 32-bit access mask. Which bits belong to whom? The access rights mask is a 32-bit value. The upper 16 bits are defined by the operating system and the lower 16 bits are defined by the object being secured. For example, consider the value 0x00060002 for the access rights mask. This breaks down as the sy...

Code
Dec 3, 2003
Post comments count0
Post likes count0

Which window style bits belong to whom?

Raymond Chen
Raymond Chen

There are 64 bits of styles in the parameters to CreateWindowEx. Which ones belong to whom? Windows defines the meanings of the high word of the dwStyle parameter and all of the bits in the dwExStyle parameter. The low 16 bits of the dwStyle parameter are defined by the implementor of the window class (by the person who calls RegisterClass). In W...

Code
Dec 2, 2003
Post comments count0
Post likes count0

Which message numbers belong to whom?

Raymond Chen
Raymond Chen

Valid window messages break down into four categories. 0 .. 0x3FF (WM_USER-1): System-defined messages. The meanings of these messages are defined by the operating system and cannot be changed. Do not invent new messages here. Since the meanings are defined by Windows, the operating system understands how to parse the WPARAM and LPARAM paramet...

Code
Nov 26, 2003
Post comments count0
Post likes count0

Other tricks with WM_GETDLGCODE

Raymond Chen
Raymond Chen

The WM_GETDLCODE message lets you influence the behavior of the dialog manager. A previous entry on using WM_GETDLGCODE described the flag which controls whether edit control content is auto-selected when focus changes. I was going to write a bit about the other flags, but it turns out that Knowledge Base Article 83302 already covers this, so I...

Code
Nov 24, 2003
Post comments count0
Post likes count0

A shortcut to the Run dialog

Raymond Chen
Raymond Chen

Here's a little script that opens the Run dialog. You can save it as "Run.js" and double-click it. The advantage of this approach over various others people have come up with is that this one is actually documented. (And therefore is less likely to break in the next version of the operating system.)

CodeTips/Support
Nov 18, 2003
Post comments count0
Post likes count0

Make sure the buttons match the question

Raymond Chen
Raymond Chen

When your program displays a dialog box with buttons, please make the buttons match the text. Consider this dialog, which appears after you install patches from Windows Update: It asks a yes/no question, but the options are "OK" and "Cancel". Either the buttons should be c...

Code
Nov 14, 2003
Post comments count0
Post likes count0

Preventing edit control text from being autoselected in a dialog box

Raymond Chen
Raymond Chen

By default, when the user TABs to an edit control in a dialog box, the entire contents of the edit control are autoselected. This occurs because the edit control responds with the flag in response to the message. To prevent it from happening, remove that flag. All this subclass procedure does is remove the flag from the return value of the ...

Code
Nov 13, 2003
Post comments count0
Post likes count0

Another different type of dialog procedure

Raymond Chen
Raymond Chen

The other method of using a window-procedure-like dialog box is to change the rules of the game. Normally, the window procedure for a dialog box is the function, which calls the dialog procedure and then takes action if the dialog procedure indicated that it desired the default action to take place. The dialog procedure is subservient to , prov...

Code