The Old New Thing

How to void your warranty

MSDN just published an article telling people that it's okay to use reserved fields in an internal structure. Anybody who does this has just voided their warranty. Please put a "This program has a high likelihood of crashing after you install the next Service Pack or upgrade your OS" in your license agreement.And you wonder why app compat is ...
Comments are closed.0 0
Code

What is the window nesting limit?

In the old days, Windows didn't bother enforcing a nesting limit because, well, if you want to nest windows 200 deep, that's your decision. Many window operations are recursive, but since everything happened on the application's stack, it was your own responsibility to make your stack big enough so it didn't overflow. But Windows NT moved the ...
Comments are closed.0 0
Code

Welcome to the New Old New Thing

Hey there, everybody. It's going to take me a while to settle in, so please be patient. It seems I always celebrate a new blog by designing some insane multi-part series on some obscure aspect of Win32, so I think I'll welcome this site with a series of articles that demonstrate various things you can do with the shell namespace. I haven't ...

How do I pass a lot of data to a process when it starts up?

As we discussed yesterday, if you need to pass more than 32767 characters of information to a child process, you'll have to use something other than the command line. One method is to wait for the child process to go input idle, then FindWindow for some agreed-upon window and send it a WM_COPYDATA message. This method has a few problems...
Comments are closed.0 0
Code

What is the command line length limit?

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 ...
Comments are closed.0 0
Code

Why you should never suspend a thread

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...
Comments are closed.0 0
Code

Which access rights bits belong to whom?

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 ...
Comments are closed.0 0
Code

Which window style bits belong to whom?

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...
Comments are closed.0 0
Code

Which message numbers belong to whom?

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 ...
Comments are closed.0 0
Code

Other tricks with WM_GETDLGCODE

The WM_GETDLCODE message lets you influence the behavior of the dialog manager. A previous entry on using WM_GETDLGCODE described the DLGC_HASSETSEL 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 ...
Comments are closed.0 0
Code