0

是否可以在 Ruby 中获取当前窗口 TickCount?

http://msdn.microsoft.com/en-us/library/ms724408%28v=vs.85%29.aspx

4

2 回答 2

1

是的,例如FFI是可能的。首先,您应该安装ffigem:

gem install ffi

然后附加这个函数:

require 'ffi'
module Foo
  extend FFI::Library

  ffi_lib "kernel32.dll"
  ffi_convention :stdcall

  attach_function :get_tick_count, :GetTickCount, [ ], :int
end
puts Foo.get_tick_count #=> 107073812
于 2011-04-14T12:22:57.630 回答
1

使用windows api:

require 'Win32API'

t = Win32API.new("kernel32", "GetTickCount", nil, 'L')
t.call()

Time.now - t.call() / 1000.0获取机器启动的时间

于 2011-04-14T12:26:03.173 回答