API

For general discussion related FlowStone
Post Reply
S1User
Posts: 58
Joined: Thu Sep 17, 2015 4:05 pm

API

Post by S1User »

If anyone knows...

Why does triggering this Ruby code with a button work in design mode but when I compile it to a standalone exe it doesn't work?

Code: Select all

require 'win32API'

api = Win32API.new('user32', 'MessageBox', ['L', 'P', 'P', 'L'], 'I')

message = "This is a sample Windows message box generated using Win32API"
title = "Win32API from Ruby"

api.call(0,message,title,0)
Attachments
apistuff.fsm
(1.35 KiB) Downloaded 859 times
Tronic
Posts: 539
Joined: Wed Dec 21, 2011 12:59 pm

Re: API

Post by Tronic »

You have to include the right ruby library folder in
$LOAD_PATH global variable
ruby use it to search the required file

Code: Select all

# set the current exe ruby library directory to work with
Dir.chdir("C:\\your app folder\\ruby_library")
# list all sub directory
your_lib_dir=Dir["**/"].reject{|o| not File.directory?(o)}
your_lib_dir.each {|dir|
   path = File.expand_path(dir)
   # add the path to $LOAD_PATH where ruby search for the require method
   $LOAD_PATH.unshift path unless $LOAD_PATH.include? path
   }


When you ship or install your application in other pc, you have to enclose the required file with it.
./-- exe folder
     |
     |--ruby_library
Post Reply