I’m new to Ruby and I have been trying to get this piece of code to call
MessageBox but can’t. I know I am missing something but I don’t know
what it is. Any help with this would be greatly appreciated!
Here is the code so far:
require 'Win32API'
LoadLibrary = Win32API.new('kernel32','LoadLibrary','P','L')
GetProcAddress = Win32API.new('kernel32','GetProcAddress','LP','L')
Load = LoadLibrary.call('user32.dll')
Proc = GetProcAddress.call(Load,'MessageBox')
Proc.call(0,"Hello World!","MessageBox in Ruby",0)
I know everything is ok except my “Proc.call”. What am I missing?
Is this the error you’re seeing?
I don’t think it’s necessary to use
GetProcAddressfor this. Here is some example code for displaying a message box:In your current code
Procis the return value fromGetProcAddressand not a callable object. I suspect this is0because the call toGetProcAddresshas failed.