0

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);
  }
javanix
  • 1,270
  • 3
  • 24
  • 40

1 Answers1

0

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.

Igor Tandetnik
  • 50,461
  • 4
  • 56
  • 85
  • Thank you, just noticed that actually. Where does the __uuid function come from, just out of curiosity? – javanix Jul 25 '13 at 02:23
  • It's not a function, it's a special (non-standard, Microsoft-specific) operator, somewhat similar to `sizeof` or `typeid`. It reads the annotation attached to a type via `__declspec(uuid)`, which in turn is a non-standard, Microsoft-specific declarator. If you look at how `IDXGIFactory1` is defined in the system headers, you'll see `__declspec(uuid)` on it (usually hidden behind a macro, so it'll take some digging). – Igor Tandetnik Jul 25 '13 at 05:11