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…
Year: 2015
ExpandEnvironmentStringsA returns a different required buffer length than ExpandEnvironmentStringsW
I was writing some ANSI-only code the other day to handle the case where an environment string expansion could return a buffer larger than MAX_PATH (the test code I was modifying assumed that it could only ever see a MAX_PATH output, I wanted to make it more resilient). The way the code worked, I defined…
PathCchCanonicalizeEx doesn’t actually canonicalize filenames (AKA: Hey Larry, it helps to RTFM).
So I was working on some file path parsing logic the other day and I ran into a problem – I was converting a file name passed in on the command line to a long filename acceptable path (one starting with \\?\). As I mentioned before, the Win32 APIs that accept \\?\ filenames assume that…
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…

