2010-07-20 22 views
5

J'ai écrit une petite application pour transférer des fichiers en utilisant les composants indy, maintenant je veux démarrer le programme antivirus lorsque le transfert est terminé pour vérifier les fichiers. Comment puis-je exécuter le programme antivirus installé côté client, lorsque le téléchargement est terminé?Exécuter un programme antivirus par programmation en utilisant Delphi

MISE À JOUR J'ai besoin d'implémenter quelque chose de similaire à firefox lorsque vous téléchargez un fichier, puis exécutez l'antivirus installé dans la machine.

merci d'avance.

+2

Ne pas la plupart des programmes antivirus crochet dans le système de fichiers et de détecter de nouveaux fichiers de toute façon? –

+0

Demandez-vous comment démarrer une application automatiquement sur l'ordinateur de l'autre utilisateur (pas le vôtre)? Es-tu en train d'essayer de faire un service? Vous avez écrit un programme anti-virus ou vous voulez que le programme anti-virus scanne votre programme qui n'est pas un anti-virus? Je suis confus. –

+0

@Warren P, j'ai mis à jour ma question. juste j'ai besoin de scanner un fichier en utilisant l'antivirus installé lorsque mon application cliente a terminé le téléchargement. – Salvador

Répondre

7

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

on dirait qu'il ya deux interfaces COM, vous devez saisir, dont un est consigné par écrit ici:

IAttachmentExecute

Cette interface fait partie des interfaces shell Windows.

ici est le commentaire de la source

/** 
* 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

La source C++ montrant comment fonctionne Firefox sur http://mxr.mozilla.org/mozilla1.9.1/source/toolkit/components/downloads/src/nsDownloadScanner.cpp – glob

2

Vérifiez comment les autres programmes le font, comme Winrar. Très probablement, il ne fait que commencer le programme anti-virus avec le fichier ou le dossier que vous souhaitez analyser en tant que paramètre de ligne de commande. Vous pouvez consulter le manuel de votre programme anti-virus pour vérifier comment cela est fait.

0

vous pouvez utiliser shellexecute ou CreateProcess, j'utilise shellexecute mais j'ai entendu CreateProcess est mieux si vous voulez exécuter un antivirus appelé dire antivvv en utilisant ShellAPI le faire de cette façon:

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

Pourquoi cela a-t-il baissé? –

+0

Je ne suis pas le seul, mais probablement parce qu'il ne fait rien pour faire de l'AV pour vérifier un fichier. –

+1

Cela dépend uniquement des options de ligne de commande du programme antivirus. -1 semble dur. – Tobiasopdenbrouw