Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

После detach/attach не работают некоторый функции winapi #1878

Open
Maximus5 opened this Issue Jul 31, 2015 · 0 comments

Comments

Projects
None yet
1 participant
@Maximus5
Copy link
Owner

Maximus5 commented Jul 31, 2015

Originally reported on Google Code with ID 1879

Задача: получить PID процесса, которому принадлежит foreground-окно.
Получаю хэндл окна через GetForegroundWindow, и передаю в GetWindowThreadProcessId.
Однако в некоторых случаях вызов завершается ошибкой "Invalid window handle."

Происходит это в случае если из конему запустить фар, сделать deattach, и снова attach.

Ниже lua-скрипт для воспроизведения:

local ffi = require"ffi"
local C = ffi.C
ffi.cdef[[
//https://msdn.microsoft.com/library/ms633505
HWND GetForegroundWindow(void);
//https://msdn.microsoft.com/library/ms633522
DWORD GetWindowThreadProcessId(HWND hWnd,LPDWORD lpdwProcessId);
]]
local hWnd = C.GetForegroundWindow()
local lpdwProcessId = ffi.new("DWORD[1]",1)
if 0==C.GetWindowThreadProcessId(hWnd,lpdwProcessId) then
  far.Message("","",nil,"we")
else
  far.Message(lpdwProcessId[0])
end

Хотелось бы понять в чём ошибка.

Reported by anton.sinitsin on 2015-01-22 19:21:32

@Maximus5 Maximus5 self-assigned this Jul 31, 2015

@Maximus5 Maximus5 added the Type-Other label Jul 31, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.