c 修改服务器文件名,Lotus C API 实现 Lotus Notes Client 端直接修改数据库文件名字...

Lotus Notes Client 端直接修改数据库文件名字

Lotus Notes Client可以创建删除数据库,但是无法修改数据库文件名字。本文用Lotus Notes C API实现。

一,演示,假定服务器上有数据库a.nsf要改名为b.nsf。

1, 选择Rename File菜单,Rename File菜单为Lotus Notes C API添加的Add-In Menu .

2, 弹出对话框

3,选择OK,发送命令Load Rename a.nsf b.nsf到Domino Server Console

3, 服务器端有如下显示

5,服务器端程序Rename.exe完成改名任务

二,实现

Lotus Notes Client端Add-In Menu .

1,新建Win32 Application工程

2,修改工程设置

3,添加如下对话框资源

4,添加如下代码

// test1.cpp : Defines the entry point for the DLL application.

//

/* Standard library include files */

#include "stdafx.h"

#include #include /* Domino and Notes include files */

#include #include #include #include #include #include "resource.h"

HANDLE hRetInfo;

STATUS nError;

char str1[50];

char str2[50];

char str3[50];

HINSTANCE hinst = NULL;

HWND hwndDLG = NULL;

BOOL CALLBACK DlgProc(HWND hDlg, UINT message,WPARAM wParam, LPARAM lParam);

BOOL APIENTRY DllMain( HANDLE hModule,

DWORD  ul_reason_for_call,

LPVOID lpReserved

)

{

switch(ul_reason_for_call)

{

case DLL_PROCESS_ATTACH:

hinst = (HINSTANCE)hModule;

case DLL_PROCESS_DETACH:

break;

}

return TRUE;

}

BOOL CALLBACK DlgProc(HWND hDlg, UINT message,

WPARAM wParam, LPARAM lParam)

{

switch(message)

{

case WM_INITDIALOG:

return TRUE;

case WM_SHOWWINDOW:

return TRUE;

case WM_COMMAND:

if(LOWORD(wParam)==IDOK)

{

GetWindowText(GetDlgItem(hDlg,IDC_EDIT1),str1,50);

GetWindowText(GetDlgItem(hDlg,IDC_EDIT2),str2,50);

GetWindowText(GetDlgItem(hDlg,IDC_EDIT3),str3,50);

char str[200]="";

strcat(str,"Load Rename ");

strcat(str,str2);

strcat(str," ");

strcat(str,str3);

nError = NSFRemoteConsole (str1, "dbcache flush", &hRetInfo);

if (nError != NOERROR)

return (ERR(nError));

nError = NSFRemoteConsole (str1, str, &hRetInfo);

if (nError != NOERROR)

return (ERR(nError));

OSMemFree (hRetInfo);

MessageBox(NULL,"Successful!","window",MB_OK);

}

if(LOWORD(wParam)==IDCANCEL)

{

SendMessage(hDlg,WM_CLOSE,wParam,lParam);

}

return TRUE;

case WM_CLOSE:

DestroyWindow(hDlg);

hwndDLG = NULL;

return TRUE;

}

return FALSE;

}

extern "C" NAMRESULT LNCALLBACK AddinMenuProc (WORD wMsg, LONG lParam)

{

switch (wMsg)

{

case NAMM_INIT:

{

NAM_INIT_INFO *pInitInfo;

/* lParam is a pointer to the NAM_INIT_INFO structure */

pInitInfo = (NAM_INIT_INFO *)lParam;

/* Add the menu item to the Notes Actions menu */

/* Assign this menu item an id and a name */

pInitInfo->wMenuID = 0;

strcpy (pInitInfo->MenuItemName, "&Rename File");

/* tell Notes that there are no more menu items to add */

return (NAM_INIT_STOP);

}

case NAMM_COMMAND:

{

//MessageBox(NULL,"Hello World","window",MB_OK);

hwndDLG = CreateDialog(hinst,MAKEINTRESOURCE(IDD_DIALOG1),

NULL,(DLGPROC)DlgProc);

ShowWindow(hwndDLG, SW_SHOW);

return (NOERROR);

}

default:          /* default processing for all other messages */

return (NAM_NOERROR);

}

}

5,添加.def文件 test1.def

LIBRARY    TEST1

DESCRIPTION 'TEST1 - Sample menu add-in'

HEAPSIZE    0

EXPORTS

AddinMenuProc      @1   ;

6,把编译好的test1.dll拷到Lotus Notes Client的程序目录

7,修改Lotus Notes Client的Notes.ini文件,添加如下:

addinmenus=test1.dll

服务器端编写一个Win32 Console Application

1,新建Win32 Console Application 工程

2,添加如下代码

//Rename.CPP

#include "StdAfx.h"

#include "iostream.h"

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

{

// Check the command line.

char dir[100];

char str1[100],str2[100];

if (argc != 3)

{

cout << "\nUsage:\n\t" << argv[0] << " \n" << endl;

return (1);

}

int i=0,j=0;

char *p=argv[0];

char *pos=argv[0];

while(*p)

{i++;

if(*p=='\\')

{

while(i>0){

str1[j]=str2[j]=dir[j]=*pos;

pos++;i--;j++;

}

i=0;

}

p++;

}

dir[j]='\0';

str1[j]='\0';

str2[j]='\0';

strcat(str1,"data\\");

strcat(str1,argv[1]);

strcat(str2,"data\\");

strcat(str2,argv[2]);

MoveFile(str1,str2);

return (0);

}

3,把编译好的Rename.exe拷贝到Domino的程序目录

rar.gif

文件:

Lotus Notes Client 端直接修数据库改文件名字.rar

大小:

204KB

下载:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值