[Win32utils-devel] Trouble with get_osfhandle and MSVC

Daniel Berger djberg96 at gmail.com
Thu Jul 12 14:57:08 UTC 2012


Hi,

Ruby 1.9.3-p194

I'm having trouble getting get_osfhandle to work with a Ruby compiled
with MSVC. With mingw this code works fine, but with MSVC I get an
invalid handle error.

require 'windows/handle'
require 'windows/error'

include Windows::Handle
include Windows::Error

file   = File.open('test.txt')
handle = get_osfhandle(file.fileno)

if handle == INVALID_HANDLE_VALUE || handle == 0
  raise get_last_error
end

file.close

Any ideas?

Regards,

Dan


More information about the win32utils-devel mailing list