Главная страница
    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.041 c
2-1154607114
TrainerOfDolphins
2006-08-03 16:11
2006.08.27
Refresh с возвратом на вновь вставленную запись.


15-1154011493
Vlad
2006-07-27 18:44
2006.08.27
Майкрософт шалит? :-)


15-1154501290
vidiv
2006-08-02 10:48
2006.08.27
Русская ISA Server 2004


15-1154431998
cyborg
2006-08-01 15:33
2006.08.27
Библиотека звуков


2-1155022166
4IZH
2006-08-08 11:29
2006.08.27
программное перемещение указателя мыши





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
Английский Французский Немецкий Итальянский Португальский Русский Испанский