DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Daniel has posted 5 posts at DZone. View Full User Profile

Launching The Default Web Browser On MS Windows

08.12.2007
| 2465 views |
  • submit to reddit
        # This code will launch your default web browser to the URL you provide

require 'Win32API'

ShellExecute = Win32API.new('shell32', 'ShellExecute', 'LPPPPI', 'L')

unless ShellExecute.call(0, 'open', 'http://www.rubyforge.org', 0, 0, 1) > 0
   raise "ShellExecute failed"
end