Showing tag results for Code

Oct 28, 2013
Post comments count0
Post likes count0

Using GetLogicalProcessorInformationEx to see the relationship between logical and physical processors

Raymond Chen
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 count0

My, those threads start up really fast nowadays

Raymond Chen
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 count0

When should I use the FIND_FIRST_EX_LARGE_FETCH flag to FindFirstFileEx?

Raymond Chen
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 count0

Opening and manipulating Internet Explorer windows programmatically

Raymond Chen
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 count0

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
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 count0

What is the inverse of AdjustWindowRect and AdjustWindowRectEx?

Raymond Chen
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
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
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
Oct 10, 2013
Post comments count0
Post likes count0

How do I find out what size the window manager would have chosen for my window?

Raymond Chen
Raymond Chen

We saw some time ago how the window manager decides where to place a newly-created window if you pass the values when creating the window. But what if you want to filter the values first? If you pass an explicit upper left corner but pass for the width and height, then the bottom right corner will be down near the bottom right corner of the scre...

Code