我写了一个小应用程序来使用 indy 组件传输文件,现在我想在传输完成后启动防病毒程序来检查文件。
下载完成后如何执行安装在客户端的防病毒程序?
更新 下载文件然后执行机器中安装的防病毒软件时,我需要实现类似于firefox的东西。
提前致谢。
我写了一个小应用程序来使用 indy 组件传输文件,现在我想在传输完成后启动防病毒程序来检查文件。
下载完成后如何执行安装在客户端的防病毒程序?
更新 下载文件然后执行机器中安装的防病毒软件时,我需要实现类似于firefox的东西。
提前致谢。
看起来您应该获取两个 COM 接口,其中一个记录在此处:
该接口是 windows shell 接口的一部分。
这是源代码中的评论
/**
* Code overview
*
* Download scanner attempts to make use of one of two different virus
* scanning interfaces available on Windows - IOfficeAntiVirus (Windows
* 95/NT 4 and IE 5) and IAttachmentExecute (XPSP2 and up). The latter
* interface supports calling IOfficeAntiVirus internally, while also
* adding support for XPSP2+ ADS forks which define security related
* prompting on downloaded content.
*
* Both interfaces are synchronous and can take a while, so it is not a
* good idea to call either from the main thread. Some antivirus scanners can
* take a long time to scan or the call might block while the scanner shows
* its UI so if the user were to download many files that finished around the
* same time, they would have to wait a while if the scanning were done on
* exactly one other thread. Since the overhead of creating a thread is
* relatively small compared to the time it takes to download a file and scan
* it, a new thread is spawned for each download that is to be scanned. Since
* most of the mozilla codebase is not threadsafe, all the information needed
* for the scanner is gathered in the main thread in nsDownloadScanner::Scan::Start.
* The only function of nsDownloadScanner::Scan which is invoked on another
* thread is DoScan.
检查其他程序是如何做到的,比如 Winrar。很可能它只是使用您要扫描的文件或文件夹作为命令行参数启动防病毒程序。您可以查看您的防病毒程序手册以检查它是如何完成的。
您可以使用 shellexecute 或 createprocess,我使用 shellexecute,但我听说 createprocess 更好,如果您想使用 shellapi 执行名为 say antivvv 的防病毒软件,请这样做:
uses ShellApi;
...
ShellExecute(Handle, 'open', 'c:\program files\antivvv.exe', nil, nil, SW_SHOWNORMAL) ;