[Win32utils-devel] How to initialize and pass a VARIANT to IAccessible::get_accName?

Bill Agee billagee at gmail.com
Wed Dec 15 00:38:16 EST 2010

On Tue, Dec 14, 2010 at 6:36 PM, Heesob Park <phasis at gmail.com> wrote:

> After some debugging, I found that passing VARIANT parameter is same
> to passing four DWORD parameters  with each VARIANT content element.
> Get_accName = Win32::API::Function.new(table[10], 'PPP', 'L')
> should be
> Get_accName = Win32::API::Function.new(table[10], 'PLLLLP', 'L')
> hr = Get_accName.call(desktop_iacc_ptr, self_var, name_bstr)
> should be
> hr =
> Get_accName.call(desktop_iacc_ptr,self_var[0,4].unpack('L').first,self_var[4,4].unpack('L').first,self_var[8,4].unpack('L').first,self_var[12,4].unpack('L').first,name_bstr)

Outstanding!  The code works great now.  With your changes in place,
get_accName return S_OK, and the BSTR contains the expected string
('Desktop') when I print it with wprintf:

  Wprintf = Windows::API.new('wprintf', 'PP', 'I', 'msvcrt')

  format_str = multi_to_wide("The object name is: '%s'\n")
  format_str_ptr = [format_str].pack('p').unpack('L').first
  Wprintf.call(format_str_ptr, name_bstr.unpack('L').first)

This is huge; being able to pass a VARIANT means that the IAccessible and
IUIAutomation interfaces are now wide open. :)

Thanks so much!

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/win32utils-devel/attachments/20101214/713374a8/attachment.html>

More information about the win32utils-devel mailing list