Loading X-Files from resources

I found lots ot tutorials on the Web about loading X-Files from files, but nothing about loading them from application resources.

First, add the x-file to your resources file. In the Resources window, select Add Resources. In the "Add Resource" dialog, select "Import." Select the x-file. Visual Studio will then prompt you to enter a string name for the resource type. For example, "xfile."

Now, to load the x-file in your application, use code like the following:

#include "resource.h"

CComPtr<ID3DXFile> pFile;
CComPtr<ID3DXFileEnumObject> pEnum;

hr = D3DXFileCreate(&pFile);

D3DXF_FILELOADRESOURCE res;
res.hModule = GetModuleHandle(NULL);
res.lpName = MAKEINTRESOURCE(IDR_XFILE1); // resource ID
res.lpType = "xfile"; // name of the resource type

hr = pFile->CreateEnumObject(&res, D3DXF_FILELOAD_FROMRESOURCE, &pEnum);


This posting is provided "AS IS" with no warranties, and confers no rights.