How t o use I Of f i ceAnt i Vi r us i nt er f ace
and dev el op ant i v i r us pr ogr am f or MS Of f i ce P lfurvriw=Dqwlyluxv=DSL=hqdeohv=vriwz duh= ghyhorshuv=wr=ghyhors=dssolfdwlrqv=wkdw=vfdq= P lfurvriw=R iilfh=grfxp hqwv=ehiruh=rshqlqj= wkhp I Wkh=Dqwlyluxv=DSL=dovr=vxssruwv=vfdqqlqj= P lfurvriw=LH=frgh=grz qordgv/=vxfk=dv=Dfwlyh]= frqwurovI Wkh=sulp du|=sxusrvh=ri=wklv=DSL=lv=wr=jlyh=d= vriwz duh=ghyhorshuv=wkh=delolw|=wr=ghvljq=dqg= lp sohp hqw=dqwlyluxv=vriwz duh=wkdw=fdq=eh=xvhg= e|=doo=dssolfdwlrqvI Wkh=dqwlyluxv=frp srqhqw=lv=d=vwdqgdug=Dfwlyh]=frp srqhqw=|rx=uhjlvwhu=dv=dq=lq0 surfhvv=vhuyhu=wkdw=vxssruwv=wkh=P VR iilfhDqwlYluxv=frp srqhqw=fdwhjru|= +FDWLGbP VR iilfhDqwlYluxv==WJXLG=O =*-89IIFF0G<,044g0ESDH0 DF<,IDI<*,I LH=dqg=P V=R iilfh=lp sohp hqw=wkh=dqwlyluxv=frp srqhqw=dv=iroorz v R ewdlq=wkh=olvw=ri=doo=wkh=lqvwdoohg=dqwlyluxv=frp srqhqwv=uhjlvwhuhg=dv=vxssruwlqj= wkh=P VR iilfhDqwlYluxv=frp srqhqw=fdwhjru|I Odxqfk=wkh=lqvwdoohg=frp srqhqwvI T xhu|=iru=wkh=LR iilfhDqwlYluxv=lqwhuidfhI Fdoo=LR iilfhDqwlYluxvIVfdq=p hwkrg=wr=rewdlq=doo=wkh=lqvwdoohg=frp srqhqwvI Frqwlqxh=wr=rshq=wkh=iloh=diwhu=wkh=yluxv=vfdq/=uhjdugohvv=ri=wkh=KUHVXOW=ydoxhI= Wkh=dqwlyluxv=vriwz duh=z duqv=d=xvhu=li=d=iloh=kdv=d=nqrz q=yluxv=exw=rshqv=wkh=iloh= diwhu=wkh=z duqlqjI=Lw=lv=xs=wr=wkh=xvhu=wr=wdnh=dfwlrq=frqfhuqlqj=wkh=z duqlqjI {The Antivirus API enables software vendors to develop applications that scan Microsoft Office documents before opening them. The API also supports scanning Microsoft Internet Explorer 5 code downloads, such as ActiveXControls or installs. However, be aware that the Internet Explorer scanning support applies only to automatic code downloads and not to file downloads or HTML documents. The primary purpose of this API is to give independent software vendors (ISVs) the ability to design and implement scanning software that can be used by all applications.} unit msoav; interface uses Windows, SysUtils, ActiveX, ComObj, Classes; const IID_IOfficeAntiVirus : TGUID = '{56FFCC30-D398-11d0-B2AE-00A0C908FA49}'; //DEFINE_GUID(IID_IOfficeAntiVirus, //0x56ffcc30, 0xd398, 0x11d0, 0xb2, 0xae, 0x0, 0xa0, 0xc9, 0x8, 0xfa, 0x49); CATID_MSOfficeAntiVirus : TGUID = '{56FFCC30-D398-11d0-B2AE-00A0C908FA49}'; //DEFINE_GUID(CATID_MSOfficeAntiVirus, //0x56ffcc30, 0xd398, 0x11d0, 0xb2, 0xae, 0x0, 0xa0, 0xc9, 0x8, 0xfa, 0x49); type TInfoStruct = record fIsFile : boolean; fIsReadOnly : boolean; fIsInstalled : boolean; fIsHTTPDownload : boolean; end; //Contains information about the file to be scanned. { * cbSize - Integer value that specifies the size of an MSOAVINFO structure. * hWnd - Handle to the parent window of the Microsoft Office 2000 * application. * pwzFullPath - Address of a wide character string that contains the full path of the file about to be opened. * lpStg - Address of the OLE storage location of the file about to be * opened. Ads by Google AntiVirus Delphi Virus Scan Delphi for Web Andr oi d App Dev el oper s Dhvwkhwlfdoo|=Sohdvlqj=Ghvljq=iru= DqgurlgI=R swlp lh=Xvdelolw|=Wrgd|S grruIfrp Dow nl oad Open Sour ce ETL Ohdglqj=R shq=Vrxufh=Hqwhusulvh=Gdwd= Wudqvirup dwlrq=WrrovI=Grz qordg=Qrz S z z z IWdohqgIfrp ?RshqbVrxufhbHWO Usi ng Dat a Model s i n SOA Vfdolqj=VRD=Xvlqj=P rgho0Edvhg= VwdqgdugvI=Lqirup dwlyh=Z klwhsdshu z heIsurjuhvvIfrp ?gdwdwhqg Home Ghoskl=Wxwruldov Ghoskl= Frp srqhqwv Klqwv=dqg=Wlsv Ghoskl=Errnv Vhdufk Olqnv Ihhgedfn Derxw Frrohvw=Jdgjhwv Top answers for Api www.Answered- Questions.com Api Discover 100+ answers for Api www.Answered- Questions.com Searching for Api? Call (866) 457-6701 To Get Matched to Up to 4 Screened & Approved Service Providers Now! www.ServiceMagic.com Screened And Approved Home Chitika | Opt out? Most Popul ar Wudlqlqj=iru= P FVG G|qdp lfdoo|= Ordglqj=GOO*v Dq=Lfrq=Hwudfwru= dqg=Ylhz hu Krz =wr=P ryh= Frqwurov=dqg= Vdyh=wkhlu= Srvlwlrqv Fuhdwlqj=Frqwurov= dw=Uxq=Wlp h Krz =wr= Lp sohp hqw=Z hlug= Vkdshg=Z lqgrz v ToolKit for Delphi Privacy Information Lat est Del phi Hi nt s Xvh=Sro|Olqh= udwkhu=wkdq= P ryhWr=dqg= OlqhWr Klglqj=|rxu= dssolfdwlrq=iurp = wkh=Wdvnedu Krz =wr=klgh=dqg= vkrz =wkh= Z lqgrz v=Wdvnedu Krz =wr= surjudp p dwlfdoo|= suhvv=wkh=%Vwduw%= Exwwrq Page 1 of 4 Using the Microsoft Antivirus API with Borland Delphi 10/7/2011 http://www.delphi-central.com/MS_Office_AV_API.aspx * pwzHostName - Address of a wide character string that contains the host application name for the antivirus scanner user interface. * pwzOrigURL - Address of a wide character string that contains the URL of the origin of a downloaded file. } TMsoavinfo = record cbSize : integer; info : ULONG; wnd : HWND; FullPath : Pointer; pwzHostName : PWChar; pwzOrigURL : PWChar; end; //This is the interface an antivirus scanner uses to interact with a host //application. IOfficeAntiVirus = interface(IUnknown) ['{56FFCC30-D398-11d0-B2AE-00A0C908FA49}'] function Scan(pmsoavinfo : PChar) : HResult; stdcall; end; function TestBit(const Value: Cardinal; const Bit: byte): Boolean; procedure GetRegisteredAntiviruses(ProgIDs: TStrings); implementation function TestBit(const Value: Cardinal; const Bit: byte): Boolean; begin Result := (Value and (1 shl (Bit mod 32))) <> 0; end; procedure GetRegisteredAntiviruses(ProgIDs: TStrings); var CatInformation: ICatInformation; Enum: IEnumGUID; CLSID: TGUID; nFetched: Cardinal; CatId: TGUID; begin CatInformation := CreateComObject(CLSID_StdComponentCategoryMgr) as ICatInformation; CatId := CATID_MSOfficeAntiVirus; OleCheck(CatInformation.EnumClassesOfCategories(1, @CatId, 0, nil, Enum)); ProgIDs.BeginUpdate; try ProgIDs.Clear; while (Enum.Next(1, CLSID, nFetched) = S_OK) do begin ProgIDs.Add(GuidToString(clsid)); end; finally ProgIDs.EndUpdate; end; end; end. Qrz =L=z loo=vkrz =d=vp doo=hdp soh=krz =wr=xvh=LR iilfhDqwlYluxv=lqwhuidfh=wr=lp sohp hqw= rz q=dqwlyluxv=surjudp =iru=P lfurvriw=R iilfhI library msoavtest; uses ComServ, msoav, umsoavtest; exports DllGetClassObject, DllCanUnloadNow, DllRegisterServer, DllUnregisterServer; begin end. unit umsoavtest; interface uses Windows, ActiveX, ComObj, ShlObj, Dialogs, msoav; type TMSOTest = class(TComObject, IOfficeAntiVirus) protected function Scan(pmsoavinfo : PChar) : HResult; stdcall; end; Page 2 of 4 Using the Microsoft Antivirus API with Borland Delphi 10/7/2011 http://www.delphi-central.com/MS_Office_AV_API.aspx const Class_MsoTest: TGUID = '{F56BE781-C8BE-11D7-8601-00E0184D1E9D}'; implementation uses ComServ, SysUtils, ShellApi, Registry; procedure UpdateCat(Register: Boolean; const ClassID: string); const SCatImplBaseKey = 'CLSID\%s\Implemented Categories'; SCatImplKey = SCatImplBaseKey + '\%s'; var CatReg: ICatRegister; Rslt: HResult; CatInfo: TCATEGORYINFO; Description: string; begin Rslt := CoCreateInstance(CLSID_StdComponentCategoryMgr, nil, CLSCTX_INPROC_SERVER, ICatRegister, CatReg); if Succeeded(Rslt) then begin if Register then begin CatInfo.catid := CATID_MSOfficeAntiVirus; CatInfo.lcid := $0409; StringToWideChar('', CatInfo.szDescription, Length('') + 1); OleCheck(CatReg.RegisterCategories(1, @CatInfo)); OleCheck(CatReg.RegisterClassImplCategories(StringToGUID(ClassID), 1, @CATID_MSOfficeAntiVirus)); end else begin OleCheck(CatReg.UnRegisterClassImplCategories(StringToGUID(ClassID), 1, @CATID_MSOfficeAntiVirus)); DeleteRegKey(Format(SCatImplBaseKey, [ClassID])); end; end else begin if Register then begin CreateRegKey('Component Categories\' + GUIDToString(CATID_MSOfficeAntiVirus), '409', ''); CreateRegKey(Format(SCatImplKey, [ClassID, GUIDToString(CATID_MSOfficeAntiVirus)]), '', ''); end else begin DeleteRegKey(Format(SCatImplKey, [ClassID, GUIDToString(CATID_MSOfficeAntiVirus)])); DeleteRegKey(Format(SCatImplBaseKey, [ClassID])); end; end; if Register then begin Description := GetRegStringValue('CLSID\' + ClassID, ''); CreateRegKey('AppID\' + ClassID, '', Description); CreateRegKey('CLSID\' + ClassID, 'AppID', ClassID); end else DeleteRegKey('AppID\' + ClassID); end; { TMSOTest } function TMSOTest.Scan(pmsoavinfo: PChar): HResult; var Info : TMsoavinfo; Struct : TInfoStruct; p : pointer; begin p := pointer(pmsoavinfo); if not Assigned(p) then begin //no information available Result := S_OK; Exit; end; Move(P^, Info, SizeOf(Tmsoavinfo)); if Info.cbSize <> SizeOf(Tmsoavinfo) then begin //wrong size of the structure Result := S_OK; Exit; end; Struct.fIsFile := TestBit(Info.Info, 0); Struct.fIsReadOnly := TestBit(Info.Info, 1); Struct.fIsInstalled := TestBit(Info.Info, 2); Struct.fIsHTTPDownload := TestBit(Info.Info, 3); if struct.fIsFile then begin MessageDlg(PWChar(Info.FullPath), mtWarning, [mbOK], 0); end; Result := S_OK; end; Page 3 of 4 Using the Microsoft Antivirus API with Borland Delphi 10/7/2011 http://www.delphi-central.com/MS_Office_AV_API.aspx type TMSOAvFactory = class(TComObjectFactory) public procedure UpdateRegistry(Register: Boolean); override; end; procedure TMSOAVFactory.UpdateRegistry(Register: Boolean); var ClassID: string; begin ClassID := GUIDToString(Class_MsoTest); if Register then begin inherited UpdateRegistry(Register); UpdateCat(true, ClassID); end else begin UpdateCat(false, ClassID); inherited UpdateRegistry(Register); end; end; initialization TComObjectFactory.Create(ComServer, TMsoTest, Class_MsoTest, 'MsoTest', '', ciMultiInstance, tmApartment); end. Wklv=wxwruldo=z dv=nlqgo|=surylghg=e|=vhujh=shuhyrq|n Search 98IS4 Z he 98IS4 z z z IGhoskl0FhqwudoIfrp Lqwhuqhw=Jxlgh Krp h=Vhdufk=Ghoskl=Wxwruldov=Klqwv=)=Wlsv=Iuhhz duh=Frp srqhqwv=Sulydf|== Z hep dvwhu=Glvfxvvlrqv Frs|uljkw=4<<.0S8=Ghoskl=FhqwudoI=Ghoskl=lv=d=wudghp dun=ri=Eruodqg Lqwhuqdwlrqdo/= LqfI Page 4 of 4 Using the Microsoft Antivirus API with Borland Delphi 10/7/2011 http://www.delphi-central.com/MS_Office_AV_API.aspx