win32ole and uint64 handling

D

Daniel Berger

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
 
M

Masaki Suketa

Hello,
In message "win32ole and uint64 handling"
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,066
Latest member
VytoKetoReviews

Latest Threads

Top