Showing tag results for Code

Jan 21, 2005
Post comments count0
Post likes count0

Why are kernel HANDLEs always a multiple of four?

Raymond Chen
Raymond Chen

Not very well known is that the bottom two bits of kernel HANDLEs are always zero; in other words, their numeric value is always a multiple of 4. Note that this applies only to kernel HANDLEs; it does not apply to pseudo-handles or to any other type of handle (USER handles, GDI handles, multimedia handles...) Kernel handles are things you can pas...

Code
Jan 19, 2005
Post comments count0
Post likes count0

CreateProcess does not wait for the process to start

Raymond Chen
Raymond Chen

The function creates a new process, but it doesn't wait for the process to get off the ground before returning. It just creates the process object and lets it go to do its thing. The Win32 process model is that each process initializes itself in context. When a process object is created, it is practically empty, save for enough information to g...

Code
Jan 10, 2005
Post comments count0
Post likes count0

Taskbar notification balloon tips don't penalize you for being away from the keyboard

Raymond Chen
Raymond Chen

The function is used to do various things, among them, displaying a balloon tip to the user. As discussed in the documentation for the structure, the uTimeout member specifies how long the balloon should be displayed. But what if the user is not at the computer when you display your balloon? After 30 seconds, the balloon will time out, and the...

Code
Jan 10, 2005
Post comments count0
Post likes count0

Taskbar notification balloon tips don’t penalize you for being away from the keyboard

Raymond Chen
Raymond Chen

The function is used to do various things, among them, displaying a balloon tip to the user. As discussed in the documentation for the structure, the uTimeout member specifies how long the balloon should be displayed. But what if the user is not at the computer when you display your balloon? After 30 seconds, the balloon will time out, and the...

Code
Jan 5, 2005
Post comments count0
Post likes count1

PulseEvent is fundamentally flawed

Raymond Chen
Raymond Chen

The function releases one thread (or all threads, if manual-reset) which is/are waiting for the pulsed event, then returns the event to the unset state. If no threads happen to be waiting, then the event goes to the unset state without anything happening. And there's the flaw. How do you know whether the thread that you think is waiting on t...

Code
Jan 4, 2005
Post comments count0
Post likes count0

Using fibers to simplify enumerators, part 5: Composition

Raymond Chen
Raymond Chen

Another type of higher-order enumeration is composition, where one enumerator actually combines the results of multiple enumerators. (Everybody knows about derivation, but composition is another powerful concept in object-oriented programming. We've seen it before when building context menus.) In a producer-driven enumerator, you would implemen...

Code
Jan 3, 2005
Post comments count0
Post likes count0

Using fibers to simplify enumerators, part 4: Filtering

Raymond Chen
Raymond Chen

One type of higher-order enumeration is filtering, where one enumerator takes the output of another enumerator and removes some elements. In a producer-driven enumerator, you would implement filtering by substituting a new callback function that responds to callbacks on behalf of the client for items that should be filtered, and forwarding callb...

Code
Dec 31, 2004
Post comments count0
Post likes count0

Using fibers to simplify enumerators, part 3: Having it both ways

Raymond Chen
Raymond Chen

As we discovered in the previous two entries [second], the problem with enumeration is that somebody always loses. Now we will use fibers to fight back. Before you decide to use fibers in your programs, make sure to read the dire warnings at the end of this article. My goal here is to show one use of fibers, not to say that fibers are the answer ...

Code
Dec 30, 2004
Post comments count0
Post likes count0

Using fibers to simplify enumerators, part 2: When life is easier for the caller

Raymond Chen
Raymond Chen

Last time, we looked at how a directory tree enumerator function would have been written if the person writing the enumerator (the producer) got to write the spec. Now let's look at what it would look like if the person consuming the enumerator wrote the spec: #include <windows.h> #include <shlwapi.h> #include <stdio.h> #includ...

Code