Memory management for fetching a list of drive letters on Windows
Your code is leaking memory. If you throw an exception, free no longer gets called. Using a std::vector makes sure the memory is freed. 

Iterating through the array returned is quite straight-forward, considering that each drive letter has a null-terminator and than the whole vector has an extra null-terminator (requiredSize = writtenChars + 1)

auto requiredSize = GetLogicalDriveStringsW(0, nullptr);

std::vector&lt;WCHAR&gt; buffer(requiredSize + 1);
auto writtenChars = GetLogicalDriveStringsW(requiredSize, buffer.data());

if (writtenChars &gt; requiredSize)
{
    //MSDN: If the buffer is not large enough, the return value is greater than nBufferLength.
}

if (writtenChars == 0)
{
    //handle error
}

const WCHAR* currentString = buffer.data();

while (*currentString != 0)
{
    std::wcout &lt;&lt; currentString &lt;&lt; L'\n';
    //pass currentString to other methods
    currentString += wcslen(currentString) + 1;
}