Главная страница
    Top.Mail.Ru    Яндекс.Метрика
Форум: "WinAPI";
Текущий архив: 2005.12.04;
Скачать: [xml.tar.bz2];

Вниз

Где ошибка?   Найти похожие ветки 

 
Андрей Жук ©   (2005-10-03 11:39) [0]

MSDN

BOOL UnloadKeyboardLayout(          HKL hkl
);
Parameters

hkl
[in] Input locale identifier to unload.
Return Value

If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero. The function can fail for the following reasons:

An invalid input locale identifier was passed.
The input locale identifier was preloaded.
The input locale identifier is in use.
To get extended error information, call GetLastError.

Remarks

The input locale identifier is a broader concept than a keyboard layout, since it can also encompass a speech-to-text converter, an Input Method Editor (IME), or any other form of input.

Windows 95/98/Me: UnloadKeyboardLayout cannot unload the system default input locale identifier. This ensures that an appropriate character set is always available for the user to type commands for the shell or names for the file system.

Windows NT/2000/XP: UnloadKeyboardLayout can unload the system default input locale identifier.



вызываем данную функцию. Дейстквительно, выгрузить system default input locale identifier не выходит. Но! Код ошибки - 0! Т.е. операция успешно завершена, хотя возвратиля false.

Есть также некое описание
The extended error codes returned by the GetLastError function are not guaranteed to be the same in Windows 95/98/Me and Windows NT/Windows 2000. This difference applies to extended error codes generated by calls to window management, GDI, and system services functions. For example, the ActivateKeyboardLayout, GetKeyboardLayoutName, and UnloadKeyboardLayout functions do not support extended error code values; that is, you cannot retrieve errors for these functions by using the GetLastError function.

Однако тут говорится, что GetLastError не работает верно для этой функции в Windows 95/98/Me!
Где же ошибка?


 
umbra ©   (2005-10-03 12:18) [1]

какая ошибка?


 
Андрей Жук ©   (2005-10-03 12:23) [2]

Я не могу получить код ошибки. Функция выполняется, возвращает FALSE, но GetLastError возвращает 0.


 
Игорь Шевченко ©   (2005-10-03 12:25) [3]

А ты в какой системе пробуешь ?


 
Андрей Жук ©   (2005-10-03 12:49) [4]

WinXP SP2


 
Внук ©   (2005-10-04 16:15) [5]

Поскольку код не приведен в целях тренировки телепатического аппарата участников, задам на всякий случай глупый вопрос: GetLastError точно идет следующим API-вызовом после UnloadKeyboardLayout?


 
Андрей Жук ©   (2005-10-04 17:10) [6]

void DeactivateLang(WORD dwLangID)
{
     HKL Lang = LanguageHKLTable[dwLangID]; // получим HKL (хендл раскладки клавиатуры)
     if (!UnloadKeyboardLayout(Lang)) //попробуем ее выгрузить
   ShowLastError("Could not unload keyboard layout", "Unload keyboard layout failed with error %d: %s");
}


DWORD ShowLastError(LPTSTR Caption, LPTSTR Text)
{
 TCHAR szBuf[80];
 LPVOID lpMsgBuf;
 DWORD dw = GetLastError(); //получаем последнюю ошибку
 FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER |
                FORMAT_MESSAGE_FROM_SYSTEM,
                NULL,
                dw,
                MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
                (LPTSTR) &lpMsgBuf,
                0, NULL );  //форматируем вывод ошибки
 wsprintf(szBuf, Text, dw, lpMsgBuf);
 MessageBox(GetForegroundWindow(), szBuf, Caption, MB_OK |MB_ICONERROR);//выводим соощение
 return dw;
}


 
GuAV ©   (2005-10-04 18:57) [7]

Такое бывает, см. например
procedure RaiseLastOSError;
var
 LastError: Integer;
 Error: EOSError;
begin
 LastError := GetLastError;
 if LastError <> 0 then
   Error := EOSError.CreateResFmt(@SOSError, [LastError,
     SysErrorMessage(LastError)])
 else
   Error := EOSError.CreateRes(@SUnkOSError);

 Error.ErrorCode := LastError;
 raise Error;
end;


 
umbra ©   (2005-10-04 19:01) [8]


> the ActivateKeyboardLayout, GetKeyboardLayoutName, and UnloadKeyboardLayout
> functions do not support extended error code values; that
> is, you cannot retrieve errors for these functions by using
> the GetLastError function.


Скорее всего нет никакой ошибки. Выше напписано (цитата из поста 0), что UnloadKeyboardLayout не поддерживает расширенных кодов ошибок и GetLastError для этих фнкций ничего не даст. А возможные причины ошибок описаны в том же посте ниже:


> An invalid input locale identifier was passed.
> The input locale identifier was preloaded.
> The input locale identifier is in use.


1. Неферный идентификатор локале
2. Идентификатор был предварительно загружен
3. Идентификатор используется в момент вызова функции

Очевидно, что-то из этого справедливо



Страницы: 1 вся ветка

Форум: "WinAPI";
Текущий архив: 2005.12.04;
Скачать: [xml.tar.bz2];

Наверх





Память: 0.47 MB
Время: 0.038 c
14-1131903600
makvell
2005-11-13 20:40
2005.12.04
Мастерам


1-1131266070
FBuilder
2005-11-06 11:34
2005.12.04
Panels and Splitters


5-1114105409
FunkyByte
2005-04-21 21:43
2005.12.04
Как отобразить новое свойство в инспекторе объектов?


4-1127991029
Spose
2005-09-29 14:50
2005.12.04
Выключение удаленного компьютера


2-1132226754
rsy
2005-11-17 14:25
2005.12.04
Оцените мой сайт





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