How do I convert a LPVOID (void*) to string?

Nieto neto.ribeiro at email.com
Mon Oct 16 21:50:47 UTC 2017


On Monday, 16 October 2017 at 21:48:35 UTC, Nieto wrote:
> How do I convert/create a D string from LPVOID (void*)?
>
>> string GetLastErrorMessage() {
>>
>>	LPVOID lpMsgBuf;
>>	DWORD errorMessageID = GetLastError();
>>
>>	FormatMessageA(
>>		FORMAT_MESSAGE_ALLOCATE_BUFFER |
>>		FORMAT_MESSAGE_FROM_SYSTEM |
>>		FORMAT_MESSAGE_IGNORE_INSERTS,
>>		NULL,
>>		errorMessageID,
>>		MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
>>		cast(LPSTR) &lpMsgBuf,
>>		0, NULL);
>>
>>
>>	return ??
>>}

I forget to call LocalFree(lpMsgBuf); here...


More information about the Digitalmars-d-learn mailing list