Здравствуйте, sjukov, Вы писали:
S>GetForegroundWindow
S>The GetForegroundWindow function returns a handle to the foreground window (the window with which the user is currently working).
S>The system assigns a slightly higher priority to the thread that creates the foreground window than it does to other threads.
S>HWND GetForegroundWindow(VOID);
S>Function Information
S>Minimum DLL Version user32.dll
S>Header Declared in Winuser.h, include Windows.h
S>Import library User32.lib
S>Minimum operating systems Windows 95, Windows NT 3.1
Спасиб, это помогло...но только частично. Проблема в том, что при попытке вызова
int i = GetWindowModuleFileName(hWnd,buf,MAX_NAME);
либо вообще ничего не возвращается(i=0), либо в buf возвращается имя программы, установившей хук(когда как должно, по идее, возвращаться имя программы-владельца окна hWnd).
И еще 1 вопрос: перехватываемые в некоторых приложениях(таких, как Word, cmd.exe) коды клавиш неправильно расшифровываются(не учитывается текущая раскладка и нажатия SHIFT — то есть все символы трактуются как строчные латинские буквы

). Трансляция происходит следующим образом:
LogKey(WPARAM Command,PKBDLLHOOKSTRUCT KeyInfo)
{
...
if (!GetKeyboardState(pKeyBoardState))
return -1;
// переводим вирт. коды в символы ASCII
int iCharsReturned = ToAscii(KeyInfo->vkCode,
KeyInfo->scanCode, // Scan-code
pKeyBoardState,
pRetKeys,Command==WM_SYSKEYDOWN);
...
}
С чем это может быть связано?