Главная страница
    Top.Mail.Ru    Яндекс.Метрика
Форум: "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
4-1146872104
Nostradamus
2006-05-06 03:35
2006.08.27
Named Pipes


15-1154543754
X9
2006-08-02 22:35
2006.08.27
Пришлашение Gmail


2-1154599051
oleolay
2006-08-03 13:57
2006.08.27
обращение к элементам TFrame из родительской формы


9-1116212592
Xeno
2005-05-16 07:03
2006.08.27
Экшн с элементами RTS - ЭДЕМ


15-1154082377
Nic
2006-07-28 14:26
2006.08.27
Siemens A50





Afrikaans Albanian Arabic Armenian Azerbaijani Basque Belarusian Bulgarian Catalan Chinese (Simplified) Chinese (Traditional) Croatian Czech Danish Dutch English Estonian Filipino Finnish French
Galician Georgian German Greek Haitian Creole Hebrew Hindi Hungarian Icelandic Indonesian Irish Italian Japanese Korean Latvian Lithuanian Macedonian Malay Maltese Norwegian
Persian Polish Portuguese Romanian Russian Serbian Slovak Slovenian Spanish Swahili Swedish Thai Turkish Ukrainian Urdu Vietnamese Welsh Yiddish Bengali Bosnian
Cebuano Esperanto Gujarati Hausa Hmong Igbo Javanese Kannada Khmer Lao Latin Maori Marathi Mongolian Nepali Punjabi Somali Tamil Telugu Yoruba
Zulu
Английский Французский Немецкий Итальянский Португальский Русский Испанский