Да, возвращает GetWindowThreadProcessId действительно thread id, но там есть out параметр для пида.
Скопипасчу пример кода из адаптера для винапи который я сделал.
Код
local WinUser = ffi.load('User32')
ffi.cdef[[
int __stdcall GetWindowThreadProcessId(int hWnd, int *lpdwProcessId);
]]
local WinApiInterface = {}
function WinApiInterface.GetWindowThreadProcessId(handle)
local pid = ffi.new("int[1]")
local threadId = WinUser.GetWindowThreadProcessId(handle, pid)
assert(threadId ~= 0, 'GetWindowThreadProcessId error: incorrect handle passed: '..handle)
return {
pid = pid[0],
threadId = threadId
}
end
return WinApiInterface