Win32ole and uint64 handling

Hi,

Ruby 1.8.2 RC2
Windows 2000

The good news is that 1.8.2 seems to be handling uint64 types now
without segfaulting. The bad news is that it returns them as a String
instead of a Fixnum (or Bignum). Here's a little demo program:

require "win32ole"
require "socket"

host = ARGV[0] || Socket.gethostname
wmi = WIN32OLE.connect("winmgmts://#{host}/root/cimv2")

wmi.InstancesOf("Win32_Process").each{ |proc|
   # string
   p proc.Caption
   p proc.Caption.class # String
   puts "=" * 20
   
   # uint32
   p proc.ParentProcessId
   p proc.ParentProcessId.class # Fixnum
   p proc.SessionId
   p proc.SessionId.class # Fixnum
   puts "=" * 20
   
   # uint64
   p proc.KernelModeTime
   p proc.KernelModeTime.class # String ?!
   p proc.WorkingSetSize
   p proc.WorkingSetSize.class # String ?!
   break
}

Any chance this can be fixed before 1.8.2 final?

Regards,

Dan

Hello,

instead of a Fixnum (or Bignum). Here's a little demo program:

   # string
   p proc.Caption
   p proc.Caption.class # String
   puts "=" * 20
   
(snip)

   # uint64
   p proc.KernelModeTime
   p proc.KernelModeTime.class # String ?!
   p proc.WorkingSetSize
   p proc.WorkingSetSize.class # String ?!

Any chance this can be fixed before 1.8.2 final?

Unfortunately, it is not easy to fix this problem.
Because, proc.KernelModeTime and WorkingSetSize are VT_BSTR OLE type.
And win32ole converts VT_BSTR object of OLE to String of Ruby.

In VBScript, proc.KernelModeTime and proc.WorkingSetsize
are VT_BSTR(vbString) type.

Set wmi = getObject("winmgmts:")
for each proc in wmi.InstancesOf("Win32_Process")
    WScript.Echo proc.Caption
    WScript.Echo VarType(proc.Caption) ' ==> 8:vbString
    WScript.Echo "============================"

    WScript.Echo proc.ParentProcessId
    WScript.Echo VarType(proc.ParentProcessId) ' ==> 3:vbLong
    WScript.Echo proc.SessionId
    WScript.Echo VarType(proc.SessionId) ' ==> 3:vbLong
    WScript.Echo "============================"

    WScript.Echo proc.KernelModeTime
    WScript.Echo VarType(proc.KernelModeTime) ' ==> 8:vbString
    WScript.Echo proc.WorkingSetSize
    WScript.Echo VarType(proc.WorkingSetSize) ' ==> 8:vbString
    exit for
next

  Regards,
  Masaki Suketa

···

In message "win32ole and uint64 handling" on 04/07/03, Daniel Berger <djberg96@hotmail.com> writes: