Converting Win32 API results to std::wstring (or std::string)

Hmm. Just realized that this is a bit out of order and should have been published before the previous post . It turns out that there are a significant number of Win32 APIs that have a similar calling pattern – you call the API once to find the size of the buffer needed for the…

2

Recursively Deleting a directory–with long filename support.

I recently was updating some test code to handle long filename (longer than MAX_PATH) support. My initial cut at the function was something like the following (don’t worry about the VERIFY_ macros, they’re functionally equivalent to asserts): const PCWSTR LongPathPrefix=L"\\\\?\\"; void RecursivelyDeleteDirectory(const std::wstring &strDirectory) { // Canonicalize the input path to guarantee it’s a full…

9

It’s a bad idea to have a TEMP environment variable longer than about 130 characters

I’ve been working with the Win32 API for almost 20 years – literally since the very first Win32 APIs were written.  Even after all that time, I’m occasionally surprised by the API behavior. Earlier today I was investigating a build break that took out one of our partner build labs.  Eventually I root caused it to…

8

Building a flicker free volume control

When we shipped Windows Vista, one of the really annoying UI annoyances with the volume control was that whenever you resized it, it would flicker.  To be more specific, the right side of the control would flicker – the rest didn’t flicker (which was rather strange).   Between the Win7 PDC release (what we called…

30

What’s the difference between GetTickCount and timeGetTime?

I’ve always believed that the most frequently used multimedia API in winmm.dll was the PlaySound API.  However I recently was working with the results of some static analysis tools that were run on the Windows 7 codebase and I realized that in fact the most commonly used multimedia API (in terms of code breadth) was…

26

Delay Load is not a good way to check for functionality

On my previous post, Koro made the following comment: “Don’t ever check windows versions.  Instead check for functionality being present or not." You can’t always do that. Do I want to add a __try/__except to catch delay-load exceptions around every UxTheme call or just do: g_bTheme=(g_bWinNT&&(g_nWinVer>0x00050001)); Then check that flag before calling OpenThemeData? In some…

15

Fixing an accessibility bug with the trackbar common control

The trackbar common control is a strange beast.  The trackbar can be oriented either horizontally or vertically.  On LTR language machines, when the trackbar is horizontal, it works much as you’d expect it to: The minimum value of the trackbar is on the left, the maximum value is on the right (it’s reversed for RTL…

9