2013-03-11 18 views
1

我用lua調用windows API發生故障!我無法理解,幫助! 平臺:WIN7,lua5.1forwindowslua調用GetTickCount細分

<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> 
+3

歡迎來到Stack Overflow。你需要對你的問題更精確。如果你像這樣形成你的問題,你不可能得到幫助。發佈所有相關的代碼和錯誤消息。 – Magnilex 2013-03-11 15:34:13

回答

1

你過分複雜的代碼。這段代碼打印當前滴答計數:

require "alien" 

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

謝謝!這是真的〜 – CoreDesigner 2013-03-12 00:54:27