Форум: "WinAPI";
Текущий архив: 2006.08.27;
Скачать: [xml.tar.bz2];
ВнизИспользование FormatMessage Найти похожие ветки
← →
RDS © (2006-05-03 11:39) [0]Нужно получить не код ошибки, а расшифровку этого кода. Делаю следующим образом :
err:dword; perr:pchar;
................
err:=GetLastError;
//showmessage(IntToStr(err));
formatmessage(FORMAT_MESSAGE_FROM_SYSTEM,
nil,err,LANG_ENGLISH,perr,1024,nil);
showmessage(widestring(perr));
В сообщении получаю набор крокозябров. Подскажите, где может быть ошибка.
Спасибо
← →
Плохиш © (2006-05-03 11:58) [1]Память для perr распределяешь?
← →
RDS © (2006-05-03 12:27) [2]Я так понял, что FormatMessage это сам делает. Получается нужно сделать getmem(perr,1024), так?
← →
fellix (2006-05-03 12:31) [3]
> RDS © (03.05.06 11:39)
1. Создай буфер perr^ или используй FORMAT_MESSAGE_ALLOCATE_BUFFER и LocalFree.
2. Зачем там widestring?
← →
Плохиш © (2006-05-03 12:31) [4]
lpBuffer
Points to a buffer for the formatted (and null-terminated) message. If dwFlags includes FORMAT_MESSAGE_ALLOCATE_BUFFER, the function allocates a buffer using the LocalAlloc function, and places the address of the buffer at the address specified in lpBuffer.
> Получается нужно сделать getmem(perr,1024), так?
да или добавить "or FORMAT_MESSAGE_ALLOCATE_BUFFER" в первый параметр.
← →
begin...end © (2006-05-03 12:34) [5]> RDS
Посмотрите реализацию SysUtils.SysErrorMessage.
← →
RDS © (2006-05-03 13:07) [6]Спасибо, все работает
Страницы: 1 вся ветка
Форум: "WinAPI";
Текущий архив: 2006.08.27;
Скачать: [xml.tar.bz2];
Память: 0.45 MB
Время: 0.06 c