ext/dl/sample/msgbox.rb


DEFINITIONS

This source file includes following functions.


   1  # This script works on Windows.
   2  
   3  require 'dl'
   4  
   5  User32 = DL.dlopen("user32")
   6  Kernel32 = DL.dlopen("kernel32")
   7  
   8  MB_OK = 0
   9  MB_OKCANCEL = 1
  10  
  11  message_box = User32['MessageBoxA', 'ILSSI']
  12  r,rs = message_box.call(0, 'ok?', 'error', MB_OKCANCEL)
  13  
  14  case r
  15  when 1
  16    print("OK!\n")
  17  when 2
  18    print("Cancel!\n")
  19  end