lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Fietiger Cheng <fietiger@gmail.com> [2010-10-05 09:38:16]:

> // LuaCall.cpp : Defines the entry point for the DLL application.
> //
>  #include "stdafx.h"
> #include <afxdllx.h>

This sample bellow works for me:

test.c:

#include <lua.h>
#include <lauxlib.h>
#include <windows.h>

static int lua_hello(lua_State *L)
{
	MessageBox(GetForegroundWindow(), L"hello", L"Lua", MB_ICONERROR);
	return 0;
}

static struct luaL_reg test[] = {
	{ "hello", lua_hello },
	{ NULL, NULL }
};

__declspec(dllexport) int luaopen_test(lua_State *L)
{
	luaL_register(L, "test", test);
	return 0;
}

test.lua:

require('test')
test.hello()