Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2082163
  • 博文数量: 519
  • 博客积分: 10070
  • 博客等级: 上将
  • 技术积分: 3985
  • 用 户 组: 普通用户
  • 注册时间: 2006-05-29 14:05
个人简介

只问耕耘

文章分类

全部博文(519)

文章存档

2016年(1)

2013年(5)

2011年(46)

2010年(220)

2009年(51)

2008年(39)

2007年(141)

2006年(16)

我的朋友

分类: 数据库开发技术

2007-06-20 14:54:18

Lotus C API 创建服务器端服务 Add-In Task
通过Lotus C API可以创建自己的服务,定期完成特定的功能。
一,演示
addin.exe位已经编译好的程序,已经拷贝到了Domino的程序目录。手动运行load addin, 可以看到特定的功能每20秒钟运行一次。如需要自动运行,需要打开notes.ini,找到ServerTasks行,修改如下:
ServerTasks=……,addin
下图为服务运行效果:
 
二,实现
1,VC++ 创建Win32 Console Application 工程
 
 
2,修改工程设置
 
 
 
3,添加如下代码
//addin.c
#include
/* Lotus C API for Domino and Notes include files */
#include
#include
 
STATUS LNPUBLIC  AddInMain (HMODULE hModule, int argc, char *argv[])
{
   
    /* Local data. */
  //  STATUS     error;           /* return code from API calls */
    HANDLE     hOldStatusLine;  /* handle to initial default status line*/
    HANDLE     hStatusLineDesc; /* handle to new default status line */
    HMODULE    hMod;            /* add-in task's module handle */
    char string1[] = "Sample Addin";
    char string2[] = "Initializing";
    char string3[] = "Addin Test: Initialization complete.";
    char string4[] = "Idle";     /* 'Idle' replaces 'Initializing' */
    char string5[] = "Doing 20-second job";
    char string6[] = "Addin Test: 20-second job complete.";
    char string7[] = "Terminating";
    char string8[] = "Addin Test: Termination complete.";
   /*
      Initialization.
      Set the task name and status string of this add-in task. The task
      name and status string appear on the status line at the Lotus Domino
      Server in response to the 'show tasks' command. By default, the
      name in the status line is the name of the program (the value of
      argv[0]). First get the handle to this default status line descriptor
      and delete it. Then create a new status line and set the status to
      'Initializing'.
    */
 
    AddInQueryDefaults (&hMod, &hOldStatusLine);
    AddInDeleteStatusLine (hOldStatusLine);
  
    hStatusLineDesc = AddInCreateStatusLine(string1);
    AddInSetDefaults (hMod, hStatusLineDesc);
    AddInSetStatusText(string2);
   
    /* Initialization is complete */
    AddInLogMessageText(string3, NOERROR);
    AddInSetStatusText(string4);     /* 'Idle' replaces 'Initializing' */
   /* Begin the main loop.  We give up control to the server at the start of
      each iteration, and get control back when the server says it is OK to
      proceed.  When AddInIdle returns TRUE, it is time to shut down this
      task.
    */
 
    while (!AddInIdle())
    {
       
        /* Do the operations that we do every 20 seconds. */
  
        if (AddInSecondsHaveElapsed(20))
        {       
            AddInSetStatusText(string5);
            AddInLogMessageText(string6, NOERROR);
            AddInSetStatusText(string4);
        }
  
    }   /* End of main task loop. */
  
   /* We get here when the server notifies us that it is time to terminate. 
      This is usually when the user has entered "quit" to the server console.
      Clean up anything we have been doing. 
    */
    AddInSetStatusText(string7);
    AddInLogMessageText(string8, NOERROR);
   
   /* End of add-in task.  We must "return" here rather than "exit". */
   
    return (NOERROR);
}
4,把编译好的程序拷贝到Domino的程序目录
5,打开notes.ini,找到ServerTasks行,修改如下:
ServerTasks=……,addin
6,运行Domino Server
文件: Lotus C API 创建服务器端服务 Add-In Task.rar
大小: 133KB
下载: 下载
阅读(1359) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~