Code/Resource
Windows Develop
Linux-Unix program
Internet-Socket-Network
Web Server
Browser Client
Ftp Server
Ftp Client
Browser Plugins
Proxy Server
Email Server
Email Client
WEB Mail
Firewall-Security
Telnet Server
Telnet Client
ICQ-IM-Chat
Search Engine
Sniffer Package capture
Remote Control
xml-soap-webservice
P2P
WEB(ASP,PHP,...)
TCP/IP Stack
SNMP
Grid Computing
SilverLight
DNS
Cluster Service
Network Security
Communication-Mobile
Game Program
Editor
Multimedia program
Graph program
Compiler program
Compress-Decompress algrithms
Crypt_Decrypt algrithms
Mathimatics-Numerical algorithms
MultiLanguage
Disk/Storage
Java Develop
assembly language
Applications
Other systems
Database system
Embeded-SCM Develop
FlashMX/Flex
source in ebook
Delphi VCL
OS Develop
MiddleWare
MPI
MacOS develop
LabView
ELanguage
Software/Tools
E-Books
Artical/Document
FilterTextTest.cpp
Package: SwordOnline.rar [view]
Upload User: dzyhzl
Upload Date: 2019-04-29
Package Size: 56270k
Code Size: 2k
Category:
Game Server Simulator
Development Platform:
C/C++
- // FilterTextTest.cpp : Defines the entry point for the console application.
- //
- #include "stdafx.h"
- #include "iostream.h"
- #include "fstream.h"
- #include "..FilterTextFilterText.h"
- #include <Shellapi.h>
- typedef HRESULT (*LPFNCREATETEXTFILTER)(ITextFilter** ppTextFilter);
- ITextFilter* pTextFilter;
- void AddFilterWords(char *szFilterWordFile)
- {
- ifstream ifs(szFilterWordFile, ios::nocreate);
- if(!ifs)
- {
- cout<<"Can't Open FilterWordFile: "<<szFilterWordFile<<"!"<<endl;
- return;
- }
- char szLine[1024];
- while(!ifs.eof())
- {
- ifs.getline(szLine, 1023);
- if(ifs.bad())
- {
- cout<<"Read file error!"<<szFilterWordFile<<"!"<<endl;
- return;
- }
- pTextFilter->AddExpression(szLine);
- }
- }
- void DoTest(char *szTestFile)
- {
- ifstream ifs(szTestFile, ios::nocreate);
- if(!ifs)
- {
- cout<<"Can't Open FilterTestFile: "<<szTestFile<<"!"<<endl;
- return;
- }
- ofstream ofs("result.txt");
- if(!ofs)
- {
- cout<<"Can't create ResultFile: result.txt!"<<endl;
- return;
- }
- char szLine[1024];
- while(!ifs.eof())
- {
- ifs.getline(szLine, 1023);
- if(ifs.bad())
- {
- cout<<"Read file error!"<<szTestFile<<"!"<<endl;
- return;
- }
- if(pTextFilter->IsTextPass(szLine))
- {
- ofs<<"Pass "<<szLine<<endl;
- }
- else
- {
- ofs<<"Filt "<<szLine<<endl;
- }
- }
- ShellExecute(NULL, "open", "result.txt", NULL, NULL, SW_SHOW);
- }
- int main(int argc, char* argv[])
- {
- if(argc != 3)
- {
- cout<<"Usage: FilterTextTest 过滤信息文件 要测试的文本文件!"<<endl;
- return FALSE;
- }
- HMODULE m_hFilterText;
- LPFNCREATETEXTFILTER lpfnCreateTextFilter;
- if (!(m_hFilterText = ::LoadLibrary("FilterText.dll")))
- {
- cout<<"Can't load FilterText.dll!"<<endl;
- return FALSE;
- }
- if (!(lpfnCreateTextFilter = (LPFNCREATETEXTFILTER)GetProcAddress(m_hFilterText, "CreateTextFilter")))
- {
- FreeLibrary(m_hFilterText);
- cout<<"Can't find function CreateTextFilter!"<<endl;
- return FALSE;
- }
- lpfnCreateTextFilter(&pTextFilter);
- AddFilterWords(argv[1]);
- DoTest(argv[2]);
- FreeLibrary(m_hFilterText);
- return 0;
- }