Showing tag results for Code

Mar 9, 2009
Post comments count0
Post likes count1

Why doesn’t the MoveWindow function generate the WM_GETMINMAXINFO message?

Raymond Chen

Commenter Phil Quirk asks why calling does not result in a message being sent to validate the moved window size. Well, because you moved it after all. You're being trusted to respect your own rules. After all, if you didn't want the window to be wider than 200 pixels, you shouldn't have passed , right? The message is for obtaining minimum ...

Code
Mar 5, 2009
Post comments count0
Post likes count1

Fixups are not the same as rewriting code, they’re just fixups

Raymond Chen

Classically speaking, a linker cannot rewrite the code the compiler generated; its job is merely to resolve symbols. Of course, resolving symbols means that references to those symbols in the code generated by the compiler turn from "I don't know" to "Here it is." Somebody named George appeared to be confused by this, believing that all changes by...

Code
Feb 23, 2009
Post comments count0
Post likes count1

Why is there no supported way to get the command line of another process?

Raymond Chen

Commenter Francisco Moraes wonders whether there is a supported way of getting the command line of another process. Although there are certainly unsupported ways of doing it or ways that work with the assistance of a debugger, there's nothing that is supported for programmatic access to another process's command line, at least nothing provided b...

Code
Feb 20, 2009
Post comments count0
Post likes count1

Foreground activation permission is like love: You can’t steal it, it has to be given to you

Raymond Chen

This is the blog entry that acted as the inspiration for the last topic in my 200 PDC talk. When somebody launches a second copy of your single-instance program, you usually want the second copy to send its command line to the first instance (and deal with the current directory somehow), and then you want the first instance to come to the foreg...

Code
Feb 17, 2009
Post comments count0
Post likes count1

Why doesn’t the file system have a function that tells you the number of files in a directory?

Raymond Chen

There are any number of bits of information you might want to query from the file system, such as the number of files in a directory or the total size of the files in a directory. Why doesn't the file system keep track of these things? Well, of course, one answer is that it certainly couldn't keep track of every possible fragment of information ...

Code
Feb 16, 2009
Post comments count0
Post likes count1

Don’t keep track of information you don’t need

Raymond Chen

This is sort of an extreme corollary to Don't save anything you can recalculate. Sure, it sounds like such an obvious principle, but many people fail to understand its consequences. Let's look at the principle again. Don't keep track of information you don't need. I remember being asked to look at a customer's program, and one thing that struck...

Code
Feb 6, 2009
Post comments count0
Post likes count1

A process shutdown puzzle: Answers

Raymond Chen

Last week, I posed a process shutdown puzzle in honor of National Puzzle Day. Let's see how we did. Part One asked us to explain why the thread no longer exists. That's easy. One of the things that happen inside is that all threads (other than the one calling ) are forcibly terminated in the nastiest way possible. This happens before the noti...

Code
Feb 2, 2009
Post comments count0
Post likes count1

How do I programmatically show and hide the Quick Launch bar?

Raymond Chen

Commenter Mihai wants to know how to show or hide the Quick Launch bar programmatically. That's not something a program should be doing. Whether the Quick Launch bar is shown or hidden is an end user setting, and programs should not be overriding the user's preferences. Explorer consciously does not expose an interface for showing and hiding tas...

Code
Jan 29, 2009
Post comments count0
Post likes count1

A process shutdown puzzle

Raymond Chen

In honor of National Puzzle Day, I leave you today with a puzzle based on an actual customer problem. Part One: The customer explains the problem. We have this DLL, and during its startup, it creates a thread with the following thread procedure: DWORD CALLBACK ThreadFunction(void *) { HANDLE HandleArray[2]; HandleArray[0] = SetUpStuff()...

Code