Reputation: 5
Presently I am developing a small security application in Delphi. It is intended to be installed in Windows XP and higher OS-s and almost finished, but I'd like to implement the feature to scan MS Office files while opening. To that end, I'm planning to use IOfficeAntiVirus interface. I am trying to realize using the scan method of the interface based on the article by Serge Perevoznyk (http://www.delphi-central.com/MS_Office_AV_API.aspx).
The original example supposed to display a message box when a file is opened, however it does not, although I tried it on different versions of Windows and Office. I compared this solution with the information on MSDN. It seemed to be correct. I suppose there should be some additional settings in the Windows Registry which I missed to make. Can anyone give me some hint where shall I look for the solution?
Upvotes: 0
Views: 383
Reputation: 5
Just for information's sake if anyone is interested. Remy's answer is correct, however there is a small bug in the initialization section of the above mentioned example project.
Instead of
TComObjectFactory.Create(ComServer, TMsoTest, Class_MsoTest, 'MsoTest', '', ciMultiInstance, tmApartment);
The correct command is:
TMSOAVFactory.Create(ComServer, TMsoTest, Class_MsoTest, 'MsoTest', '', ciMultiInstance, tmApartment);
Upvotes: 0
Reputation: 596352
You do not use IOfficeAntiVirus
, you implement it.
You need to create a new ActiveX Library that contains a new ActiveX Control whose implementation class implements the Scan()
method. In the Control's registration code, you have to use ICatRegister
to register your Control as using the CATID_MSOfficeAntiVirus
category. That way, Office/IE can find your ActiveX Control so it can instantiate it and call its Scan()
implementation. The second half of Serge's article shows you how to do that (Serge's example shows Scan()
taking a PChar
as input, but it actually takes a TMsoavinfo^
instead. Don't pass TMsoavinfo
using a PChar
).
You then have to register the resulting DLL using Windows' command-line regsvr32.exe
app.
If Office/IE is not calling your Scan()
implementation, then you are likely not registering your ActiveX control correctly, such as if you are not taking 32bit/64bit and/or UAC issues into account.
Upvotes: 1