The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
win32-api and function pointers

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Daniel Berger

Posts: 1383
Nickname: djberg96
Registered: Sep, 2004

Daniel Berger is a Ruby Programmer who also dabbles in C and Perl
win32-api and function pointers Posted: Jun 12, 2008 7:25 PM
Reply to this message Reply

This post originated from an RSS feed registered with Ruby Buzz by Daniel Berger.
Original Post: win32-api and function pointers
Feed Title: Testing 1,2,3...
Feed URL: http://djberg96.livejournal.com/data/rss
Feed Description: A blog on Ruby and other stuff.
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by Daniel Berger
Latest Posts From Testing 1,2,3...

Advertisement
It wasn't very long into the win32-ole rewrite that we discovered we need to be able to wrap a raw function pointer (address) via win32-api if we wanted to continue. It was easy enough to add. So, now, with the release of 1.1.0, you can do this:
require 'win32/api'
include Win32

LoadLibrary    = API.new('LoadLibrary', 'P', 'L')
GetProcAddress = API.new('GetProcAddress', 'LP', 'L')
 
hlib = LoadLibrary.call('user32')
addr = GetProcAddress.call(hlib, 'MessageBeep')
func = Win32::API::Function.new(addr, 'L', 'L') # This is the new bit
func.call(0)

The original motivation came from the GetActiveObject() function which takes and returns a pointer to an active object. Since that only gives us an address and not a name, we had to be able to deal with that.

So now we do. :)

Read: win32-api and function pointers

Topic: Sending mail from Rails through Google SMTP Previous Topic   Next Topic Topic: Vancouver.rb Q&A with Adam Palmblad on Startup TeamPages.com, Ruby on Rails, Tips and Tricks on...

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use