有没有可能在Ruby中获取当前的windows TickCount?
(http://msdn.microsoft.com/en-us/library/ms724408%28v=vs.85%29.aspx)
发布于 2011-04-14 20:22:58
是的,以FFI为例,这是可能的。首先,您应该安装ffi gem:
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-14 20:26:03
使用windows api:
require 'Win32API'
t = Win32API.new("kernel32", "GetTickCount", nil, 'L')
t.call()或Time.now - t.call() / 1000.0来获取机器启动的时间
https://stackoverflow.com/questions/5662568
复制相似问题