使用delphi以编程方式执行防病毒程序

时间:2010-07-20 16:33:46

标签: delphi delphi-7 antivirus-integration windows-xp-sp2

我写了一个小应用程序来使用indy组件传输文件,现在我想在传输完成时启动防病毒程序来检查文件。

下载完成后如何执行客户端安装的防病毒程序?

更新 我需要在下载文件时执行类似于firefox的操作,然后执行机器中安装的防病毒软件。

提前感谢。

3 个答案:

答案 0 :(得分:7)

See the nice person's answer to my other question.

看起来你应该抓住两个COM接口,其中一个记录在这里:

IAttachmentExecute

此接口是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.

I found some more implementation information here. The feature is called AES.

答案 1 :(得分:2)

检查其他程序如何执行此操作,例如Winrar。最有可能的是,它只是使用您要扫描的文件或文件夹作为命令行参数启动防病毒程序。您可以查看防病毒程序的手册,看看它是如何完成的。

答案 2 :(得分:0)

你可以使用shellexecute或createprocess,   我使用shellexecute但我听说createprocess更好  如果你想使用shellapi执行一个名为antivvv的防病毒软件,请执行以下操作:

uses ShellApi;
 ...
 ShellExecute(Handle, 'open', 'c:\program files\antivvv.exe', nil, nil, SW_SHOWNORMAL) ;