lua 5.3最简单plugin编写

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

/* Pop-up a Windows message box with your choice of message and caption */
int lua_msgbox(lua_State* L)
{
    const char* message = luaL_checkstring(L, 1);
    const char* caption = luaL_optstring(L, 2, "");
    int result = MessageBoxA(NULL, message, caption, MB_OK);
    lua_pushnumber(L, result);
    return 1;
}

int __declspec(dllexport) libinit(lua_State* L)
{
    lua_register(L, "msgbox", lua_msgbox);
    return 0;
}

 

posted on 2019-03-07 23:36  cutepig  阅读(195)  评论(0编辑  收藏  举报

导航