next up previous contents
Next: 1.3 Some information about Up: 1. Introduction Previous: 1.1 Features   Contents

1.2 How to use

Using LuaCOM is straightforward: you just have to link your program with LuaCOM's library, include the LuaCOM's header -- luacom.h -- and call the proper initialization and termination functions before using any of LuaCOM's functionalities. Here is an example of a simple C program using LuaCOM.
    * Sample C program using luacom
   #include <stdio.h>
   #include <ole2.h> // needed for OleInitialize and OleUninitialize
   #include <lua.h>

   #include "luacom.h"

   int main (int argc, char *argv[]) {

     /* COM initialization */

     /* library initialization */

     lua_State *L = lua_open();


     if(lua_dofile("activex_sample.lua") != 0) {
       puts("Error running sample.lua!");

     return 0;
Notice that it's necessary to initialize COM before lua_open and to terminate it only after the last lua_close, otherwise faults may occur.

Vinicius da Silva Almendra 2003-06-27