require 'Win32API'
require 'win32ole'
require 'darkhall/util'

module DarkHall
	module Util
		module_function
		
		def multiple_boot?
			api = Win32API.new('user32.dll', 'FindWindow', 'pp', 'i')
			handle = api.call(nil, WINDOW_CAPTION)
			
			return handle != 0
		end
		
		def reboot_game
			wsh = WIN32OLE.new('WScript.Shell')
			if defined?(ExerbRuntime) then
				wsh.Run(ExerbRuntime.filename)
			else
				wsh.Run(%Q|rubyw "#{$0}"|)
			end
		end
		
		def open_manual
			api = Win32API.new('shell32.dll','ShellExecuteA',%w(p p p p p i),'i')
			api.call(0, 'open', File.expand_path('manual/index.html'), 0, 0, 1)
		end
	end
end
