我需要通过只知道 HWND 来获取进程的名称
我知道使用 win32api 或 dl 或 win32/api 是可能的,但我对那个 api 的那个太奇怪的参数一无所知......我是菜鸟编程
我通过win32/api(不是win32api)获得HWND,是一个整数,不是十六进制,但我可以很容易地转换它......
这是给我句柄的代码......
require 'win32/api'
include Win32
# Callback example - Enumerate windows
EnumWindows = API.new('EnumWindows', 'KP', 'L', 'user32')
GetWindowText = API.new('GetWindowText', 'LPI', 'I', 'user32')
EnumWindowsProc = API::Callback.new('LP', 'I'){ |handle, param|
buf = "\0" * 200
GetWindowText.call(handle, buf, 200);
if (!buf.index(param).nil?)
puts "window was found: handle #{handle}"
0 # stop looking after we find it
else
1
end
}
EnumWindows.call(EnumWindowsProc, 'the title here ')
现在呢?
请帮忙!