资源描述:
《复合文档操作函数》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、复合文档操作函数Complexstructuredaccess(1)Read(14)tomakecommentsThereasonforthisisthatitisdifferentfromthestructuredfileaccessthatwaspreviouslydiscussed;Thiscomplexstructuredfileisalsocalleda"compositedocument〃・Somedocumentsarenotstructured,suchasnotepadfiles:Structuredfilescanbedividedintothefollowingca
2、tegories:Standardstructureddocuments,customstructureddocumentssuchasBMPfiles,andcompositedocuments・Heretotalkaboutstructuredstorage(compounddocuments)isprovidedbytheWindowssystemthroughtheCOM,itcanfinishlikeWindowsdirectorystructurecomplexaccessfilestructure;NotethedirectorystructureofWindows:adi
3、rectorycancontainsubdirectoriesandfiles,thennestedlayersof.・・Sometimesweneedthefilestoragemayalsobelayersofbranches,thespecificcontentofthefilesmayalsobemultifarious,suchasabranchofafileisapicture,isastringlist,isarecord(orstructure),etc・,storethefilecontentindatabaseisalsohelpless,I'mafraid.This
4、compositefilesupportsmultiplethreads,anddifferentthreadsindifferentprocessescansimultaneouslyaccessdifferentpartsofacompositefile・ThemosttypicalexampleofacompositefileisOLE(forexample,youcanembedaspreadsheetinWord);Thismayalsobetheoriginofthiscompositefile・Perhapswiththis,it'seasytocreateyourownf
5、ileformat・AccessandaccesscompositedocumentsmainlyusethethreeCOMinterfacesdefinedintheActiveXunit:IStorage(similartoaWindowsdirectory,whichisafolder);IStrearn(similartothefileinthedirectory,butinthiscase,〃flow〃,atleast512bytesperflow);IEnumStatStg(forlistingthehierarchyofIStorage)The"interface"isa
6、complexconcept,andit'sacollectionoffunctionsforthetimebeing・Here,salistofalltherelevantfunctions(notyetfullymastered,andthelearningprocessisslowlycommented):FunctionsinIStorage:Double-clickthecodetoselectall//createasub-istorageinterfaceFunctionCreateStorage(PwcsName:POleStr;{specifythename}ofthe
7、childIStorageinterfaceGrfMode:Longint;{specifyaccessmode}DwStgFmt:Longint;{reserved,mustbe0}Reserved2:Longint;(reserved,mustbe0}OutSTG:IStorage{returnchildIStorageinterface}):HResult;Stdcall;//openthecurrentIStoragesub