This site is moving to The Zen Source Library
Please Update your bookmarks

Creating a DocFile

The function to create a DocFile is StgCreateDocFile.

   function StgCreateDocFile(   Unicode filename,
                                STGM flags,
                                Reserved must be 0,
                                Storage returned
                             ) : HResult;

A DocFile is itself a Storage, so here the storage returned is your file's root storage.

To check if the function was successful use the SUCEEDED( ) function. For Example

   Hr := StgCreateDocFile(....);

   if(   SUCEEDED(  Hr  )   ) then
      //DocFile was created
   else begin
      //Create failed

Don't compare the HResult to S_OK, unless the help file specifically says that is what the function returns. The reason for this is that OLE can return different values that all mean that the function succeeded but each has a subtly different meaning. In other words there are multiple success (and failure) codes, this allows OLE to provide additional information as to why the function succeeded (or failed).

Before completing the explanation on creating a DocFile I'll quickly go through some related material that will help you understand what's going on. This material is also relevant for most of the other routines to be used later in this article, so lets get this out of the way.

All information on these www pages is copyright (©) 1997 Andre .v.d. Merwe And may not be copied or mirrored without my permission.