// myLibrary2.cpp : Defines the entry point for the DLL application.
//
#include "stdafx.h"
extern "C" {
#include "d:\trunk\packages\Lua5.1\include\lua.h"
#include "d:\trunk\packages\Lua5.1\include\lualib.h"
}
#include <stdio.h>
#pragma comment(lib, "d:/trunk/Packages/Lua5.1/lib/Lua5.1.lib")
BOOL APIENTRY DllMain(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
{
if(ul_reason_for_call == DLL_PROCESS_DETACH) {
printf("DLL_PROCESS_DETACH (mylibrary2)\n");
}
return TRUE;
}
//////////////////////////////////////////////////////////////////////////
///
static int module_cleanup(lua_State* L) {
printf("module_cleanup (mylibrary2)\n");
return 0;
}
//////////////////////////////////////////////////////////////////////////
///
extern "C" __declspec(dllexport) int luaopen_mylibrary2(lua_State* L) {
printf("luaopen_mylibrary2\n");
/* env.__gc = module_cleanup */
lua_pushcclosure(L, module_cleanup, 0);
lua_setfield(L, LUA_ENVIRONINDEX, "__gc");
return 0;
}