annotate ruby/rbdc/examples/win32msgbox.rb @ 0:0cfcc391201f

initial from svn dyncall-1745
author Daniel Adler
date Thu, 19 Mar 2015 22:26:28 +0100
parents
children 5e159be89d73
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
1 #//////////////////////////////////////////////////////////////////////
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
2 #
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
3 # win32msgbox.rb
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
4 # Copyright 2007-2014 Tassilo Philipp
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
5 #
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
6 # Dyncall sample loading user32.dll on windows, listing all user32
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
7 # symbols and displaying a # native windows message box by calling
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
8 # MessageBoxA(...).
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
9 #
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
10 #///////////////////////////////////////////////////////////////////////
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
11
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
12 require 'rbdc'
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
13
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
14 l = Dyncall::ExtLib.new
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
15 if l.load('user32') != nil and l.syms_init('user32')
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
16 l.syms_each { |s| puts s }
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
17 puts l.syms_count
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
18 puts l.exists?(:NonExistant)
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
19 puts l.exists?(:MessageBoxA)
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
20 puts l.call(:MessageBoxA, 'IZZI)i', 0, 'Hello world from dyncall!', 'dyncall demo', 0)
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
21 # @@@ check puts on dyncall called function returning a void... crashes e.g. change above signature to IZZI)v
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
22 end