This is very frustrating. I want to select a directory in Windows and pass the directory name to a Ruby script as an argument.
I know I need Win32API,
I know I need to call SHBrowseForFolder
but:
1. I cannot figure out what
this reference to the new method for WinAPI32 wants me to do (what's up with that l and p and i and v? What?)
and
2. I cannot figure out what arguments to pass to SHBrowseForFolder, as
Microsoft's reference is even more obscure to me (lpbi? what?).
Is my brain pea sized or is this really all not explaining it very well? Is there a better reference the Win32 API? I've been looking for one all morning.
I mean, I see
this for Python and I'm thinking, it's probably just as simple in Ruby - it has to be, right?
require 'Win32API'
fSelect = Win32API.new('shell32', 'SHBrowseForFolder', [], 'P')
fName = fSelect.call()
puts fName
to return on screen the name of the selected folder. Because I gather that SHBrowseForFolder does not need arguments and it returns a pointer to a string (whatever that means). But I get a segmentation fault. Why?
posted by Skyanth at 3:35 AM on September 21, 2006