Subject:
[ruby-ffi] Re: unable to find method?
From:
bbiker
Date:
12/18/09 12:19 AM
To:
ruby-ffi



On Dec 17, 7:28 pm, rogerdpack <rogerpack2...@gmail.com> wrote:
> Perhaps I'm missing something here...
>
> require 'ffi'
>
> module Hello
>   extend FFI::Library
>   ffi_lib 'user32'
>   attach_function 'FindWindow', [ :string, :string], :pointer # blows
> up
> end
>
> ref:http://msdn.microsoft.com/en-us/library/ms633499(VS.85).aspx
>
> What might it be...?
> -r

'FindWindow' does not exists in user32.dll ... the following 4
functions are in user32.dll although at I am at loss to explain the
differences among them.

FindWindowA
FindWindowExA
FindWindowExW
FindWindowW

This was my result from snippet:

irb(main):002:0>
irb(main):003:0* module Hello
irb(main):004:1> extend FFI::Library
irb(main):005:1> ffi_lib 'user32'
irb(main):006:1> attach_function 'FindWindow',
[ :string, :string], :pointer
irb(main):007:1> end
FFI::NotFoundError: Function 'FindWindow' not found in [user32]
        from C:/Ruby19/lib/ruby/gems/1.9.1/gems/ffi-0.5.4-x86-mingw32/
lib/ffi/library.rb:77:in `attach_function'
        from (irb):6:in `<module:Hello>'
        from (irb):3
        from C:/Ruby19/bin/irb:12:in `<main>'

This is the result when I used 'FindWindowW':

irb(main):010:1> module Hello
irb(main):011:1> extend FFI::Library
irb(main):012:1> ffi_lib 'user32'
irb(main):013:1> attach_function 'FindWindow',
[ :string, :string], :pointer
irb(main):014:1> end
=> #<FFI::Pointer address=7E42C9C3>

I suggest you go to: http://www.nirsoft.net/utils/dll_export_viewer.html
and download their dll_export_viewer utility...it's free.

Hope this helps.

renard@nc.rr.com