DirectX File Reference

This section discusses the function, interfaces, objects, and data types introduced with DirectX version 6.0 that are used to write to and read from Microsoft® DirectX® (.x) files. This section also briefly introduces the relationship between the interfaces and provides a hierarchy chart that shows interface inheritance. The DirectX file methods allow reading from and writing to both text and binary files.

You should be familiar with the format of DirectX files as outlined in DirectX File Format Architecture before using these interfaces. Understanding the file format will help you better understand the purpose of the interfaces and their methods.

This section contains the following topics.

Introduction

The following summary discusses how to load data from a DirectX (.x) file and how to save data to a DirectX file. The DirectX file methods work with both text and binary DirectX files and support loading from various sources, such as files, memory, resources, or URLs.

To use the DirectX file interfaces, you must first use the DirectXFileCreate function to create an IDirectXFile object.

Loading a File

Use the following procedure to load a DirectX file.

  1. Use the DirectXFileCreate function to create an IDirectXFile object.
  2. If templates are not present in the DirectX file that you are going to load, use the IDirectXFile::RegisterTemplates method to register those templates.
  3. Use the IDirectXFile::CreateEnumObject method to create an IDirectXFileEnumObject enumerator object.
  4. Loop through the objects in the file. For each object, perform the following steps.
    1. Use the IDirectXFileEnumObject::GetNextDataObject method to retrieve each IDirectXFileData object.
    2. Use the IDirectXFileData::GetType method to retrieve the data's type.
    3. Load the data using the IDirectXFileData::GetData method.
    4. If the object has optional members, retrieve the optional members by calling the IDirectXFileData::GetNextObject method.
  5. Release the IDirectXFileData object.
  6. Release the IDirectXFileEnumObject object.
  7. Release the IDirectXFile object.

Saving a File

Use the following procedure to save DirectX file templates and data to a DirectX file.

  1. Use the DirectXFileCreate function to create an IDirectXFile object.
  2. Use the IDirectXFile::RegisterTemplates method to inform the DirectX file system about any templates that you are going to use.
  3. Use the IDirectXFile::CreateSaveObject method to create an IDirectXFileSaveObject object.
  4. Use the IDirectXFileSaveObject::SaveTemplates method to save templates, if desired.
  5. Loop through the objects to save. For each top-level object, perform the following steps.
    1. Use the IDirectXFileSaveObject::CreateDataObject method to create an IDirectXFileData object as a top-level object in the file. If the top-level data object has optional child objects, add them to the object by using the appropriate method from the "How to Add" column in the next step.
    2. Each IDirectXFileData object can have optional child objects if its template allows it. The child objects can be any one of the three types of objects: IDirectXFileData, IDirectXFileDataReference, or IDirectXFileBinary. Loop through the objects you need to save, adding each optional child member to the object list in the manner appropriate to its type, as shown in the following table.
      Object Type How to Add
      Data Call the IDirectXFileSaveObject::CreateDataObject method to create an IDirectXFileData object, and then call the IDirectXFileData::AddDataObject method to add it as a child of the object.
      Data Reference Call the IDirectXFileData::AddDataReference method to create and add the data reference object as a child of the object.
      Binary Call the IDirectXFileData::AddBinaryObject method to create and add the binary object as a child of the object.
    3. Call the IDirectXFileSaveObject::SaveData method to save the data object and all of its children.
    4. Release the IDirectXFileData object.
  6. Release the IDirectXFileSaveObject object.
  7. Release the IDirectXFile object.

Hierarchy Chart

The following diagram shows the relationship between the DirectX file interfaces.

 IUnknown
 |
 +--IDirectXFile
 |
 +--IDirectXFileEnumObject
 |
 +--IDirectXFileObject
 |  |
 |  +--IDirectXFileBinary
 |  |
 |  +--IDirectXFileData
 |  |
 |  +--IDirectXFileDataReference
 |
 +--IDirectXFileSaveObject

Function and Interfaces

DirectX supplies the following DirectX file function and interfaces.

The following table provides the Globally Unique Identifier (GUID) that corresponds with each DirectX File interface. For information about using a GUID with the QueryInterface method to determine a child object's type, see the introduction to the IDirectXFileData interface.
Interface GUID
IDirectXFile IID_IDirectXFile
IDirectXFileBinary IID_IDirectXFileBinary
IDirectXFileData IID_IDirectXFileData
IDirectXFileDataReference IID_IDirectXFileDataReference
IDirectXFileEnumObject IID_IDirectXFileEnumObject
IDirectXFileObject IID_IDirectXFileObject
IDirectXFileSaveObject IID_IDirectXFileSaveObject

DirectXFileCreate Function

The DirectXFileCreate function creates the IDirectXFile interface.

Syntax

STDAPI DirectXFileCreate(LPDIRECTXFILE *ppDirectXFile);

Parameters

ppDirectXFile
Address of a pointer to receive the created IDirectXFile interface.

Return Value

Returns one of the following values:
DXFILE_OK
DXFILEERR_BADALLOC
DXFILEERR_BADVALUE

Remarks

After using this function, use the IDirectXFile methods to: register templates (RegisterTemplates), create an enumerator object (CreateEnumObject), or create a save object (CreateSaveObject).

IDirectXFile

This interface enables you to create the IDirectXFileEnumObject and IDirectXFileSaveObject objects and to register templates.

Use the DirectXFileCreate function to create an instance of this object.

The IDirectXFile interface provides the following methods.

IDirectXFile::CreateEnumObject

IDirectXFile

Creates an enumerator object.

Syntax

HRESULT CreateEnumObject(
  LPVOID pvSource,
  DXFILELOADOPTIONS dwLoadOptions,
  LPDIRECTXFILEENUMOBJECT * ppEnumObj);

Parameters

pvSource
Pointer to data whose contents depend on the value of dwLoadOptions as outlined in the following table.
dwLoadOptions value Contents of pvSource
DXFILELOAD_FROMFILE Name of the file
DXFILELOAD_FROMRESOURCE DXFILELOADRESOURCE structure
DXFILELOAD_FROMMEMORY DXFILELOADMEMORY structure
DXFILELOAD_FROMURL Name of the Uniform Resource Locator (URL)
dwLoadOptions
Value that specifies the source of the data. One of the DXFILELOADOPTIONS values.
ppEnumObj
Address of a pointer to receive the created IDirectXFileEnumObject interface.

Return Value

Returns one of the following values:
 
DXFILE_OK
DXFILEERR_BADALLOC
DXFILEERR_BADFILEFLOATSIZE
DXFILEERR_BADFILETYPE
DXFILEERR_BADFILEVERSION
DXFILEERR_BADRESOURCE
DXFILEERR_BADVALUE
DXFILEERR_FILENOTFOUND
DXFILEERR_RESOURCENOTFOUND
DXFILEERR_URLNOTFOUND

Remarks

After using this method, use one of the IDirectXFileEnumObject methods to retrieve a data object.

IDirectXFile::CreateSaveObject

IDirectXFile

Creates an instance of an IDirectXFileSaveObject object.

Syntax

HRESULT CreateSaveObject(
  LPCSTR szFileName,
  DXFILEFORMAT dwFileFormat,
  LPDIRECTXFILESAVEOBJECT * ppSaveObj);

Parameters

szFileName
Pointer to the name of the file to use for saving data.
dwFileFormat
File format. One of the DXFILEFORMAT constants.
ppSaveObj
Address of a pointer to receive the created IDirectXFileSaveObject object.

Return Value

Returns one of the following values:
DXFILE_OK
DXFILEERR_BADALLOC
DXFILEERR_BADFILE
DXFILEERR_BADVALUE

Remarks

After using this method, use methods of the IDirectXFileSaveObject interface to create data objects and to save templates or data.

IDirectXFile::RegisterTemplates

IDirectXFile

Registers custom templates.

Syntax

HRESULT RegisterTemplates(
  LPVOID pvData,
  DWORD cbSize);

Parameters

pvData
Pointer to a buffer consisting of a DirectX file in text or binary format that contains templates.
cbSize
Size of the buffer pointed to by pvData, in bytes.

Return Value

Returns one of the following values:
DXFILE_OK
DXFILEERR_BADFILEFLOATSIZE
DXFILEERR_BADFILETYPE
DXFILEERR_BADFILEVERSION
DXFILEERR_BADVALUE
DXFILEERR_PARSEERROR

Remarks

The following code fragment provides an example call to RegisterTemplates and example contents for the buffer to which pvData points.

IDirectXFile * pDXFile;

char *szTemplates = "xof 0303txt 0032\
    template SimpleData { \
        <2b934580-9e9a-11cf-ab39-0020af71e433> \
        DWORD item1;DWORD item2;DWORD item3;} \
    template ArrayData { \
        <2b934581-9e9a-11cf-ab39-0020af71e433> \
        DWORD cItems; array DWORD aItem[2][cItems]; [...] } \
    template RestrictedData { \
        <2b934582-9e9a-11cf-ab39-0020af71e433> \
        DWORD item; [SimpleData]}";

hr = pDXFile->RegisterTemplates(szTemplates, strlen(szTemplates));

All templates must specify a name and a UUID (Universally Unique Identifier).

IDirectXFileBinary

This interface enables you to read binary data and to retrieve information about it.

The IDirectXFileBinary interface provides the following methods.

In addition, IDirectXFileBinary inherits the IDirectXFileObject::GetId and IDirectXFileObject::GetName methods.

IDirectXFileBinary::GetMimeType

IDirectXFileBinary

Retrieves the mime type for the binary data.

Syntax

HRESULT GetMimeType(LPCSTR * pszMimeType);

Parameters

pszMimeType
Address of a pointer to receive the mime type string.

Return Value

Returns one of the following values:
DXFILE_OK
DXFILEERR_BADVALUE

When there is no Mime type specified in a specified .X file for a binary object, the function will set *pszMimeType to NULL.

IDirectXFileBinary::GetSize

IDirectXFileBinary

Retrieves the size of the binary data.

Syntax

HRESULT GetSize(DWORD * pcbSize);

Parameters

pcbSize
Pointer to receive the size of the binary data, in bytes.

Return Value

Returns one of the following values:
DXFILE_OK
DXFILEERR_BADVALUE

IDirectXFileBinary::Read

IDirectXFileBinary

Reads binary data.

Syntax

HRESULT Read(
  LPVOID pvData,
  DWORD cbSize,
  LPDWORD pcbRead);

Parameters

pvData
Pointer to the buffer that receives the data that has been read.
cbSize
Size of the buffer pointed to by pvData, in bytes.
pcbRead
Pointer to the number of bytes read.

Return Value

Returns one of the following values:
DXFILE_OK
DXFILEERR_BADVALUE
DXFILEERR_NOMOREDATA

IDirectXFileData

The IDirectXFileData interface provides methods that enable you to build or to access the immediate hierarchy of the data object. Template restrictions determine the hierarchy. Data types allowed by the template are called optional members. The optional members are not required, but an object might miss important information without them. These optional members are saved as children of the data object. The children can be another data object, a reference to an earlier data object, or a binary object.

When saving objects to a DirectX file, use AddBinaryObject, AddDataObject, or AddDataReference to add binary objects, data objects, or data reference objects, respectively, to the file. For more information, see Saving a File.

When enumerating objects in an existing DirectX file, use the GetData, GetNextObject, and GetType methods as follows:

  1. Use GetType to retrieve the object's template's GUID. For example, for a mesh object GetType retrieves the GUID for the mesh template.
  2. Use GetData to retrieve required members of the object in a contiguous chunk of memory.
  3. For each child object, perform the following steps.
    1. Use GetNextObject to retrieve a child object.
    2. Use QueryInterface to determine the child object's type (data, data reference, or binary) by querying for support of the IDirectXFileData, IDirectXFileDataReference, and IDirectXFileBinary interfaces, in turn. The interface supported indicates the object's type. The following code fragment determines whether an object is a binary object by determining if it supports IDirectXFileBinary.
      IDirectXFileObject *DXFileObj;
      IDirectXFileBinary *DXFileBinary;
      
      if (FAILED(DXFileObj->QueryInterface(IID_IDirectXFileBinary,
                                           (LPVOID *)&DXFileBinary))
      {
          // Object does not support IDirectXFileBinary and therefore
      	// is not a binary object.
      }    
      else
      {
          // Object is binary.
      }	
      
    3. After you have determined the child object's type, use methods of the appropriate interface (IDirectXFileData, IDirectXFileDataReference, or IDirectXFileBinary) to act upon the child object.

The IDirectXFileData interface provides the following methods.

In addition, IDirectXFileData inherits the IDirectXFileObject::GetId and IDirectXFileObject::GetName methods.

IDirectXFileData::AddBinaryObject

IDirectXFileData

Creates and adds a binary object as a child object.

Syntax

HRESULT AddBinaryObject(
  LPCSTR szName,
  const GUID * pguid,
  LPCSTR szMimeType,
  LPVOID pvData,
  DWORD cbSize);

Parameters

szName
Pointer to the name of the object. Optional, specify NULL if the object does not need a name.
pguid
Pointer to the GUID representing the object. Optional, specify NULL if the object does not need a GUID.
szMimeType
Pointer to the object's mime type.
pvData
Pointer to the object's data.
cbSize
Size of the buffer pointed to by pvData, in bytes.

Return Value

Returns one of the following values:
DXFILE_OK
DXFILEERR_BADALLOC
DXFILEERR_BADVALUE

Remarks

For more information about saving child objects, see the introduction to this interface, IDirectXFileData.

IDirectXFileData::AddDataObject

IDirectXFileData

Adds a data object as a child object.

Syntax

HRESULT AddDataObject(LPDIRECTXFILEDATA pDataObj);

Parameters

pDataObj
Pointer to the IDirectXFileData object to add as a child object.

Return Value

Returns one of the following values:
DXFILE_OK
DXFILEERR_BADALLOC
DXFILEERR_BADVALUE

Remarks

Use the IDirectXFileSaveObject::CreateDataObject method to create the IDirectXFileData object before calling this method.

For more information about saving objects, see the introduction to this interface, IDirectXFileData.

IDirectXFileData::AddDataReference

IDirectXFileData

Creates and adds a data reference object as a child object.

Syntax

HRESULT AddDataReference(
  LPCSTR szRef,
  const GUID * pguidRef);

Parameters

szRef
Pointer to the name of the referenced data object. Can be NULL if pguidRef provides a reference to the GUID.
pguidRef
Pointer to the GUID representing the data. Can be NULL if szRef provides a reference to the name.

Return Value

Returns one of the following values:
DXFILE_OK
DXFILEERR_BADALLOC
DXFILEERR_BADVALUE

Remarks

At least one of the szRef or pguidRef parameters must be non-NULL.

For more information about saving objects, see the introduction to this interface, IDirectXFileData.

IDirectXFileData::GetData

IDirectXFileData

Retrieves the data for one of the object's members or the data for all members.

Syntax

HRESULT GetData(
  LPCSTR szMember,
  DWORD * pcbSize,
  void ** ppvData);

Parameters

szMember
Name of the member for which to retrieve data. Specify NULL to retrieve all required members' data.
pcbSize
Pointer to receive the ppvData buffer size, in bytes.
ppvData
Address of a pointer to receive the data associated with szMember. If szMember is NULL, *ppvData is set to point to a buffer containing all required members' data in a contiguous block of memory.

Return Value

Returns one of the following values:
DXFILE_OK
DXFILEERR_BADARRAYSIZE
DXFILEERR_BADDATAREFERENCE
DXFILEERR_BADVALUE

Remarks

This method retrieves the data for required members of a data object but no data for optional (child) members. Use GetNextObject to retrieve child objects.

For more information about enumerating objects, see the introduction to this interface, IDirectXFileData.

IDirectXFileData::GetNextObject

IDirectXFileData

Retrieves the next child data object, data reference object, or binary object in the DirectX file.

Syntax

HRESULT GetNextObject(LPDIRECTXFILEOBJECT * ppChildObj);

Parameters

ppChildObj
Address to receive a pointer to the child object's IDirectXFileObject interface.

Return Value

Returns one of the following values:
DXFILE_OK
DXFILEERR_BADVALUE
DXFILEERR_NOMOREOBJECTS

Remarks

To determine the type of object retrieved, use QueryInterface to query the retrieved object for support of IDirectXFileData, IDirectXFileDataReference, or IDirectXFileBinary interfaces. The interface supported indicates the type of object (data, data reference, or binary).

For more information about child objects, enumerating objects and determining the type of object, see the introduction to this interface, IDirectXFileData.

IDirectXFileData::GetType

IDirectXFileData

Retrieves the GUID of the object's template.

Syntax

HRESULT GetType(const GUID ** ppguid);

Parameters

ppguid
Address of a pointer to receive the GUID of the object's template.

Return Value

Returns one of the following values:
DXFILE_OK
DXFILEERR_BADVALUE

IDirectXFileDataReference

The IDirectXFileDataReference interface provides support for data reference objects. A data reference object refers to a data object that is defined earlier in the file. This allows you to use the same object multiple times without repeating it in the file.

After you have determined that an object is a data reference object, use this interface's Resolve method to get the real object that is defined earlier in the file. For information about how to determine that you have a data reference object, see the IDirectXFileData interface.

In addition, IDirectXFileDataReference inherits the IDirectXFileObject::GetId and IDirectXFileObject::GetName methods.

IDirectXFileDataReference::Resolve

IDirectXFileDataReference

Resolves data references.

Syntax

HRESULT Resolve(LPDIRECTXFILEDATA * ppDataObj);

Parameters

ppDataObj
Address of a pointer to receive the IDirectXFileData object.

Return Value

Returns one of the following values:
DXFILE_OK
DXFILEERR_BADVALUE
DXFILEERR_NOTFOUND

IDirectXFileEnumObject

This interface enables you to loop through to retrieve all data objects in the file and to retrieve a data object by GUID or by name.

The IDirectXFileEnumObject interface provides the following methods.

IDirectXFileEnumObject::GetDataObjectById

IDirectXFileEnumObject

Retrieves the data object that has the specified GUID.

Syntax

HRESULT GetDataObjectById(
  REFGUID rguid,
  LPDIRECTXFILEDATA * ppDataObj);

Parameters

rguid
Reference to the desired GUID.
ppDataObj
Pointer to receive the retrieved IDirectXFileData object.

Return Value

Returns one of the following values:
DXFILE_OK
DXFILEERR_BADVALUE
DXFILEERR_NOTFOUND

IDirectXFileEnumObject::GetDataObjectByName

IDirectXFileEnumObject

Retrieves the data object that has the specified name.

Syntax

HRESULT GetDataObjectByName(
  LPCSTR szName,
  LPDIRECTXFILEDATA * ppDataObj);
  

Parameters

szName
Pointer to the desired name.
ppDataObj
Pointer to receive the retrieved IDirectXFileData object.

Return Value

Returns one of the following values:
DXFILE_OK
DXFILEERR_BADVALUE
DXFILEERR_NOTFOUND

IDirectXFileEnumObject::GetNextDataObject

IDirectXFileEnumObject

Retrieves the next top-level object in the DirectX file. Top-level objects are always data objects. Data reference objects and binary objects can only be children of data objects.

Syntax

HRESULT GetNextDataObject(
  LPDIRECTXFILEDATA * ppDataObj);
  

Parameters

ppDataObj
Pointer to receive the retrieved IDirectXFileData object.

Return Value

Returns one of the following values:
DXFILE_OK
DXFILEERR_BADVALUE
DXFILEERR_NOMOREOBJECTS

IDirectXFileObject

IDirectXFileObject is the base interface for DirectX file objects. IDirectXFileData, IDirectXFileDataReference and IDirectXFileBinary interfaces all inherit from this interface.

The IDirectXFileObject interface provides the following methods.

IDirectXFileObject::GetId

IDirectXFileObject

Retrieves a pointer to the GUID that identifies a DirectX file object.

Syntax

HRESULT GetId (LPGUID pGuid)

Parameters

pGuid
Pointer to a GUID to receive the object's ID. The function will set the GUID to a NULL GUID if the object does not have an ID.

Return Value

Returns one of the following values.
DXFILE_OK
DXFILEERR_BADVALUE

IDirectXFileObject::GetName

IDirectXFileObject

Retrieves a pointer to a DirectX file object's name.

Syntax

HRESULT GetName (LPSTR pstrNameBuf, LPDWORD pdwBufLen)

Parameters

pstrNameBuf
Pointer to the buffer in which the DirectX file object's name will be copied. Set to NULL if only the buffer length is needed.
pdwBufLen
Pointer to a DWORD specifying the length of the buffer pointed to by pstrNameBuf. pdwBufLen will be modified to the buffer length needed to hold the object's name even if pstrNameBuf is NULL. In either case, the function will return DXFILEERR_BADVALUE if the original value of pdwBufLen is not as large as or larger than the length needed to hold the object's name.

Return Value

Returns one of the following values.
DXFILE_OK
DXFILEERR_BADALLOC

IDirectXFileSaveObject

This interface enables you to create data objects and to save templates and data objects. Use IDirectXFile::CreateSaveObject to create an instance of this object. Then use SaveTemplates to save the templates. Use CreateDataObject to create a data object, and use SaveData to save the data.

Note that templates are not required in every file. For example, you could put all templates in one DirectX file rather than duplicating them in every DirectX file.

The IDirectXFileSaveObject interface provides the following methods.

IDirectXFileSaveObject::CreateDataObject

IDirectXFileSaveObject

Creates a data object.

Syntax

HRESULT CreateDataObject(
  REFGUID rguidTemplate,
  LPCSTR szName,
  const GUID * pguid,
  DWORD cbSize,
  LPVOID pvData,
  LPDIRECTXFILEDATA * ppDataObj);
  

Parameters

rguidTemplate
GUID representing the data object's template.
szName
Pointer to the name of the data object. Optional, specify NULL if the object does not have a name. If the object is going to be referenced by a data reference object, at least one of the szName or pguid parameters must be non-NULL.
pguid
Pointer to a GUID representing the data object. Optional, specify NULL if the object does not have a GUID. If the object is going to be referenced by a data reference object, at least one of the szName or pguid parameters must be non-NULL.
cbSize
Size of the data object, in bytes.
pvData
Pointer to a buffer containing all required member's data.
ppDataObj
Address of a pointer to receive the created IDirectXFileData object.

Return Value

Returns one of the following values:
DXFILE_OK
DXFILEERR_BADALLOC
DXFILEERR_BADVALUE

Remarks

Save any templates by using the SaveTemplates method before saving the data created by this method. Save the created data by using the SaveData method. If you need to save optional data, use the IDirectXFileData::AddDataObject method after using this method and before using SaveData. If the object has child objects, add them before calling SaveData.

IDirectXFileSaveObject::SaveData

IDirectXFileSaveObject

Saves a data object and its children to a DirectX file.

Syntax

HRESULT SaveData(
  LPDIRECTXFILEDATA pDataObj);
  

Parameters

pDataObj
Pointer to the IDirectXFileData object to save.

Return Value

Returns one of the following values:
DXFILE_OK
DXFILEERR_BADARRAYSIZE
DXFILEERR_BADVALUE

IDirectXFileSaveObject::SaveTemplates

IDirectXFileSaveObject

Saves templates to a DirectX file.

Syntax

HRESULT SaveTemplates(
  DWORD cTemplates,
  const GUID ** ppguidTemplates);
  

Parameters

cTemplates
Total number of templates to save.
ppguidTemplates
Address of a pointer to an array of the GUIDs for all templates to save.

Return Value

Returns one of the following values:
DXFILE_OK
DXFILEERR_BADVALUE

Remarks

The following code fragment provides an example call to SaveTemplates and example contents for the array to which ppuuid points.

IDirectXFileSaveObject * pDXFileSaveObject;

const GUID *aIds[] = {
    &DXFILEOBJ_SimpleData,
    &DXFILEOBJ_ArrayData,
    &DXFILEOBJ_RestrictedData};

hr = pDXFileSaveObject->SaveTemplates(3, aIds);

After using this method to save the templates, use the IDirectXFileSaveObject::CreateDataObject method to create a data object.

Data Types

The DirectX file interfaces use the following constants and structures.

DXFILEFORMAT Constants

Specifies values used by the IDirectXFile::CreateSaveObject method to indicate the format to use when saving the DirectX file.

Syntax

typedef DWORD DXFILEFORMAT;
#define DXFILEFORMAT_BINARY     0
#define DXFILEFORMAT_TEXT       1
#define DXFILEFORMAT_COMPRESSED 2

Values

DXFILEFORMAT_BINARY
Indicates a binary file.
DXFILEFORMAT_TEXT
Indicates a text file.
DXFILEFORMAT_COMPRESSED
Indicates a compressed file.
The default value for the file format is DXFILEFORMAT_BINARY. The file format values can be combined together in a logical OR to create compressed text or compressed binary files. If a file is specified as both binary (0) and text (1), it will be saved as a text file because the value will be indistinguishable from the text file format value (0 + 1 = 1). If you indicate that the file format should be text and compressed, the file will first be written out as text and then compressed. However, compressed text files are not as efficient as binary text files, so in most cases you will want to indicate binary and compressed. Setting a file to be compressed without specifying a format will result in a binary, compressed file.

DXFILELOADMEMORY Structure

Identifies a resource to be loaded when an application uses the IDirectXFile::CreateEnumObject method and specifies DXFILELOAD_FROMMEMORY.

Syntax

typedef struct _DXFILELOADMEMORY {
    LPVOID lpMemory;
    DWORD dSize;
}DXFILELOADMEMORY, *LPDXFILELOADMEMORY;

Members

lpMemory
Pointer to a block of memory to be loaded.
dSize
Size, in bytes, of the block of memory to be loaded.

DXFILELOADOPTIONS Constants

Specifies values used by the IDirectXFile::CreateEnumObject method to indicate the source of the file data.

Syntax

typedef DWORD DXFILELOADOPTIONS;
#define DXFILELOAD_FROMFILE  0x00L
#define DXFILELOAD_FROMRESOURCE 0x01L
#define DXFILELOAD_FROMMEMORY 0x02L
#define DXFILELOAD_FROMSTREAM 0x04L
#define DXFILELOAD_FROMURL 0x08L

Values

DXFILELOAD_FROMFILE
Indicates data read from a file.
DXFILELOAD_FROMRESOURCE
Indicates data read from a resource.
DXFILELOAD_FROMMEMORY
Indicates data read from memory.
DXFILELOAD_FROMSTREAM
Indicates data read from a stream. Not currently supported.
DXFILELOAD_FROMURL
Indicates data read from a URL (Uniform Resource Locator).

DXFILELOADRESOURCE Structure

Identifies a resource to be loaded when an application uses the IDirectXFile::CreateEnumObject method and specifies DXFILELOAD_FROMRESOURCE.

Syntax

typedef struct _DXFILELOADRESOURCE {
    HMODULE hModule;
    LPCTSTR lpName;
    LPCTSTR lpType;
}DXFILELOADRESOURCE, *LPDXFILELOADRESOURCE;

Members

hModule
Handle of the module containing the resource to be loaded. If this member is NULL, the resource must be attached to the executable file that will use it.
lpName
Name of the resource to be loaded. For example, if the resource is a mesh, this member should specify the name of the mesh file.
lpType
User-defined type identifying the resource.

Return Values

The methods of the DirectX file Component Object Model (COM) interfaces can return the following values in addition to standard COM return values.

DXFILE_OK
Command completed successfully. Equivalent to DD_OK.
DXFILEERR_BADALLOC
Memory allocation failed.
DXFILEERR_BADARRAYSIZE
Array size is invalid.
DXFILEERR_BADCACHEFILE
The cache file containing the X file date is invalid. A cache file contains data retrieved from the network, cached on the hard disk, and retrieved in subsequent requests.
DXFILEERR_BADDATAREFERENCE
Data reference is invalid.
DXFILEERR_BADFILE
File is invalid.
DXFILEERR_BADFILEFLOATSIZE
Floating-point size is invalid.
DXFILEERR_BADFILETYPE
File is not a DirectX file.
DXFILEERR_BADFILEVERSION
File version is not valid.
DXFILEERR_BADRESOURCE
Resource is invalid.
DXFILEERR_BADTYPE
Object type is invalid.
DXFILEERR_BADVALUE
Parameter is invalid.
DXFILEERR_FILENOTFOUND
File could not be found.
DXFILEERR_NOMOREDATA
No further data is available.
DXFILEERR_NOMOREOBJECTS
All objects have been enumerated.
DXFILEERR_NOTFOUND
Object could not be found.
DXFILEERR_PARSEERROR
File could not be parsed.
DXFILEERR_RESOURCENOTFOUND
Resource could not be found.
DXFILEERR_URLNOTFOUND
URL could not be found.

Top of Page Top of Page
© 2000 Microsoft and/or its suppliers. All rights reserved. Terms of Use.