The Old New Thing

It’s the address space, stupid

Nowadays, computers have so much memory that running out of RAM is rarely the cause for an "out of memory" error. Actually, let's try that again. For over a decade, hard drive have been so large (and cheap) that running out of swap space is rarely the cause for an "out of memory" error. In user-mode, the term memory refers to virtual ...
Comments are closed.0 0
Code

Once you return from the WM_ENDSESSION message, your process can be terminated at any time

A customer had a program which performed some final I/O operations as it exited. Various C++ objects deleted files or flushed buffers as part of their destructors. The customer found that if their program was left running when the user shut down Windows, then the files never got deleted, and the buffers were never flushed. On the other hand, ...
Comments are closed.0 0
Code

The default error mode (SetErrorMode) is not zero

A customer put the following code at the start of their program: // If this assertion fires, then somebody else changed the error mode // and I just overwrote it with my error mode. ASSERT(SetErrorMode(SEM_FAILCRITICALERRORS) == 0); The customer wanted to know whether it was a valid assumption that the initial error mode for a process is ...
Comments are closed.0 0
Code

Where did the names of the fonts Marlett and Verdana come from?

Commenter BAA says that the -lett part of Marlett comes from the designer Virginia Howlett. BAA adds, "I forget the 'Mar' but I believe it was a co-creator." If so, then that co-creator was Suzan Marashi, if Vincent Connare is to be trusted. On page 17 of the PDF document From The Dark Side..., Connare identifies the authors of the font as ...

Wait, this is not my regular bicycle commute home

I dreamed that I finished biking home and decided not to take the stairs. Instead I took my bicycle into the elevator to go to my dream-land 31st-floor high-rise condo. (As if.) For "security reasons" there were no buttons in the elevator. You had to open a secret panel and flip a circuit-breaker switch corresponding to the floor you want to...

Drawing content at a fixed screen position, regardless of window position

Today's Little Program draws content at a fixed screen position. The idea is that the window is really a viewport into some magical world. Unfortunately, our magical world just has a sign that says "Booga booga." Creating a more interesting magical world is left as an exercise. Start with our scratch program and make these changes: void ...
Comments are closed.0 0
Code

Of what use is the RDW_INTERNALPAINT flag?

For motivational purposes, let's start with a program that displays a DWM thumbnail. Start with the scratch program and add the following: #include <dwmapi.h> HWND g_hwndThumbnail; HTHUMBNAIL g_hthumb; void UpdateThumbnail(HWND hwndFrame, HWND hwndTarget) { if (g_hwndThumbnail != hwndTarget) { g_hwndThumbnail = hwndTarget; ...
Comments are closed.0 0
Code

Solving the problem rather than answering the question: Why does somebody want to write an unkillable process?

Via their customer liaison, a customer wanted to know how to create a process that runs with the context of the user, but which the user cannot terminate without elevating to administrator. The customer is engaging in the futile arms race between programs and users (which is more properly a walls and ladders scenario). And we saw that ...

AttachThreadInput is like taking two threads and pooling their money into a joint bank account, where both parties need to be present in order to withdraw any money

Consider this code: // Code in italics is wrong foregroundThreadId = ::GetWindowThreadProcessId(::GetForegroundWindow(), 0); myThreadId = GetCurrentThreadId(); if (foregroundThreadId != myThreadId) { AttachThreadInput(foregroundThreadId, myThreadId, TRUE); BringWindowToTop(myWindowHandle); If you try to ...
Comments are closed.0 0
Code

Feedback usabilla icon