I have the win32 API CommandLineToArgvW
which returns a LPWSTR*
and
warns me that
CommandLineToArgvW
allocates a
And what about an answer using Microsoft Windows Implementation Libraries (WIL)?
First of all "install" WIL (from a terminal):
c:\dev>git clone https://github.com/microsoft/wil.git
And then:
#include
#include
#include "c:/dev/wil/include/wil/resource.h"
int main(int argc, char* argv[])
{
{
int n = 0;
wil::unique_hlocal_ptr p(::CommandLineToArgvW(L"cmd.exe p1 p2 p3", &n));
for (int i = 0; i < n; i++) {
std::wcout << p.get()[i] << L"\n";
}
}
return 0;
}