Sha256: 273b97465d0b951b48e642ee19933b8ba05f7de327e59de3fc9d10e3573565e6

Contents?: true

Size: 1.42 KB

Versions: 5

Compression:

Stored size: 1.42 KB

Contents

require 'Win32API'

module Windows
   module Handle
      INVALID_HANDLE_VALUE = -1
      
      HANDLE_FLAG_INHERIT            = 0x00000001
      HANDLE_FLAG_PROTECT_FROM_CLOSE = 0x00000002
      
      CloseHandle          = Win32API.new('kernel32', 'CloseHandle', 'L', 'I')
      DuplicateHandle      = Win32API.new('kernel32', 'DuplicateHandle', 'LLLLLIL', 'I')
      GetHandleInformation = Win32API.new('kernel32', 'GetHandleInformation', 'LL', 'I')
      SetHandleInformation = Win32API.new('kernel32', 'SetHandleInformation', 'LLL', 'I')

      GetOSFHandle         = Win32API.new('msvcrt', '_get_osfhandle', 'I', 'L')
      OpenOSFHandle        = Win32API.new('msvcrt', '_open_osfhandle', 'LI', 'I')
            
      def CloseHandle(handle)
         CloseHandle.call(handle) != 0
      end
      
      def DuplicateHandle(sphandle, shandle, thandle, access, ihandle, opts)
         DuplicateHandle.call(sphandle, shandle, thandle, access, ihandle, opts) != 0
      end
      
      def GetHandleInformation(handle, flags)
         GetHandleInformation.call(handle, flags) != 0
      end
      
      def SetHandleInformation(handle, mask, flags)
         SetHandleInformation.call(handle, mask, flags) != 0
      end
      
      def get_osfhandle(fd)
         GetOSFHandle.call(fd)
      end
      
      def open_osfhandle(handle, flags)
         OpenOSFHandle.call(handle, flags)
      end
   end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
windows-pr-0.6.2 lib/windows/handle.rb
windows-pr-0.6.4 lib/windows/handle.rb
windows-pr-0.6.5 lib/windows/handle.rb
windows-pr-0.6.6 lib/windows/handle.rb
windows-pr-0.6.3 lib/windows/handle.rb