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 */
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) |