Thanks, folks!  By coincidence, I had just successfully wrapped the API
call myself and was about to share the solution.  Dan's code may be
better (I'm still learning Ruby), but I'll go ahead and post mine below
anyway.

Jamal


require 'Win32API'

app = Win32API.new("kernel32", "GetModuleFileName", ['L', 'P', 'L'],
'L') 
handle = 0
size = 260
buffer = ' ' * size
result = app.Call(handle, buffer, size) 
puts(result) # number of characters returned to buffer (20 in this case)

path = buffer.unpack("Z*").to_s # unpack to single string
puts(path) # C:\TestRuby\ruby.exe

-----Original Message-----
From: Berger, Daniel [mailto:Daniel.Berger / qwest.com] 
Sent: Monday, April 17, 2006 4:29 PM
To: ruby-talk ML
Subject: Re: Full paths of Ruby interpreter and running script


> -----Original Message-----
> From: Jamal Mazrui [mailto:Jamal.Mazrui / fcc.gov] 
> Sent: Monday, April 17, 2006 1:47 PM
> To: ruby-talk ML
> Subject: Re: Full paths of Ruby interpreter and running script

<snip>
 
> Windows has an API function, GetModuleFileName , that returns 
> the full path of the running executable.  I may be able to 
> wrap an API call using the Win32API library, but prefer a 
> native Ruby approach if possible.
> 
> Jamal

Yep, that'll work.  For anyone who's curious:

require 'Win32API'

buf = 0.chr * 260
GetModuleFileName = Win32API.new('kernel32', 'GetModuleFileName', 'LPL',
'L')

GetModuleFileName.call(0, buf, buf.size)
puts buf.strip # "c:\\ruby\\bin\\ruby.exe"

That being said, I *thought* there was a way to do this from within Ruby
(without resorting to Win32API) but I can't think of it now, assuming it
exists.

Regards,

Dan