Showing tag results for Code

May 23, 2014
Post comments count0
Post likes count1

Why is the debugger telling me I crashed because my DLL was unloaded, when I see it loaded right here happily executing code?

Raymond Chen

A customer was puzzled by what appeared to be contradictory information coming from the debugger. We have Windows Error Reporting failures that tell us that we are executing code in our DLL which has been unloaded. Here's a sample stack: But if we ask the debugger what modules are loaded, our DLL is right there, loaded as happy as can be: ...

Code
May 22, 2014
Post comments count0
Post likes count1

Why does my radio button group selection get reset each time my window regains activation?

Raymond Chen

A customer reported (all incomplete information and red herrings preserved): We have an issue related to two radio buttons in a window. The code programmatically checks the second button by sending the message. We observe that if the user clicks somewhere else on the screen (so that our application loses focus), and then clicks on the taskbar i...

Code
May 19, 2014
Post comments count0
Post likes count1

Creating a simple shell item, just as fake as a simple pidl

Raymond Chen

Continuing from Creating a simple pidl: For the times you care enough to send the very fake: Instead of creating a simple pidl, we'll create a simple shell item. The idea is the same. We build a file system bind context containing the information about the fake file, and we pass that bind context to the function. Take that program that creat...

Code
May 16, 2014
Post comments count0
Post likes count1

An extensible interlocked arithmetic function (via lambdas)

Raymond Chen

Some time ago, I noted that you can build other interlocked operations out of . Here's an example: (There's a corresponding C++ version, which I leave as an exercise.) This function atomically updates a "highest value seen so far" variable. It follows the usual pattern: Capture the starting value. Do a computation based on that value. Comp...

Code
May 14, 2014
Post comments count0
Post likes count1

The mystery of the icon that never appears

Raymond Chen

A customer reported a problem showing an icon on their dialog box. We verified that this code does execute during the handling of the message. No assertion fires, yet no icon appears either. Our dialog template says The customer did some helpful preliminary troubleshooting: Verify that the code does indeed execute. It sounds obvio...

Code
May 12, 2014
Post comments count0
Post likes count1

Enumerating bit sequences with isolated zero-bits via the Fibonacci recurrence

Raymond Chen

Today's Little Program enumerates bit sequences of a particular length subject to the constraint that you cannot have consecutive 0-bits. This may sound kind of arbitrary, but it is important in magnetic media storage, because you cannot go too long without a flux reversal (traditionally represented by a 1); otherwise, the read head's clock start...

Code
May 8, 2014
Post comments count0
Post likes count1

How can you use both versions 5 and 6 of the common controls within the same module?

Raymond Chen

Commenter Medinoc was baffled by the statement that the decision to use the visual-styles-enabled version of the common controls library is done on a window-by-window basis. " Isn't it rather on a per-module basis, depending on each module's manifest? If it is indeed on a per-window basis, how does one choose?" Whether a particular call to (or ...

Code
May 7, 2014
Post comments count0
Post likes count1

Why does saving a file in Notepad fire multiple FindFirstChangeNotification events?

Raymond Chen

Many people have noticed that the and functions (and therefore their BCL equivalent and WinRT equivalent ) fire multiple events when you save a file in Notepad. Why is that? Because multiple things were modified. Notepad opens the file for writing, writes the new data, calls to truncate any excess data (in case the new file is shorter than t...

Code