1

我用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>
4

1 回答 1

1

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

require "alien"

local kernel = alien.load("kernel32.dll")
local ticks = kernel.GetTickCount
ticks:types({ret="ulong"})
print(ticks())
于 2013-03-11T17:28:00.140 回答