Question

I am relatively new to C++ in general, and very new to Windows development.

I am writing a program that uses the DXGI library - it compiles just fine, but when I run the executable, the HRESULT from the CreateDXGIFactory1 comes out as 0x80004002, or E_NOINTERFACE.

Am I missing some sort of library, or is there a deeper issue at play here?

The code I am using follows:

Output is "Error: 0x80004002".

  //Initialize a UUID
  GUID uuid;
  HRESULT hCreateUUID = CoCreateGuid(&uuid);

  //Convert the UUID to string
  LPOLESTR stringUUID;
  HRESULT hStringToUUID = StringFromCLSID(uuid, &stringUUID);

  //Initialize the factory pointer
  IDXGIFactory1* pFactory;

  //Actually create it
  HRESULT hCreateFactory = CreateDXGIFactory1(uuid, (void**)(&pFactory));
  if (hCreateFactory == S_OK) {
    printf("Factory creation was a success\n");
  } else {
    printf("ERROR: 0x%X\n", hCreateFactory);
  }
Was it helpful?

Solution

You are passing a random, freshly created GUID. This makes no sense. You are supposed to pass the IID of the interface you wish to obtain - namely, __uuidof(IDXGIFactory1). The example in the documentation shows just that.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top