The Old New Thing

When are global objects constructed and destructed by Visual C++?

Today we're going to fill in the following chart: The C++ language specification provides some leeway to implementations on when global static objects are constructed. It can construct the object before main begins, or it construct the object on demand according to complicated rules. You can read [basic.start.init] for the gory details. ...
Comments are closed.0 0
Code

If only DLLs can get DllMain notifications, how can an EXE receive a notification when a thread is created (for example)?

When a DLL is loaded, it receives a DLL_PROCESS_ATTACH notification, and when it is unloaded (or when the process terminates), it gets a DLL_PROCESS_DETACH notification. DLLs also receive DLL_THREAD_ATTACH notifications when a thread is created and DLL_THREAD_DETACH notifications when a thread exits. But what if you are an EXE? EXEs don't ...
Comments are closed.0 0
Code

The GetCurrentThread function is like a check payable to Bearer: What it means depends on who's holding it

The Get­Current­Thread function returns a pseudo-handle to the current thread. The documentation goes into significant detail on what this means, but I fear that it may have fallen into the trap of providing so much documentation that people decide to skip it. Okay, so first of all, what is a pseudo-handle? a pseudo-handle is a ...
Comments are closed.0 0
Code

Is there a way to disable a specific balloon notification without disabling all of them?

There is a group policy called Turn off all balloon notifications, but what if you want to turn off only one specific notification? The taskbar does not offer fine-grained policy control over balloon notifications. All you have is the giant sledgehammer that turns off all of them. If there is a specific balloon you want to disable, you have ...

Enumerating notification icons via UI Automation

Today's Little Program uses accessibility to enumerate the current notification icons (and possibly click on one of them). This could be done manually via IAccessible, but the BCL folks conveniently created the System.Windows.Automation namespace which contains classes that take a lot of the grunt work out of walking the accessibility tree...
Comments are closed.0 0
Code

Some parts of an interface can change but others can't

When I wrote about asking the compiler to answer calling convention questions, some people were concerned about whether this was a reliable mechanism or whether it was relying on something that can change in the future. This is a special case of the question, "What parts of an interface can change, and what can't?" And it all boils down to...
Comments are closed.0 0
Code

Why is there a 64KB no-man's land near the end of the user-mode address space?

We learned some time ago that there is a 64KB no-man's land near the 2GB boundary to accommodate a quirk of the Alpha AXP processor architecture. But that's not the only reason why it's there. The no-man's land near the 2GB boundary is useful even on x86 processors because it simplifies parameter validation at the boundary between user mode ...

Standard handles are really meant for single-threaded programs

When I discussed the conventions for managing standard handles, Sven2 noted that I implied that you need to call Set­Std­Handle with a new handle if you close the current handle and asked "Wouldn't it make more sense to call it the other way round? I.e., first set the new handle, then close the old one? It would ensure that any other ...
Comments are closed.0 0
Code

Enumerating cyclical decompositions with Stirling numbers

This whole enumeration nightmare-miniseries started off with Stirling numbers of the second kind. But what about Stirling numbers of the first kind? Those things ain't gonna enumerate themselves! The traditional formulation of the recursion for Stirling numbers of the first kind (unsigned version, since it's hard to enumerate negative ...
Comments are closed.0 0
Code