From: Takaaki Tateishi Date: 2002-10-31T17:55:17+09:00 Subject: Re: Close Internet Explorer At Thu, 31 Oct 2002 16:49:10 +0900, > callback procedure such as EnumWindows(). Ruby/DL will be the > better one for his problem. > Ruby/DL -- http://www.ruby-lang.org/en/raa-list.rhtml?id=629 ... > require 'dl' In the alternative, we rewrite your code with `dl/import.rb' as follows. require 'dl/import' module Foo extend DL::Importable dlload "user32" extern "BOOL EnumWindows(void *, long)" extern "BOOL PostMessage(long, int, long, long)" extern "BOOL GetClassName(long, void *, int)" WM_CLOSE = 0x0010 def enum_windows_proc(hwnd, lparam) buff = DL.malloc(16) name = "IEFrame" r = getClassName(hwnd, buff, buff.size) if /^#{name}$/ =~ buff.to_s r = postMessage(hwnd, WM_CLOSE, 0, 0) end 1 end EnumWindowsProc = callback "int enum_windows_proc(long, long)" end Foo.enumWindows(Foo::EnumWindowsProc, 0) -- Takaaki Tateishi