(1)水印嵌入位置选择下划线和颜色,编程实现如下
struct wordfont
{
long line;
long color;
} wf[100];
(2)打开嵌入对话框,选择用户需要进行嵌入水印的word文档然后进行MD5加密计算,得出嵌入后结果。
void CWordwaterDlg::OnQlwater()
{
CQLwater QLwater;
if (IDOK==QLwater.DoModal())
{
m=int(fmod(double(QLwater.m_editm),double(10)));
switch (m)
{
case 0:m=3;p=1;break;
case 1:m=3;p=1;break;
case 2:m=3;p=1;break;
case 3:m=3;p=1;break;
case 4:m=4;p=3;break;
case 5:m=7;p=4;break;
case 6:m=7;p=4;break;
case 7:m=7;p=4;break;
case 8:m=11;p=7;break;
case 9:m=11;p=7;break;
}
tempm=m;
n=m*tempn;
tempsum=0;
(3)调用WORD系统文件
wfilename=QLwater.FileName;
_Application app;
COleVariant covTrue((short)TRUE),
covFalse((short)FALSE),
covOptional((long)DISP_E_PARAMNOTFOUND, VT_ERROR);
if(!app.CreateDispatch("Word.Application"))
{
AfxMessageBox("Couldn't start Word.");
}
else
{
app.SetVisible(TRUE);
}
(4)打开指定目录路径下的word文件,效果如图3.2所示.
Documents docs(app.GetDocuments());
appDoc.AttachDispatch(docs.Open(
COleVariant(QLwater.FileName,VT_BSTR),
covFalse,
covFalse,
covFalse,
covOptional,
covOptional,
covFalse, 基于WORD文档的防篡改水印系统设计与实现(8):http://www.youerw.com/jisuanji/lunwen_1627.html