Showing tag results for Code

Oct 28, 2013
Post comments count0
Post likes count1

Using GetLogicalProcessorInformationEx to see the relationship between logical and physical processors

Raymond Chen

Today's Little Program uses the function to print the mapping of logical processors to physical processors, as well as the mapping of logical processors to packages. (A dual-core processor is a single package with two cores. If those cores are themselves dual-hyperthreaded, then you have four logical processors total.) The helper function tak...

Code
Oct 25, 2013
Post comments count0
Post likes count1

My, those threads start up really fast nowadays

Raymond Chen

Here's a little puzzle inspired by an actual bug: Can the assertion at the start of ever fire? Naturally, the answer is Yes, otherwise it wouldn't be a very interesting article. The assertion can fire if the worker thread starts running before the call the returns. In that case, the caller hasn't yet received the handle or ID of the newly...

Code
Oct 24, 2013
Post comments count0
Post likes count1

When should I use the FIND_FIRST_EX_LARGE_FETCH flag to FindFirstFileEx?

Raymond Chen

Windows 7 introduces a new flag to the function called . The documentation says that it "uses a larger buffer for directory queries, which can increase performance of the find operation." This is classic MSDN-style normative documentation: It provides "just the facts". Far be it for MSDN to tell you how to write your application; the job of f...

Code
Oct 21, 2013
Post comments count0
Post likes count1

Opening and manipulating Internet Explorer windows programmatically

Raymond Chen

Today's Little Program takes the JavaScript application from a few years ago and converts it to C#. This was inspired by a customer who started with the question, "How can I close all Internet Explorer windows programmatically?" This was a strange request. After all, the user may be rather upset that their Amazon shopping spree was suddenly ter...

Code
Oct 18, 2013
Post comments count0
Post likes count1

The case of the redirected standard handles that won't close even though the child process has exited (and a smidge of Microspeak: reduction)

Raymond Chen

A customer had a supervisor process whose job is to launch two threads. Each thread in turn launches a child process, let's call them A and B, each with redirected standard handles. They spins up separate threads to read from the child processes' stdout in order to avoid deadlocks. What they've found is that even though child process&nbs...

CodeMicrospeak
Oct 17, 2013
Post comments count0
Post likes count1

What is the inverse of AdjustWindowRect and AdjustWindowRectEx?

Raymond Chen

We saw over a decade ago (my goodness I've been doing this way too long) that the and functions do not take menu wrapping into account because they don't take a window handle parameter, so they don't know what menu to test for wrapping. Still, they are useful functions if you aren't worried about menu wrapping because they let you do window siz...

Code
Oct 16, 2013
Post comments count0
Post likes count1

Why does my window get a WM_ACTIVATE message when it isn't active?

Raymond Chen

Say you launch a program, and for whatever reason the program takes a long time to start up, so you start doing something else, say launching Calculator and balancing your checkbook. Eventually, the program you launched a while back gets itself off the ground and creates its main window. And the window sits in the background (since the window manag...

Code
Oct 11, 2013
Post comments count0
Post likes count1

C++ corner case: You can implement pure virtual functions in the base class

Raymond Chen

In our discussion , we saw that you can declare a pure virtual function with the syntax, and if you try to call one of these functions from the base class, you will get the dreaded R6025 - pure virtual function call error. In that article, I wrote that a pure virtual function is "a method which is declared by the base class, but for which no i...

Code