lua调用GetTickCount细分

时间:2013-03-11 15:16:43

标签: lua

我用lua调用windows API发生故障!我无法理解,帮忙! 平台:win7,lua5.1forwindows

<i>require "alien"

--alien.load("Dll.dll")
--print(alien.defalt)
--[[
def = alien.load("msvcrt.dll")
def.puts:types("int", "string")
def.puts("foo")

scanf = def.scanf
scanf:types("int", "string", "ref int", "ref double")
_, x, y = scanf("%i%lf", 0, 0)
print(x, y)
--]]

local Kernel32 = alien.load('kernel32.dll')
GetTickCount = Kernel32.GetTickCount
GetTickCount:types{ret = "ulong", "void", abi = "stdcall"}
local c = GetTickCount(nil)</i>

1 个答案:

答案 0 :(得分:1)

你的代码过于复杂。此代码段打印当前的滴答计数:

require "alien"

local kernel = alien.load("kernel32.dll")
local ticks = kernel.GetTickCount
ticks:types({ret="ulong"})
print(ticks())