Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,653 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I have used mciSendStringW()
in my programs to play audios
One of the parameter in this function takes LPWSTR
as an output. I know it is a pointer to something string-like, wide-character.
Here is my try but it throws build error:
LPWSTR returnedString;
mciSendStringW(..., &returnedString, 1024, ...);
Note that the third parameter takes a something number, the string length, this means returnedString
must be an array-like.
so I have tried this:
wchar_t returnedString[1024];
But still didnt work. It simply throws error.
WCHAR wszCommand[]{ L"insert command here" };
WCHAR wszBuffer[1024]{};
LPWSTR pwszBuffer = static_cast<LPWSTR>(HeapAlloc(GetProcessHeap(), 0, 1024 * sizeof(WCHAR)));
mciSendStringW(wszCommand, wszBuffer, ARRAYSIZE(wszBuffer), hwnd);
mciSendStringW(wszCommand, pwszBuffer, 1024, hwnd);
Its just a buffer. Consider the two different ways to pass the pointer to the buffer as shown above.