From: ptkwt@...1.aracnet.com (Phil Tomson) Date: 2001-09-23T11:42:24+09:00 Subject: [ruby-talk:21568] ANN: Ruby Win32 Library Well, it's not complete yet, but there are a few useful things in it so I'm announcing it now. You can download it from: http://www.aracnet.com/~ptkwt/win32ext.tar There is a pre-built shared lib included: Win32.so - but I've found that if I move to a different version of Ruby that sometimes it needs to be rebuilt. Best to run ruby extconf.rb and then make. Here's the README.txt file: Ruby Win32 library What is it? The ultimate goal of the Ruby Win32 library is to build a hierarchical library similar in function and structure to Perl's Win32 libraries. Everything here is released under the same license as Ruby. It is organized as follows: Win32 - toplevel module which contains some functions and constants Process - a class defined under Win32 which allows for OO creation and manipulation of processes. (more to come) How do I use it? Process usage example: require "win32process" myProcess = Win32::Process.new("c:\\Windows\\notepad.exe","notepad tmp.txt",TRUE,Win32::CREATE_NEW_PRODUCT_GROUP,".") #check the process id: puts myProcess.pid #wait 1 second: myProcess.wait(1000) #kill the process: myProcess.kill(exitCode) #where exitcode is an integer Win32 module functions: InWinNT? - returns true if running on Win(NT|2K) InWin98? - returns true if running on Win(95|98) (and probably ME) GetOSVersion - returns a hash composed of the elements of the OSVERSIONINFO struct. Keys are: "MajorVer","MinorVer","BuildNum", "PlatformID" Win32 constants: Several constants from winbase.h are made available to the Ruby side. They are accessable with a Win32:: prefix, like: Win32::INFINITE, Win32::CREATE_PROCESS_GROUP Process class methods: Process.timedSystemCommand(command, redirFile=nil, time=100) where: 'command' is a string containing the command to run 'redirFile' is a string containing a filename to redirect STDOUT of the process. 'time' is a FixNum indicating the number of seconds to wait before the process is terminated. Process.new - see usage example above Process instance methods: wait(time) - where time is in miliseconds kill(exitcode) - where exitcode is a FixNum indicating the exitcode [in the future I'll add suspend and resume methods as well] Building: run: ruby extconf.rb make NOTE: there is not currently a 'make install' so you'll have to either manually put the Win32.so in your local directory, or you'll have to copy it to your ruby/site-library for now. #end of README.txt I'm probably going to be working on converting Perl's Win32::GuiTest module over to Ruby as the next, but I'm open to requests. Phil