#!ruby # -*- mode: ruby; coding: utf-8 -*- # Last updated: <2022/08/16 23:17:28 +0900> # # ffi sample. messagebox. # # winapi - What are the Ruby Win32API Parameters | How do I pass a null pointer? - Stack Overflow # https://stackoverflow.com/q/8099694 # # * Windows10 x64 21H2 # * Ruby 1.8.7 p330 i386-mswin32, i386-mingw32 + ffi 1.9.14 x86-mingw32 # * Ruby 1.9.3 p551 i386-mingw32 + ffi 1.9.14 x86-mingw32 # * Ruby 2.6.10 p210 i386-mingw32 + ffi 1.15.5 x86-mingw32 require "rubygems" require 'ffi' module Win32 extend FFI::Library ffi_lib "user32" attach_function :messageBox, :MessageBoxA, [:pointer, :string, :string, :long], :int end rc = Win32.messageBox(nil, "Hello World", "MessageBoxA by FFI", 0x40) puts rc