How do I convert a LPVOID (void*) to string?
Kagamin
spam at here.lot
Thu Oct 19 17:26:52 UTC 2017
> string GetLastErrorMessage() {
>
> wchar* lpMsgBuf;
> DWORD errorMessageID = GetLastError();
>
> uint len=FormatMessageW(
> FORMAT_MESSAGE_ALLOCATE_BUFFER |
> FORMAT_MESSAGE_FROM_SYSTEM |
> FORMAT_MESSAGE_IGNORE_INSERTS,
> NULL,
> errorMessageID,
> MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
> cast(LPWSTR) &lpMsgBuf,
> 0, NULL);
>
> string msg=lpMsgBuf[0..len].to!string;
> LocalFree(lpMsgBuf);
>
> return msg;
>}
More information about the Digitalmars-d-learn
mailing list