Вниз
Скачать: CL | DM;

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

 
Андрей Жук ©   (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 вся ветка

Скачать: CL | DM;



Память: 0.47 MB
Время: 0.023 c
3-1129698079
syte_ser78
2005-10-19 09:01
2005.12.04
многострочный DBGrid


14-1131976315
hbreaker
2005-11-14 16:51
2005.12.04
Форма и цвет. Мой хомяк.


2-1132068213
PAI
2005-11-15 18:23
2005.12.04
Довольно большая программа понемногу, но "подъедает" память.


14-1131633246
seg
2005-11-10 17:34
2005.12.04
Первопроходцы интернета Винт Серф и Боб Кан получили высочайшую н


2-1130844404
Moningstar
2005-11-01 14:26
2005.12.04
Из DLL не в DLL




   Наверх