免安装WinPcap的方式建立应用程序或者安装程序
来源:互联网 发布:无主之地2mac汉化包 编辑:程序博客网 时间:2024/04/27 20:25
- 免安装WinPcap的方式建立应用程序或者安装程序2007-05-17 19:01:20大 中 小前段时间使用WinPcap开发了一个捕获分析软件。还算顺利,但是在制作安装包的时候遇到一些问题。我当然不愿意让别人使用我的软件的时候安装两次,最好免安装绿色版,后来经过分析。发现一些规律,我使用Delphi7+WinPcap3.1可以实现绿色免安装使用。之前在网上看到很多都不太实用。在Xp和2000下测试成功。下面介绍我是如何制作绿色版本的。1)准备WinPcap的文件首先在可以先安装WinPcap3.1(好像最新到了4.0了,不过3.1稳定),然后在把%SystemRoot%System32目录下:Packet.dll,wpcap.dll,WanPacket.dll,pthreadVC.dll和%SystemRoot%System32/drivers目录下:npf.sys还有Winpcap安装目录下:daemon_mgm.exe,NetMonInstaller.exe,npf_mgm.exe,rpcapd.exe共9个文件复制到应用程序根目录。2)在应用程序中编写代码
procedure TMonForm.FormCreate(Sender: TObject);
varlpBuf:array[0..254] of Char;
ls_Driver : String;
ls_NpfFile:String;
ls_Lcname:String;
ls_windows:String;
begin//获取%SystemRoot%的目录
GetWindowsDirectory(lpBuf,254);
ls_windows := StrPas(lpbuf);
//获取系统目录%SystemRoot%System32
GetSystemDirectory(lpBuf,254);
GS_SystemDir := StrPas(lpbuf);//复制npf.sys到系统目录,并删除假目录,有时候会出现目录名和文件
//同名导致应用程序启动后看不到网卡
ls_Driver := GS_SystemDir + '/drivers';
ls_NpfFile := ls_Driver + '/npf.sys';
ls_Lcname := ExtractFilePath(Application.ExeName) + 'npf.sys';
RemoveDirectory(PChar(ls_NpfFile));
RemoveDirectory(PChar(GS_SystemDir + '/Packet.dll'));
RemoveDirectory(PChar(GS_SystemDir + '/WanPacket.dll'));
RemoveDirectory(PChar(GS_SystemDir + '/wpcap.dll'));
binPath := ExtractFilePath(Application.ExeName) ; //应用程序根目录
//判断是否存在该系统文件
if not FileExists(ls_Lcname) then
begin
Application.MessageBox(Pchar('丢失系统文件!'),PChar('错误'), MB_OK + MB_ICONSTOP);
Application.Terminate;
end;
RemoveDirectory(PChar(ls_NpfFile));
CopyFile(PChar(ls_Lcname),PChar(ls_NpfFile),false);
CopyFile(PChar(ExtractFilePath(Application.ExeName)+ 'Packet.dll'),PChar(GS_SystemDir + '/Packet.dll'),false);
CopyFile(PChar(ExtractFilePath(Application.ExeName)+ 'WanPacket.dll'),PChar(GS_SystemDir + '/WanPacket.dll'),
false);
CopyFile(PChar(ExtractFilePath(Application.ExeName) + 'wpcap.dll'),
PChar(GS_SystemDir + '/wpcap.dll'),false);
CopyFile(PChar(ExtractFilePath(Application.ExeName)+ 'pthreadVC.dll'),PChar(GS_SystemDir + '/pthreadVC.dll'),
false);
CopyFile(PChar(ls_Lcname),PChar(ls_NpfFile),false);
//这是关键部分--->启动捕获服务
WinExec(PChar(binPath + '/NetMonInstaller.exe u'),SW_HIDE);
WinExec(PChar(binPath + '/daemon_mgm.exe -u'),SW_HIDE);
WinExec(PChar(binPath + '/npf_mgm.exe -u'),SW_HIDE);WinExec(PChar(binPath + '/npf_mgm.exe -r'),SW_HIDE);
WinExec(PChar(binPath + '/daemon_mgm.exe -r'),SW_HIDE);
WinExec(PChar(binPath + '/NetMonInstaller.exe i'),SW_HIDE);
//启动显示界面//......下面就是应用程序代码,完全可以实现免安装和一体化打包
end;
- 免安装WinPcap的方式建立应用程序或者安装程序
- Winpcap 免安装
- Winpcap 免安装
- Winpcap的安装使用方法
- Winpcap的安装使用方法
- winpcap的静默安装
- Linux打包免安装的Qt程序
- winpcap 安装
- WinpCap安装
- 免安装版Tomcat双击应用程序闪退的解决办法
- iPhone免证书安装程序
- mysql安装(Win)_zip免安装方式
- Android 应用程序安装方式 的详细调研
- android应用程序的安装方式与原理
- android应用程序的安装方式与原理
- android应用程序的安装方式与原理
- android应用程序的安装方式与原理
- android应用程序的安装方式与原理
- 运维服务管理的5大难点及对策
- 标记数据分析
- PB做的史上最强的矢量画图软件(VISIO也要低头)
- CRM如何才能满足客户需求
- 技术谋杀了CRM战略
- 免安装WinPcap的方式建立应用程序或者安装程序
- 本质啊本质之四:数组的本质
- 电子产品节能迫在眉睫
- 北京图王软件开发有限公司产品介绍-Visual Graph专业图形引擎
- 基于Visual Graph快速开发出电力系统
- 矿井人员定位考勤系统设计方案
- 农村宅基地的信息化系统图形应用解决方案
- How to display "Writing language" menu automatically in edwin context menu on Symbian S60
- 如何快速开发图形仿真软件系统